Plot Top Features by Factor from Integration Results
Source:R/plot_top_factor_features.R
plot_top_factor_features.Rd
Visualizes the top loading features for each factor from multi-omics integration results (e.g., MOFA, MCIA, DIABLO, RGCCA).
Usage
plot_top_factor_features(
expomicset,
feature_col = "feature",
factors = NULL,
top_n = 5,
facet_cols = NULL,
exp_name_cols = NULL,
alpha = 0.5
)
Arguments
- expomicset
A
MultiAssayExperiment
object containing integration results in themetadata
slot (must includeintegration_results
).- feature_col
A character string indicating the column name to use for y-axis feature labels (e.g.,
"feature"
,"gene_symbol"
). This should match a column in the output ofpivot_feature()
. Default is"feature"
.- factors
Character vector of factors to include (e.g., "Factor1", "Factor2"). If
NULL
, all factors are plotted.- top_n
Integer specifying the number of top features to show per factor. Default is
5
.- facet_cols
Optional color palette for facet strip backgrounds (one per
exp_name
), used to distinguish factors.- exp_name_cols
Optional color palette for experiment labels in the plot (
exp_name
), passed toscale_color_manual()
.- alpha
Numeric value between 0 and 1 controlling the transparency of facet strip background fill. Default is
0.5
.
Value
A ggplot2
object with one facet per factor, showing the
top features and their loadings by experiment.
Details
This function supports the following integration methods:
"MOFA"
: Uses feature weights from MOFA2 (get_weights()
)."MCIA"
: Uses block loadings from MCIA (@block_loadings
)."DIABLO"
: Extracts block-specific loadings fromloadings
."RGCCA"
: Extracts block-specific loadings froma
.
For each factor, it:
Selects the top
top_n
features by absolute loading.Merges with feature metadata using
pivot_feature()
.Creates a point-range plot showing the loading magnitude.
Facets each factor with a customizable strip background.
The feature_col
argument allows you to control which feature-level
metadata column (e.g., gene symbols, metabolite names) is used for
labeling the y-axis.
If palettes are not provided, defaults are chosen using
ggpubr::get_palette()
.
Examples
# create example data
mae <- make_example_data(
n_samples = 20,
return_mae = TRUE
)
#> Ensuring all omics datasets are matrices with column names.
#> Creating SummarizedExperiment objects.
#> Creating MultiAssayExperiment object.
#> MultiAssayExperiment created successfully.
mae <- run_multiomics_integration(
mae,
method = "MCIA",
n_factors = 3
)
#> Scaling each assay in MultiAssayExperiment.
#> Running multi-omics integration using MCIA...
#> Applying MCIA with `nipalsMCIA`
#> Performing column-level pre-processing...
#> Column pre-processing completed.
#> Performing block-level preprocessing...
#> Block pre-processing completed.
#> Computing order 1 scores
#> Computing order 2 scores
#> Computing order 3 scores
# plot top features using default `feature` column
top_feature_p <- mae |>
plot_top_factor_features()