This function executes the adonis2 function of the vegan package and returns the result.
Arguments
- ta
A tidytacos object.
- predictors
A character vector with predictors to include in the model.
- permutations
The number of permutations (more permutations takes longer but gives a more accurate p-value).
- ...
Arguments passed on to
vegan::adonis2formulaModel formula. The left-hand side (LHS) of the formula must be either a community data matrix or a dissimilarity matrix, e.g., from
vegdistordist. If the LHS is a data matrix, functionvegdistwill be used to find the dissimilarities. The right-hand side (RHS) of the formula defines the independent variables. These can be continuous variables or factors, they can be transformed within the formula, and they can have interactions as in a typicalformula.datathe data frame for the independent variables, with rows in the same order as the community data matrix or dissimilarity matrix named on the LHS of
formula.methodthe name of any method used in
vegdistto calculate pairwise distances if the left hand side of theformulawas a data frame or a matrix.sqrt.distTake square root of dissimilarities. This often euclidifies dissimilarities.
addAdd a constant to the non-diagonal dissimilarities such that all eigenvalues are non-negative in the underlying Principal Co-ordinates Analysis (see
wcmdscalefor details). Choice"lingoes"(orTRUE) use the recommended method of Legendre & Anderson (1999: “method 1”) and"cailliez"uses their “method 2”.byby = NULLwill assess the overall significance of all terms together,by = "terms"will assess significance for each term (sequentially from first to last), settingby = "margin"will assess the marginal effects of the terms (each marginal term analysed in a model with all other variables),by = "onedf"will analyse one-degree-of-freedom contrasts sequentially. The argument is passed on toanova.cca.parallelNumber of parallel processes or a predefined socket cluster. With
parallel = 1uses ordinary, non-parallel processing. The parallel processing is done with parallel package.na.actionHandling of missing values on the right-hand-side of the formula (see
na.failfor explanation and alternatives). Missing values are not allowed on the left-hand-side. NB, argumentsubsetis not implemented.strataGroups within which to constrain permutations. The traditional non-movable strata are set as Blocks in the permute package, but some more flexible alternatives may be more appropriate.
Value
An object of class "adonis" (see adonis).
Examples
res <- urt %>%
perform_adonis(c("plate", "method"), by = "terms")
res
#> Permutation test for adonis under reduced model
#> Terms added sequentially (first to last)
#> Permutation: free
#> Number of permutations: 999
#>
#> adonis2(formula = as.formula(paste("counts_matrix", formula_RHS, sep = " ~ ")), data = metadata, permutations = permutations, by = "terms")
#> Df SumOfSqs R2 F Pr(>F)
#> plate 1 0.663 0.00905 1.9454 0.018 *
#> method 1 0.677 0.00924 1.9863 0.014 *
#> Residual 211 71.913 0.98171
#> Total 213 73.253 1.00000
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
