R帮助基于不平衡因子变量对距离矩阵进行下采样,以用于vegan :: adonis

问题描述

我有一个尺寸为62x62的距离矩阵和一个样本数据帧62x4。我想根据样本数据中的一个因子变量对距离矩阵进行随机下采样(1000倍):
> table(sampledf$bleach.type)

  Augresistant Augsusceptible   Sepresistant Sepsusceptible 
             4             28              4             26

例如,我有一个尺寸为16x16的距离矩阵,可以输入到素食主义者函数adonis中。我曾尝试对单个距离矩阵进行下采样,但是所得的采样数据和距离矩阵给我造成了阿多尼斯错误

library(caret)
library(vegan)
library(usedist)
> sub_Meta <- downSample(sampledf,sampledf$bleach.type)
> ps_bc_sub <- dist_subset(ps_bc,sub_Meta$sampleid)
> adonis(ps_bc_sub ~ bleach*type,data = sub_Meta)
Error in `colnames<-`(`*tmP*`,value = colnames(lhs)) : 
  attempt to set 'colnames' on an object with less than two dimensions

关于为什么会出现此错误的任何建议?另外,对于生成下采样距离矩阵有什么建议吗?

以下是数据文件摘要

> summary(sampledf)
                        sampleid  bleach            type            bleach.type
 Acropora.cervicornis.Aug10A: 1   Aug:32   resistant  : 8   Augresistant  : 4  
 Acropora.cervicornis.Aug10B: 1   Sep:30   susceptible:54   Augsusceptible:28  
 Acropora.cervicornis.Aug13A: 1                             Sepresistant  : 4  
 Acropora.cervicornis.Aug13B: 1                             Sepsusceptible:26  
 Acropora.cervicornis.Aug1A : 1                                                
 Acropora.cervicornis.Aug1B : 1                                                
 (Other)                    :56   

> class(ps_bc)
[1] "dist"
> dim(ps_bc)
[1] 62 62
> colnames(ps_bc)
[1] "Acropora.cervicornis.Aug10B"
> ps_bc
                            Acropora.cervicornis.Aug10A Acropora.cervicornis.Aug10B Acropora.cervicornis.Aug13A
Acropora.cervicornis.Aug10B                  0.06787487                                                        
Acropora.cervicornis.Aug13A                  0.42352534                  0.42006233                            
Acropora.cervicornis.Aug13B                  0.18734849                  0.13655777                  0.39778368
Acropora.cervicornis.Aug1A                   0.09257763                  0.05159875                  0.42248644
Acropora.cervicornis.Aug1B                   0.05713956                  0.05667783                  0.42583401

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)