Visualize BIOM data with boxplots.
bdiv_boxplot(
biom,
x = NULL,
bdiv = "Bray-Curtis",
layers = "x",
weighted = TRUE,
tree = NULL,
within = NULL,
between = NULL,
stat.by = x,
facet.by = NULL,
colors = TRUE,
shapes = TRUE,
patterns = FALSE,
flip = FALSE,
stripe = NULL,
ci = "ci",
level = 0.95,
p.adj = "fdr",
outliers = NULL,
xlab.angle = "auto",
p.label = 0.05,
transform = "none",
caption = TRUE,
...
)
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.
An rbiom object, such as from as_rbiom()
.
Any value accepted by as_rbiom()
can also be given here.
A categorical metadata column name to use for the x-axis. Or
NULL
, which groups all samples into a single category.
Beta diversity distance algorithm(s) to use. Options are:
"Bray-Curtis"
, "Manhattan"
, "Euclidean"
,
"Jaccard"
, and "UniFrac"
. For "UniFrac"
, a
phylogenetic tree must be present in biom
or explicitly
provided via tree=
. Multiple/abbreviated values allowed.
Default: "Bray-Curtis"
One or more of
c("bar", "box" ("x"), "violin", "dot", "strip", "crossbar", "errorbar", "linerange", "pointrange")
.
Single letter abbreviations are also accepted. For instance,
c("box", "dot")
is equivalent to c("x", "d")
and "xd"
.
Default: "x"
Take relative abundances into account. When
weighted=FALSE
, only presence/absence is considered.
Multiple values allowed. Default: TRUE
A phylo
object representing the phylogenetic
relationships of the taxa in biom
. Only required when
computing UniFrac distances. Default: biom$tree
Dataset field(s) for intra- or inter- sample
comparisons. Alternatively, dataset field names given elsewhere can
be prefixed with '=='
or '!='
to assign them to within
or
between
, respectively. Default: NULL
Dataset field with the statistical groups. Must be
categorical. Default: NULL
Dataset field(s) to use for faceting. Must be categorical.
Default: NULL
How to color the groups. Options are:
TRUE
- Automatically select colorblind-friendly colors.
FALSE
or NULL
- Don't use colors.
Auto-select colors from this set. E.g. "okabe"
Custom colors to use. E.g. c("red", "#00FF00")
Explicit mapping. E.g. c(Male = "blue", Female = "red")
See "Aesthetics" section below for additional information.
Default: TRUE
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.
See "Aesthetics" section below for additional information.
Default: TRUE
Patterns for each group.
Options are similar to colors
's: TRUE
, FALSE
, NULL
, pattern
names ("brick"
, "chevron"
, "fish"
, "grid"
, etc), or a named
vector mapping groups to specific pattern names.
See "Aesthetics" section below for additional information.
Default: FALSE
Transpose the axes, so that taxa are present as rows instead
of columns. Default: FALSE
Shade every other x position. Default: same as flip
How to calculate min/max of the crossbar,
errorbar, linerange, and pointrange layers.
Options are: "ci"
(confidence interval), "range"
,
"sd"
(standard deviation), "se"
(standard error), and
"mad"
(median absolute deviation).
The center mark of crossbar and pointrange represents
the mean, except for "mad"
in which case it represents the median.
Default: "ci"
The confidence level for calculating a confidence interval.
Default: 0.95
Method to use for multiple comparisons adjustment of
p-values. Run p.adjust.methods
for a list of available
options. Default: "fdr"
Show boxplot outliers? TRUE
to always show.
FALSE
to always hide. NULL
to only hide them when
overlaying a dot or strip chart. Default: NULL
Angle of the labels at the bottom of the plot.
Options are "auto"
, '0'
, '30'
, and '90'
.
Default: "auto"
.
Minimum adjusted p-value to display on the plot with a bracket.
p.label = 0.05
- Show p-values that are <= 0.05.
p.label = 0
- Don't show any p-values on the plot.
p.label = 1
- Show all p-values on the plot.
If a numeric vector with more than one value is
provided, they will be used as breaks for asterisk notation.
Default: 0.05
Transformation to apply. Options are:
c("none", "rank", "log", "log1p", "sqrt", "percent")
. "rank"
is
useful for correcting for non-normally distributions before applying
regression statistics. Default: "none"
Add methodology caption beneath the plot.
Default: TRUE
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, d.size = 2
ensures only the points on the
dot layer have their size set to 2
.
All built-in color palettes are colorblind-friendly. The available
categorical palette names are: "okabe"
, "carto"
, "r4"
,
"polychrome"
, "tol"
, "bright"
, "light"
,
"muted"
, "vibrant"
, "tableau"
, "classic"
,
"alphabet"
, "tableau20"
, "kelly"
, and "fishy"
.
Patterns are added using the fillpattern R package. Options are "brick"
,
"chevron"
, "fish"
, "grid"
, "herringbone"
, "hexagon"
, "octagon"
,
"rain"
, "saw"
, "shingle"
, "rshingle"
, "stripe"
, and "wave"
,
optionally abbreviated and/or suffixed with modifiers. For example,
"hex10_sm"
for the hexagon pattern rotated 10 degrees and shrunk by 2x.
See fillpattern::fill_pattern()
for complete documentation of options.
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.
Other beta_diversity:
bdiv_clusters()
,
bdiv_corrplot()
,
bdiv_heatmap()
,
bdiv_ord_plot()
,
bdiv_ord_table()
,
bdiv_stats()
,
bdiv_table()
,
distmat_stats()
Other visualization:
adiv_boxplot()
,
adiv_corrplot()
,
bdiv_corrplot()
,
bdiv_heatmap()
,
bdiv_ord_plot()
,
plot_heatmap()
,
rare_corrplot()
,
rare_multiplot()
,
rare_stacked()
,
stats_boxplot()
,
stats_corrplot()
,
taxa_boxplot()
,
taxa_corrplot()
,
taxa_heatmap()
,
taxa_stacked()
library(rbiom)
biom <- rarefy(hmp50)
bdiv_boxplot(biom, x="==Body Site", bdiv="UniFrac", stat.by="Body Site")
Run the code above in your browser using DataLab