Skip to content
Prev 69 / 490 Next

pegas::amova()

Hi Eric,

Can you provide a minimum working example and post your session information?

The following example works for me (adapted from https://github.com/emmanuelparadis/pegas/pull/2#issue-67437033):

library('pegas')
data(microbov)
set.seed(20150409)
mic20 <- microbov[sample(nInd(microbov), 20)]
microdf <- data.frame(other(mic20))
d <- dist(tab(mic20))
amova(d ~ spe/breed, data = microdf, nperm = 0)

SPE   <<- as.factor(microdf$spe)
BREED <<- as.factor(microdf$breed)
amova(d ~ SPE/BREED, nperm = 0)
R version 3.2.1 (2015-06-18)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.4 (Yosemite)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] pegas_0.8-1    adegenet_2.0.0 ade4_1.7-2     ape_3.3       

loaded via a namespace (and not attached):
 [1] Rcpp_0.11.6      spdep_0.5-88     plyr_1.8.3       LearnBayes_2.15  tools_3.2.1     
 [6] boot_1.3-16      digest_0.6.8     nlme_3.1-120     gtable_0.1.2     lattice_0.20-31 
[11] Matrix_1.2-1     igraph_1.0.1     shiny_0.12.1     DBI_0.3.1        parallel_3.2.1  
[16] proto_0.3-10     coda_0.17-1      dplyr_0.4.2      stringr_1.0.0    grid_3.2.1      
[21] R6_2.1.0         sp_1.1-1         ggplot2_1.0.1    reshape2_1.4.1   seqinr_3.1-3    
[26] deldir_0.1-9     magrittr_1.5     scales_0.2.5     htmltools_0.2.6  MASS_7.3-41     
[31] splines_3.2.1    assertthat_0.1   mime_0.3         colorspace_1.2-6 xtable_1.7-4    
[36] httpuv_1.3.2     stringi_0.5-5    munsell_0.4.2  

The data frame implementation works now, so you can use your strata directly instead of pulling the levels from it:

my_strata <- strata(my_data)
amova_out <- pegas::amova(dists~l2/l1, data = my_strata, nperm=nperm, is.squared=T)

Additionally, poppr has a wrapper to ADE4's implementation of AMOVA that explicitly handles strata called poppr.amova.

Cheers,
Zhian