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

Differential expression (DESeq2)

Identify differentially expressed genes between two groups using DESeq2, from bulk RNA-seq counts or single-cell counts aggregated into patient-level pseudobulk samples.

Identify differentially expressed genes between two groups using DESeq2, from bulk RNA-seq counts or single-cell counts aggregated into patient-level pseudobulk samples.

Bulk RNA-seq DEA via DESeq2

Description

Analysis summary

Performs differential gene expression analysis between two biological or clinical cohorts in bulk RNA-seq, estimating effect sizes (log2 fold change) and statistical significance controlled for false discovery rate.

Computation

Raw read counts are modeled per gene with a negative binomial GLM (DESeq2): size factors normalize for sequencing depth, and gene-wise dispersions are shrunk toward a consensus trend line so that low-count genes do not generate false positives. The two groups are compared with a Wald test, and p-values are corrected for multiple testing with the Benjamini-Hochberg procedure (FDR); covariates (e.g. batch, age, sex) can be incorporated into the design formula to control confounding. Output per gene: base mean expression, log2 fold change (positive = enriched in the primary group), standard error, Wald statistic, raw and adjusted p-values (q-values), and a categorical directional label.

When to use

Use for bulk RNA-seq experiments with raw integer read counts comparing exactly two conditions. For single-cell RNA-seq use the mode pseudobulk of this analysis and aggregate counts per sample/donor first (pseudobulk mode of this analysis) before running this model.For continuous or pre-normalized intensities (e.g. proteomics log2 abundances), use ttest_dea instead.

Caveats

Requires un-normalized, raw integer counts: TPM/FPKM, library-normalized or log-transformed values violate the negative binomial assumptions. The full, minimally pre-filtered transcriptome must be provided, since DESeq2 relies on the global distribution of genes to compute size factors and the mean-dispersion trend. Supports two-group pairwise contrasts only. Small sample sizes (n < 3 per group) severely limit statistical power and inflate false negative rates.

Example questions

example questions
  • What genes are differentially expressed between Female and Male bladder cancer patients?

  • Which genes are upregulated in treatment responders vs non-responders?

  • Find the top 20 differentially expressed genes adjusted for age and gender.

Input columns

input columns
column
type
required
description

index

any

required

Bulk RNA-seq sample identifier — maps to bk_sample_id. One row per (sample, gene) in the long-form input. SQL alias: bm.bk_sample_id AS index.

count_raw

numeric

required

Raw integer counts required by DESeq2. Must NOT be TPM or normalised counts. SQL alias: bc.count_raw (no alias needed, column name matches canonical name). Do …

gene_name

categorical

required

Gene name — the feature axis of the volcano plot. SQL alias: bc.gene_name (no alias needed, column name matches canonical name). Do NOT filter to a gene subset…

contrast_group

categorical

required

