pmartinezarbizu / pairwiseAdonis

Pairwise multilevel comparison using adonis
GNU General Public License v3.0
69 stars 24 forks source link

restricted permutations does not work #46

Open Gian77 opened 1 year ago

Gian77 commented 1 year ago

Hello,

I am trying to calculate pariwise comparisons across sites, bust using blocks= so not to shuffle permutations between samples not of the same type. I am having this error below, however it seesm the data is well balanced.

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

I made a test datframe and it is giving the same error (below). Is there something I am interpreting or doing worngly? Thanks much! Gian

test_data <- data.frame(
  Tree = c(rep(1, times=10),rep(2, times=10), rep(3, times=10), rep(4, times=10)),
  Treatment = factor(c(
    rep("A", each=5), rep("B", each=5), rep("A", each=5), rep("B", each=5),
    rep("A", each=5), rep("B", each=5), rep("A", each=5), rep("B", each=5))),
  Moisture = runif(20*2 , min=20, max=50),
  pH = runif(20*2 , min=4, max=9),
  N = runif(20*2 , min=15, max=100)
)
test_data

table(test_data$Treatment, test_data$Tree) 

pairwise.adonis(test_data[,3:5],
                factors = test_data$Tree,
                sim.function = "vegdist",
                sim.method = "jaccard",
                p.adjust.m = "bonferroni",
                reduce = NULL,
                perm = how(blocks = test_data$Treatment, nperm = 999, observed = TRUE))

This is the error

> pairwise.adonis(test_data[,3:5],
+                 factors = test_data$Tree,
+                 sim.function = "vegdist",
+                 sim.method = "jaccard",
+                 p.adjust.m = "bonferroni",
+                 reduce = NULL,
+                 perm = how(blocks = test_data$Treatment, nperm = 999, observed = TRUE))
Error in check(sn, control = control, quietly = quietly) : 
  Number of observations and length of Block 'strata' do not match.
OndroV commented 1 year ago

Hi, I got the same error. Maybe is it because pairwiseAdonis doesn't work with how(blocks = ..., plots = ..., within = ...) design? When I reduced the permutation structure to just strata = 'my_factor', error disappeared (but obviously the design is not what I wanted originally)