API Reference
Public functions and types
These are the functions and types exported by BigRiverPlots.jl.
BigRiverPlots.check_comps — Method
check_comps(comp::Int, ncomp::Int) =>
Checks that a requested component index exists in a fitted model.
Arguments
compis the index of the single component to be drawn.ncompis the number of components available in the fitted model.
Output
- Nothing is returned. An error is thrown when the index falls outside
1:ncomp, so that an out of range request fails with a clear message instead of a bounds error raised deep inside Plots. This is the method the plots of a single component need, such as the loadings plot.
BigRiverPlots.check_comps — Method
check_comps(comps::Tuple{Int, Int}, ncomp::Int) =>
Checks that a requested pair of component indices exists in a fitted model.
Arguments
compsis a tuple naming the two components to be placed on the x and y axes.ncompis the number of components available in the fitted model.
Output
- Nothing is returned. An error is thrown when either index falls outside
1:ncomp, so that an out of range request fails with a clear message instead of a bounds error raised deep inside Plots. This is the method the plots of two components need, such as the scores plot.
BigRiverPlots.get_biplot_coords — Method
getbiplotcoords(scores::Matrix{Float64}, loadings::Matrix{Float64}; comps::Tuple{Int, Int} = (1, 2), varnames::Vector{String} = String[], nonzero::Bool = false, ntop::Int = 0, arrowscale::Float64 = 0.0) =>
Returns the coordinates of two components of a matrix of scores together with the loading arrows of the same two components, ready for plotting.
Arguments
scoresis the matrix of scores, observations (rows) by components (columns), which places the points.loadingsis the matrix of loadings, variables (rows) by components (columns), which points the arrows. It should come from the same fitted model asscores.compsis a tuple naming the two components placed on the x and y axes, default is(1, 2).varnamesis a vector of names, one per variable, default isString[]for no names, in which case the variables are named by their index. They are subset along with the arrows, which is why they are given here.nonzerokeeps only the variables whose loading is not zero on at least one of the two components drawn, default isfalse. This is what the models with an L1 penalty need, since most of their arrows would otherwise be drawn as stubs of length zero piled at the origin.ntopkeeps only thentopvariables of largest arrow length, default is0for all of them. This is what the dense models need, since an arrow per variable over thousands of them buries the points.arrowscaleis the factor the arrows are scaled by, default is0.0to scale them automatically. The loadings are unit length, so on the scale of the scores the arrows would be invisibly short: they are stretched to about four fifths of the point cloud. The scaling is conventional, so the DIRECTIONS and the RELATIVE lengths of the arrows carry meaning while the absolute length does not.
Output
sxymatrix contains the scores of the observations on the two components, in two columns.axymatrix contains the scaled arrow tips of the variables kept, in two columns.namesvector contains the names of the variables kept, one per row ofaxy.
BigRiverPlots.get_ellipse_coords — Method
getellipsecoords(x::AbstractVector, y::AbstractVector; nstd::Float64 = 2.5, npoints::Int = 100) =>
Returns the points of a confidence ellipse around a cloud of observations.
Arguments
xis a vector of the coordinates of the observations on the first component.yis a vector of the coordinates of the observations on the second component.nstdis the number of standard deviations the ellipse is drawn at, default is2.5. A larger value draws a wider ellipse: at 2.5 the ellipse covers most of a class that is roughly normal, so a point outside it is worth a look.npointsis the number of points the ellipse is traced with, default is100.
Output
exvector contains the coordinates of the ellipse on the first component.eyvector contains the coordinates of the ellipse on the second component.
The ellipse is the unit circle scaled by nstd standard deviations along each of the principal axes of the covariance of the cloud, then rotated onto those axes and moved onto its center. It is computed here rather than taken from covellipse of StatsPlots, so that the package needs no dependency beyond RecipesBase and the standard library.
BigRiverPlots.get_jive_variance_coords — Method
getjivevariance_coords(blocks::Vector{Matrix{Float64}}, joint::Vector{Matrix{Float64}}, individual::Vector{Matrix{Float64}}; blocknames::Vector{String} = String[]) =>
Returns the fraction of each data block's variation that is joint, individual, and residual, ready for plotting as stacked bars.
Arguments
blocksis the vector of raw data blocks the JIVE model was fitted on, one matrix per block, variables (rows) by observations (columns). They are needed because the fractions are measured against the total variation of each block.jointis the vector of joint structure matrices of the fitted model,m.J, one per block and the same shape as the block.individualis the vector of individual structure matrices of the fitted model,m.A, one per block and the same shape as the block.blocknamesis a vector of names, one per block, default isString[]for no names, in which case the blocks are named by their index.
Output
varJvector contains the fraction of each block explained by the joint structure.varIvector contains the fraction of each block explained by its individual structure.varRvector contains the residual fraction, what neither the joint nor the individual structure accounts for, so the three sum to one for each block.namesvector contains the names of the blocks.
The fractions are the squared Frobenius norm of a structure over the squared norm of the block, following the definition of variation explained in JIVE. The residual is one minus the joint and the individual, so a block whose joint fraction is large is one that shares much of its variation with the other blocks.
BigRiverPlots.get_levels — Method
get_levels(group::AbstractVector) =>
Returns the unique levels of a grouping vector, in order of first appearance.
Arguments
groupis a vector of class labels, one per observation, or an empty vector when the observations are not grouped.
Output
vLevelsvector contains the unique labels found ingroup, in order of first appearance, or an empty vector whengroupis empty. The recipes draw one series per level, which is what gives categorical colors and one legend entry per class.
BigRiverPlots.get_loadings_coords — Method
getloadingscoords(loadings::Matrix{Float64}; comp::Int = 1, varnames::Vector{String} = String[], nonzero::Bool = false, ntop::Int = 0) =>
Returns the loadings of one component of a matrix of loadings, ready for plotting, together with the names of the variables they belong to.
Arguments
loadingsis the matrix of loadings, variables (rows) by components (columns). Any set of variable weights can be given: the loadings of a PCA or a sparse PCA, the right factors of a penalized matrix decomposition, the X loadings of a PLS regression, the loadings of a discriminant model, the canonical directions of a CCA, or the joint loadings of a block of a JIVE model.compis the component whose loadings are drawn, default is1.varnamesis a vector of names, one per variable, default isString[]for no names, in which case the variables are named by their index. They are subset along with the loadings, which is why they are given here rather than passed to the plot asxticks: the caller cannot know which variablesnonzeroandntopwill keep.nonzerokeeps only the variables whose loading is not zero, default isfalse. This is what the models with an L1 penalty need, since most of their loadings sit exactly at zero and drawing them all leaves the selected ones lost in a flat line.ntopkeeps only thentopvariables of largest absolute loading, in variable order, default is0for all of them. This is what the dense models need, since a loading over thousands of variables is not readable. Whennonzerois also given, the zeros are dropped first and the largest of what remains are kept.
Output
xvector contains the positions of the variables kept, one to the number kept.yvector contains the loadings of the variables kept on the component.namesvector contains the names of the variables kept, or their indices as strings when novarnameswere given.
BigRiverPlots.get_loadings_heatmap_coords — Method
getloadingsheatmap_coords(loadings::Matrix{Float64}; comps::Vector{Int} = Int[], varnames::Vector{String} = String[], compnames::Vector{String} = String[], nonzero::Bool = false, ntop::Int = 0) =>
Returns the loadings of a fitted model, ready for plotting as a heatmap, together with the names of the variables and of the components they belong to.
Arguments
loadingsis the matrix of loadings, variables (rows) by components (columns). Any set of variable weights can be given: the loadings of a PCA or a sparse PCA, the right factors of a penalized matrix decomposition, the X loadings of a PLS regression, the loadings of a discriminant model, the canonical directions of a CCA, or the joint loadings of a block of a JIVE model.compsis a vector naming the components to be drawn, default isInt[]for all of them. Unlike the loadings plot, which draws one component, the heatmap draws them together, which is what shows whether two components select the same variables.varnamesis a vector of names, one per variable, default isString[]for no names, in which case the variables are named by their index. They are subset along with the loadings, which is why they are given here rather than passed to the plot asyticks: the caller cannot know which variablesnonzeroandntopwill keep.compnamesis a vector of names, one per component, default isString[]for no names, in which case the components are named by their index. They are subset along with the loadings too, followingcomps.nonzerokeeps only the variables whose loading is not zero on AT LEAST ONE of the components drawn, default isfalse. This is what the models with an L1 penalty need, since most of their rows are zero throughout and leave the heatmap a flat field of the midtone.ntopkeeps only thentopvariables of largest absolute loading, taken over the components drawn and returned in variable order, default is0for all of them. This is what the dense models need, since a heatmap of thousands of rows resolves to nothing. Whennonzerois also given, the zeros are dropped first and the largest of what remains are kept.
Output
zmatrix contains the loadings kept, variables (rows) by components (columns).xnamesvector contains the names of the components drawn.ynamesvector contains the names of the variables kept.
BigRiverPlots.get_mosaic_coords — Method
getmosaiccoords(counts::Matrix{Float64}; rownames::Vector{String} = String[], colnames::Vector{String} = String[], xpad::Float64 = 0.02, ypad::Float64 = 0.02) Splits a contingency table into the tile geometry of a mosaic plot.
Arguments
countsis the contingency table, one row per row category and one column per column category, holding counts or any non negative weights.rownamesis a vector of names, one per row, default isString[]in which case the rows are named by their index.colnamesis a vector of names, one per column, default isString[]in which case the columns are named by their index.xpadis the gap left between the columns, default is0.02.ypadis the gap left between the stacked tiles within a column, default is0.02.
Output
x,ware the centre and width of each column.bottoms,heightsare the lower edge and height of every tile.countsis passed back through, so the recipe can label the tiles with the raw count.condprobsis the conditional probability of each cell within its column, P(y|x).jointprobsis each cell's count over the grand total, its share of the whole table.colmarginalsis the total of each column, andcoltotalprobits share of the grand total, so the top strip can show either the column count or the marginal P(x).rnames,cnames,yticksname the tiles and place the row ticks.
BigRiverPlots.get_pairs_coords — Method
getpairscoords(scores::Matrix{Float64}; comps::Vector{Int} = Int[], compnames::Vector{String} = String[]) =>
Returns the components of a matrix of scores to be crossed against one another, ready for plotting, together with the names they belong to.
Arguments
scoresis the matrix of scores, observations (rows) by components (columns). Any set of sample coordinates can be given: the projected data of a PCA or a sparse PCA, the left factors of a penalized matrix decomposition, the X scores of a PLS regression, the X variates of a discriminant model, the canonical variates of a CCA, or the joint scores of a JIVE model.compsis a vector naming the components to be crossed, default isInt[]for all of them. The grid drawn is square in the number given, so it grows fast: four components make sixteen cells, and six make thirty six. Three or four is usually as much as reads.compnamesis a vector of names, one per component ofscores, default isString[]for no names, in which case the components are named by their index. They are subset along with the scores, followingcomps, which is why they are given here rather than passed to the plot as ticks.
Output
zmatrix contains the scores of the components kept, observations (rows) by components (columns).namesvector contains the names of the components kept, one per column ofz.
BigRiverPlots.get_predict_observations_coords — Method
getpredictobservations_coords(observed::Matrix{Float64}, predicted::Matrix{Float64}; resp::Int = 1) =>
Returns the observed and predicted values of one response, ready for plotting one against the other, together with the reference line and the coefficient of determination.
Arguments
observedis the matrix of observed responses, observations (rows) by responses (columns): the Y a PLS regression was fitted or tested against.predictedis the matrix of predicted responses of the same shape, as returned byplskern_predict.respis the response column drawn, default is1. A PLS regression can predict several responses at once, so one is chosen; call the plot again with a differentrespfor each.
Output
xvector contains the observed values of the response.yvector contains the predicted values of the response.linetuple contains the two endpoints of the line of perfect prediction, as(lo, hi), spanning the range of the values shown so the diagonal reaches corner to corner.r2is the coefficient of determination between observed and predicted, the fraction of the variance of the observed accounted for, so a value near one is a close fit.
BigRiverPlots.get_scores_coords — Method
getscorescoords(scores::Matrix{Float64}; comps::Tuple{Int, Int} = (1, 2)) =>
Returns the coordinates of two components of a matrix of scores, ready for plotting.
Arguments
scoresis the matrix of scores, observations (rows) by components (columns). Any set of sample coordinates can be given: the projected data of a PCA or a sparse PCA, the left factors of a penalized matrix decomposition, the X scores of a PLS regression, the X variates of a discriminant model, the canonical variates of a CCA, or the joint scores of a JIVE model.compsis a tuple naming the two components placed on the x and y axes, default is(1, 2).
Output
xvector contains the scores of the observations on the first component.yvector contains the scores of the observations on the second component.
BigRiverPlots.get_scree_coords — Method
getscreecoords(values::AbstractVector; ncomp::Int = 0, compnames::Vector{String} = String[], cumulative::Bool = false) =>
Returns the per component values of a fitted model, ready for plotting as a scree, together with the names of the components they belong to.
Arguments
valuesis a vector of one value per component: the variances of a PCA or a sparse PCA, the weightsdof a penalized matrix decomposition or a sparse CCA, or the canonical correlations of a CCA. Any per component quantity can be given, since the scree only asks that it fall off from the first component to the last.ncompis the number of leading components to keep, default is0for all of them. A scree is read for its elbow, which is near the front, so the long tail can be dropped without losing the shape.compnamesis a vector of names, one per component, default isString[]for no names, in which case the components are named by their index. They are subset along with the values, which is why they are given here rather than passed to the plot as ticks.cumulativereturns the running total of the values rather than the values themselves, default isfalse. On the proportion of variance of a PCA this gives the rising curve read against a threshold, the companion to the falling bars.
Output
xvector contains the positions of the components kept, one to the number kept.yvector contains the values of the components kept, cumulated when asked.namesvector contains the names of the components kept, or their indices as strings when nocompnameswere given.
BigRiverPlots.get_sparsity_coords — Method
getsparsitycoords(loadings::Matrix{Float64}; comps::Vector{Int} = Int[], ncomp::Int = 0, compnames::Vector{String} = String[], asfraction::Bool = false) =>
Returns the count of selected variables per component of a loading matrix, ready for plotting, together with the names of the components they belong to.
Arguments
loadingsis a matrix of loadings, variables (rows) by components (columns), from a model with an L1 penalty: the loadings of a sparse PCA, the right factors of a penalized matrix decomposition, the loadings of a sparse discriminant model, or the canonical vectors of a sparse CCA. A variable is counted as selected on a component when its loading there is not zero.compsis a vector naming the components to be drawn, default isInt[]for all of them. It selects an explicit, possibly non contiguous, set, such as[1, 3, 4].ncompis the number of leading components to keep, default is0for all of them. It is a shorthand for the leadingncompcomponents, and is ignored whencompsis given.compnamesis a vector of names, one per component ofloadings, default isString[]for no names, in which case the components are named by their index. They are subset along with the counts, followingcomps, which is why they are given here rather than passed to the plot as ticks.asfractionreturns the fraction of the variables selected rather than the count, default isfalse. On a model with many variables the fraction reads more easily than a raw count, since it does not depend on knowing how many variables there are.
Output
xvector contains the positions of the components kept, one to the number kept.yvector contains the number of variables selected on each component, or the fraction when asked.namesvector contains the names of the components kept, or their indices as strings when nocompnameswere given.
BigRiverPlots.get_vip_coords — Method
getvipcoords(vips::Matrix{Float64}; comp::Int = 0, varnames::Vector{String} = String[], above::Bool = false, ntop::Int = 0) =>
Returns the VIP scores of one component of a VIP matrix, sorted from the largest to the smallest, ready for plotting as horizontal bars, together with the names of the variables they belong to.
Arguments
vipsis the matrix of Variable Importance in Projection scores, variables (rows) by components (columns), as returned byvipon a fitted plsda or splsda. Columnhis the VIP through the firsthcomponents together, so the last column is the overall importance and is the one usually read.compis the component whose column is drawn, default is0for the last, the overall VIP. A VIP is cumulative, so an earlier column reads the importance built up to that component alone.varnamesis a vector of names, one per variable, default isString[]for no names, in which case the variables are named by their index. They are subset and sorted along with the scores, which is why they are given here.abovekeeps only the variables scoring above one, default isfalse. One is the usual threshold for an important variable, since the VIP scores are scaled so that their mean square is one, so a score above one is above average.ntopkeeps only thentopvariables of largest VIP, default is0for all of them. This is what a model over many variables needs when the names are wanted, though the plot hides the names past a few dozen and shows every bar as a curve regardless.
The scores are always returned sorted from the largest to the smallest. The plot lays them out as horizontal bars up the y-axis, so over many variables the sorted bars read as a smooth curve falling away from the threshold, and the count of variables clearing one is the height at which the curve crosses the line.
Output
xvector contains the positions of the variables, one to the number kept, in sorted order.yvector contains the VIP scores, from the largest to the smallest.namesvector contains the names of the variables in the same sorted order, or their indices as strings when novarnameswere given.
BigRiverPlots.plot_biplot! — Method
plot_biplot!(scores::Matrix{Float64}, loadings::Matrix{Float64}; comps::Tuple{Int, Int} = (1, 2), group::AbstractVector = [], varnames::Vector{String} = String[], nonzero::Bool = false, ntop::Int = 0, arrowscale::Float64 = 0.0, kwargs...) Adds a biplot of a fitted model to the current plot.
Arguments
scoresis the matrix of scores, observations (rows) by components (columns), which places the points.loadingsis the matrix of loadings, variables (rows) by components (columns), which points the arrows. It should come from the same fitted model asscores.compsis a tuple naming the two components placed on the x and y axes, default is(1, 2).groupis a vector of class labels, one per observation, used to color the points and to trace one confidence ellipse per class, default is[]for no grouping.varnamesis a vector of names, one per variable, default isString[]in which case the variables are named by their index. They are given here rather than as annotations because they are subset along with the arrows.nonzerokeeps only the variables whose loading is not zero on at least one of the two components drawn, default isfalse, which is what the models with an L1 penalty need.ntopkeeps only thentopvariables of longest arrow, default is0for all of them, which is what the dense models need over many variables.arrowscaleis the factor the arrows are scaled by, default is0.0to scale them onto the cloud of points automatically.
BigRiverPlots.plot_biplot — Method
plot_biplot(scores::Matrix{Float64}, loadings::Matrix{Float64}; comps::Tuple{Int, Int} = (1, 2), group::AbstractVector = [], varnames::Vector{String} = String[], nonzero::Bool = false, ntop::Int = 0, arrowscale::Float64 = 0.0, kwargs...) Generates a biplot of a fitted model, drawing the observations as points and the variables as arrows.
Arguments
scoresis the matrix of scores, observations (rows) by components (columns), which places the points.loadingsis the matrix of loadings, variables (rows) by components (columns), which points the arrows. It should come from the same fitted model asscores.compsis a tuple naming the two components placed on the x and y axes, default is(1, 2).groupis a vector of class labels, one per observation, used to color the points and to trace one confidence ellipse per class, default is[]for no grouping.varnamesis a vector of names, one per variable, default isString[]in which case the variables are named by their index. They are given here rather than as annotations because they are subset along with the arrows.nonzerokeeps only the variables whose loading is not zero on at least one of the two components drawn, default isfalse, which is what the models with an L1 penalty need.ntopkeeps only thentopvariables of longest arrow, default is0for all of them, which is what the dense models need over many variables.arrowscaleis the factor the arrows are scaled by, default is0.0to scale them onto the cloud of points automatically.
BigRiverPlots.plot_confidence — Method
plot_confidence((x::Vector{<:AbstractFloat}, y ::Vector{<:String}, ε ::Vector; kwargs...)
Generates a confidence plot.
Arguments
xcontains estimated values.yis a vector where each element correponds the labels of each estimates included inx.εvector contains the variations relative to each x-value estimates in the confidence interval.
If the variation in not symmetrical, `ε` should be a 2-tuple of vector, where the first vector
corresponds to the left variation and the second to the right to the x-estimates.BigRiverPlots.plot_jive_variance! — Method
plotjivevariance!(blocks::Vector{Matrix{Float64}}, joint::Vector{Matrix{Float64}}, individual::Vector{Matrix{Float64}}; blocknames::Vector{String} = String[], kwargs...) Adds a stacked bar plot of the joint, individual, and residual variation of each block of a JIVE model to the current plot.
Arguments
blocksis the vector of raw data blocks the model was fitted on, one matrix per block, variables (rows) by observations (columns).jointis the vector of joint structure matrices,m.J, one per block.individualis the vector of individual structure matrices,m.A, one per block.blocknamesis a vector of names, one per block, default isString[]in which case the blocks are named by their index.
BigRiverPlots.plot_jive_variance — Method
plotjivevariance(blocks::Vector{Matrix{Float64}}, joint::Vector{Matrix{Float64}}, individual::Vector{Matrix{Float64}}; blocknames::Vector{String} = String[], kwargs...) Generates a stacked bar plot of the joint, individual, and residual variation of each block of a JIVE model.
Arguments
blocksis the vector of raw data blocks the model was fitted on, one matrix per block, variables (rows) by observations (columns).jointis the vector of joint structure matrices,m.J, one per block.individualis the vector of individual structure matrices,m.A, one per block.blocknamesis a vector of names, one per block, default isString[]in which case the blocks are named by their index.
BigRiverPlots.plot_loadings! — Method
plot_loadings!(loadings::Matrix{Float64}; comp::Int = 1, varnames::Vector{String} = String[], nonzero::Bool = false, ntop::Int = 0, kwargs...) Adds a bar plot of the variable loadings of one component of a fitted model to the current plot.
Arguments
loadingsis the matrix of loadings, variables (rows) by components (columns).compis the component whose loadings are drawn, default is1.varnamesis a vector of names, one per variable, default isString[]in which case the variables are named by their index. They are given here rather than asxticksbecause they are subset along with the loadings.nonzerokeeps only the variables whose loading is not zero, default isfalse, which is what the models with an L1 penalty need.ntopkeeps only thentopvariables of largest absolute loading, default is0for all of them, which is what the dense models need over many variables.
BigRiverPlots.plot_loadings — Method
plot_loadings(loadings::Matrix{Float64}; comp::Int = 1, varnames::Vector{String} = String[], nonzero::Bool = false, ntop::Int = 0, kwargs...) Generates a bar plot of the variable loadings of one component of a fitted model.
Arguments
loadingsis the matrix of loadings, variables (rows) by components (columns).compis the component whose loadings are drawn, default is1.varnamesis a vector of names, one per variable, default isString[]in which case the variables are named by their index. They are given here rather than asxticksbecause they are subset along with the loadings.nonzerokeeps only the variables whose loading is not zero, default isfalse, which is what the models with an L1 penalty need.ntopkeeps only thentopvariables of largest absolute loading, default is0for all of them, which is what the dense models need over many variables.
BigRiverPlots.plot_loadings_heatmap! — Method
plotloadingsheatmap!(loadings::Matrix{Float64}; comps::Vector{Int} = Int[], varnames::Vector{String} = String[], compnames::Vector{String} = String[], nonzero::Bool = false, ntop::Int = 0, kwargs...) Adds a heatmap of the variable loadings of every component of a fitted model to the current plot.
Arguments
loadingsis the matrix of loadings, variables (rows) by components (columns).compsis a vector naming the components to be drawn, default isInt[]for all of them.varnamesis a vector of names, one per variable, default isString[]in which case the variables are named by their index. They are given here rather than asyticksbecause they are subset along with the loadings.compnamesis a vector of names, one per component, default isString[]in which case the components are named by their index.nonzerokeeps only the variables whose loading is not zero on at least one of the components drawn, default isfalse, which is what the models with an L1 penalty need.ntopkeeps only thentopvariables of largest absolute loading over the components drawn, default is0for all of them, which is what the dense models need over many variables.
BigRiverPlots.plot_loadings_heatmap — Method
plotloadingsheatmap(loadings::Matrix{Float64}; comps::Vector{Int} = Int[], varnames::Vector{String} = String[], compnames::Vector{String} = String[], nonzero::Bool = false, ntop::Int = 0, kwargs...) Generates a heatmap of the variable loadings of every component of a fitted model.
Arguments
loadingsis the matrix of loadings, variables (rows) by components (columns).compsis a vector naming the components to be drawn, default isInt[]for all of them.varnamesis a vector of names, one per variable, default isString[]in which case the variables are named by their index. They are given here rather than asyticksbecause they are subset along with the loadings.compnamesis a vector of names, one per component, default isString[]in which case the components are named by their index.nonzerokeeps only the variables whose loading is not zero on at least one of the components drawn, default isfalse, which is what the models with an L1 penalty need.ntopkeeps only thentopvariables of largest absolute loading over the components drawn, default is0for all of them, which is what the dense models need over many variables.
BigRiverPlots.plot_mosaic! — Method
plot_mosaic!(counts::Matrix{Float64}; rownames::Vector{String} = String[], colnames::Vector{String} = String[], mode::Symbol = :count, marginals::Symbol = :none, xpad::Float64 = 0.02, ypad::Float64 = 0.02, kwargs...) Adds a mosaic plot of a contingency table to the current plot.
Arguments
countsis the contingency table, one row per row category and one column per column category, holding counts or any non negative weights.rownamesis a vector of names, one per row, default isString[]in which case the rows are named by their index.colnamesis a vector of names, one per column, default isString[]in which case the columns are named by their index.modeis what each tile is labelled with, default is:count.:countwrites the raw count,:conditionalthe conditional probabilityP(y|x), and:totalthe joint probability, the cell's share of the whole table.marginalsis what the strip along the top shows, default is:none.:countwrites the total of each column and:probabilitythe marginal probability of each column.xpadis the gap left between the columns, default is0.02.ypadis the gap left between the stacked tiles within a column, default is0.02.
BigRiverPlots.plot_mosaic — Method
plot_mosaic(counts::Matrix{Float64}; rownames::Vector{String} = String[], colnames::Vector{String} = String[], mode::Symbol = :count, marginals::Symbol = :none, xpad::Float64 = 0.02, ypad::Float64 = 0.02, kwargs...) Generates a mosaic plot of a contingency table, the area of each tile proportional to its count.
Arguments
countsis the contingency table, one row per row category and one column per column category, holding counts or any non negative weights.rownamesis a vector of names, one per row, default isString[]in which case the rows are named by their index. They are given here rather than asyticksbecause the plot places them against the tiles rather than at even spacing.colnamesis a vector of names, one per column, default isString[]in which case the columns are named by their index.modeis what each tile is labelled with, default is:count.:countwrites the raw count,:conditionalthe conditional probabilityP(y|x), and:totalthe joint probability, the cell's share of the whole table.marginalsis what the strip along the top shows, default is:none.:countwrites the total of each column and:probabilitythe marginal probability of each column.xpadis the gap left between the columns, default is0.02.ypadis the gap left between the stacked tiles within a column, default is0.02.
BigRiverPlots.plot_pairs! — Method
plot_pairs!(scores::Matrix{Float64}; comps::Vector{Int} = Int[], group::AbstractVector = [], compnames::Vector{String} = String[], kwargs...) Adds a scatter matrix of the sample scores of a fitted model to the current plot.
Arguments
scoresis the matrix of scores, observations (rows) by components (columns).compsis a vector naming the components to be crossed, default isInt[]for all of them. At least two are needed, and three or four is usually as much as reads.groupis a vector of class labels, one per observation, used to color the points of the cells off the diagonal, default is[]for no grouping.compnamesis a vector of names, one per component, default isString[]in which case the components are named by their index. They are given here rather than as labels because they are subset along with the scores, and because each names both a row and a column of the grid.
BigRiverPlots.plot_pairs — Method
plot_pairs(scores::Matrix{Float64}; comps::Vector{Int} = Int[], group::AbstractVector = [], compnames::Vector{String} = String[], kwargs...) Generates a scatter matrix of the sample scores of a fitted model, crossing every component against every other.
Arguments
scoresis the matrix of scores, observations (rows) by components (columns).compsis a vector naming the components to be crossed, default isInt[]for all of them. At least two are needed, and three or four is usually as much as reads.groupis a vector of class labels, one per observation, used to color the points of the cells off the diagonal, default is[]for no grouping.compnamesis a vector of names, one per component, default isString[]in which case the components are named by their index. They are given here rather than as labels because they are subset along with the scores, and because each names both a row and a column of the grid.
BigRiverPlots.plot_predict_observations! — Method
plotpredictobservations!(observed::Matrix{Float64}, predicted::Matrix{Float64}; resp::Int = 1, kwargs...) Adds a predicted versus observed plot of a regression to the current plot.
Arguments
observedis the matrix of observed responses, observations (rows) by responses (columns).predictedis the matrix of predicted responses of the same shape, as returned byplskern_predict.respis the response column drawn, default is1. Call again with a differentrespfor each response of a multivariate regression.
BigRiverPlots.plot_predict_observations — Method
plotpredictobservations(observed::Matrix{Float64}, predicted::Matrix{Float64}; resp::Int = 1, kwargs...) Generates a predicted versus observed plot of a regression, with the line of perfect prediction and the R squared.
Arguments
observedis the matrix of observed responses, observations (rows) by responses (columns).predictedis the matrix of predicted responses of the same shape, as returned byplskern_predict.respis the response column drawn, default is1. Call again with a differentrespfor each response of a multivariate regression.
BigRiverPlots.plot_scores! — Method
plot_scores!(scores::Matrix{Float64}; comps::Tuple{Int, Int} = (1, 2), group::AbstractVector = [], kwargs...) Adds a scatter plot of the sample scores of a fitted model to the current plot.
Arguments
scoresis the matrix of scores, observations (rows) by components (columns).compsis a tuple naming the two components placed on the x and y axes, default is(1, 2).groupis a vector of class labels, one per observation, used to color the points, default is[]for no grouping.
BigRiverPlots.plot_scores — Method
plot_scores(scores::Matrix{Float64}; comps::Tuple{Int, Int} = (1, 2), group::AbstractVector = [], kwargs...) Generates a scatter plot of the sample scores of a fitted model.
Arguments
scoresis the matrix of scores, observations (rows) by components (columns).compsis a tuple naming the two components placed on the x and y axes, default is(1, 2).groupis a vector of class labels, one per observation, used to color the points, default is[]for no grouping.
BigRiverPlots.plot_scree! — Method
plot_scree!(values::AbstractVector; ncomp::Int = 0, compnames::Vector{String} = String[], cumulative::Bool = false, kwargs...) Adds a scree plot of the per component values of a fitted model to the current plot.
Arguments
valuesis a vector of one value per component, such asm.variances,m.dorm.corrs.ncompis the number of leading components to keep, default is0for all of them.compnamesis a vector of names, one per component, default isString[]in which case the components are named by their index. They are given here rather than asxticksbecause they are subset along with the values.cumulativedraws the running total of the values rather than the values themselves, default isfalse, useful on the proportion of variance of a PCA.
BigRiverPlots.plot_scree — Method
plot_scree(values::AbstractVector; ncomp::Int = 0, compnames::Vector{String} = String[], cumulative::Bool = false, kwargs...) Generates a scree plot of the per component values of a fitted model, as bars with a line riding their tops.
Arguments
valuesis a vector of one value per component, such asm.variances,m.dorm.corrs.ncompis the number of leading components to keep, default is0for all of them.compnamesis a vector of names, one per component, default isString[]in which case the components are named by their index. They are given here rather than asxticksbecause they are subset along with the values.cumulativedraws the running total of the values rather than the values themselves, default isfalse, useful on the proportion of variance of a PCA.
BigRiverPlots.plot_sparsity! — Method
plot_sparsity!(loadings::Matrix{Float64}; ncomp::Int = 0, compnames::Vector{String} = String[], asfraction::Bool = false, kwargs...) Adds a bar plot of the number of variables each component of a penalized model keeps nonzero to the current plot.
Arguments
loadingsis a matrix of loadings, variables (rows) by components (columns), from a model with an L1 penalty.ncompis the number of leading components to keep, default is0for all of them.compnamesis a vector of names, one per component, default isString[]in which case the components are named by their index. They are given here rather than asxticksbecause they are subset along with the counts.asfractiondraws the fraction of the variables selected rather than the count, default isfalse.
BigRiverPlots.plot_sparsity — Method
plot_sparsity(loadings::Matrix{Float64}; ncomp::Int = 0, compnames::Vector{String} = String[], asfraction::Bool = false, kwargs...) Generates a bar plot of the number of variables each component of a penalized model keeps nonzero.
Arguments
loadingsis a matrix of loadings, variables (rows) by components (columns), from a model with an L1 penalty.ncompis the number of leading components to keep, default is0for all of them.compnamesis a vector of names, one per component, default isString[]in which case the components are named by their index. They are given here rather than asxticksbecause they are subset along with the counts.asfractiondraws the fraction of the variables selected rather than the count, default isfalse.
BigRiverPlots.plot_vip! — Method
plot_vip!(vips::Matrix{Float64}; comp::Int = 0, varnames::Vector{String} = String[], above::Bool = false, ntop::Int = 0, kwargs...) Adds a horizontal bar plot of the Variable Importance in Projection of a discriminant model to the current plot.
Arguments
vipsis the matrix of VIP scores, variables (rows) by components (columns), as returned byvipon a fitted plsda or splsda.compis the component whose column is drawn, default is0for the last, the overall VIP.varnamesis a vector of names, one per variable, default isString[]in which case the variables are named by their index. They are given here rather than asyticksbecause they are sorted and subset along with the scores. The plot hides them past a few dozen, since there is no room for a tick per variable.abovekeeps only the variables scoring above one, the usual threshold for an important variable, default isfalse.ntopkeeps only thentopvariables of largest VIP, default is0for all of them.
BigRiverPlots.plot_vip — Method
plot_vip(vips::Matrix{Float64}; comp::Int = 0, varnames::Vector{String} = String[], above::Bool = false, ntop::Int = 0, kwargs...) Generates a horizontal bar plot of the Variable Importance in Projection of a discriminant model, sorted, with a threshold line at one.
Arguments
vipsis the matrix of VIP scores, variables (rows) by components (columns), as returned byvipon a fitted plsda or splsda.compis the component whose column is drawn, default is0for the last, the overall VIP.varnamesis a vector of names, one per variable, default isString[]in which case the variables are named by their index. They are given here rather than asyticksbecause they are sorted and subset along with the scores. The plot hides them past a few dozen, since there is no room for a tick per variable.abovekeeps only the variables scoring above one, the usual threshold for an important variable, default isfalse.ntopkeeps only thentopvariables of largest VIP, default is0for all of them.
Internal functions
Internal helpers, documented for reference. These are not part of the public API and may change.