plot_alpha_diversity: plot_alpha_diversity

View source: R/plot_alpha_diversity.R

plot_alpha_diversityR Documentation

plot_alpha_diversity

Description

This is a function for plotting alpha diversity. Alpha diversity can only accept intergers ( counts) OTU table!

Usage

plot_alpha_diversity(
  phyloseq,
  feature,
  feature2 = NA,
  level = NA,
  measures = NA,
  p_test = FALSE,
  colors = NULL,
  dotsize = 0.3,
  label = FALSE,
  print_to_screen = FALSE
)

Arguments

phyloseq

A phyloseq object contain OTU table, taxonomy table, sample metadata and phylogenetic tree, or a phyloseq object only contain constructed OTU table and metadata. OTU table of the phyloseq can only be intergers (counts) !

feature

The column name of the feature you want to select from metadata.

feature2

The column name of another feature you want to select from metadata. Default is NA.

level

Which taxonomy level will be used to calculate alpha diversity. Default is NA. If NA, the original OTU table in phyloseq will be used. If level is given, first an OTU table with taxonomy will be constructed using construct_otu_table, then the OTU table will be used to calculate alpha diversity through phyloseq::plot_richness(). The level name should be one of "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species".

measures

The measures to calculate alpha diversity. Default is NA. If NA, all available alpha diversity measures will be calculated and generate a table. If not NA, measures should be one of c("Observed", "Chao1", "ACE", "Shannon", "Simpson", "InvSimpson", "Fisher"). Note: "Observed", "Chao1", "ACE", "Fisher" these 4 measures can accepts only integers.

p_test

The p-value to test alpha diversity. Default is FALSE, will not calculate p-value. p_test should be either "wilcox" or "kruskal". PS: "wilcox" can only work with two groups.

colors

A vector of colors. The number of colors should be larger than the number of feature. Default is NULL, if NULL, plot_alpha_diversity will use ggsci::jco theme for the plot.

dotsize

See geom_dotplot(dotsize). Default is 0.3.

label

Default is FALSE. If TRUE, add sample name labels to plot.

print_to_screen

Default is FALSE. If TRUE, print alpha-diversity table to the screen.

Examples

plot_alpha_diversity(demo_phyloseq_object, feature = "diagnosis", measures = "Chao1",
p_test = "kruskal")

yeguanhuav/visualization416S documentation built on March 22, 2022, 9:03 p.m.