knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

microbiomer

The goal of microbiomer is to provide a small set of tools to more seamlessly integrate tools/functions from both the phyloseq and tidyverse-packages.

Note this is a package in development; although the functions were not yet tested extensively within the context of this package, they were tested across several projects as source code. Nevertheless, use these functions at your own risk and please file a report if you come across issues.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("wsteenhu/microbiomer")

The package has not been submitted to CRAN.

Example

Load packages

library(microbiomer); library(phyloseq)
library(tidyverse)

Load data

data(ps_NP)
ps_NP

The package includes nasopharyngeal microbiota data collected at 1 week, 1 month and 1 year of life. For more information, see ?ps_NP.

Convert

ps_NP_RA <- otu_table(ps_NP) %>%
  to_RA() 

ps_NP_RA[1:5,1:3] # depict example

to_RA converts the otu_table-object nested within a phyloseq-object into a total-sum-scaled table (relative abundances instead of raw reads).

Filter

ps_NP %>% ntaxa()

ps_NP %>%
  pres_abund_filter()

Use a filter described by Subramanian et al. (Nature, 2014) to filter phyloseq-objects.

Extract metadata

ps_NP %>%
  meta_to_df() %>%
  head()

meta_to_df() convers the sample_data()-objects within a phyloseq-object into a tidyverse-formatted data table. Also try otu_tab_to_df() and ps_to_df()

Prepare for plotting

ps_NP %>%
  prep_bar(n = 5) %>%
  head()

The function prep_bar() converts your phyloseq-object into an object that can be readily used for plotting. It includes all metadata-columns, a column 'OTU' (with formatted OTU-names) and a column 'value' with read counts/relative abundances (depending on the format of the otu_table).

Barplot

ps_NP %>% 
  subset_samples(., birth_mode == "vag" & visit_name == "w1") %>% # select samples
  to_RA %>%
  create_bar()

Note this plotting function can be used in conjunction with other ggplot2-functions/extensions, such as coord_flip()/ggforce::facet_col() and facet_wrap().



wsteenhu/microbiomer documentation built on March 11, 2021, 6:05 p.m.