plot_stacked_bar: plot_stacked_bar

Description Usage Arguments Examples

Description

This is a function for stacked barplot. PS: When faceting the stacked bar plot, use facet_wrap( vars(column_name), scales = "free_x")

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
plot_stacked_bar(
  phyloseq = NULL,
  level = NA,
  feature = NA,
  otu_table = NULL,
  metadata = NULL,
  order = NULL,
  relative_abundance = TRUE,
  legend_position = "top",
  colors = NULL,
  collapse = 0.01,
  title = NA,
  x_text_angle = 90
)

Arguments

phyloseq

A phyloseq object contain otu table, taxonomy table, sample metadata and phylogenetic tree. Set it to NULL if using an OTU table and metadata to draw the stacked barplot.

level

A taxonomy level to plot stacked bar. Default is NA. Required when using phyloseq object.

feature

The feature that will show as a colorbar under x axis. Default is NA.

otu_table

An OTU table. Taxa are colnames, SampleID are rownames (just like phyloseq). Set it to NULL if using phyloseq.

metadata

A metadata for the OTU table. SampleID are rownames (just like phyloseq). Set it to NULL if using phyloseq.

order

A vector of arranged SampleID in wanted order. Default is NULL. If NULL, plot_stacked_bar will automatically arrange samples by the most abundance taxonomy in decreasing order.

relative_abundance

Turn plot into relative abundance or not. Default is TRUE.

legend_position

Legend position. Default is "top". legend_position should be one of "none", "left", "right", "bottom", "top".

colors

A vector of colors. The number of colors should be larger than the number of level. Default is NULL, if NULL, plot_stacked_bar will use distinctive_colors for the plot.

collapse

Default is 0.01, collapse taxonomy which abundance is lower than 1 percent of total into "Others". Set it to FALSE if want to show all taxonomy levels.

title

Default is NA, value for ggplot2::labs(title).

x_text_angle

Default is 90, value for ggplot2::ggplot(themt(axis.text.x = element_text( angle))).

Examples

1
2
# Minimum usage
plot_stacked_bar(demo_phyloseq_object, level = "Genus")

yeguanhuav/visual16S documentation built on Feb. 19, 2022, 10:32 a.m.