sparse.cor: Calculate Sparse Correlation Matrix

View source: R/Seurat.Utils.R

sparse.corR Documentation

Calculate Sparse Correlation Matrix

Description

Computes a sparse correlation matrix from a given sparse matrix input. This function is useful for efficiently handling large datasets where most values are zero, facilitating the calculation of both covariance and correlation matrices without converting to a dense format.

Usage

sparse.cor(smat)

Arguments

smat

A sparse matrix object, typically of class Matrix from the Matrix package.

Value

A list with two elements:

  • cov: The covariance matrix derived from the input sparse matrix.

  • cor: The correlation matrix derived from the covariance matrix.

Examples

## Not run: 
library(Matrix)
smat <- Matrix(rnorm(1000), nrow = 100, sparse = TRUE)
cor_res <- sparse.cor(smat)
print(cor_res$cor)

## End(Not run)


vertesy/Seurat.utils documentation built on Dec. 4, 2024, 5:20 p.m.