Contrast variable — the clinical/metadata variable that defines exactly two groups to compare. SQL alias: c.gender AS contrast_group (or any binary clinical va…

patient_id

any

required

Patient identifier — used to count unique patients in stats output.

Visualizations

  • volcano How to read: Each dot is one gene. Its horizontal position is the log2 fold change — right of centre means higher in the first arm of the contrast, left means higher in the second; its vertical position is the significance of the difference as -log10 adjusted p-value, so higher is more significant. Dotted lines mark the significance cut-offs on both axes. Red dots are genes significantly higher in the first arm, blue dots significantly higher in the second, and grey dots are not significant. The most significant genes are labelled (plus any explicitly highlighted genes), and hovering a dot shows its fold change, base mean, raw p-value and adjusted p-value.

Example analysis 1

Name — DEA: Gender Contrast (TCGA Bladder Cancer)

Analysis parameters

analysis_name, analysis_params, viz_params

Visualization — volcano

DEA: Gender Contrast (TCGA Bladder Cancer)

Output table

descriptive_stats (2 rows)
type
group
n_samples
n_patients

per_group

female

118

107

per_group

male

315

301

statistical_tests (first 10 of 51 rows)
type
total_genes
significant
higher_in_female
higher_in_male
padj_threshold
lfc_threshold
group_1
group_2
groups_all
covariates
lfc_shrinkage
gene_name
log2FoldChange
padj
baseMean
significance

dea_summary

17283

344

136

208

0.05

1.0

female

male

['female', 'male']

none

gene

EIF1AY

-10.16

0.0

688.4

Up in male

gene

ZFY

-8.347

0.0

386.0

Up in male

gene

DDX3Y

-7.714

1.816e-256

1841.0

Up in male

gene

KDM5D

-7.665

3.579e-247

1417.0

Up in male

gene

USP9Y

-7.762

3.528e-239

686.0

Up in male

gene

NLGN4Y

-6.25

6.045e-239

347.3

Up in male

gene

RPS4Y1

-7.645

3.351e-235

6611.0

Up in male

gene

UTY

-7.77

2.673e-234

516.9

Up in male

gene

TMSB4Y

-9.237

9.706e-170

126.3

Up in male

scRNAseq Pseudobulk DEA via DESeq2

Description

Analysis summary

One analysis mode with three variants that identify genes expressed at different levels in single-cell RNA-seq, by summing each patient's cells into pseudo-bulk samples so that cells from one patient are not treated as independent replicates. The variants compare two patient groups across all cell types (bulk-like), two patient groups within one chosen cell type, or one cell type against the rest within the same patients.

Computation

All three variants share one computation: raw counts are summed per patient and per arm into pseudo-bulk samples, and DESeq2 runs on them as in the bulk mode, with the patient as the replicate. They differ only in how the arms are formed — all cell types pooled per patient (variant 1), one cell type only (variant 2), or the cell type and the rest as arms with patient as a blocking covariate (variant 3). Log2 fold changes are shrunken (apeglm) in every variant; the unshrunken estimate is kept for reference, and shrinkage changes fold changes but not p-values or significance. The descriptive statistics report the cell-type composition of the pseudo-bulk samples and, in variant 3, which patients were dropped for lacking both arms; the summary always states which shrinkage was applied.

When to use

Variant 1 for a bulk-like whole-sample contrast between two groups (e.g. responders vs non-responders); variant 2 for a cell-type-intrinsic contrast within a chosen compartment (e.g. malignant cells only); variant 3 for cell-identity questions — which genes mark a cell type — within patients (e.g. malignant vs rest), optionally restricted to a patient subgroup. Use the bulk mode for bulk RNA-seq.

Caveats

Variant 1 confounds expression with composition: because all cell types are summed, a difference can reflect a shift in cell-type proportions rather than gene regulation, so it is bulk-like and the hardest to interpret biologically. Variant 2 removes that composition effect but needs enough cells of the chosen type per patient. Variant 3 is a within-patient design: patients lacking either arm are dropped, which can shrink the cohort substantially, and the result is not comparable to a between-patient contrast; its 'rest' arm pools all other cell types, so its composition varies by patient. Patients below the minimum-cell threshold are dropped in every variant, which can shift the cohort. Exactly two arms are supported, and no per-cell inference is possible.

Example questions

example questions
  • scRNAseq pseudobulk DEA between two clinical groups (all cell types aggregated per patient)

  • scRNAseq pseudobulk DEA within a specific cell type between two clinical groups

Input columns

input columns
column
type
required
description

index

any

required

Bulk RNA-seq sample identifier — maps to bk_sample_id. One row per (sample, gene) in the long-form input. SQL alias: bm.bk_sample_id AS index.

count_raw

numeric

required

Raw integer counts required by DESeq2. Must NOT be TPM or normalised counts. SQL alias: bc.count_raw (no alias needed, column name matches canonical name). Do …

gene_name

categorical

required

Gene name — the feature axis of the volcano plot. SQL alias: bc.gene_name (no alias needed, column name matches canonical name). Do NOT filter to a gene subset…

contrast_group

categorical

required

Contrast variable — the clinical/metadata variable that defines exactly two groups to compare. SQL alias: c.gender AS contrast_group (or any binary clinical va…

patient_id

any

required

Patient identifier — used to count unique patients in stats output.

cell_type

categorical

required

Cell type label from the metadata table (e.g. cell_type_level_2_mid). One row per (patient × cell_type × gene). When present, the analysis aggregates count_raw…

n_cells

numeric

required

Number of cells of the given cell_type for this patient, derived from COUNT(*) in the scRNAseq metadata table. Used to compute n_cells_in_pseudobulk (total cel…

Visualizations

  • volcano How to read: Each dot is one gene. Its horizontal position is the log2 fold change — right of centre means higher in the first arm of the contrast, left means higher in the second; its vertical position is the significance of the difference as -log10 adjusted p-value, so higher is more significant. Dotted lines mark the significance cut-offs on both axes. Red dots are genes significantly higher in the first arm, blue dots significantly higher in the second, and grey dots are not significant. The most significant genes are labelled (plus any explicitly highlighted genes), and hovering a dot shows its fold change, base mean, raw p-value and adjusted p-value. The two arms are either two patient groups or a cell type and the rest, and the axis label notes that fold changes are apeglm-shrunken.

Example analysis 1

Name — Pseudobulk DEA (NSCLC, 5 oldest M vs 5 oldest F): Gender

Analysis parameters

analysis_name, analysis_params, viz_params

Visualization — volcano

Pseudobulk DEA (NSCLC, 5 oldest M vs 5 oldest F): Gender

Output table

descriptive_stats (2 rows)
type
group
n_samples
n_patients
cells_per_patient_median
cells_per_patient_iqr
malignant_pct
fibroblast_pct
momac_pct
t_nk_pct
plasma_pct
other_pct

per_group

female

5

5

4923.0

[2783.0, 5613.0]

42.5

12.5

11.9

10.4

3.9

18.7

per_group

male

5

5

4761.0

[3444.0, 5342.0]

25.0

13.6

13.8

13.2

11.3

23.1

statistical_tests (first 10 of 51 rows)
type
total_genes
significant
higher_in_female
higher_in_male
padj_threshold
lfc_threshold
group_1
group_2
groups_all
covariates
lfc_shrinkage
gene_name
log2FoldChange
padj
baseMean
significance
log2FoldChange_unshrunken

dea_summary

15455

246

84

162

0.05

1.0

female

male

['female', 'male']

apeglm (PyDESeq2)

gene

KDM5D

-15.37

7.643e-15

680.7

Up in male

-13.03

gene

DDX3Y

-15.12

1.119e-14

579.9

Up in male

-12.79

gene

UTY

-15.07

3.062e-14

562.4

Up in male

-12.75

gene

SCNN1A

1.74

1.172e-12

2218.0

Up in female

1.794

gene

USP9Y

-13.38

5.029e-11

194.2

Up in male

-11.22

gene

EIF1AY

-13.31

4.562e-10

189.1

Up in male

-11.18

gene

FGL1

4.095

3.995e-07

171.5

Up in female

4.318

gene

ZFY

-11.02

4.279e-06

46.47

Up in male

-9.161

gene

CD46

1.107

1.123e-05

3108.0

Up in female

1.175

Last updated

Was this helpful?