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

Cell-type proportions

Quantify and compare cell-type composition across samples or patient groups using individual cell or spot counts, or precomputed densities and fractions.

Quantify and compare cell-type composition across samples or patient groups using individual cell or spot counts, or precomputed densities and fractions.

Count-based proportions (boxplot)

Description

Analysis summary

Computes how a cohort's units — samples, patients or slides — are composed: within each denominator unit, the share of its entities (most often cells) falling in each category of a grouping variable, one proportion per unit.

Computation

Within every denominator unit, the entities falling in each category of the grouping variable (optionally split by a stratification variable) are counted and divided by the unit's total entity count, giving per-unit proportions that sum to 1. The output keeps one proportion per denominator unit rather than a single average composition, so the unit-to-unit (patient-to-patient, slide-to-slide) biological spread is preserved. Pairwise statistical comparisons of the proportions between groups (within each stratum when the data is stratified) are computed automatically and returned with the results.

When to use

Use for composition and abundance questions whenever the entities can be counted individually: cell-type proportions per sample in single-cell or spatial transcriptomics, spot composition per slide, and so on. It answers 'how much of each unit is X?' — not 'what fraction of cells express gene Y?': that is an expression question, answered by sparse_aggregation_analysis. When only pre-aggregated densities are available and entities cannot be counted, use the density mode of this analysis instead.

Caveats

A denominator unit with few entities (e.g. a sample with a handful of cells) yields noisy proportions, and proportions of rare categories are unstable across units.

Example questions

example questions
  • Single-cell cell type proportions per sample

  • Single-cell cell type proportions per sample, stratified

Input columns

input columns
column
type
required
description

count_index

any

required

Entity to count per denominator (e.g. cell_id); each distinct value is counted once per denominator, so each entity must appear on its own row.

denominator

any

required

Denominator unit — proportions sum to 1 per value here.

x_group

categorical

required

Primary grouping variable (e.g. condition, cell type).

y_group

categorical

optional

Stratification variable (e.g. gender, condition), or — in density mode — the category whose share is computed.

patient_id

categorical

required

Patient identifier. Always required, even in density mode where it isn't used by this analysis itself, because population summary statistics are computed from …

Visualizations

  • boxplot How to read: Each box shows the distribution of per-denominator proportions for one group: the centre line is the median, the box spans the interquartile range of the values, and the dots are the individual denominator units (samples, patients or slides) — their vertical spread is the unit-to-unit variability of the composition. When the data is stratified, side-by-side boxes are keyed by the legend. Significance brackets with stars mark groups with at least one significant pairwise comparison after multiple-testing correction (★ p<0.05, ★★ p<0.01, ★★★ p<0.001, ★★★★ p<0.0001). The y-axis is the share of each denominator unit, in percent.

Example analysis 1

Name — Cell Type Proportions (MOSAIC, Age >= 40)

Analysis parameters

analysis_name, analysis_params, viz_params

Visualization — boxplot

Cell Type Proportions (MOSAIC, Age >= 40)

Output table

descriptive_stats (first 10 of 15 rows)
x_group
n
mean
std
min
p10
p25
p50
p75
p90
max

B_cell

28

0.02075

0.03623

0.0003849

0.001079

0.00206

0.004988

0.02614

0.0378

0.1764

DC

28

0.01119

0.008652

0.0001374

0.001981

0.004234

0.01051

0.01488

0.01773

0.03785

Endothelial

29

0.05131

0.02365

0.01214

0.02499

0.04483

0.04934

0.0568

0.06959

0.147

Epithelial_absorptive

1

0.0001093

0.0001093

0.0001093

0.0001093

0.0001093

0.0001093

0.0001093

0.0001093

Epithelial_other

22

0.008505

0.01495

0.0001047

0.000138

0.0005463

0.00279

0.008379

0.02233

0.05648

Epithelial_secretory

7

0.02174

0.03162

0.0001489

0.0001965

0.0004309

0.001995

0.03338

0.03338

0.08501

Fibroblast

29

0.1843

0.1163

0.01821

0.0364

0.1145

0.1729

0.2357

0.3209

0.5269

Granulocyte

29

0.007664

0.01424

0.000298

0.0007236

0.001887

0.003267

0.005027

0.01868

0.06557

Malignant

29

0.3266

0.1383

0.02004

0.2029

0.2223

0.3231

0.3924

0.5534

0.5966

Mast

28

0.005844

0.005115

0.0004717

0.0007444

0.00154

0.004471

0.008185

0.01292

0.01837

statistical_tests (first 10 of 105 rows)
Test used for pairwise comparison
Contrast
Statistic
Mean Difference
Higher Group
P-value
Adjusted P-value
Significance level
comparison_a
comparison_b

wilcoxon

(Malignant, Granulocyte)

839.0

0.3189

Malignant

8.008e-11

1.248e-09

★★★★

Malignant

Granulocyte

wilcoxon

(MoMac, Granulocyte)

838.0

0.1301

MoMac

8.88e-11

1.248e-09

★★★★

MoMac

Granulocyte

wilcoxon

(Malignant, Mast)

812.0

0.3207

Malignant

9.623e-11

1.248e-09

★★★★

Malignant

Mast

wilcoxon

(Mast, MoMac)

0.0

-0.1319

MoMac

9.623e-11

1.248e-09

★★★★

Mast

MoMac

wilcoxon

(MoMac, DC)

812.0

0.1266

MoMac

9.623e-11

1.248e-09

★★★★

MoMac

DC

wilcoxon

(MoMac, Stromal other)

812.0

0.132

MoMac

9.623e-11

