metagMisc icon indicating copy to clipboard operation
metagMisc copied to clipboard

Strata argument from adonis2 can't be added

Open AndreaVazgel opened this issue 1 year ago • 1 comments

I'm trying to perform a pairwise comparison for my data, but when I add the "strata" argument from adonis2 it shows an error:

ad2_pair3 = adonis_pairwise(x = Datos, dd = data_dis, group.var = "Hg_level", permut = 9999, p.adj = T, method = "bray", strata = Site) ad2_pair3

Result: Error in check(sn, control = control, quietly = quietly) : Number of observations and length of Block 'strata' do not match.

However, I don't think that error make sense because I have run adonis2 with similar arguments and I didn't have any problem: ad2 = adonis2(data_dis ~ Hg_level, data = Datos, permutations = 9999, method = "bray", strata = Site) ad2

Result: adonis2(formula = data_dis ~ Hg_level, data = Datos, permutations = 9999, method = "bray", strata = Site) Df SumOfSqs R2 F Pr(>F)
Hg_level 2 3.128 0.0699 5.2609 0.0026 Residual 140 41.616 0.9301
Total 142 44.744 1.0000

  • data_dis is my dissimilarity matrix
  • Hg_level is my independent variable (3 levels)
  • Datos is my general data.frame
  • Site is another categorical variable (9 levels) for whose levels I want to constrain permutations

Do you know what is the solution for this error? Or, Is there another way to introduce this argument?

Thx, Andrea.

AndreaVazgel avatar Jun 20 '24 17:06 AndreaVazgel

Hello Andrea,
Thank you for reporting this issue.
I'm afraid the current implementation of adonis_pairwise does not support strata argument.
I will add this enhancement to the to-do list.

vmikk avatar Jun 20 '24 18:06 vmikk