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

  • comp is the index of the single component to be drawn.
  • ncomp is 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.
source
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

  • comps is a tuple naming the two components to be placed on the x and y axes.
  • ncomp is 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.
source
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

  • scores is the matrix of scores, observations (rows) by components (columns), which places the points.
  • loadings is the matrix of loadings, variables (rows) by components (columns), which points the arrows. It should come from the same fitted model as scores.
  • comps is a tuple naming the two components placed on the x and y axes, default is (1, 2).
  • varnames is a vector of names, one per variable, default is String[] 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.
  • nonzero keeps only the variables whose loading is not zero on at least one of the two components drawn, default is false. 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.
  • ntop keeps only the ntop variables of largest arrow length, default is 0 for all of them. This is what the dense models need, since an arrow per variable over thousands of them buries the points.
  • arrowscale is the factor the arrows are scaled by, default is 0.0 to 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

  • sxy matrix contains the scores of the observations on the two components, in two columns.
  • axy matrix contains the scaled arrow tips of the variables kept, in two columns.
  • names vector contains the names of the variables kept, one per row of axy.
source
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

  • x is a vector of the coordinates of the observations on the first component.
  • y is a vector of the coordinates of the observations on the second component.
  • nstd is the number of standard deviations the ellipse is drawn at, default is 2.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.
  • npoints is the number of points the ellipse is traced with, default is 100.

Output

  • ex vector contains the coordinates of the ellipse on the first component.
  • ey vector 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.

source
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

  • blocks is 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.
  • joint is the vector of joint structure matrices of the fitted model, m.J, one per block and the same shape as the block.
  • individual is the vector of individual structure matrices of the fitted model, m.A, one per block and the same shape as the block.
  • blocknames is a vector of names, one per block, default is String[] for no names, in which case the blocks are named by their index.

Output

  • varJ vector contains the fraction of each block explained by the joint structure.
  • varI vector contains the fraction of each block explained by its individual structure.
  • varR vector contains the residual fraction, what neither the joint nor the individual structure accounts for, so the three sum to one for each block.
  • names vector 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.

source
BigRiverPlots.get_levels — Method

get_levels(group::AbstractVector) =>

Returns the unique levels of a grouping vector, in order of first appearance.

Arguments

  • group is a vector of class labels, one per observation, or an empty vector when the observations are not grouped.

Output

  • vLevels vector contains the unique labels found in group, in order of first appearance, or an empty vector when group is empty. The recipes draw one series per level, which is what gives categorical colors and one legend entry per class.
source
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

  • loadings is 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.
  • comp is the component whose loadings are drawn, default is 1.
  • varnames is a vector of names, one per variable, default is String[] 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 as xticks: the caller cannot know which variables nonzero and ntop will keep.
  • nonzero keeps only the variables whose loading is not zero, default is false. 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.
  • ntop keeps only the ntop variables of largest absolute loading, in variable order, default is 0 for all of them. This is what the dense models need, since a loading over thousands of variables is not readable. When nonzero is also given, the zeros are dropped first and the largest of what remains are kept.

Output

  • x vector contains the positions of the variables kept, one to the number kept.
  • y vector contains the loadings of the variables kept on the component.
  • names vector contains the names of the variables kept, or their indices as strings when no varnames were given.
source
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

  • loadings is 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.
  • comps is a vector naming the components to be drawn, default is Int[] 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.
  • varnames is a vector of names, one per variable, default is String[] 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 as yticks: the caller cannot know which variables nonzero and ntop will keep.
  • compnames is a vector of names, one per component, default is String[] for no names, in which case the components are named by their index. They are subset along with the loadings too, following comps.
  • nonzero keeps only the variables whose loading is not zero on AT LEAST ONE of the components drawn, default is false. 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.
  • ntop keeps only the ntop variables of largest absolute loading, taken over the components drawn and returned in variable order, default is 0 for all of them. This is what the dense models need, since a heatmap of thousands of rows resolves to nothing. When nonzero is also given, the zeros are dropped first and the largest of what remains are kept.

Output

  • z matrix contains the loadings kept, variables (rows) by components (columns).
  • xnames vector contains the names of the components drawn.
  • ynames vector contains the names of the variables kept.
source
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

  • counts is the contingency table, one row per row category and one column per column category, holding counts or any non negative weights.
  • rownames is a vector of names, one per row, default is String[] in which case the rows are named by their index.
  • colnames is a vector of names, one per column, default is String[] in which case the columns are named by their index.
  • xpad is the gap left between the columns, default is 0.02.
  • ypad is the gap left between the stacked tiles within a column, default is 0.02.

