For the complete documentation index, see llms.txt. This page is also available as Markdown.

Single-cell / Spatial feature correlation

Compute pairwise Pearson/Spearman correlation and co-occurrence matrices between features, optionally stratified by a grouping variable.

Compute pairwise Pearson/Spearman correlation and co-occurrence matrices between features, optionally stratified by a grouping variable.

Sparse correlation + co-occurrence dotplot

Description

Analysis summary

Computes, between every pair of features over sparse observations (cells or spots), both a correlation coefficient of their expression levels and the share of observations co-expressing both — the two faces of pairwise association in sparse data.

Computation

Per stratum of the optional grouping variable (or globally when absent), the observations are pivoted to a wide observation-by-feature matrix; observations missing any feature value are excluded, zero-valued ones kept. Every feature pair then gets a Pearson or Spearman correlation coefficient over the expression values, its two-sided p-value, and the co-expression share — the fraction of observations where both features' presence signals are above zero — with the observation counts backing each. The diagonal (a feature against itself) carries a coefficient of 0. Gene signatures collapse their member genes into per-observation averages before the matrix is computed.

When to use

Use for sparse single-cell or spatial-transcriptomics data, where the binary expressed/not-expressed dimension is informative alongside the correlation: it answers 'which features correlate and which actually co-occur'. For correlation matrices on bulk (dense) data, use correlation_analysis instead; for the overlap between exactly two features, use coexpression_analysis.

Caveats

Correlation over sparse counts is dominated by the many zero-zero pairs — a high correlation can mean shared abundance rather than shared regulation, which is what the co-expression share disambiguates. Each p-value is uncorrected for the many pairs tested. Observations missing any feature of the panel are dropped, so the effective cohort is the intersection across the panel.

Example questions

example questions
  • Single-cell pairwise gene correlation per cell type

  • Single-cell pairwise gene signature correlation per cell type

Input columns

input columns
column
type
required
description

index

any

required

Unique observation identifier used to align feature vectors across rows. e.g. cell barcode (scRNA-seq), spot barcode (Visium), sample_id (bulk).

value_sparsity

numeric

required

Raw presence/absence signal — value_sparsity > 0 marks an observation as expressing/present. Used exclusively to compute co-occurrence percentage, not for corr…

value

numeric

required

Continuous quantity to correlate across observations. e.g. count_lognorm or count_scaled (scRNA-seq / Visium), normalised bulk expression, z-score.

x_group

categorical

required

Feature label — each unique value becomes both a row and a column in the correlation matrix. e.g. gene_name, pathway_score_name, protein_name.

y_group

categorical

optional

Stratification variable. When provided, one correlation matrix is computed per unique value. e.g. cell_type, spot_cluster, tissue_region, sample_group.

patient_id

categorical

required

Patient identifier required for population summary statistics.

Visualizations

  • dotplot How to read: One dot per feature pair: its colour encodes the correlation coefficient on a diverging red-blue scale centred on zero (red positive, blue negative) and its area the share of observations co-expressing both (size legend). The two axes are the same feature list — the matrix is symmetric — and the diagonal carries no information. When the data is stratified, a dropdown switches between strata. Hovering a dot shows the coefficient, the p-value and the co-expression counts; the accompanying statistical table repeats the coefficients and p-values, each unordered pair once.

Example analysis 1

Name — Gene Correlation Heatmap for ERBB2, TP53, and ROR1 in Immune Cells (Age > 40)

Analysis parameters

analysis_name, analysis_params, viz_params

Visualization — dotplot

Gene Correlation Heatmap for ERBB2, TP53, and ROR1 in Immune Cells (Age > 40)

Output table

descriptive_stats (first 10 of 21 rows)
y_group
x_group_a
x_group_b
pearson_correlation
p_value
co_expression
n
n_non_zeros_a
n_non_zeros_b
n_co_expressed

Mast

ERBB2

ROR1

0.2012

8.411e-08

0.001435

697

15

2

1

Plasma

ERBB2

TP53

0.05437

0.0006178

0.004291

3962

130

223

17

Granulocyte

ROR1

TP53

0.1444

0.002621

0.002315

432

2

15

1

Granulocyte

ERBB2

TP53

0.07783

0.1062

0.006944

432

26

15

3

MoMac

ERBB2

ROR1

0.01668

0.1321

0.0003681

8150

239

46

3

Plasma

ROR1

TP53

0.02199

0.1663

0.0007572

3962

20

223

3

B_cell

ERBB2

ROR1

0.02714

0.2785

0.0006266

1596

44

16

1

DC

ERBB2

TP53

0.02978

0.2926

0.01119

1251

61

187

14

B_cell

ERBB2

TP53

0.01836

0.4635

0.004386

1596

44

170

7

T_NK

ERBB2

ROR1

-0.007992

0.4723

0.0

8091

182

23

0

statistical_tests (first 10 of 21 rows)
y_group
x_group_a
x_group_b
pearson_correlation
p_value
co_expression
n
n_non_zeros_a
n_non_zeros_b
n_co_expressed

Mast

ERBB2

ROR1

0.2012

8.411e-08

0.001435

697

15

2

1

Plasma

ERBB2

TP53

0.05437

0.0006178

0.004291

3962

130

223

17

Granulocyte

ROR1

TP53

0.1444

0.002621

0.002315

432

2

15

1

Granulocyte

ERBB2

TP53

0.07783

0.1062

0.006944

432

26

15

3

MoMac

ERBB2

ROR1

0.01668

0.1321

0.0003681

8150

239

46

3

Plasma

ROR1

TP53

0.02199

0.1663

0.0007572

3962

20

223

3

B_cell

ERBB2

ROR1

0.02714

0.2785

0.0006266

1596

44

16

1

DC

ERBB2

TP53

0.02978

0.2926

0.01119

1251

61

187

14

B_cell

ERBB2

TP53

0.01836

0.4635

0.004386

1596

44

170

7

T_NK

ERBB2

ROR1

-0.007992

0.4723

0.0

8091

182

23

0

Last updated

Was this helpful?