rarefy: rarefy

rarefy_otuR Documentation

rarefy

Description

Prepare data for rerafy curves.

Usage

rarefy_otu(phy, step = 10, rep = 3, measures = c("Observed", "Shannon"))

Arguments

phy

phyloseq

step

steps

rep

times of repetition

measures

(Optional). Default is NULL, meaning that all available alpha-diversity measures will be included. Alternatively, you can specify one or more measures as a character vector of measure names. Values must be among those supported: c("Observed", "Chao1", "ACE", "Shannon", "Simpson", "InvSimpson", "Fisher").

Value

rarefy table

Examples

library(phyloseq)
data(its)
phy <- phyloseq(otu_table(its, taxa_are_rows = TRUE))
rare <- rarefy_otu(phy)
x_min <- group_by(rare, id) %>%
    summarise(across(Depth, max)) %>%
    .[, "Depth"] %>%
    min()
ggplot(rare, aes(Depth, Observed, group = id, color = id)) +
    geom_vline(xintercept = x_min, linetype = "dashed", color = "grey60") +
    stat_summary(fun = "mean", geom = "smooth", size = .7) +
    stat_summary(
        fun.data = "mean_cl_normal", geom = "errorbar",
        size = .5, aes(width = max(Depth) / 30)
    ) +
    theme_bw2(15) +
    theme(legend.justification = c(1, 0), legend.position = c(1, 0))

yanpd01/yyeasy documentation built on Dec. 1, 2022, 10:58 p.m.