plotRDA and plotCCA create an RDA/CCA plot starting from the output of CCA and RDA functions, two common methods for supervised ordination of microbiome data.

plotCCA(x, ...)

# S4 method for class 'SingleCellExperiment'
plotCCA(x, dimred, ...)

# S4 method for class 'matrix'
plotCCA(x, ...)

plotRDA(x, ...)

# S4 method for class 'SingleCellExperiment'
plotRDA(x, dimred, ...)

# S4 method for class 'matrix'
plotRDA(x, ...)

Arguments

x

a TreeSummarizedExperiment or a matrix of weights. The latter is returned as output from getRDA.

...

additional parameters for plotting, inherited from plotReducedDim, geom_label and geom_label_repel.

  • add.ellipse: One of c(TRUE, FALSE, "fill", "colour"), indicating whether ellipses should be present, absent, filled or colored. (default: ellipse.fill = TRUE)

  • ellipse.alpha: Numeric scalar. Between 0 and 1. Adjusts the opacity of ellipses. (Default: 0.2)

  • ellipse.linewidth: Numeric scalar. Specifies the size of ellipses. (Default: 0.1)

  • ellipse.linetype: Integer scalar. Specifies the style of ellipses. (Default: 1)

  • confidence.level: Numeric scalar. Between 0 and 1. Adjusts confidence level. (Default: 0.95)

  • add.vectors: Logical scalar. Should vectors appear in the plot. (Default: TRUE)

  • vec.size: Numeric scalar. Specifies the size of vectors. (Default: 0.5)

  • vec.colour: Character scalar. Specifies the colour of vectors. (Default: "black")

  • vec.linetype: Integer scalar. Specifies the style of vector lines. (Default: 1)

  • arrow.size: Numeric scalar. Specifies the size of arrows. (Default: arrow.size = 0.25)

  • label.size: Numeric scalar. Specifies the size of text and labels. (Default: 4)

  • label.colour: Character scalar. Specifies the colour of text and labels. (Default: "black")

  • sep.group: Character scalar. Specifies the separator used in the labels. (Default: "\U2014")

  • repl.underscore: Character scalar. Used to replace underscores in the labels. (Default: " ")

  • vec.text: Logical scalar. Should text instead of labels be used to label vectors. (Default: TRUE)

  • repel.labels: Logical scalar. Should labels be repelled. (Default: TRUE)

  • parse.labels: Logical scalar. Should labels be parsed. (Default: TRUE)

  • add.significance: Logical scalar. Should explained variance and p-value appear in the labels. (Default: TRUE)

  • add.expl.var: Logical scalar. Should explained variance appear on the coordinate axes. (Default: TRUE)

  • add.centroids: Logical scalar. Should centroids of variables be added. (Default: FALSE)

  • add.species: Logical scalar. Should species scores be added. (Default: FALSE)

dimred

Character scalar or integer scalar. Determines the reduced dimension to plot. This is the output of addRDA and resides in reducedDim(tse, dimred).

Value

A ggplot2 object

Details

plotRDA and plotCCA create an RDA/CCA plot starting from the output of CCA and RDA functions, two common methods for supervised ordination of microbiome data. Either a TreeSummarizedExperiment or a matrix object is supported as input. When the input is a TreeSummarizedExperiment, this should contain the output of addRDA in the reducedDim slot and the argument dimred needs to be defined. When the input is a matrix, this should be returned as output from getRDA. However, the first method is recommended because it provides the option to adjust aesthetics to the colData variables through the arguments inherited from plotReducedDim.

Examples

# Load dataset
library(miaViz)
data("enterotype", package = "mia")
tse <- enterotype
 
# Run RDA and store results into TreeSE
tse <- addRDA(
    tse,
    formula = assay ~ ClinicalStatus + Gender + Age,
    FUN = getDissimilarity,
    distance = "bray",
    na.action = na.exclude
    )
               
# Create RDA plot coloured by variable
plotRDA(tse, "RDA", colour.by = "ClinicalStatus")
#> Warning: Removed 243 rows containing non-finite outside the scale range
#> (`stat_ellipse()`).
#> Too few points to calculate an ellipse
#> Too few points to calculate an ellipse
#> Warning: Removed 243 rows containing missing values or values outside the scale range
#> (`geom_point()`).

 
# Create RDA plot with empty ellipses
plotRDA(tse, "RDA", colour.by = "ClinicalStatus", add.ellipse = "colour")
#> Warning: Removed 243 rows containing non-finite outside the scale range
#> (`stat_ellipse()`).
#> Too few points to calculate an ellipse
#> Too few points to calculate an ellipse
#> Warning: Removed 243 rows containing missing values or values outside the scale range
#> (`geom_point()`).

 
# Create RDA plot with text encased in labels
plotRDA(tse, "RDA", colour.by = "ClinicalStatus", vec.text = FALSE)
#> Warning: Removed 243 rows containing non-finite outside the scale range
#> (`stat_ellipse()`).
#> Too few points to calculate an ellipse
#> Too few points to calculate an ellipse
#> Warning: Removed 243 rows containing missing values or values outside the scale range
#> (`geom_point()`).

 
# Create RDA plot without repelling text
plotRDA(tse, "RDA", colour.by = "ClinicalStatus", repel.labels = FALSE)
#> Warning: Removed 243 rows containing non-finite outside the scale range
#> (`stat_ellipse()`).
#> Too few points to calculate an ellipse
#> Too few points to calculate an ellipse
#> Warning: Removed 243 rows containing missing values or values outside the scale range
#> (`geom_point()`).

 
# Create RDA plot without vectors
plotRDA(tse, "RDA", colour.by = "ClinicalStatus", add.vectors = FALSE)
#> Warning: 'add.vectors' is FALSE, so other arguments for vectors and labels will be disregarded.
#> Warning: Removed 243 rows containing non-finite outside the scale range
#> (`stat_ellipse()`).
#> Too few points to calculate an ellipse
#> Too few points to calculate an ellipse
#> Warning: Removed 243 rows containing missing values or values outside the scale range
#> (`geom_point()`).

 
# Calculate RDA as a separate object
rda_mat <- getRDA(
    tse,
    formula = assay ~ ClinicalStatus + Gender + Age,
    FUN = getDissimilarity,
    distance = "bray",
    na.action = na.exclude
    )
 
# Create RDA plot from RDA matrix
plotRDA(rda_mat)
#> Warning: Removed 243 rows containing missing values or values outside the scale range
#> (`geom_point()`).