A generic function to compute a correlation matrix for different input types, including matrix, data.frame and SingleCellExperiment objects.

cellTypeCorMat(input, mask = NULL, reducedDimName = "PhiSpace", groupBy = NULL)

# S4 method for class 'matrix'
cellTypeCorMat(input, mask = NULL, reducedDimName = "PhiSpace", groupBy = NULL)

# S4 method for class 'data.frame'
cellTypeCorMat(input, mask = NULL, reducedDimName = "PhiSpace", groupBy = NULL)

# S4 method for class 'SingleCellExperiment'
cellTypeCorMat(input, mask = NULL, reducedDimName = "PhiSpace", groupBy = NULL)

Arguments

input

A matrix containing numeric data for correlation computation.

mask

A zero-one matrix with the same number of rows as the input. Optional. If provided, each column of mask defines a subset of rows used to compute a separate correlation matrix.

reducedDimName

A character string specifying the name of the reduced dimension to use for SingleCellExperiment objects. Defaults to "PhiSpace".

groupBy

A column of colData(input) when input is an SCE object. If provided, mask will be defined according to colData(input)[,groupBy].

Value

If mask is provided, returns a list of correlation matrices (one per column of mask). Otherwise, returns a single correlation matrix.

Details

This method calculates the correlation matrix directly for the input matrix.

This method first converts the data.frame to a matrix and then calculates the correlation matrix.

This method uses the reduced dimension "PhiSpace" of the SingleCellExperiment object to compute the correlation matrix. If "PhiSpace" is not available, an error is raised.