#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
總結(jié):第1、6、7距離算法較多帖努,但是1計算距離前無法對原始OTU進行hellinger轉(zhuǎn)換,相反6和7均可以粪般,但是7操作步驟稍顯復雜然磷,使用6更快捷方便
ps:怎么做hellinger轉(zhuǎn)換?
otu_table <- as(otu_table(ps),"matrix")
#hellinger轉(zhuǎn)換
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方法最方便姿搜。