Skip to contents

Compute correlations between pairs of features given in idxi and idxj

Usage

corSubsetPairs(
  Y,
  idxi,
  idxj,
  method = c("pearson", "spearman"),
  silent = FALSE,
  setNANtoZero = FALSE
)

Arguments

Y

matrix where rows are features

idxi

indecies

idxj

indecies

method

specify which correlation method: "pearson" or "spearman"

silent

suppress messages

setNANtoZero

replace NAN correlation values with a zero

Value

Compute local correlations between for all k: cor(Y[,idxi[k]], Y[,idxj[k]])

Examples

# Simulate simple dataset
N = 600
Y = matrix(rnorm(N*100), 100, N)

# select pairs to compute correlations between
i1 = sample.int(N, 200, replace=TRUE)
i2 = sample.int(N, 200, replace=TRUE)

# evaluate all piars
C = corSubsetPairs(t(Y), i1,i2)
#> Covariance matrix...
#>  sparsity:99.944 %
#>  memory usage:0 Mb

# show value
C[i1[10], i2[10]]
#> [1] -0.06592665

# show values from evaluating this pair directly
cor(Y[,i1[10]], Y[,i2[10]])
#> [1] -0.06592665