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,
  ylab,
  xlab,
  main,
  xaxis,
  lines = TRUE,
  rotate = 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

ylab

y-axis label

xlab

x-axis label

lines

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

rotate

Logical; Tilting x-axis labels if many levels are involved

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
15
data(phy); data(cla); data(ord); data(fam); data(met)

otu_tabs = list(Phylum = phy, Class = cla, Order = ord, Family = fam)
set <- tidy_micro(otu_tabs = otu_tabs, meta = met) %>%
filter(day == 7) %>% ## Only including the first week
mutate(bpd1 = factor(bpd1))

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

CharlieCarpenter/tidy.micro documentation built on Jan. 19, 2020, 6:28 p.m.