Skip to contents

This function computes pairwise co-association (Pearson correlation) between cell states (defined as combinations of SE and cell type) across samples. It evaluates co-association under multiple data transformations (with/without non-SE states and missing value handling) and returns an averaged correlation matrix.

Usage

Coassociation(
  scmeta,
  Sample = "Sample",
  SE = "SE",
  CellType = "CellType",
  NonSE = "NonSE",
  nperm = 1000,
  test = TRUE
)

Arguments

scmeta

A data.frame containing single-cell metadata.

Sample

Character. Column name in scmeta specifying sample IDs.

SE

Character. Column name in scmeta specifying spatial ecotype labels.

CellType

Character. Column name in scmeta specifying cell type annotations.

NonSE

Character. Label used to denote non-SE cells (default: "NonSE").

Value

A symmetric matrix of Pearson correlation coefficients between cell states, averaged across multiple normalization strategies.

Details

Cell states are defined as concatenations of SE and cell type labels. The function computes abundances of SE-associated cell state under four schemes: (1) including all SE and NonSE states, (2) excluding NonSE states, (3) same as in (1), but treating zero abundance as missing values (NA), and (4) same as in (2), but treating zero abundance as NA. Pairwise Pearson correlations between cell states were then calculated across all scRNA-seq samples for each abundance matrix, using the cor function in R with pairwise complete observations. The final co-association values were obtained by averaging the correlations across the four schemes.