fantaxtic_bar-deprecated | R Documentation |
This function generates a ggplot2
barplot for the relative abundances
of taxa in a phyloseq object.
fantaxtic_bar(physeq_obj, color_by, label_by = NULL, facet_by = NULL, grid_by = NULL, facet_type = "wrap", bar_width = 0.9, facet_cols = 1, gen_uniq_lbls = TRUE, other_label= NULL, order_alg = "hclust", color_levels = NULL, base_color = "#6495ed", other_color = "#f3f3f3", palette = NULL)
physeq_obj |
A phyloseq object with an |
color_by |
The name of the taxonomic level by which to color the bars. |
label_by |
The name of the taxonomic level by which to label the bars and generate subcolors. |
facet_by |
The name of the factor in the |
grid_by |
The name of a second factor in the |
facet_type |
The type of faceting from ggplot2 to use, either |
facet_cols |
The number of columns to use for faceting. |
gen_uniq_lbls |
Generate unique labels (default = |
other_label |
A character vector specifying the names of taxa in
|
order_alg |
The algorithm by which to order samples, or one or more taxa
found in |
color_levels |
Character vector containing names of levels. Useful to enforce identical colors for levels across different plots or to pair levels with colors. |
base_color |
The base color from which to generate colors. |
other_color |
The base color from which to generate shades for "other" taxa. |
palette |
A user specified palette to color the bars with. Replaces
|
bar_width |
The width of the bars as a fraction of the binwidth (default = 0.9). |
Coloring occurs by a user specified taxonomic level, and subcoloring according to another level can be added if desired (e.g. color by phylum, subcolor by genus). In addition, one or more taxon names can be specified as "other" that receive a specific color (e.g. outliers, collapsed taxa).
By default, unique labels per taxon will be generated in the case that
multiple taxa with identical labels exist, unless the user chooses to suppress
this. Moreover, NA
values in the tax_table
of the phyloseq
object will be renamed to "Unknown"
to avoid confusion. WARNING:
duplicate labels in the data lead to incorrect displaying of data and
labels.
To facilitate visualisation and/or interpretation, samples can be reordered according alphabetically, by the abundance of a certain taxon, by hierarhical clustering or by the abundance of "other" taxa.
A ggplot2
object.
fantaxtic-deprecated
#Load data
data(GlobalPatterns)
#Get the 10 most abundant OTUs / ASVs
ps_tmp <- get_top_taxa(physeq_obj = GlobalPatterns, n = 10, relative = TRUE,
discard_other = FALSE, other_label = "Other")
#Create labels for missing taxonomic ranks
ps_tmp <- name_taxa(ps_tmp, label = "Unkown", species = T, other_label = "Other")
#Generate a barplot that is colored by Phylum and labeled by Species, coloring
#collapsed taxa grey.
fantaxtic_bar(ps_tmp, color_by = "Phylum", label_by = "Species", other_label = "Other")
#Generate a barplot that is colored by Phylum and lebeled by Species. As multiple
# ASVs have the same family annotation, generate unique labels.
fantaxtic_bar(ps_tmp, color_by = "Phylum", label_by = "Family", other_label = "Other",
gen_uniq_lbls = TRUE)
#Change the sample ordering
fantaxtic_bar(ps_tmp, color_by = "Phylum", label_by = "Family", other_label = "Other",
order_alg = "other.abnd")
#Add faceting by sample type
fantaxtic_bar(ps_tmp, color_by = "Phylum", label_by = "Family",
facet_by = "SampleType", other_label = "Other")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.