[R-sig-genetics] pegas::amova()
Eric Crandall
eric.d.crandall at gmail.com
Mon Jul 20 21:16:52 CEST 2015
Hi Emmanuel or others,
I was directed here to ask a question about the amova function in pegas. Hopefully this is the right place.
I have been using pegas::amova() in a function that loops over a database of species to calculate amova at up to three hierarchical levels. My function recently broke, apparently due to a recent update <https://cran.r-project.org/web/packages/pegas/NEWS> to Pegas - specifically this change:
o amova() failed when the factors in the rhs of the formula were
in a data frame. Thanks to Zhian Kamvar for the fix.
As a workaround to for pegas:amova not being able to use a dataframe of factors, I was assigning the factors to the global environment:
level1factor<<-as.factor(sp[[l1]])
level2factor<<-as.factor(sp[[l2]])
amova_out<-pegas::amova(dists~level2factor/level1factor, nperm=nperm, is.squared=T)
Now, after the update, my function is throwing an error. The traceback goes
4 stop("'bin' must be numeric or a factor")
3 FUN(X[[i]], ...)
2 lapply(gr, tabulate)
1 pegas::amova(dists ~ level2factor/level1factor, nperm = nperm,
is.squared = T)
As far as I can tell, the objects that I am submitting to tabulate() in gr via lapply() ARE factors.
When I try to reproduce the problem by running step by step through the pegas::amova function, everything works fine.
So I am stumped for now. Does anyone have any ideas?
Many thanks,
Eric Crandall
PS - I’m very happy to see strata being added to genind objects in adegenet. Will these eventually be usable by pegas::amova or a similar amova function?
[[alternative HTML version deleted]]
More information about the R-sig-genetics
mailing list