#1
ps <- physeq
phyloseq::distance(ps,"wunifrac")# Weighted UniFrac
phyloseq::distance(ps,"unifrac")# Unweighted UniFrac
phyloseq::distance(ps,"bray")#bary curtis
phyloseq::distance(ps,"jaccard",binary=T)#binary jaccard
#2
phyloseq::UniFrac(ps,T)# Weighted UniFrac
phyloseq::UniFrac(ps,F)# Unweighted UniFrac
#3
picante::unifrac(as(t(otu_table(ps)),"matrix"), phy_tree(ps))# Unweighted UniFrac, Rooted phylogeny required for UniFrac calculation
#4
vegan::vegdist(t(otu_table(ps)), "bray")#bary curtis
vegan::vegdist(t(otu_table(ps)), "jaccard",binary = T)#binary jaccard
#5
vegan::designdist(t(otu_table(ps)),method = "(A+B-2*J)/(A+B)",terms = "minimum")#bary curtis
vegan::designdist(t(otu_table(ps)),method = "(A+B-2*J)/(A+B-J)",terms = "binary")#binary jaccard
#6
library(MicrobiotaProcess)
get_dist(ps,"unifrac","hellinger")# Weighted UniFrac
get_dist(ps,"wunifrac","hellinger")# Unweighted UniFrac
get_dist(ps,"bray","hellinger")#bary curtis
get_dist(ps,"jaccard","hellinger",binary=T)#binary jaccard
#7
mpse <- as.mpse(ps) %>% mp_decostand(.abundance = Abundance,method = "hellinger")
mpse %>% mp_cal_dist(.abundance = hellinger,distmethod = "wunifrac",action = "get")# Weighted UniFrac
mpse %>% mp_cal_dist(.abundance = hellinger,distmethod = "unifrac",action = "get")# Unweighted UniFrac
mpse %>% mp_cal_dist(.abundance = hellinger,distmethod = "bray",action = "get")#bary curtis
mpse %>% mp_cal_dist(.abundance = hellinger,distmethod = "jaccard",action = "get",binary=T)#binary jaccard
总结:第1、6、7距离算法较多,但是1计算距离前无法对原始OTU进行hellinger转换,相反6和7均可以,但是7操作步骤稍显复杂,使用6更快捷方便
ps:怎么做hellinger转换?
otu_table <- as(otu_table(ps),"matrix")
#hellinger转换
x1 <- decostand(otu_table,MARGIN = 2,method = "hellinger")
x2 <- t(labdsv::hellinger(t(otu_table)))
x3 <- apply(otu_table,2,function(x) {
sqrt(x/sum(x))}
)
x4 <- sqrt(sweep(otu_table,2,colSums(otu_table),FUN = "/"))
显然,decostand方法最方便。