sparseDistanceMatrixXY: Create sparse distance, covariance or correlation matrix from...

Description Usage Arguments Value Author(s) References Examples

View source: R/multiscaleSVDxpts.R

Description

Exploit k-nearest neighbor algorithms to estimate a sparse matrix measuring the distance, correlation or covariance between two matched datasets. Critical to the validity of this function is the basic mathematical relationships between euclidean distance and correlation and between correlation and covariance. For applications of such matrices, one may see relevant publications by Mauro Maggioni and other authors.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
sparseDistanceMatrixXY(
  x,
  y,
  k = 3,
  r = Inf,
  sigma = NA,
  kmetric = c("euclidean", "correlation", "covariance", "gaussian"),
  eps = 0.000001,
  kPackage = "RcppHNSW",
  ncores = NA,
  verbose = FALSE
)

Arguments

x

input matrix, should be n (samples) by p (measurements)

y

input matrix second view, should be n (samples) by q (measurements)

k

number of neighbors

r

radius of epsilon-ball

sigma

parameter for kernel PCA.

kmetric

similarity or distance metric determining k nearest neighbors

eps

epsilon error for rapid knn

kPackage

name of package to use for knn

ncores

number of cores to use

verbose

verbose output

Value

matrix sparse p by q matrix is output with p by k nonzero entries

Author(s)

Avants BB

References

http://www.math.jhu.edu/~mauro/multiscaledatageometry.html

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
set.seed(120)
mat = matrix( rnorm(60), nrow=6 )
mat2 = matrix( rnorm(120), nrow=6 )
smat = sparseDistanceMatrixXY( mat, mat2, 3 )
smat2 = sparseDistanceMatrixXY( mat2, mat, 3 )
testthat::expect_is(smat, "Matrix")
testthat::expect_is(smat, "dgCMatrix")
testthat::expect_is(smat2, "Matrix")
testthat::expect_is(smat2, "dgCMatrix")
testthat::expect_equal(sum(smat), 154.628961265087)
testthat::expect_equal(sum(smat2), 63.7344262003899)

## End(Not run)

neuroconductor-devel/ANTsR documentation built on April 1, 2021, 1:02 p.m.