R/plot_paired_abundances.R
plot_paired_abundances.Rd
User specified taxa are plotted.
plot_paired_abundances(
x,
select.taxa = NULL,
group = NULL,
group.colors = NULL,
dot.opacity = 0.25,
dot.size = 2,
add.box = FALSE,
box.opacity = 0.25,
group.order = NULL,
add.violin = TRUE,
violin.opacity = 0.25,
ncol = NULL,
nrow = NULL,
line = NULL,
line.down = "#7209b7",
line.stable = "#8d99ae",
line.up = "#14213d",
line.na.value = "grey50",
line.guide = "legend",
line.opacity = 0.25,
line.size = 1,
jitter.width = 0
)
phyloseq-class
object.
a character list of taxa to be plotted. eg. select.taxa <- c("OTU-370251", "OTU-311173", "OTU-341024").
Grouping variable to compare. x axis, eg. before-after, t1-t2.
Colors for plotting groups.
For ggplot alpha to determine opacity for points.
For ggplot point size.
Logical. If boxplot to the added. Default=TRUE
For ggplot alpha to determine opacity for box.
Default is NULL. a list specifying order of x-axis.
Logical. If half violin to the added. Default=TRUE
If add.violin=TRUE, opacity for violin.
If 2 or more taxa to plot, specify number of columns.
If 2 or more taxa to plot, specify number of rows.
Variable to use for lines. E.g. "subject" before-after
Line Color for change when negative. Decreased abundance.
Line Color for no change.
Line Color for change when positive. Increased abundance.
"grey50" for no/missing observations.
"none" to plot guide for line.
Line opacity.
Size of line to plot.
Value to avoid over plotting by moving points.
ggplot
object. This can be further modified using ggpubr.
Useful for instances where user is interested only in some taxa and thier change after an intervention. This can also be used at higher taxonomic levels, output from phyloseq::tax_glom or microbiome::aggregate_taxa.
if (FALSE) {
library(microbiome)
library(microbiomeutilities)
library(gghalves)
library(tidyr)
data(peerj32) # Source: https://peerj.com/articles/32/
pseq <- peerj32$phyloseq # Ren
pseq.rel <- microbiome::transform(pseq, "compositional")
select.taxa <- c("Akkermansia", "Dialister")
group.colors <- c("brown3", "steelblue", "grey70")
p <- plot_paired_abundances(pseq.rel,
select.taxa = select.taxa,
group = "time",
group.colors = group.colors,
dot.opacity = 0.25,
dot.size = 2,
group.order = NULL,
line = "subject"
)
p
}