Plots a flash object. Several types of plot are possible: see parameter plot_type below as well as functions flash_plot_scree, flash_plot_bar, flash_plot_heatmap, flash_plot_histogram, flash_plot_scatter, and flash_plot_structure.

# S3 method for flash
plot(
  x,
  include_scree = TRUE,
  include_pm = TRUE,
  order_by_pve = FALSE,
  kset = NULL,
  pm_which = c("factors", "loadings"),
  pm_subset = NULL,
  pm_groups = NULL,
  pm_colors = NULL,
  plot_type = c("scree", "bar", "heatmap", "histogram", "scatter", "structure"),
  ...
)

Arguments

x

An object inheriting from class flash.

include_scree

[Deprecated] This parameter has been deprecated; please use plot_type instead.

include_pm

[Deprecated] This parameter has been deprecated; please use plot_type instead.

order_by_pve

If order_by_pve = TRUE, then factor/loadings pairs will be ordered according to proportion of variance explained, from highest to lowest. (By default, they are plotted in the same order as kset; or, if kset is NULL, then they are plotted in the same order as they are found in fl.)

kset

A vector of integers specifying the factor/loadings pairs to be plotted. If order_by_pve = FALSE, then kset also specifies the order in which they are to be plotted.

pm_which

Whether to plot loadings \(L\) or factors \(F\).

pm_subset

A vector of row indices \(i\) or column indices \(j\) (depending on the argument to pm_which) specifying which values \(\ell_{i \cdot}\) or \(f_{j \cdot}\) are to be shown. If the dataset has row or column names, then names rather than indices may be specified. If pm_subset = NULL, then all values will be plotted.

pm_groups

A vector specifying the group to which each row of the data \(y_{i \cdot}\) or column \(y_{\cdot j}\) belongs (groups may be numeric indices or strings). A group must be provided for each plotted row \(i\) or column \(j\), so that the length of pm_groups is exactly equal to the number of rows or columns in the full dataset or, if pm_subset is specified, in the subsetted dataset.

pm_colors

A character vector specifying a color for each unique group specified by pm_groups, or, if pm_groups = NULL, a vector specifying a color for each plotted row \(i\) or column \(j\). For effects, see parameter plot_type.

plot_type

The type of plot to return. Options include:

"scree"

A scree plot showing the proportion of variance explained per factor/loadings pair. See flash_plot_scree.

"bar"

A bar plot of posterior means for loadings or factors (depending on argument pm_which), with one bar per row or column. Colors of bars are specified by argument pm_colors. This type of plot is most useful when rows or columns are small in number or ordered in a logical fashion (e.g., spatially). See flash_plot_bar.

"heatmap"

A heatmap showing posterior means for loadings or factors, with rows or columns grouped using a 1-d embedding. Here pm_color specifies the diverging color gradient (low-mid-high). See flash_plot_heatmap.

"histogram"

Overlapping semi-transparent histograms of posterior means for loadings or factors, with one histogram per group specified by pm_groups (or a single histogram if pm_groups is NULL). Colors of histograms are specified by pm_colors. See flash_plot_histogram.

"scatter"

A scatter plot showing the relationship between posterior means for loadings or factors and a user-supplied covariate. If a covariate is not supplied, then data column or row means will be used. Colors of points are specified by pm_colors. See flash_plot_scatter.

"structure"

A "structure plot" (stacked bar plot) produced using function structure_plot in package fastTopics. Here pm_colors specifies the colors of different factor/loadings pairs (as specified by kset) rather than different groups (as specified by pm_groups). Note that factors/loadings must be nonnegative for structure plots to make sense. See flash_plot_structure.

...

Additional parameters to be passed to respective flash_plot_xxx functions. See flash_plot_scree, flash_plot_bar, flash_plot_heatmap, flash_plot_histogram, flash_plot_scatter, and flash_plot_structure for details.

Value

A ggplot object.