microbiome是专门针对微生物数据分析的R包。 详细的用法参考: https://microbiome.github.io/tutorials/Diversity.html#content
这里只是简单的用途介绍
1. 多样性指数,包括丰富度,Chao,Shannon, Simpson, 均匀度,优势度,稀有度
library(microbiome)
library(knitr)
data(dietswap)
pseq <- dietswap
#所有指数
tab <- alpha(pseq, index = "all")
head(tab)
observed chao1 diversity_inverse_simpson diversity_gini_simpson
Sample-1 104 114.6667 7.561722 0.8677550
Sample-2 110 121.6364 8.102943 0.8765881
diversity_shannon diversity_fisher diversity_coverage evenness_camargo
Sample-1 2.940698 16.69360 4 0.2014036
Sample-2 2.822472 15.20257 3 0.2261992
evenness_pielou evenness_simpson evenness_evar evenness_bulla dominance_dbp
Sample-1 0.6331719 0.07270887 0.1709714 0.3298916 0.3279347
Sample-2 0.6004646 0.07366312 0.1334372 0.2755652 0.2428626
dominance_dmn dominance_absolute dominance_relative dominance_simpson
Sample-1 0.4297198 2774 0.3279347 0.1322450
Sample-2 0.4656170 5121 0.2428626 0.1234119
dominance_core_abundance dominance_gini rarity_log_modulo_skewness
Sample-1 0.9992907 0.8625360 2.057691
Sample-2 0.9994309 0.8843695 2.057552
rarity_low_abundance rarity_rare_abundance
Sample-1 0.02896323 0.000000e+00
Sample-2 0.02997249 4.268235e-04
#####分开计算
#单独算richness和chao
tab <- richness(pseq)
#算各种优势度指数
tab <- dominance(pseq, index = "all")
#算各种稀有度指数
tab <- rarity(pseq, index = "all")
#算coverage,默认50%
tab <- coverage(pseq, threshold = 0.5)
#算核心物种
tab <- core_abundance(pseq, detection = .1/100, prevalence = 50/100)
#Gini index基尼系数,可以衡量多样性
tab <- inequality(pseq)
#五种均匀度指数
tab <- evenness(pseq, "all")
2.beta多样性
library(microbiome)
library(dplyr)
data(peerj32)
pseq <- peerj32$phyloseq
#计算组内部的差异
b.pla <- divergence(subset_samples(pseq, group == "Placebo"))
3. 物种组成 画的图感觉不是很好看,略过
4. 核心微生物 主要是core_members和core两个函数。
#detection,出现率的检测限
#prevalence,流行度阈值
core_members(x, detection = 1/100, prevalence = 50/100, include.lowest = FALSE)
core_members得到核心物种的分类信息;core得到核心物种所有信息。 和这两和函数对应的是rare_members和rare,得到稀有种信息。
5.画图 plot_landscape函数可以对PCA,NMDS,PCOA,t-SNE进行可视化。
#method,可选以上几种降维方法
plot_landscape(x, method = "PCoA", distance = "bray",
transformation = "identity", col = NULL, main = NULL,
x.ticks = 10, rounding = 0, add.points = TRUE, adjust = 1,
size = 1, legend = FALSE, shading = TRUE)
6.微生物稳定性分析 已有研究表明,某些微生物群落具有双稳态丰度分布,即丰度低、丰度高的峰清晰,而中间丰度的范围不稳定。因此,中间丰度范围的不稳定性是双稳定的一个指标。
#稳定性分析
intermediate_stability(x, reference.point = NULL,
method = "correlation", output = "scores")
#双峰性分析
bimodality(x, method = "potential_analysis", peak.threshold = 1,
bw.adjust = 1, bs.iter = 100, min.density = 1, verbose = TRUE)
END