fantaxtic_bar-deprecated: Generate a barplot of relative taxon abundances

fantaxtic_bar-deprecatedR Documentation

Generate a barplot of relative taxon abundances

Description

This function generates a ggplot2 barplot for the relative abundances of taxa in a phyloseq object.

Usage

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)

Arguments

physeq_obj

A phyloseq object with an otu_table, a tax_table and, in case of facetting, sample_data.

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 sample_data by which to facet the plots.

grid_by

The name of a second factor in the sample_data by which to facet to plots, resulting in a grid.

facet_type

The type of faceting from ggplot2 to use, either grid or wrap (default).

facet_cols

The number of columns to use for faceting.

gen_uniq_lbls

Generate unique labels (default = TRUE)?

other_label

A character vector specifying the names of taxa in label_by to use a specific color for.

order_alg

The algorithm by which to order samples, or one or more taxa found in label_by. Algorithms can be one of hclust (hierarhical clustering; default), as.is (current order) or alph (alphabetical).

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 base_color.

bar_width

The width of the bars as a fraction of the binwidth (default = 0.9).

Details

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.

Value

A ggplot2 object.

See Also

fantaxtic-deprecated

Examples

#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")

gmteunisse/Fantaxtic documentation built on June 7, 2024, 8:47 a.m.