metacoder icon indicating copy to clipboard operation
metacoder copied to clipboard

Alpha-diversity assessed by richness (Chao1, ACE)

Open taowis opened this issue 4 years ago • 2 comments

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?

taowis avatar Dec 29 '21 15:12 taowis

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?

zachary-foster avatar Jan 05 '22 21:01 zachary-foster

That made sense. Thank you for the suggestion.

taowis avatar Jan 12 '22 06:01 taowis