Generates a plot of PCA loadings, illustrating the contribution of features to each principal component. This function can be used to investigate which feature (groups) are contributing to the variance seen in the plot and which need further investigation.
Usage
plot_pca_loading(
data = NULL,
variable,
qc_types = NA,
pca_dims = c(1, 2, 3, 4),
log_transform = TRUE,
top_n = 30,
vertical_bars = FALSE,
abs_loading = TRUE,
filter_data = FALSE,
include_qualifier = FALSE,
include_istd = FALSE,
include_feature_filter = NA,
exclude_feature_filter = NA,
min_median_value = NA,
font_base_size = 8
)Arguments
- data
A
MRMhubExperimentobject.- variable
A character string indicating the variable to use for PCA analysis. Must be one of: "area", "height", "intensity", "norm_intensity", "response", "conc", "conc_raw", "rt", "fwhm".
- qc_types
A character vector specifying the QC types to plot. It must contain at least one element. The default
NAplots any of the non-blank QC types ("SPL", "TQC", "BQC", "HQC", "MQC", "LQC", "NIST", "LTR") present in the dataset.- pca_dims
A numeric vector indicating for which PCA dimensions to the loadings should be shown. Default is c(1, 2, 3, 4).
- log_transform
A logical value indicating whether to log-transform the data before the PCA. Default is
TRUE.- top_n
Number of top features with highest absolute loading that will be to shown for each PC dimension. Default is 30.
- vertical_bars
Show vertical bars instead of horizontal bars in the plot. Default is
FALSE.- abs_loading
Show absolute loading values instead of signed loadings. Default is
TRUE.- filter_data
A logical value indicating whether to use all data (default) or only QC-filtered data (filtered via
filter_features_qc()).- include_qualifier
A logical value indicating whether to include qualifier features. Default is
TRUE.- include_istd
A logical value indicating whether to include internal standard (ISTD) features. Default is
TRUE.- include_feature_filter
A regex pattern or a vector of feature names used to filter features by
feature_id. IfNAor an empty string ("") is provided, the filter is ignored. When a vector of length > 1 is supplied, only features with exactly these names are selected (applied individually as OR conditions).- exclude_feature_filter
A regex pattern or a vector of feature names used to exclude features by
feature_id. IfNAor an empty string ("") is provided, the filter is ignored. When a vector of length > 1 is supplied, only features with exactly these names are excluded (applied individually as OR conditions).- min_median_value
Minimum median feature value across the selected QC-type samples required for a feature to be included.
NA(default) applies no filtering. This is a fast way to exclude noisy features; for principled QC-based filtering usefilter_features_qc().- font_base_size
Numeric. Base font size (in points) for plot text. Default is 8.