Learn R Programming

KMDA (version 1.0)

mdist: Metabolite Distance Metric

Description

This function calculates a distance metric between two metabolomic measurements. These measurements can be either scalers or vectors.

Usage

mdist(x, y)

Arguments

x
a numerical scalar or vector of metabolomic measurements.
y
a numerical scalar or vector of metabolomic measurements.

Value

  • This function returns a non-negative value if x and y are of the same dimension. Otherwise it returns -1.

Details

If x and y are of different dimensions, function mdist returns a value of -1, which indicates the $mdist(x,y)$ is not defined in this scenario. When x and y have the same dimension, suppose they have $p$ components. If $p=1$, then x or y is the abundance level measurement of a single metabolite, which is a non-negative real number. If $p>1$, then x or y is measurements of a metebolite-set with multiple metabolites. In this case, let $x_i$ be the $i$th component of x, which is non-negative and denotes the abundance level measurement of the $i$th metabolite in the metabolite-set. The distance between x and y is defined as: $$mdist(x,y)= \sqrt { \sum_i I[\delta_{x_i} \neq \delta_{y_i}]+ \sum_i (x_i-y_i)^2 },$$ where $\delta_{x_i}=0$ if $x_i=0$, elsewise, $\delta_{x_i}=1$, and $I[\cdot]$ is the indicator function.

References

Zhan, X., Patterson, A. D., & Ghosh, D. (2015). Kernel approaches for differential expression analysis of mass spectrometry-based metabolomics data. BMC Bioinformatics, 16(1), 77.

Examples

Run this code
x=c(0,1,2)
	y=c(1,0,3)
	z=c(0,1,2,3)
	mdist(x,y)
	mdist(x,z)

Run the code above in your browser using DataLab