computeCorrelations: Compute correlations between modes

computeCorrelationsR Documentation

Compute correlations between modes

Description

Compute Spearman correlations between two sets of features, using data collected for the same cells in different modalities.

Usage

computeCorrelations(x, y, ...)

## S4 method for signature 'ANY'
computeCorrelations(
  x,
  y,
  subset.cols = NULL,
  block = NULL,
  equiweight = TRUE,
  use.names = TRUE,
  BPPARAM = SerialParam()
)

## S4 method for signature 'SummarizedExperiment'
computeCorrelations(x, y, use.names = TRUE, ..., assay.type = "logcounts")

Arguments

x, y

Normalized expression matrices containing features in the rows and cells in the columns. Each matrix should have the same set of columns but a different set of features, usually corresponding to different modes for the same cells.

Alternatively, SummarizedExperiment objects containing such a matrix.

Finally, y may be NULL, in which correlations are computed between features in x.

...

For the generic, further arguments to pass to specific methods.

For the SummarizedExperiment method, further arguments to pass to the ANY method.

subset.cols

Vector indicating the columns of x (and y) to retain for computing correlations.

block

A vector or factor of length equal to the number of cells, specifying the block of origin for each cell.

equiweight

Logical scalar indicating whether each block should be given equal weight, if block is specified. If FALSE, each block is weighted by the number of cells.

use.names

Logical scalar specifying whether row names of x and/or y should be reported in the output, if available.

For the SummarizedExperiment method, this may also be a string specifying the rowData column containing the names to use; or a character vector of length 2, where the first and second entries specify the rowData columns containing the names in x and y respectively. If either entry is NA, the existing row names for the corresponding object are used. Note that this only has an effect on y if it is a SummarizedExperiment.

BPPARAM

A BiocParallelParam object specifying the parallelization scheme to use.

assay.type

String or integer scalar specifying the assay containing the matrix of interest in x (and y, if a SummarizedExperiment).

Details

If block is specified, correlations are computed separately for each block of cells. For each feature pair, the reported rho is set to the average of the correlations across all blocks. If equiweight=FALSE, the average is weighted by the number of cells in each block.

Similarly, the p-value corresponding to each correlation is computed separately for each block and then combined across blocks with Stouffer's method. More specifically, combining is done using the one-sided p-values for both signs of the correlation, and the smaller p-value is taken (and multiplied by 2). This ensures that a low p-value can only be achieved if the blocks agree in the sign. If equiweight=FALSE, each per-block p-value is weighted by the number of cells.

Value

A DataFrame where each row corresponds to a pair of features in x and y. (If y=NULL, each pair corresponds to a pair of features in x.) This contains the following fields:

  • feature1, the name (character) or row index (integer) of each feature in x.

  • feature2, the name (character) or row index (integer) of one of the top correlated features to feature1. This is another feature in x if y=NULL, otherwise it is a feature in y.

  • rho, the Spearman rank correlation for the current pair of feature1 and feature2.

  • p.value, the approximate p-value associated with rho under the null hypothesis that the correlation is zero.

  • FDR, the adjusted p-value.

The rows are sorted by feature1 and then p.value.

Author(s)

Aaron Lun

See Also

findTopCorrelations, to avoid computing correlations for all pairs of features when y has many rows.

Examples

library(scuttle)
sce1 <- mockSCE()
sce1 <- logNormCounts(sce1)

sce2 <- mockSCE(ngenes=10) # pretend this is protein data.
sce2 <- logNormCounts(sce2)

output <- computeCorrelations(sce1, sce2)
output


LTLA/mumosa documentation built on Oct. 1, 2024, 8:47 a.m.