R语言:microeco:一个用于微生物群落生态学数据挖掘的R包,第四:trans_beta class

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: 999

adonis2(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: 999

adonis2(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: 999

adonis2(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

这个包的改动有些大,以前的代码不能直接跑了。我发觉,学习这个包还是要基于需求啊,否则会很快忘掉。以前我使用vegan包分析+ggplot2包做PCOA分析,等把这个包分享完了,我会再分享其它的R语言。

相关推荐
唐Sun_数智人2 小时前
IIOT工业物联网的数据分析与预测维护_SunIOT
物联网·数据挖掘·数据分析
纪伊路上盛名在3 小时前
如何初步部署自己的服务器,达到生信分析的及格线
linux·运维·服务器·python·学习·r语言·github
sp_fyf_202412 小时前
计算机前沿技术-人工智能算法-大语言模型-最新研究进展-2024-10-02
人工智能·神经网络·算法·计算机视觉·语言模型·自然语言处理·数据挖掘
985小水博一枚呀14 小时前
【对于Python爬虫的理解】数据挖掘、信息聚合、价格监控、新闻爬取等,附代码。
爬虫·python·深度学习·数据挖掘
weixin_4664851115 小时前
Yolov8分类检测记录
yolo·分类·数据挖掘
安静的_显眼包O_o1 天前
【数据分析】DataFrame.query()
数据挖掘·数据分析·pandas
技术无疆1 天前
【Python】Streamlit:为数据科学与机器学习打造的简易应用框架
开发语言·人工智能·python·深度学习·神经网络·机器学习·数据挖掘
羊小猪~~1 天前
机器学习/数据分析--用通俗语言讲解时间序列自回归(AR)模型,并用其预测天气,拟合度98%+
人工智能·python·机器学习·数据挖掘·数据分析·回归·时序数据库
satan–01 天前
R语言的下载、安装及环境配置(Rstudio&VSCode)
开发语言·windows·vscode·r语言
凭栏落花侧1 天前
决策树:简单易懂的预测模型
人工智能·算法·决策树·机器学习·信息可视化·数据挖掘·数据分析