lands.grp.test {Morphoscape}R Documentation

Significance tests between sets of weights

Description

lands.grp.test() performs a statistical test for whether the optimal adaptive landscape for two subgroups are significantly different from each other. The p-value of the test is the proportion of weight sets that are shared between the two subgroups among their respective top weight sets. multi.lands.grp.test() performs this test for all pairs of subgroups.

Usage

lands.grp.test(grpa, grpb, method = "chi-squared",
               quantile = 0.05)

multi.lands.grp.test(x, method = "chi-squared",
                     quantile = 0.05)

## S3 method for class 'lands.grp.test'
print(x, digits = max(3L, getOption("digits") - 3L), ...)

## S3 method for class 'multi.lands.grp.test'
print(x, digits = max(3L, getOption("digits") - 3L), 
      style = "matrix", ...)

Arguments

grpa, grpb

for lands.grp.test(), the two grp_Wprime objects containing the adaptive landscapes to be compared; these are the output of calls to calcGrpWprime.

x

for multi.lands.grp.test(), a by_Wprime object, the output of a call to calcWprimeBy.

for print(), the output of a call to lands.grp.test() or multi.lands.grp.test().

method

the method used to determine which sets of weights are in the "best" sets of weights that are to be comapred between the two groups. Allowable options include "chi-squared" and "quantile". See calcGrpWprime for details.

quantile

the top quantile used to determine the best sets of weights to be included in the average to compute the optimal set of weights. Should be a number between 0 and 1, with a low value indicating that only the few top sets of weights will be used. See calcGrpWprime for details.

digits

the number of significant digits to print.

style

how to display the results of the pairwise tests; allowable options include "matrix" and "table". Abbreviations allowed.

...

passed to print.default.

Details

lands.grp.test() performs pairwise comparisons between two adaptive groups by comparing the number of shared landscapes n_{A+B} in the top percentile of each group with the total number of landscapes in this top percentile n_{total}. The probability P(A=B) thus is calculated as:

P(A=B) = n_{A+B}/n_{total}

If method = "quantile" is used, then the top percentile is defined by quantile. If method = "chi-squared" is used, then the top percentile is calculated from the chi-squared value \chi^2_i as:

\chi^2_i = -2 \log \frac{Z_{max}}{Z_i}

where Z_{max} is the largest Z among the weights, and a p-value is computed for each \chi^2_i value using a \chi^2 distribution with 2 d.f.; any set of weights with a p-value less than quantile is included in the optimal set of weights.

multi.lands.grp.test() is a wrapper for lands.grp.test(), applying the function pairwise to all combinations of groups calculated by calcWprimeBy.

Value

For lands.grp.test(), a lands.grp.test object containing the following components:

n.match

the number of sets of weights that match between the two supplied subgroups

p.val

the p-value of the test, computed as the number of sets of weights that match divided by the number of sets of weights compared

matching

a matrix containing the sets of weights that match between the two subgroups

method

the argument supplied to method

quantile

the argument supplied to quantile

For multi.lands.grp.test(), a multi.lands.grp.test object containing the following components:

res

a data frame containing the results of the tests, with the columns Group A and Group B indicating the groups involved in the comparison, the column Matches containing the number of matching sets of weights in the comparison, and the column p value containing the p-value of the test.

method

the argument supplied to method

quantile

the argument supplied to quantile

For print.multi.lands.grp.test(), setting style = "table" prints the res component as-is; setting style = "matrix" creates a matrix where the p-values of the test are below the diagonal and the number of matches of the test are above the diagonal.

References

Jones, K. E., Dickson, B. V., Angielczyk, K. D., & Pierce, S. E. (2021). Adaptive landscapes challenge the "lateral-to-sagittal"" paradigm for mammalian vertebral evolution. Current Biology, 31(9), 1883-1892.

See Also

calcGrpWprime and calcWprimeBy for creatign the objects used as inputs to these functions

Examples

data("warps")
data("turtles")

warps_fnc <- as_fnc_df(warps, 
                       func.names = c("hydro", "fea"))

kr_surf <- krige_surf(warps_fnc, new_data = turtles)

grid_weights <- generate_weights(n = 3, data = kr_surf)

all_lscps <- calc_all_lscps(kr_surf,
                            grid_weights = grid_weights)

# Comparing adaptive landscapes of Ecology groups S and M
wprime_S <- calcGrpWprime(all_lscps,
                          index = Ecology == "S")
wprime_M <- calcGrpWprime(all_lscps,
                          index = Ecology == "M")
lands.grp.test(wprime_S, wprime_M)

# Comparing adaptive landscapes of all Group subgroups
wprime_by_Group <- calcWprimeBy(all_lscps, by = ~Group)
tests <- multi.lands.grp.test(wprime_by_Group)
tests
print(tests, style = "table")

[Package Morphoscape version 1.0.2 Index]