ra_bars: Function to make stacked bar charts of taxa relative...

Description Usage Arguments Value Examples

View source: R/ra_bars.R

Description

A function to make stacked bar charts of taxa relative abuncance with the choice to stratify by a variable of interest

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
ra_bars(
  micro_set,
  table,
  ...,
  top_taxa = 0,
  RA = 0,
  specific_taxa,
  main,
  subtitle,
  ylab,
  xlab,
  xaxis,
  lines = TRUE
)

Arguments

micro_set

A tidy_micro data set

table

OTU table you'd like to use when calculating alpha diversity. Your lowest level is recommended

...

A categorical variable by which you'd like to stratify your relative abundances

top_taxa

Only plot X taxa with the highest relative abundance. The rest will be aggregated into an "Other" category.

RA

Only plot taxa with a relative abundance higher than X. The rest will be aggregated into an "Other" category.

specific_taxa

Plot this specific taxa even if it doesn't meet the top_taxa or RA requirements

main

Plot title

subtitle

Subtitle for the plot

ylab

y-axis label

xlab

x-axis label

xaxis

Labels for the x-axis ticks. Most useful for categorical variables and defaults to the levels

lines

Logical; Add outlines around the different taxa colors in the stacked bar charts

Value

Returns a ggplot that you can add geoms to if you'd like

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(bpd_phy); data(bpd_cla); data(bpd_ord); data(bpd_fam); data(bpd_clin)
otu_tabs = list(Phylum = bpd_phy, Class = bpd_cla,
Order = bpd_ord, Family = bpd_fam)

set <- tidy_micro(otu_tabs = otu_tabs, clinical = bpd_clin) %>%
filter(day == 7) ## Only including the first week

## Full cohort abundance
set %>%
ra_bars(table = "Family", top_taxa = 10)

## Stratified by variable of interest
set %>%
ra_bars(table = "Family", bpd1, top_taxa = 10)

tidyMicro documentation built on Jan. 13, 2021, 6:18 a.m.