getCorM: Calculate Column-wise Correlation Matrix

View source: R/methods.R

getCorMR Documentation

Calculate Column-wise Correlation Matrix

Description

Efficiently computes a column-wise correlation matrix for a given input matrix. Supports Pearson and Spearman correlations, with optional weighting for features.

Usage

getCorM(method, x, w, nCores)

Arguments

method

A character string specifying the correlation metric to use. Currently supported options are: - "spearman": Spearman rank correlation - "pearson": Pearson correlation

x

A numeric matrix where each column represents a sample.

w

(Optional) A numeric vector of weights for each feature (row) in x. If not provided, all features are equally weighted.

nCores

The number of cores to use for parallel processing.

Value

A correlation matrix of the same dimensions as the number of columns in 'x'. The values represent the pairwise correlations between samples (columns) based on the chosen method and optional weights.

Examples

library(scater)
library(splatter)

sce <- splatSimulate(group.prob = rep(1, 5)/5, sparsify = FALSE, 
        batchCells=100, nGenes=1000, method = "groups", verbose = FALSE, 
        dropout.type = "experiment")
sce <- logNormCounts(sce)
cores <- 2
logX <- as.matrix(logcounts(sce))
w <- rowVars_fast(logX, cores)
corMat <- getCorM("spearman", logcounts(sce), w, cores)


khazum/ccImpute documentation built on July 26, 2024, 1:13 a.m.