1.248e-09

★★★★

MoMac

Stromal_other

wilcoxon

(Malignant, Stromal other)

811.0

0.3208

Malignant

1.069e-10

1.248e-09

★★★★

Malignant

Stromal_other

wilcoxon

(Mast, Fibroblast)

1.0

-0.1784

Fibroblast

1.069e-10

1.248e-09

★★★★

Mast

Fibroblast

wilcoxon

(Fibroblast, Stromal other)

811.0

0.1785

Fibroblast

1.069e-10

1.248e-09

★★★★

Fibroblast

Stromal_other

wilcoxon

(Malignant, DC)

809.0

0.3154

Malignant

1.32e-10

1.282e-09

★★★★

Malignant

DC

Density-based proportions (stacked bar)

Description

Analysis summary

Computes the mean composition of each group from pre-computed measurements that cannot be decomposed into countable entities — for example histomics-derived cell densities per slide or tissue region — as the mean share of each category in the group's composition.

Computation

Each measurement is first normalised to a proportion within its denominator unit (the unit's measurements sum to 1), and those per-unit proportions are then averaged within each group to give the mean composition — one mean share per category per group. Missing category-unit combinations are counted as zero before averaging, so a rare category's mean is taken over all units, not only those where it appears. Pairwise statistical comparisons between the categories within each group are computed automatically and returned with the results.

When to use

Use when the input provides pre-aggregated density or fraction values (e.g. histomics cell densities) rather than countable entities. When the entities can be counted individually, prefer the count mode of this analysis, which keeps the unit-to-unit variability visible instead of averaging it away.

Caveats

Averaging across denominator units yields the typical composition of each group but not the unit-to-unit spread.

Example questions

example questions
  • Histomics cell type density proportions across groups

Input columns

input columns
column
type
required
description

denominator

any

required

Denominator unit — proportions sum to 1 per value here.

value

numeric

required

Pre-computed numeric measurement (e.g. cell density) to normalise within each denominator.

x_group

categorical

required

Primary grouping variable (e.g. condition, cell type).

y_group

categorical

optional

Stratification variable (e.g. gender, condition), or — in density mode — the category whose share is computed.

patient_id

categorical

required

Patient identifier. Always required, even in density mode where it isn't used by this analysis itself, because population summary statistics are computed from …

Visualizations

  • bar How to read: Each bar is one group; its stacked segments (keyed by the legend) show the mean share of each category in the group's composition, summing to 100%, with the percentage written inside each segment. The chart shows the typical composition per group but not the unit-to-unit spread — use the count mode's boxplot for that. Pairwise comparisons between the categories within each group are reported in the accompanying statistical table.

Example analysis 1

Name — Histomics Cell Type Proportions by Gender (TCGA Bladder Cancer, Age > 40)

Analysis parameters

analysis_name, analysis_params, viz_params

Visualization — bar

Histomics Cell Type Proportions by Gender (TCGA Bladder Cancer, Age > 40)

Output table

descriptive_stats (first 10 of 12 rows)
x_group
y_group
n
mean
std
min
p10
p25
p50
p75
p90
max

female

density_cancer_cell_in_tumor

108

2295.0

1448.0

206.3

724.1

1365.0

2170.0

2760.0

3955.0

8442.0

female

density_eosinophils_in_tumor

108

30.65

36.85

0.7768

3.069

9.041

18.43

36.58

61.76

226.9

female

density_fibroblasts_in_tumor

108

456.9

252.2

109.2

199.5

296.0

425.4

547.3

710.5

1806.0

female

density_lymphocytes_in_tumor

108

558.7

561.7

9.979

127.3

213.4

403.0

658.6

1271.0

3965.0

female

density_neutrophils_in_tumor

108

45.35

63.75

1.17

6.979

11.71

24.23

52.14

94.89

371.5

female

density_plasmocytes_in_tumor

108

43.39

83.18

0.4036

1.107

3.901

12.28

36.58

97.18

447.7

male

density_cancer_cell_in_tumor

310

2740.0

1554.0

61.56

1163.0

1648.0

2414.0

3571.0

4880.0

9861.0

male

density_eosinophils_in_tumor

310

26.66

42.48

0.1785

1.98

4.501

13.07

28.11

73.23

396.6

male

density_fibroblasts_in_tumor

310

417.0

243.8

40.03

143.2

237.3

375.4

544.2

752.5

1435.0

male

density_lymphocytes_in_tumor

310

454.3

475.1

9.718

62.71

145.7

315.0

564.5

1056.0

2860.0

statistical_tests (6 rows)
Test used for pairwise comparison
Group
Contrast
Statistic
Mean Difference
Higher Group
P-value
Adjusted P-value
Significance level
comparison_a
comparison_b

wilcoxon

Density eosinophils in tumor

(Female, Male)

19900.0

3.987

Female

0.003517

0.01623

★

female

male

wilcoxon

Density cancer cell in tumor

(Female, Male)

13730.0

-445.1

Male

0.005409

0.01623

★

female

male

wilcoxon

Density neutrophils in tumor

(Female, Male)

19540.0

3.903

Female

0.009516

0.01903

★

female

male

wilcoxon

Density lymphocytes in tumor

(Female, Male)

19190.0

104.3

Female

0.02337

0.03505

★

female

male

wilcoxon

Density fibroblasts in tumor

(Female, Male)

18610.0

39.89

Female

0.0833

0.09996

female

male

wilcoxon

Density plasmocytes in tumor

(Female, Male)

17640.0

5.963

Female

0.4044

0.4044

female

male

Last updated

Was this helpful?