Learn R Programming

ume (version 1.5.2)

uplot_pca: uplot_pca

Description

This function performs Principal Component Analysis (PCA) on a dataset, and visualizes the results in various ways, including a scatter plot of the first two principal components (PC1 vs PC2) and a Van Krevelen plot projected using PC1 values. The PCA is performed on the molecular formula data, aggregated by a grouping variable, and handles cases where columns exhibit zero variance (which cannot be included in PCA).

Usage

uplot_pca(
  mfd,
  grp,
  int_col = "norm_int",
  palname = "viridis",
  col_bar = TRUE,
  ...
)

Value

A list containing:

pca

The PCA model object (class prcomp).

t_score

A data table of PCA scores (principal component values for each sample).

fig_vk

A Van Krevelen plot projected with PC1 values.

fig_pca

A scatter plot of the first two principal components (PC1 vs PC2).

mfd

The input data table, augmented with principal component values.

Arguments

mfd

data.table with molecular formula data as derived from ume::assign_formulas. Column names of elements/isotopes must match names in the isotope column of ume::masses; values are integers representing counts per formula.

grp

Character vector. Names of columns (e.g., sample or file identifiers) used to aggregate results.

int_col

Character. The name of the column that contains the intensity values to be used (e.g. for clustering or color coding). Default usually is "norm_int" for normalized intensity values.

palname

Color palette name for f_colorz() (viridis, magma, plasma, etc.).

col_bar

Logical. If TRUE, adds a color legend (default is TRUE).

...

Additional arguments passed to methods.

Details

Principal Component Analysis (PCA) Plotting

See Also

uplot_vk for the Van Krevelen plot function.

Other plots: uplot_cluster(), uplot_cvm(), uplot_dbe_minus_o_freq(), uplot_dbe_vs_c(), uplot_freq_ma(), uplot_freq_vs_ppm(), uplot_hc_vs_m(), uplot_heteroatoms(), uplot_isotope_precision(), uplot_kmd(), uplot_lcms(), uplot_ma_vs_mz(), uplot_ms(), uplot_n_mf_per_sample(), uplot_ratios(), uplot_reproducibility(), uplot_ri_vs_sample(), uplot_vk()