我需要在R中编码嵌套的permanova肛门的帮助。我有一个矩阵os距离,我想在3个嵌套级别之间划分方差。我正在使用adonis函数,据我了解,我还想在strata参数中重复嵌套结构,以便将随机改组限制在级别内。这是我第一次使用这种方法,我想我缺少了一些东西。是否可以在strata参数中设置多个嵌套级别?到目前为止,我能够做到这一点,但是我不确定方向是否正确。 当我尝试在层中设置嵌套级别时,出现以下错误:
perm = adonis(lma.dist ~ Family/genus/Spec, strata= Family/genus/Spec, data=df)
> Error in getPermuteMatrix(permutations, n, strata = strata):
object 'Family' not found
但是当我在地层上仅设置一个级别(甚至没有级别)时,adonis函数似乎运行良好。(使用所有数据集运行)
perm2 = adonis(lma.dist ~ Family/genus/Spec, strata= df$Spec, data=df)
Call:
adonis(formula = lma.dist ~ Family/genus/Spec, data = df, strata = df$Family)
Blocks: strata
Permutation: free
Number of permutations: 999
Terms added sequentially (first to last)
Df SumsOfSqs MeanSqs F.Model R2 Pr(>F)
Family 13 110.262 8.4817 20.5826 0.47732 0.001 ***
Family:genus 12 34.755 2.8963 7.0284 0.15046 0.001 ***
Family:genus:Spec 5 3.155 0.6309 1.5311 0.01366 0.056 .
Residuals 201 82.828 0.4121 0.35856
Total 231 231.000 1.00000
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
lma.dist是一个欧式距离的矩阵对象(232 x 232)。这是一个子集:
dput(head(lma.dist))structure(c(0, 0.645, 0.538, 0.538, 0.108, 0.43,0.645, 0, 0.108, 0.108, 0.753, 0.215, 0.538, 0.108, 0, 0, 0.645, 0.108, 0.538, 0.108, 0, 0, 0.645, 0.108, 0.108, 0.753, 0.645, 0.645, 0, 0.538, 0.43, 0.215, 0.108, 0.108, 0.538, 0, 0.43, 0.215, 0.108, 0.108, 0.538, 0, 0, 0.645, 0.538, 0.538, 0.108, 0.43, 0.968, 0.323, 0.43, 0.43, 1.075, 0.538, 0.215, 0.86, 0.753, 0.753, 0.108, 0.645, 0.215, 0.86, 0.753, 0.753, 0.108, 0.645, 0.43, 0.215, 0.108, 0.108, 0.538, 0, 0.215, 0.86, 0.753, 0.753, 0.108, 0.645, 0.108, 0.753, 0.645, 0.645, 0, 0.538, 0.215, 0.86, 0.753, 0.753, 0.108, 0.645, 0, 0.645, 0.538, 0.538, 0.108, 0.43, 0.323, 0.968, 0.86, 0.86, 0.215, 0.753, 0.43, 0.215, 0.108, 0.108, 0.538, 0, 0.43, 1.075, 0.968, 0.968, 0.323, 0.86, 0.215, 0.86, 0.753, 0.753, 0.108, 0.645), .Dim = c(6L, 20L), .Dimnames = list(c("Xl_AP_319","Xl_AP_351", "Xl_AP_326", "Xl_AP_422", "Xl_AP_146", "Xl_AP_188"), c("Xl_AP_319", "Xl_AP_351", "Xl_AP_326", "Xl_AP_422", "Xl_AP_146", "Xl_AP_188", "Xl_AP_252", "Xl_AP_101", "Xl_AP_218", "Xl_CE_334", "Vt_Q16_304", "Vt_Q16_124", "Vt_EF_255", "Vt_EF_159", "Vt_EF_191", "Vt_EF_28", "Vt_CE_199", "Vt_CE_185", "Vt_CE_271", "Vp_Q16_297")))
df是一个数据帧(232 x 3),带有用于家族,属和规格的标签(因子)。这两个数据中的行名和列名相同。
dput(head(df[1:20,]))structure(list(Family("Xyridaceae","Xyridaceae", "Xyridaceae","Xyridaceae", "Xyridaceae", "Xyridaceae"), genus =c("Xyris","Xyris", "Xyris", "Xyris", "Xyris", "Xyris"), Spec = c("Xyris longiscapa","Xyris longiscapa", "Xyris longiscapa", "Xyris longiscapa", "Xyris longiscapa", "Xyris longiscapa")), .Names = c("Family", "genus", "Spec"), row.names =("Xl_AP_319","Xl_AP_351", "Xl_AP_326", "Xl_AP_422", "Xl_AP_146", "Xl_AP_188"), class = "data.frame")