bb_bars: Create stacked bar charts based on beta binomial model...

Description Usage Arguments Value Examples

View source: R/bb_bars.R

Description

bb_bars takes the output from bb_mods and creates stacked bar charts of the estimated relative abundance for each taxa. The benefit of modeling each taxa before created stacked bar charts is the ability to control for potential confounders. The function will facet wrap interaction terms. Currently, only quant_style = "discrete" can be used for an interaction between two quantitative variables

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
bb_bars(
  modsum,
  ...,
  range,
  quant_style = c("continuous", "discrete"),
  top_taxa = 0,
  RA = 0,
  specific_taxa,
  lines = TRUE,
  xaxis,
  main,
  subtitle,
  xlab,
  ylab = "Relative Abundance (%)",
  facet_labels,
  facet_layout = 1
)

Arguments

modsum

The output from bb_mods

...

The covariate you'd like to plot. Can be an interaction term or main effect, but must be in the models created by bb_mods

range

The range you'd like to plot over for a quantitative variable. Will default to the first and third quartiles

quant_style

"continuous" will plot over the entire range specified; "discrete" will plot only the endpoints of the range specified. "continuous" by default. This option is ignored without a quantitative variable

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

Character; Plot these specific taxa even if it doesn't meet the top_taxa or RA requirements

lines

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

xaxis

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

main

Plot title

subtitle

Subtitle for the plot

xlab

x-axis label

ylab

y-axis label

facet_labels

Labels for the facets created for interaction terms

facet_layout

Rearrange the facets created for interaction terms

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

## Creating beta binomial models on filtered tidy_micro set

bb_phy <- set %>%
otu_filter(ra_cutoff = 0.1, exclude_taxa = c("Unclassified", "Bacteria")) %>%
bb_mods(table = "Phylum", bpd1)

bb_phy %>%
bb_bars(bpd1, top_taxa = 4, xlab = "BPD Severity")

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