This function is a wrapper around mantel from the vegan package that extends the function by efficently applying the mantel test between all members of either the results of precise_dist or a named list of distance matrices.

precise_correlations(data, method = "mgc", permutations = 999,
  parallel = FALSE, verbose = FALSE)

Arguments

data

Either a named list of distance matrices or the native output of precise_dist.

method

A string value of the correlation method to use. Options include "pearson", "spearman" or "kendall".

permutations

Number of permutations in assessing significance.

parallel

TRUE or FALSE. Should the function expect a future plan to be defined? See details.

verbose

TRUE or FALSE. Should the function tell you what is happening internally?

Value

A list containing three objects; output = table of all results, stat_cor = the distance correlation matrix and signif_cor = the distance significance matrix.

Details

Without specific domain knowledge, choosing the appropriate distance(s) for a dataset can be a very difficult task. Given a list of distance matrices, this function calculates the correlation between all of them i.e. it calculates a correlation matrix of distance relationships. This can be helpful for filtering certain distances from downstream operations, for example, distances which are too similar or too different from other distances. Note that before running this function, the input data should probably be coerced into all distances or all similarities using precise_transform.

References

Muchmore, B., Muchmore P. and Alarcón-Riquelme ME. (2018). Optimal Distance Matrix Construction with PreciseDist and PreciseGraph.

Jari Oksanen, F. Guillaume Blanchet, Michael Friendly, Roeland Kindt, Pierre Legendre, Dan McGlinn, Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, Eduard Szoecs and Helene Wagner (2018). vegan: Community Ecology Package. R package version 2.5-1. https://CRAN.R-project.org/package=vegan

Examples

library(PreciseDist) library(heatmaply)
#> Loading required package: plotly
#> Loading required package: ggplot2
#> #> Attaching package: ‘plotly’
#> The following object is masked from ‘package:ggplot2’: #> #> last_plot
#> The following object is masked from ‘package:stats’: #> #> filter
#> The following object is masked from ‘package:graphics’: #> #> layout
#> Loading required package: viridis
#> Loading required package: viridisLite
#> #> ====================== #> Welcome to heatmaply version 0.15.2 #> #> Type citation('heatmaply') for how to cite the package. #> Type ?heatmaply for the main documentation. #> #> The github page is: https://github.com/talgalili/heatmaply/ #> Please submit your suggestions and bug-reports at: https://github.com/talgalili/heatmaply/issues #> Or contact: <tal.galili@gmail.com> #> ======================
test_matrix <- replicate(100, rnorm(10)) test_distances <- test_matrix %>% precise_dist(dists = c("euclidean", "manhattan", "random_forest_sqrt", "random_forest_two"))
#> [1] "Starting dists calculations at 2018-11-29 15:20:13" #> [1] "Finished dists calculations at 2018-11-29 15:20:15" #> [1] "Calculations took: 1.48 seconds" #> [1] "Starting dist_funcs calculations at 2018-11-29 15:20:15" #> [1] "Finished dist_funcs calculations at 2018-11-29 15:20:15" #> [1] "Calculations took: 0 seconds"
test_input_data <- test_distances %>% precise_transform(enforce_dist = TRUE) test_mantel_output <- test_input_data %>% precise_mantel(method = "pearson", permutations = 999, parallel = FALSE, verbose = TRUE)
#> Error in precise_mantel(., method = "pearson", permutations = 999, parallel = FALSE, verbose = TRUE): could not find function "precise_mantel"
View(test_mantel_output$output)
#> Error in as.data.frame(x): object 'test_mantel_output' not found
heatmaply(test_mantel_output$stat_cor)
#> Error in heatmaply(test_mantel_output$stat_cor): object 'test_mantel_output' not found
heatmaply(test_mantel_output$signif_cor)
#> Error in heatmaply(test_mantel_output$signif_cor): object 'test_mantel_output' not found