grunwaldlab / metacoder

Parsing, Manipulation, and Visualization of Metabarcoding/Taxonomic data
http://grunwaldlab.github.io/metacoder_documentation
Other
134 stars 28 forks source link

Alpha-diversity assessed by richness (Chao1, ACE) #329

Open biosciences opened 2 years ago

biosciences commented 2 years ago

I can see you have done alpha-diversity assessment by using Inverse Simpson index, how could I assess the alpha-diversity by richness using Chao1 and ACE?

zachary-foster commented 2 years ago

You can use other functions in vegan for that. The only challenge is finding the right on and converting the formatting between what the two packages expect. Here is an example using the tutorial data at https://grunwaldlab.github.io/metacoder_documentation/workshop--07--diversity_stats.html:

library(vegan)
#> Loading required package: permute
#> Loading required package: lattice
#> This is vegan 2.5-7
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
load("~/Desktop/clean_data.Rdata")

abund_mat <- obj$data$otu_rarefied[, sample_data$SampleID]
alpha_data <- t(estimateR(t(abund_mat))) # needs to be transposed with t because vegan expects columns to be taxa and then transposed back
sample_data <- bind_cols(sample_data, as.data.frame(alpha_data))

hist(sample_data$S.ACE)

hist(sample_data$S.chao1)

Created on 2022-01-05 by the reprex package (v2.0.1)

Does that make sense?

biosciences commented 2 years ago

That made sense. Thank you for the suggestion.