tax_stackplot: Plotting stackplot of taxonomy for groups or samples

View source: R/tax_stackplot.R

tax_stackplotR Documentation

Plotting stackplot of taxonomy for groups or samples

Description

Input taxonomy composition, and metadata (SampleID and groupID). Then select top N high abundance taxonomy and group other low abundance. When Select samples can draw sample composition by facet groups. If used group can show mean of each group. Finally, return a ggplot2 object.

Usage

tax_stackplot(
  tax_sum,
  metadata,
  topN = 8,
  groupID = "Group",
  style = "group",
  sorted = "abundance"
)

Arguments

tax_sum

composition matrix, like OTU table and rowname is taxonomy, typical output of usearch -sintax_summary;

metadata

matrix or dataframe, including sampleID and groupID;

topN

Top N taxonomy to show, default 8, alternative 4, 6, 10 ...;

groupID

column name for groupID;

style

group or sample, default group

sorted

Legend sorted type, default abundance, alternative alphabet

Details

By default, returns top 8 taxonomy and group mean stackplot The available style include the following:

  • group: group mean stackplot

  • sample: each sample stackplot and facet by group

Value

ggplot2 object.

Author(s)

Contact: Yong-Xin Liu metagenome@126.com

References

Yong-Xin Liu, Yuan Qin, Tong Chen, Meiping Lu, Xubo Qian, Xiaoxuan Guo & Yang Bai. A practical guide to amplicon and metagenomic analysis of microbiome data. Protein Cell, 2020(41), 1-16, DOI: https://doi.org/10.1007/s13238-020-00724-8

See Also

tax_stackplot

Examples

# Taxonomy table in phylum level, rownames is Phylum, colnames is SampleID
data(tax_phylum)
# metadata, include SampleID, Group and Site
data(metadata)
# tax_sum and metadata as input, default include top 8 taxonomy, groupID is Group, show group mean and sorted by abundance
tax_stackplot(tax_sum = tax_phylum, metadata)
# Set top10 taxonomy, group by "Site", group mean, and sort by abundance
tax_stackplot(tax_sum = tax_phylum, metadata, topN = 10, groupID = "Site", style = "group", sorted = "abundance")
# Set top 10 taxonomy, group by "Group", and sample composition sorted by alphabet
tax_stackplot(tax_sum = tax_phylum, metadata, topN = 10, groupID = "Group", style = "sample", sorted = "alphabet")

microbiota/amplicon documentation built on April 30, 2023, 1:48 p.m.