当前位置: 首页 > news >正文

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

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

http://www.lryc.cn/news/319966.html

相关文章:

  • Excel文件导入导出,SpringBoot整合EasyExcel批量导入导出,采用的JDBC+EasyExcel(附带整个Demo)
  • Git——本地使用详解
  • 深度学习pytorch——Tensor维度变换(持续更新)
  • Selenium-webdriver_manager判断是否已经下载过驱动(复用缓存驱动)
  • 【SQL】1174. 即时食物配送 II (窗口函数row_number; group by写法;对比;定位错因)
  • mvcc介绍
  • 强化PaaS平台应用安全:关键策略与措施
  • K8s 集群高可用master节点ETCD挂掉如何恢复?
  • 【Godot 4.2】常见几何图形、网格、刻度线点求取函数及原理总结
  • 如何利用POI导出报表
  • 自动部署SSL证书到阿里云腾讯云CDN
  • 【系统性】 循序渐进学C++
  • rust - 一个日志缓存记录的通用实现
  • elasticsearch(RestHighLevelClient API操作)(黑马)
  • 用尾插的思想实现移除链表中的元素
  • 【Kubernetes】k8s删除master节点后重新加入集群
  • HCIP—OSPF虚链路实验
  • RAxML-NG安装与使用-raxml-ng-v1.2.0(bioinfomatics tools-013)
  • Tomcat内存马
  • pytorch之诗词生成3--utils
  • OpenAI的ChatGPT企业版专注于安全性、可扩展性和定制化。
  • JS06-class对象
  • 深度学习1650ti在win10安装pytorch复盘
  • Node.js与webpack(三)
  • 测试覆盖率那些事
  • Etcd 介绍与使用(入门篇)
  • Docker 安装 LogStash
  • Selenium笔记
  • ChatGPT :确定性AI源自于确定性数据
  • linux驱动开发面试题