mva: Perform multivariate analyses to investigate sample...

View source: R/mva.R

mvaR Documentation

Perform multivariate analyses to investigate sample clustering

Description

mva performs multivariate analysis using several possible methods. The available methods are PCA, PCoA, OPLS and OPLS-DA. The OPLS method requires a numeric y-variable, whilst OPLS-DA requires two groups for comparison. By default, for OPLS and OPLS-DA the number of predictive and orthogonal components are set to 1. Blank samples are automatically detected (using TIC) and excluded. Missing data are imputed using average lipid intensity across all samples.

Usage

mva(
  data,
  measure = "Area",
  method = c("PCA", "PCoA", "OPLS", "OPLS-DA"),
  group_col = NULL,
  groups = NULL,
  ...
)

plot_mva(
  mvaresults,
  components = c(1, 2),
  color_by = NULL,
  ellipse = TRUE,
  hotelling = TRUE
)

plot_mva_loadings(
  mvaresults,
  components = c(1, 2),
  color_by = NULL,
  top.n = nrow(mvaresults$loadings)
)

top_lipids(mvaresults, top.n = 10)

Arguments

data

LipidomicsExperiment object.

measure

Which measure to use as intensity, usually Area (default). The measure should be already summarized and normalized.

method

Either PCA, PCoA, OPLS or OPLS-DA. Default is PCA.

group_col

Sample annotation to use as grouping column. If not provided, samples are treated independently.

groups

A numeric grouping (OPLS) or two groups to be used for supervised analysis (OPLS-DA), ignored in other methods.

...

Extra arguments to be passed to opls() for OPLS-DA, ignored in other methods.

mvaresults

Results obtained from mva().

components

Which components to plot. Ignored for PCoA, OPLS and OPLS-DA results. Default is first 2 components.

color_by

Sample annotation (or lipid annotation in case of plot_mva_loadings) to use as color. Defaults to individual samples / lipids

ellipse

Whether to plot ellipses around groups

hotelling

Whether to plot Hotelling T2.

top.n

Number of top ranked features to highlight in the plot. If omitted, returns top 10 lipids.

Value

Multivariate analysis results in mvaresults object. The object contains the following:

  • scores Sample scores

  • loadings Feature or component loadings (not for PCoA)

  • method Multivariate method that was used

  • row_data Lipid molecule annotations

  • col_data Sample annotations

  • original_object Original output object as returned by corresponding analysis methods

plot_mva returns a ggplot of the sample scores.

plot_mva_loadings returns a ggplot of the loadings.

top_lipids returns s dataframe of top.n lipids with their annotations.

Functions

  • plot_mva(): plots a multivariate scatterplot of sample scores to investigate sample clustering.

  • plot_mva_loadings(): Plot a multivariate scatterplot of feature loadings to investigate feature importance.

  • top_lipids(): extracts top lipids from OPLS-DA results

Examples

data(data_normalized)

# PCA
mvaresults <- mva(data_normalized, measure = "Area", method = "PCA")
plot_mva(mvaresults, color_by = "group")
# NOT RUN
# plot_mva(mvaresults, color_by = "Diet", components = c(2, 3))

# PCoA
mvaresults <- mva(data_normalized, measure = "Area", method = "PCoA")
# NOT RUN
# plot_mva(mvaresults, color_by = "group")

# OPLS-DA
mvaresults <- mva(
  data_normalized,
  method = "OPLS-DA", group_col = "Diet", groups = c("HighFat", "Normal")
)
plot_mva(mvaresults, color_by = "group")
plot_mva_loadings(mvaresults, color_by = "Class", top.n = 10)
top_lipids(mvaresults, top.n = 10)

ahmohamed/lipidr documentation built on July 7, 2023, 2:22 a.m.