bdiv_heatmap | R Documentation |
Display beta diversities in an all vs all grid.
bdiv_heatmap(
biom,
bdiv = "Bray-Curtis",
weighted = TRUE,
tree = NULL,
grid = "devon",
color.by = NULL,
order.by = NULL,
limit.by = NULL,
label = TRUE,
label_size = NULL,
rescale = "none",
clust = "complete",
trees = TRUE,
asp = 1,
tree_height = 10,
track_height = 10,
legend = "right",
title = TRUE,
xlab.angle = "auto",
...
)
biom |
An rbiom object, such as from |
bdiv |
Beta diversity distance algorithm(s) to use. Options are:
|
weighted |
Take relative abundances into account. When
|
tree |
A |
grid |
Color palette name, or a list with entries for |
color.by |
Add annotation tracks for these metadata column(s).
See "Annotation Tracks" section below for details.
Default: |
order.by |
Which metadata column(s) to use for ordering the samples
across the x and y axes. Overrides any |
limit.by |
Metadata definition(s) to use for sample subsetting prior
to calculations.
See "Ordering and Limiting" section below for details.
Default: |
label |
Label the matrix rows and columns. You can supply a list
or logical vector of length two to control row labels and column
labels separately, for example
|
label_size |
The font size to use for the row and column labels. You
can supply a numeric vector of length two to control row label sizes
and column label sizes separately, for example
|
rescale |
Rescale rows or columns to all have a common min/max.
Options: |
clust |
Clustering algorithm for reordering the rows and columns by
similarity. You can supply a list or character vector of length two to
control the row and column clustering separately, for example
Default: |
trees |
Draw a dendrogram for rows (left) and columns (top). You can
supply a list or logical vector of length two to control the row tree
and column tree separately, for example
|
asp |
Aspect ratio (height/width) for entire grid.
Default: |
tree_height , track_height |
The height of the dendrogram or annotation
tracks as a percentage of the overall grid size. Use a numeric vector
of length two to assign |
legend |
Where to place the legend. Options are: |
title |
Plot title. Set to |
xlab.angle |
Angle of the labels at the bottom of the plot.
Options are |
... |
Additional arguments to pass on to ggplot2::theme().
For example, |
A ggplot2
plot.
The computed data points and ggplot
command are available as $data
and $code
,
respectively.
Metadata can be displayed as colored tracks above the heatmap. Common use cases are provided below, with more thorough documentation available at https://cmmr.github.io/rbiom .
## Categorical ---------------------------- color.by = "Body Site" color.by = list('Body Site' = "bright") color.by = list('Body Site' = c("Stool", "Saliva"), 'colors' = "bright") color.by = list('Body Site' = c('Stool' = "blue", 'Saliva' = "green")) ## Numeric -------------------------------- color.by = "Age" color.by = list('Age' = "reds") color.by = list('Age' = c(20,NA), 'colors' = "reds") # at least 20 years old color.by = list('Age' = c(20,40)) # between 20 and 40 years old (inclusive) ## Multiple Tracks ------------------------ color.by = c("Body Site", "Age") color.by = list('Body Site' = "bright", 'Age' = "reds") color.by = list( 'Body Site' = c('Stool' = "blue", 'Saliva' = "green"), 'Age' = list(range = c(20,40), 'colors' = "reds") )
The following entries in the track definitions are understood:
colors
- A pre-defined palette name or custom set of colors to map to.
range
- The c(min,max) to use for scale values.
label
- Label for this track. Defaults to the name of this list element.
side
- Options are "top"
(default) or "left"
.
na.color
- The color to use for NA
values.
bins
- Bin a gradient into this many bins/steps.
guide
- A list of arguments for guide_colorbar() or guide_legend().
All built-in color palettes are colorblind-friendly.
Categorical palette names: "okabe"
, "carto"
, "r4"
,
"polychrome"
, "tol"
, "bright"
, "light"
,
"muted"
, "vibrant"
, "tableau"
, "classic"
,
"alphabet"
, "tableau20"
, "kelly"
, and "fishy"
.
Numeric palette names: "reds"
, "oranges"
, "greens"
,
"purples"
, "grays"
, "acton"
, "bamako"
,
"batlow"
, "bilbao"
, "buda"
, "davos"
,
"devon"
, "grayC"
, "hawaii"
, "imola"
,
"lajolla"
, "lapaz"
, "nuuk"
, "oslo"
,
"tokyo"
, "turku"
, "bam"
, "berlin"
,
"broc"
, "cork"
, "lisbon"
, "roma"
,
"tofino"
, "vanimo"
, and "vik"
.
order.by
controls which metadata column(s) are used to arrange
samples on the plot. It also enables subsetting to a particular set or
range of values. Prefix a column name with -
to arrange values in
descending order rather than ascending.
## Categorical ---------------------------- order.by = "Body Site" order.by = list('Body Site' = c("Stool", "Saliva")) ## Numeric -------------------------------- order.by = "-Age" order.by = list('Age' = c(20,NA)) # at least 20 years old order.by = list('-Age' = c(20,40)) # between 20 and 40 years old (inclusive) ## Multiple / Mixed ----------------------- order.by = c("-Body Site", "Age") order.by = list("Body Site", '-Age' = c(20,40))
limit.by
is used to specify a subset of samples without any
side-effects on aesthetics. It is especially useful for limiting the data
to a single categorical metadata value. Unlike the other *.by parameters,
limit.by
must always be a named list()
.
## Categorical ---------------------------- limit.by = list('Sex' = "Male") ## Numeric -------------------------------- limit.by = list('Age' = c(20,NA)) # at least 20 years old limit.by = list('Age' = c(20,40)) # between 20 and 40 years old (inclusive) ## Multiple / Mixed ----------------------- limit.by = list( 'Sex' = "Male", 'Body Site' = c("Stool", "Saliva") 'Age' = c(20,40) )
Other beta_diversity:
bdiv_boxplot()
,
bdiv_corrplot()
,
bdiv_ord_plot()
,
bdiv_ord_table()
,
bdiv_stats()
,
bdiv_table()
,
distmat_stats()
Other visualization:
adiv_boxplot()
,
adiv_corrplot()
,
bdiv_boxplot()
,
bdiv_corrplot()
,
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)
# Keep and rarefy the 10 most deeply sequenced samples.
hmp10 <- rarefy(hmp50, n = 10)
bdiv_heatmap(hmp10, color.by=c("Body Site", "Age"))
bdiv_heatmap(hmp10, bdiv="uni", weighted=c(T,F), color.by="sex")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.