mop_distance {mop}R Documentation

MOP distance calculation

Description

Calculates distances from each of the points of interest in g_matrix to a defined percentage of the reference conditions in m_matrix.

Usage

mop_distance(m_matrix, g_matrix, distance = "euclidean", percentage = 1,
             comp_each = 2000, tol = NULL, parallel = FALSE, n_cores = NULL,
             progress_bar = TRUE)

Arguments

m_matrix

matrix of variables representing the set of conditions to be used as reference. Each column represents a variable.

g_matrix

matrix of variables representing the set of conditions to be compared against the reference conditions (where distances are to be calculated). Each column represents a variable. Variable names must match those in m_matrix.

distance

character, one of two options: "euclidean" or "mahalanobis".

percentage

numeric, percentage of points of m (the closest ones) used to derive mean environmental distances to each g point.

comp_each

numeric, number of points of the g matrix to be used for distance calculations at a time (default = 2000). Increasing this number requires more RAM.

tol

tolerance to detect linear dependencies when calculating Mahalanobis distances. The default, NULL, uses .Machine$double.eps.

parallel

logical, if TRUE, calculations will be performed in parallel using n_cores of the computer. Using this option will speed up the analysis but will demand more RAM.

n_cores

numeric, number of cores to be used in parallel processing. Uses current host CPU cores - 1 by default.

progress_bar

logical, whether to show a progress bar for calculations. Valid when calculations are not run in parallel.

Value

A numeric vector with values of distances calculated according to parameters used.

Examples

# data
data("reference_matrix", package = "mop")
data("matrix_of_interest", package = "mop")

# analysis
mop_dist <- mop_distance(m_matrix = reference_matrix,
                         g_matrix = matrix_of_interest)

[Package mop version 0.1.2 Index]