View source: R/plot_overview_pq.R
| plot_overview_pq | R Documentation |
Produce, in a single call, the main relevant graphical views of alpha- and
beta-diversity for a phyloseq object as a function of one sample
variable (fact). The set of panels adapts to the type of fact:
Numeric variable — alpha-diversity is shown as a Hill-numbers scatter
plot against the variable (via ggscatt_pq(), one panel per Hill order
q, with the correlation statistics from ggstatsplot); the
ordination and UMAP points are colored by a continuous gradient. Venn/UpSet
panels are skipped (they require discrete groups).
Factor with 2 to venn_max levels — alpha-diversity bar plots with
error bars and Tukey letters (via hill_bar_pq()), a Venn diagram of
shared taxa (via ggvenn_pq()), an ordination and a UMAP colored by the
levels.
Factor with more than venn_max levels — same as above but the Venn
diagram is replaced by an UpSet plot (via upset_pq()), which stays
legible with many sets.
This is a convenience wrapper meant for quick exploration; for publication
figures, call the dedicated functions (hill_bar_pq(), ggscatt_pq(),
plot_ordination_pq(), ggvenn_pq(), upset_pq(), umap_pq()) directly to
fine-tune each panel.
plot_overview_pq(
physeq,
fact,
q = c(0, 1, 2),
add_alpha = TRUE,
add_ordination = TRUE,
add_venn = TRUE,
add_umap = TRUE,
venn_max = 4,
ordination_method = "PCoA",
dist_method = "bray",
one_plot = FALSE,
...
)
physeq |
(required) a |
fact |
(required) Name of a sample variable present in the |
q |
(vector of integer, default |
add_alpha |
(logical, default TRUE) Add the alpha-diversity panel: a
Hill-number bar plot ( |
add_ordination |
(logical, default TRUE) Add the beta-diversity ordination panel. |
add_venn |
(logical, default TRUE) Add a Venn (or UpSet) panel of
shared taxa across the levels of |
add_umap |
(logical, default TRUE) Add a UMAP panel (via |
venn_max |
(integer, default 4) Maximum number of levels for which a Venn diagram is drawn. Above this threshold an UpSet plot is used instead. |
ordination_method |
(character, default |
dist_method |
(character, default |
one_plot |
(logical, default FALSE) If TRUE, assemble the panels into a
single figure with the patchwork package. If FALSE (default), return
a named list (one entry per panel), letting the user arrange them freely.
Mirrors the |
... |
Additional arguments passed on to |
The alpha-diversity panel relies on patchwork (always) and,
for a numeric fact, on ggstatsplot (via ggscatt_pq()). Other
panels may additionally require ggVennDiagram (Venn),
ComplexUpset (UpSet) or umap (UMAP) depending on the options
used.
If one_plot = FALSE (default), a named list of plot objects (the
alpha entry is itself a multi-panel patchwork figure). If
one_plot = TRUE, a single patchwork object
assembling all panels.
Adrien Taudière
hill_bar_pq(), ggscatt_pq(), plot_ordination_pq(),
ggvenn_pq(), upset_pq(), umap_pq()
if (requireNamespace("patchwork", quietly = TRUE)) {
# Balanced 6-sample subset spanning two Height levels (fast example).
# UMAP and Venn are disabled here (too few samples / extra dependency).
sn <- sample_names(data_fungi_mini)
hi <- sn[which(data_fungi_mini@sam_data$Height == "High")[1:3]]
lo <- sn[which(data_fungi_mini@sam_data$Height == "Low")[1:3]]
ps <- prune_samples(c(hi, lo), data_fungi_mini)
ps <- clean_pq(ps)
plot_overview_pq(ps, fact = "Height", add_venn = FALSE, add_umap = FALSE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.