adonis.dispRity {dispRity} | R Documentation |
adonis dispRity (from vegan::adonis2
)
Description
Passing dispRity
objects to the adonis2
function from the vegan
package.
Usage
adonis.dispRity(
data,
formula = matrix ~ group,
method = "euclidean",
...,
warn = TRUE,
matrix = 1
)
Arguments
data |
A |
formula |
The model formula (default is |
method |
The distance method to be passed to |
... |
Any optional arguments to be passed to |
warn |
|
matrix |
|
Details
The first element of the formula (the response) must be called matrix
and the predictors must be existing in the subsets of the dispRity
object.
If data$matrix[[1]]
is not a distance matrix, distance is calculated using the dist
function. The type of distance can be passed via the standard method
argument that will be recycled by adonis2
.
If the dispRity
data has custom subsets with a single group, the formula is set to matrix ~ group
.
If the dispRity
data has custom subsets with multiple group categories (separated by a dot, e.g. c("group1.cat1", "group1.cat2", "group2.catA", "group2.catB")
being two groups with two categories each), the default formula is matrix ~ first_group
but can be set to any combination (e.g. matrix ~ first_group + second_group
).
If the dispRity
data has time subsets, the predictor is automatically set to time
.
Author(s)
Thomas Guillerme
See Also
adonis2
, test.dispRity
, custom.subsets
, chrono.subsets
.
Examples
## Adonis with one groups
## Generating a random character matrix
character_matrix <- sim.morpho(rtree(20), 50, rates = c(rnorm, 1, 0))
## Calculating the distance matrix
distance_matrix <- as.matrix(dist(character_matrix))
## Creating two groups
random_groups <- list("group1" = 1:10, "group2" = 11:20)
## Generating a dispRity object
random_disparity <- custom.subsets(distance_matrix, random_groups)
## Running a default NPMANOVA
adonis.dispRity(random_disparity)
## Adonis with multiple groups
## Creating a random matrix
random_matrix <- matrix(data = rnorm(90), nrow = 10,
dimnames = list(letters[1:10]))
## Creating two groups with two states each
groups <- as.data.frame(matrix(data = c(rep(1,5), rep(2,5), rep(c(1,2), 5)),
nrow = 10, ncol = 2, dimnames = list(letters[1:10], c("g1", "g2"))))
## Creating the dispRity object
multi_groups <- custom.subsets(random_matrix, groups)
## Running the NPMANOVA
adonis.dispRity(multi_groups, matrix ~ g1 + g2)
## Adonis with time
## Creating time series
data(BeckLee_mat50)
data(BeckLee_tree)
data(BeckLee_ages)
time_subsets <- chrono.subsets(BeckLee_mat50, BeckLee_tree,
method = "discrete", inc.nodes = FALSE, time = c(100, 85, 65, 0),
FADLAD = BeckLee_ages)
## Running the NPMANOVA with time as a predictor
adonis.dispRity(time_subsets, matrix ~ time)
## Running the NPMANOVA with each time bin as a predictor
adonis.dispRity(time_subsets, matrix ~ chrono.subsets)