Output

  • x, w are the centre and width of each column.
  • bottoms, heights are the lower edge and height of every tile.
  • counts is passed back through, so the recipe can label the tiles with the raw count.
  • condprobs is the conditional probability of each cell within its column, P(y|x).
  • jointprobs is each cell's count over the grand total, its share of the whole table.
  • colmarginals is the total of each column, and coltotalprob its share of the grand total, so the top strip can show either the column count or the marginal P(x).
  • rnames, cnames, yticks name the tiles and place the row ticks.
source
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

  • scores is 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.
  • comps is a vector naming the components to be crossed, default is Int[] 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.
  • compnames is a vector of names, one per component of scores, default is String[] for no names, in which case the components are named by their index. They are subset along with the scores, following comps, which is why they are given here rather than passed to the plot as ticks.

Output

  • z matrix contains the scores of the components kept, observations (rows) by components (columns).
  • names vector contains the names of the components kept, one per column of z.
source
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

  • observed is the matrix of observed responses, observations (rows) by responses (columns): the Y a PLS regression was fitted or tested against.
  • predicted is the matrix of predicted responses of the same shape, as returned by plskern_predict.
  • resp is the response column drawn, default is 1. A PLS regression can predict several responses at once, so one is chosen; call the plot again with a different resp for each.

Output

  • x vector contains the observed values of the response.
  • y vector contains the predicted values of the response.
  • line tuple 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.
  • r2 is 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.
source
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

  • scores is 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.
  • comps is a tuple naming the two components placed on the x and y axes, default is (1, 2).

Output

  • x vector contains the scores of the observations on the first component.
  • y vector contains the scores of the observations on the second component.
source
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

  • values is a vector of one value per component: the variances of a PCA or a sparse PCA, the weights d of 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.
  • ncomp is the number of leading components to keep, default is 0 for 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.
  • compnames is a vector of names, one per component, default is String[] 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.
  • cumulative returns the running total of the values rather than the values themselves, default is false. On the proportion of variance of a PCA this gives the rising curve read against a threshold, the companion to the falling bars.

Output

  • x vector contains the positions of the components kept, one to the number kept.
  • y vector contains the values of the components kept, cumulated when asked.
  • names vector contains the names of the components kept, or their indices as strings when no compnames were given.
source
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

  • loadings is 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.
  • comps is a vector naming the components to be drawn, default is Int[] for all of them. It selects an explicit, possibly non contiguous, set, such as [1, 3, 4].
  • ncomp is the number of leading components to keep, default is 0 for all of them. It is a shorthand for the leading ncomp components, and is ignored when comps is given.
  • compnames is a vector of names, one per component of loadings, default is String[] for no names, in which case the components are named by their index. They are subset along with the counts, following comps, which is why they are given here rather than passed to the plot as ticks.
  • asfraction returns the fraction of the variables selected rather than the count, default is false. 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

  • x vector contains the positions of the components kept, one to the number kept.
  • y vector contains the number of variables selected on each component, or the fraction when asked.
  • names vector contains the names of the components kept, or their indices as strings when no compnames were given.
source
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

  • vips is the matrix of Variable Importance in Projection scores, variables (rows) by components (columns), as returned by vip on a fitted plsda or splsda. Column h is the VIP through the first h components together, so the last column is the overall importance and is the one usually read.
  • comp is the component whose column is drawn, default is 0 for the last, the overall VIP. A VIP is cumulative, so an earlier column reads the importance built up to that component alone.
  • varnames is a vector of names, one per variable, default is String[] 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.
  • above keeps only the variables scoring above one, default is false. 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.
  • ntop keeps only the ntop variables of largest VIP, default is 0 for 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

  • x vector contains the positions of the variables, one to the number kept, in sorted order.
  • y vector contains the VIP scores, from the largest to the smallest.
  • names vector contains the names of the variables in the same sorted order, or their indices as strings when no varnames were given.
source
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

  • scores is the matrix of scores, observations (rows) by components (columns), which places the points.
  • loadings is the matrix of loadings, variables (rows) by components (columns), which points the arrows. It should come from the same fitted model as scores.
  • comps is a tuple naming the two components placed on the x and y axes, default is (1, 2).
  • group is 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.
  • varnames is a vector of names, one per variable, default is String[] 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.
  • nonzero keeps only the variables whose loading is not zero on at least one of the two components drawn, default is false, which is what the models with an L1 penalty need.
  • ntop keeps only the ntop variables of longest arrow, default is 0 for all of them, which is what the dense models need over many variables.
  • arrowscale is the factor the arrows are scaled by, default is 0.0 to scale them onto the cloud of points automatically.
source
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

  • scores is the matrix of scores, observations (rows) by components (columns), which places the points.
  • loadings is the matrix of loadings, variables (rows) by components (columns), which points the arrows. It should come from the same fitted model as scores.
  • comps is a tuple naming the two components placed on the x and y axes, default is (1, 2).
  • group is 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.
  • varnames is a vector of names, one per variable, default is String[] 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.
  • nonzero keeps only the variables whose loading is not zero on at least one of the two components drawn, default is false, which is what the models with an L1 penalty need.
  • ntop keeps only the ntop variables of longest arrow, default is 0 for all of them, which is what the dense models need over many variables.
  • arrowscale is the factor the arrows are scaled by, default is 0.0 to scale them onto the cloud of points automatically.
