r diversity.r
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了r diversity.r相关的知识,希望对你有一定的参考价值。
get_div <- function(i, physeq){
# Subsample
rarefied_physeq <- rarefy_even_depth(physeq, sample.size = min_lib, verbose = FALSE, replace = TRUE)
# Calculate observed richness for that group and store value in a df column
richness <- estimate_richness(rarefied_physeq, measures = "Observed")[ ,1]
# Calculate Simpson's E for that group and store value in a df column
simpson <- (estimate_richness(rarefied_physeq, measures = "InvSimpson")[ ,1])
simpson_e <- (estimate_richness(rarefied_physeq, measures = "InvSimpson")[ ,1]/richness)
shannon <- estimate_richness(rarefied_physeq, measures = "Shannon")[ ,1]
pielous <- shannon/log(richness)
df <- data.frame(label = sample_names(rarefied_physeq), iter = rep(i, nsamples(rarefied_physeq)), richness = richness, invsimpson = simpson, shannon = shannon, pielou = pielous, simpson_e = simpson_e)
return(df)
}
library(phyloseq)
library(pbmcapply)
trials <- 1000
physeq_filt_prev <- prune_taxa(taxa_sums(physeq_filt_prev) > 0, physeq_filt_prev)
min_lib <- min(sample_sums(physeq_filt_prev))
d16S_alpha <- pbmclapply(1:trials, get_div, physeq = physeq_filt_prev, mc.cores = 24)
以上是关于r diversity.r的主要内容,如果未能解决你的问题,请参考以下文章
——R的数据组织
+-r, +-s 的所有排列
shinydashboard ui.R 和 server.R 未读取 Global.R
R语言计算回归模型R方(R-Squared)实战
r语言中r-studio怎么调用
R电子书资料《学习R》+《R语言实战第2版》+《R数据科学》学习推荐