beta_div: Beta Diversity Calculations for tidy_micro

Description Usage Arguments Value References Examples

View source: R/beta_divs.R

Description

Calculate beta diversities of your tidy_micro set. This function reformats the data into the original OTU table and then feeds that into the vegdist function

Usage

1
beta_div(micro_set, table, method = "bray")

Arguments

micro_set

A tidy_micro data set

table

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

method

A dissimilarity method compatible with vegdist

Value

A symmetrix distance matrix

References

vegdist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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

## Bray-Curtis beta diversity
bray <- set %>% beta_div(table = "Family")

## Morisita-Horn beta diversity
horn <- set %>% beta_div(table = "Family", method = "horn")

Example output

Loading required package: tidyverse
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
✔ ggplot2 3.3.2purrr   0.3.4tibble  3.0.4dplyr   1.0.2tidyr   1.1.2stringr 1.4.0readr   1.4.0forcats 0.5.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()dplyr::lag()    masks stats::lag()
Contains 74 libraries from OTU files.

Summary of sequencing depth:
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   8851   24938   33314   36650   43590   97408 

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