source
BigRiverPlots.plot_confidence — Method

plot_confidence((x::Vector{<:AbstractFloat}, y ::Vector{<:String}, ε ::Vector; kwargs...)

Generates a confidence plot.

Arguments

  • x contains estimated values.
  • y is a vector where each element correponds the labels of each estimates included in x.
  • ε 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.
source
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

  • blocks is the vector of raw data blocks the model was fitted on, one matrix per block, variables (rows) by observations (columns).
  • joint is the vector of joint structure matrices, m.J, one per block.
  • individual is the vector of individual structure matrices, m.A, one per block.
  • blocknames is a vector of names, one per block, default is String[] in which case the blocks are named by their index.
source
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

  • blocks is the vector of raw data blocks the model was fitted on, one matrix per block, variables (rows) by observations (columns).
  • joint is the vector of joint structure matrices, m.J, one per block.
  • individual is the vector of individual structure matrices, m.A, one per block.
  • blocknames is a vector of names, one per block, default is String[] in which case the blocks are named by their index.
source
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

  • loadings is the matrix of loadings, variables (rows) by components (columns).
  • comp is the component whose loadings are drawn, default is 1.
  • varnames is a vector of names, one per variable, default is String[] in which case the variables are named by their index. They are given here rather than as xticks because they are subset along with the loadings.
  • nonzero keeps only the variables whose loading is not zero, default is false, which is what the models with an L1 penalty need.
  • ntop keeps only the ntop variables of largest absolute loading, default is 0 for all of them, which is what the dense models need over many variables.
source
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

  • loadings is the matrix of loadings, variables (rows) by components (columns).
  • comp is the component whose loadings are drawn, default is 1.
  • varnames is a vector of names, one per variable, default is String[] in which case the variables are named by their index. They are given here rather than as xticks because they are subset along with the loadings.
  • nonzero keeps only the variables whose loading is not zero, default is false, which is what the models with an L1 penalty need.
  • ntop keeps only the ntop variables of largest absolute loading, default is 0 for all of them, which is what the dense models need over many variables.
source
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

  • loadings is the matrix of loadings, variables (rows) by components (columns).
  • comps is a vector naming the components to be drawn, default is Int[] for all of them.
  • varnames is a vector of names, one per variable, default is String[] in which case the variables are named by their index. They are given here rather than as yticks because they are subset along with the loadings.
  • compnames is a vector of names, one per component, default is String[] in which case the components are named by their index.
  • nonzero keeps only the variables whose loading is not zero on at least one of the components drawn, default is false, which is what the models with an L1 penalty need.
  • ntop keeps only the ntop variables of largest absolute loading over the components drawn, default is 0 for all of them, which is what the dense models need over many variables.
source
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

  • loadings is the matrix of loadings, variables (rows) by components (columns).
  • comps is a vector naming the components to be drawn, default is Int[] for all of them.
  • varnames is a vector of names, one per variable, default is String[] in which case the variables are named by their index. They are given here rather than as yticks because they are subset along with the loadings.
  • compnames is a vector of names, one per component, default is String[] in which case the components are named by their index.
  • nonzero keeps only the variables whose loading is not zero on at least one of the components drawn, default is false, which is what the models with an L1 penalty need.
  • ntop keeps only the ntop variables of largest absolute loading over the components drawn, default is 0 for all of them, which is what the dense models need over many variables.
source
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

  • counts is the contingency table, one row per row category and one column per column category, holding counts or any non negative weights.
  • rownames is a vector of names, one per row, default is String[] in which case the rows are named by their index.
  • colnames is a vector of names, one per column, default is String[] in which case the columns are named by their index.
  • mode is what each tile is labelled with, default is :count. :count writes the raw count, :conditional the conditional probability P(y|x), and :total the joint probability, the cell's share of the whole table.
  • marginals is what the strip along the top shows, default is :none. :count writes the total of each column and :probability the marginal probability of each column.
  • xpad is the gap left between the columns, default is 0.02.
  • ypad is the gap left between the stacked tiles within a column, default is 0.02.
source
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

  • counts is the contingency table, one row per row category and one column per column category, holding counts or any non negative weights.
  • rownames is a vector of names, one per row, default is String[] in which case the rows are named by their index. They are given here rather than as yticks because the plot places them against the tiles rather than at even spacing.
  • colnames is a vector of names, one per column, default is String[] in which case the columns are named by their index.
  • mode is what each tile is labelled with, default is :count. :count writes the raw count, :conditional the conditional probability P(y|x), and :total the joint probability, the cell's share of the whole table.
  • marginals is what the strip along the top shows, default is :none. :count writes the total of each column and :probability the marginal probability of each column.
  • xpad is the gap left between the columns, default is 0.02.
  • ypad is the gap left between the stacked tiles within a column, default is 0.02.
source
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

  • scores is the matrix of scores, observations (rows) by components (columns).
  • comps is a vector naming the components to be crossed, default is Int[] for all of them. At least two are needed, and three or four is usually as much as reads.
  • group is a vector of class labels, one per observation, used to color the points of the cells off the diagonal, default is [] for no grouping.
  • compnames is a vector of names, one per component, default is String[] 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.
source
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

  • scores is the matrix of scores, observations (rows) by components (columns).
  • comps is a vector naming the components to be crossed, default is Int[] for all of them. At least two are needed, and three or four is usually as much as reads.
  • group is a vector of class labels, one per observation, used to color the points of the cells off the diagonal, default is [] for no grouping.
  • compnames is a vector of names, one per component, default is String[] 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.
source
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

  • observed is the matrix of observed responses, observations (rows) by responses (columns).
  • predicted is the matrix of predicted responses of the same shape, as returned by plskern_predict.
  • resp is the response column drawn, default is 1. Call again with a different resp for each response of a multivariate regression.
source
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

  • observed is the matrix of observed responses, observations (rows) by responses (columns).
  • predicted is the matrix of predicted responses of the same shape, as returned by plskern_predict.
  • resp is the response column drawn, default is 1. Call again with a different resp for each response of a multivariate regression.
source
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

  • scores is the matrix of scores, observations (rows) by components (columns).
  • comps is a tuple naming the two components placed on the x and y axes, default is (1, 2).
  • group is a vector of class labels, one per observation, used to color the points, default is [] for no grouping.
source
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

  • scores is the matrix of scores, observations (rows) by components (columns).
  • comps is a tuple naming the two components placed on the x and y axes, default is (1, 2).
  • group is a vector of class labels, one per observation, used to color the points, default is [] for no grouping.
source
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

  • values is a vector of one value per component, such as m.variances, m.d or m.corrs.
  • ncomp is the number of leading components to keep, default is 0 for all of them.
  • compnames is a vector of names, one per component, default is String[] in which case the components are named by their index. They are given here rather than as xticks because they are subset along with the values.
  • cumulative draws the running total of the values rather than the values themselves, default is false, useful on the proportion of variance of a PCA.
source
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

  • values is a vector of one value per component, such as m.variances, m.d or m.corrs.
  • ncomp is the number of leading components to keep, default is 0 for all of them.
  • compnames is a vector of names, one per component, default is String[] in which case the components are named by their index. They are given here rather than as xticks because they are subset along with the values.
  • cumulative draws the running total of the values rather than the values themselves, default is false, useful on the proportion of variance of a PCA.
source
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

  • loadings is a matrix of loadings, variables (rows) by components (columns), from a model with an L1 penalty.
  • ncomp is the number of leading components to keep, default is 0 for all of them.
  • compnames is a vector of names, one per component, default is String[] in which case the components are named by their index. They are given here rather than as xticks because they are subset along with the counts.
  • asfraction draws the fraction of the variables selected rather than the count, default is false.
source
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

  • loadings is a matrix of loadings, variables (rows) by components (columns), from a model with an L1 penalty.
  • ncomp is the number of leading components to keep, default is 0 for all of them.
  • compnames is a vector of names, one per component, default is String[] in which case the components are named by their index. They are given here rather than as xticks because they are subset along with the counts.
  • asfraction draws the fraction of the variables selected rather than the count, default is false.
source
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

  • vips is the matrix of VIP scores, variables (rows) by components (columns), as returned by vip on a fitted plsda or splsda.
  • comp is the component whose column is drawn, default is 0 for the last, the overall VIP.
  • varnames is a vector of names, one per variable, default is String[] in which case the variables are named by their index. They are given here rather than as yticks because 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.
  • above keeps only the variables scoring above one, the usual threshold for an important variable, default is false.
  • ntop keeps only the ntop variables of largest VIP, default is 0 for all of them.
source
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

  • vips is the matrix of VIP scores, variables (rows) by components (columns), as returned by vip on a fitted plsda or splsda.
  • comp is the component whose column is drawn, default is 0 for the last, the overall VIP.
  • varnames is a vector of names, one per variable, default is String[] in which case the variables are named by their index. They are given here rather than as yticks because 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.
  • above keeps only the variables scoring above one, the usual threshold for an important variable, default is false.
  • ntop keeps only the ntop variables of largest VIP, default is 0 for all of them.
source

Internal functions

Internal helpers, documented for reference. These are not part of the public API and may change.