Visualize taxa abundance with scatterplots and trendlines.
Usage
taxa_corrplot(
biom,
x,
rank = -1,
layers = "tc",
taxa = 6,
lineage = FALSE,
unc = "singly",
other = FALSE,
p.top = Inf,
stat.by = NULL,
facet.by = NULL,
colors = TRUE,
shapes = TRUE,
test = "emmeans",
fit = "gam",
at = NULL,
level = 0.95,
p.adj = "fdr",
transform = "none",
ties = "random",
seed = 0,
alt = "!=",
mu = 0,
strata = NULL,
caption = TRUE,
check = FALSE,
cpus = n_cpus(),
...
)Arguments
- biom
An rbiom object, or any value accepted by
as_rbiom().- x
Dataset field with the x-axis values. Equivalent to the
regrargument instats_table(). Required.- rank
What rank(s) of taxa to display. E.g.
"Phylum","Genus",".otu", etc. An integer vector can also be given, where1is the highest rank,2is the second highest,-1is the lowest rank,-2is the second lowest, and0is the OTU "rank". Runbiom$ranksto see all options for a given rbiom object. Default:-1.- layers
The elements to draw, such as the trend line, its confidence band, and the points. One or more of
c("trend", "confidence", "point", "name", "residual"). Single letter abbreviations are also accepted. For instance,c("trend", "point")is equivalent toc("t", "p")and"tp". Default:"tc"- taxa
Which taxa to display. An integer value will show the top n most abundant taxa. A value 0 <= n < 1 will show any taxa with that mean abundance or greater (e.g.
0.1implies >= 10%). A character vector of taxa names will show only those named taxa. Default:6.- lineage
Include all ranks in the name of the taxa. For instance, setting to
TRUEwill produceBacteria; Actinobacteria; Coriobacteriia; Coriobacteriales. Otherwise the taxa name will simply beCoriobacteriales. You want to set this to TRUE whenunc = "asis"and you have taxa names (such as Incertae_Sedis) that map to multiple higher level ranks. Default:FALSE- unc
How to handle unclassified, uncultured, and similarly ambiguous taxa names. Options are:
"singly"-Replaces them with the OTU name.
"grouped"-Replaces them with a higher rank's name.
"drop"-Excludes them from the result.
"asis"-To not check/modify any taxa names.
Abbreviations are allowed. Default:
"singly"- other
Sum all non-itemized taxa into an "Other" taxa. When
FALSE, only returns taxa matched by thetaxaargument. SpecifyingTRUEadds "Other" to the returned set. A string can also be given to implyTRUE, but with that value as the name to use instead of "Other". Default:FALSE- p.top
Only display taxa with the most significant differences in abundance. If
p.topis >= 1, then thep.topmost significant taxa are displayed. Ifp.topis less than one, all taxa with an adjusted p-value <=p.topare displayed. Recommended to be used in combination with thetaxaparameter to set a lower bound on the mean abundance of considered taxa. Default:Inf- stat.by
Dataset field with the statistical groups. Must be categorical. Default:
NULL- facet.by
Dataset field(s) to use for faceting. Must be categorical. Default:
NULL- colors
How to color the groups. Options are:
TRUE-Automatically select colorblind-friendly colors.
FALSEorNULL-Don't use colors.
- a palette name -
Auto-select colors from this set. E.g.
"okabe"- character vector -
Custom colors to use. E.g.
c("red", "#00FF00")- named character vector -
Explicit mapping. E.g.
c(Male = "blue", Female = "red")
A named vector doesn't have to match the plotted groups exactly. Names for groups that aren't in the plot (for instance, after filtering samples) are ignored, and groups without a name get default colors that aren't already in use. Any unnamed entries in the vector are used for those groups first, in order. A warning is given only when a name isn't recognized and a group was left without one, as a misspelled name would do. Names can be case-insensitive abbreviations (
c(m = "blue", f = "red")). For between-group beta diversity, a pair is named as its label shows it, e.g.c("Female vs Male" = "purple"). See "Aesthetics" section below for additional information. Default:TRUE- shapes
Shapes for each group. Options are similar to
colors's:TRUE,FALSE,NULL, shape names (typically integers 0 - 17), or a named vector mapping groups to specific shape names. As withcolors, names for groups that aren't in the plot are ignored and groups without a name get default shapes. See "Aesthetics" section below for additional information. Default:TRUE- test
Method for computing p-values:
'none','emmeans', or'emtrends'. Seestats_table(). Default:'emmeans'- fit
How to fit the trendline.
'lm','log', or'gam'. Default:'gam'- at
Position(s) along
regrwhere group means or local slopes are evaluated. Default:NULL, which uses the median ofregrwithin eachsplit.bystratum. A vector gives one row per position, and p-values are adjusted across all of them. Ignored by tests that do not depend on a position (e.g. a global slope withfit = "lm").- level
The confidence level for calculating a confidence interval. Default:
0.95- p.adj
Method to use for multiple comparisons adjustment of p-values. Run
p.adjust.methodsfor a list of available options. The adjustment spans every p-value in the returned table (all metrics, strata, pairs, and positions). Default:"fdr"- transform
Transformation to apply to calculated values. Options are:
c("none", "rank", "log", "log1p", "sqrt")."rank"is useful for correcting for non-normal distributions before applying regression statistics. Default:"none"- ties
When
transform="rank", how to rank identical values. Options are:c("average", "first", "last", "random", "max", "min"). Seerank()for details. Default:"random"- seed
Random seed for permutations, rarefaction, random tie-breaking, and stochastic ordinations. Results are reproducible for a given seed, and the caller's random number generator state is left unchanged. Must be a non-negative integer. Default:
0- alt
Alternative hypothesis direction. Options are
'!='(two-sided; not equal tomu),'<'(less thanmu), or'>'(greater thanmu). Default:'!='- mu
Reference value to test against. Default:
0- strata
Dataset field with the blocking/subject variable. Permutation tests permute within strata; regression models include a random intercept per stratum. The plotted trendlines are descriptive fits without the strata term. Default:
NULL- caption
Add a caption beneath the plot that states the input table (rarefied, unrarefied, or relative abundances) and the methods (metric parameters, statistical test, p-value adjustment). Default:
TRUE- check
Generate additional plots to aid in assessing data normality. Default:
FALSE- cpus
The number of CPUs to use. Set to
NULLto use all available, or to1to disable parallel processing. This also bounds R's linear algebra library (BLAS): whencpusis less than the number of threads that library is set to use, it runs on one thread until the call returns. See the Multithreading section of rbiom-package. Does not affect results, apart from rounding in the last digits of linear algebra (around 1e-15). Default:ecodive::n_cpus()(all available cores)- ...
Additional parameters to pass along to ggplot2 functions. Prefix a parameter name with a layer name to pass it to only that layer. For instance,
p.size = 2ensures only the points have their size set to2. Unprefixed parameters go to every layer whose function accepts them. An argument that no layer accepts is an error.
Value
A ggplot2 plot. The computed data points, ggplot2 command,
stats table, and stats table commands are available as $data,
$code, $stats, and $stats$code, respectively.
Aesthetics
The default colors are colorblind-friendly for up to 12 groups: Okabe and
Ito's palette ("okabe") for up to 8, and Paul Tol's ("tol") for 9-12.
Of the other palettes, "bright", "vibrant", "muted", "light", and
"carto" are also designed for color vision deficiencies. The available
categorical palette names are: "okabe", "carto", "r4",
"polychrome", "tol", "bright", "light",
"muted", "vibrant", "tableau", "classic",
"alphabet", "tableau20", "kelly", and "fishy".
Shapes can be given as per base R - numbers 0 through 17 for various shapes, or the decimal value of an ascii character, e.g. a-z = 65:90; A-Z = 97:122 to use letters instead of shapes on the plot. Character strings may used as well.
See also
Other taxa_abundance:
sample_sums(),
taxa_boxplot(),
taxa_clusters(),
taxa_da(),
taxa_forest(),
taxa_heatmap(),
taxa_shared(),
taxa_stacked(),
taxa_stats(),
taxa_sums(),
taxa_table(),
taxa_top(),
taxa_upset()
Other visualization:
adiv_boxplot(),
adiv_corrplot(),
bdiv_boxplot(),
bdiv_corrplot(),
bdiv_heatmap(),
bdiv_ord_plot(),
plot_heatmap(),
rare_corrplot(),
rare_multiplot(),
rare_stacked(),
stats_boxplot(),
stats_corrplot(),
taxa_boxplot(),
taxa_forest(),
taxa_heatmap(),
taxa_stacked(),
taxa_upset(),
theme_rbiom()
