做網站 價格seo怎么優(yōu)化方案
trans_beta class:利用trans_beta類可以變換和繪制beta分集的距離矩陣。該類中涉及到beta多樣性的分析主要包括排序、群距、聚類和方差分析。我們首先使用PCoA顯示排序。
> dataset$cal_betadiv() The result is stored in object$beta_diversity ... > t1 <- trans_beta$new(dataset = dataset, group = "Group", measure = "bray") > t1$cal_ordination(ordination = "PCoA") The ordination result is stored in object$res_ordination ... > tmp <- t1$res_ordination$scores > t2 <- trans_env$new(dataset = dataset, add_data = tmp[, 1:2]) Env data is stored in object$data_env ... > t2$cal_diff(group = "Group", method = "anova") The result is stored in object$res_diff ... Warning message: 程輯包‘agricolae’是用R版本4.3.3 來建造的 #這里需要安裝agricolae包,直接install就行。 > t2 trans_env object: Env table have 2 variables: PCo1,PCo2
> p1 <- t1$plot_ordination(plot_color = "Group", plot_shape = "Group", plot_type = c("point", "ellipse"))
#然后我們繪制并比較群距。
> t1$cal_group_distance()
> t1$plot_group_distance(distance_pair_stat = TRUE)
#這里應該會有差異比較的,但是卻沒有。示例如下,不知道有什么問題,等到有需求我會解決這個問題。
#計算和繪制組之間的樣本距離
> t1$cal_group_distance(within_group = FALSE)
> t1$plot_group_distance(distance_pair_stat = TRUE)
# 聚類圖也是一種常用的方法。
> t1$plot_clustering(group = "Group", replace_name = c("Saline", "Type"))
#perMANOVA常用于組間距離的差異檢驗。
> t1$cal_manova(cal_manova_all = TRUE) The result is stored in object$res_manova ... > t1$res_manova Permutation test for adonis under reduced model Terms added sequentially (first to last) Permutation: free Number of permutations: 999adonis2(formula = use_formula, data = metadata, cal_manova_all = TRUE)Df SumOfSqs R2 F Pr(>F) Group 2 6.1207 0.19553 10.573 0.001 *** Residual 87 25.1822 0.80447 Total 89 31.3029 1.00000 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
## manova表示每一對組
> t1$cal_manova(cal_manova_paired = TRUE) The result is stored in object$res_manova ... > t1$res_manova Permutation test for adonis under reduced model Terms added sequentially (first to last) Permutation: free Number of permutations: 999adonis2(formula = use_formula, data = metadata, cal_manova_paired = TRUE)Df SumOfSqs R2 F Pr(>F) Group 2 6.1207 0.19553 10.573 0.001 *** Residual 87 25.1822 0.80447 Total 89 31.3029 1.00000 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# manova用于指定組集:這里是“group + Type” > t1$cal_manova(cal_manova_set = "Group + Type") The result is stored in object$res_manova ... > t1$res_manova Permutation test for adonis under reduced model Terms added sequentially (first to last) Permutation: free Number of permutations: 999adonis2(formula = use_formula, data = metadata, cal_manova_set = "Group + Type")Df SumOfSqs R2 F Pr(>F) Group 2 6.1207 0.19553 10.573 0.001 *** Residual 87 25.1822 0.80447 Total 89 31.3029 1.00000 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
這個包的改動有些大,以前的代碼不能直接跑了。我發(fā)覺,學習這個包還是要基于需求啊,否則會很快忘掉。以前我使用vegan包分析+ggplot2包做PCOA分析,等把這個包分享完了,我會再分享其它的R語言。