From single-cell data to cell-type-specific differential expression

Explore a single-cell study, aggregate it into a pseudobulk study, compare disease and control in every cell type at once and find the pathways that change in each cell type.

Single-cell and single-nucleus RNA-seq show the expression of every cell, but a single cell contains few reads, and cells from the same person are not independent replicates. To compare disease and control, a robust approach is to sum up the cells of each cell type per donor into one pseudobulk profile and to compare these profiles with the methods used for bulk RNA-seq.

This guide walks you through this approach. You will:

  1. explore a single-cell study and its cell types in the scExplorer app,
  2. create a pseudobulk study with one profile per donor and cell type,
  3. calculate a disease-versus-control comparison for every cell type in one run,
  4. find out which cell types respond most strongly,
  5. compare pathway enrichment across all cell types in a heatmap and
  6. look at one pathway in one cell type.

The guide takes about 45 minutes, most of it waiting for calculations.

Before you start

  • Access: You need access to a PanHunter project with single-cell data and the apps scExplorer, New Comparison [v2], Comparisons, Enrichment Visualization and Pathway Mapping, and permission to calculate comparisons.
  • Example data: The guide uses the study Hs_Heart_KoenigSn2022, a public single-nucleus RNA-seq study of human hearts by Koenig et al. (2022, Nature Cardiovascular Research). It contains about 220,000 nuclei from 25 healthy donor hearts and 13 hearts with dilated cardiomyopathy (DCM), annotated with 15 cell types. If your project does not contain this study, follow the same steps with your own single-cell study.
  • Background: For the statistics of the comparison, see Differential gene expression analysis. The guide From differential expression to pathway enrichment explains the comparison set-up and the enrichment analysis for a single comparison in more detail.

Step 1: Explore the cell types

  1. Open the scExplorer app from the start page of your project.
  2. In the Study panel, select Hs_Heart_KoenigSn2022. The cells are shown in a UMAP embedding.
  3. In the right-hand panel, open the Annotations tab. Under Shared Annotations, click the droplet icon next to CellTypes to color the cells by cell type. Click the arrow next to CellTypes to see the list of cell types with their number of cells.

For all functions of the app, see scExplorer.

Check your result

The plot reads umap: 220752 out of 220752 cells. The 15 cell types form separate clusters; the largest populations are fibroblasts, cardiomyocytes, endothelium and macrophages.

UMAP colored by cell type

Marker genes confirm that a cluster really is the cell type it is labeled as:

  1. In the Gene Selection panel on the left, click the first field under Gene Selection - Manual Autocomplete, type RYR2 and select RYR2. RYR2 is a calcium channel typical of cardiomyocytes.
  2. The right-hand panel switches to the Features tab. Click the droplet icon below the gene to color the cells by its expression.
Check your result: marker gene

Only the cardiomyocyte cluster shows high RYR2 expression.

UMAP colored by RYR2

To see how disease and control cells are distributed within a cell type:

  1. In the Annotations tab, uncheck the box of CellTypes to deselect all cells, then check Cardiomyocytes only.
  2. Click the droplet icon next to Condition. The two conditions are called DCM and Healthy.
  3. Check the box of CellTypes again to select all cells before you continue.
Check your result: cardiomyocytes by condition

47,076 cardiomyocytes are selected; all other cells are greyed out. The bars next to each cell type show the proportion of DCM and healthy cells.

Cardiomyocytes colored by condition

Step 2: Create a pseudobulk study

A pseudobulk study sums up the counts of all cells that share the same values in the aggregation keys. With the keys SampleID and CellTypes, you get one profile per donor sample and cell type.

  1. In the Tools panel on the left, click Pseudobulk Computation. The Pseudobulk Study Creation window opens.
  2. Enter a Pseudobulk study name, for example PB_Koenig_celltypes. Pseudobulk studies usually start with PB_.
  3. In Aggregation key(s) for pseudobulk generation, keep SampleID and add CellTypes.
  4. Keep Minimum number of cells per bulk at 20. Profiles built from fewer cells are left out because they are too noisy.
  5. Make sure that all cells are selected, then click Run Pseudobulk Creation.
Check your result
Pseudobulk Study Creation

When the calculation has finished, the pseudobulk study is available as a normal study in the Sample Selector of the other apps. No further approval step is needed.

Note: The project used in this guide already contains a pseudobulk study with the same design, PB_Hs_Heart_KoenigSn2022_celltype. The following steps and screenshots use it. If you created your own, select your study instead.

Step 3: Check the pseudobulk study

  1. Open the New Comparison [v2] app from the start page.
  2. In the Sample Selector, start typing the name of the pseudobulk study in Studies and select it.
  3. Open the Selected Samples tab and look at the sample table.
  4. Open the Sample Clustering tab. In Plot Options, set Color to Sample meta data and scOriginalCluster, and Symbol to Sample meta data and Condition.

Important: In the pseudobulk study, the cell type is stored in the column scOriginalCluster and the donor sample in scOriginalSample, not under the names used in scExplorer. All other metadata, such as Condition, Sex and Age, keep their names.

Check your result: samples

The study contains 419 samples: one pseudobulk profile for each combination of donor sample and cell type that had at least 20 cells.

Selected Samples of the pseudobulk study

Check your result: PCA

The profiles cluster by cell type. The differences between DCM and healthy samples are much smaller than the differences between cell types, which is why each cell type gets its own comparison in the next step.

PCA of the pseudobulk study

Step 4: Compare DCM and healthy hearts in every cell type

With a Group By Factor, a single comparison group calculation creates one comparison per level of that factor, here one per cell type. For a description of all fields, see New Comparison: CG Calculation.

  1. Open the CG Calculation tab.
  2. Under Basics, enter a CG Run Name, for example Koenig_DCM_vs_Healthy_by_CellType, and keep Grouping at n:1.
  3. Under Formula & Factors:
    • enter the Formula ~Sex + Condition, so that the model accounts for differences between women and men.
    • set Contrast Factor to Condition and Level to Healthy. Healthy is the reference; DCM is compared against it.
    • set Group By Factor to scOriginalCluster.
  4. Leave all other sections at their defaults.
  5. Click Run Validation And Create Recipes.
  6. Check the validation results, then click Submit Calculation To SLURM and follow the progress in the Job Overview.
Check your result: set-up
CG Calculation set-up
Check your result: validation
  • Errors (0).
  • Warnings (1): one comparison was removed because no control samples are available. This is the cell type B_Cells, which occurs only in DCM samples.
  • Created recipes (14): one recipe DCM-Healthy-<cell type> per remaining cell type. The table shows the number of DCM and healthy samples per recipe. Cell types with only a few samples, such as Epicardium with 2 DCM samples, give less reliable results.
  • The DE method is autoselected as deseq2.

Validation results

Check your result: job overview

For this example the run takes about six minutes. The Job Overview does not refresh by itself: reload the page and select the run again to update the status.

Job Overview

Step 5: Find the cell types that respond

  1. Open the Comparisons app from the start page and open the Comparison Groups tab.
  2. In Analyze, select your run. It is listed with the number of comparisons and samples.
  3. Open the Single Comparison View tab. The Comparison list shows the number of significant features for each cell type. Select DCM-Healthy-Endocardium.

For all functions of the app, see Comparisons.

Check your result: comparison group
Comparison Groups tab
Check your result: significant features per cell type

The number of significant features differs a lot between cell types:

Cell typeSignificant features
Fibroblasts5313
Cardiomyocytes5013
Endothelium3632
Endocardium3475
Macrophages3423
Pericytes2766
Smooth_Muscle484
Neurons248
TNK_Cells110
Epicardium109
Lymphatic78
Adipocytes47
Mast_Cells8
Monocytes0

Fibroblasts, cardiomyocytes and the cells lining the vessels and heart chambers (endothelium, endocardium) respond most strongly to the disease. Part of the differences also reflects sample size: small populations have fewer profiles and therefore less statistical power.

Check your result: endocardium

The comparison reads DCM-Healthy-Endocardium (11 samples; 3475 sign. features). The gene with the lowest FDR is GDF6, upregulated in DCM.

Single Comparison View for endocardium

Step 6: Compare pathways across all cell types

The Comparison groups tab of the Enrichment Visualization app shows the enrichment results of many comparisons side by side in one heatmap.

  1. Open the Enrichment Visualization app from the start page and open the Comparison groups tab.
  2. Under Data selection, click into the Comparisons field. In the Comparison Selector, check your run and click Select. In the next view, check the box in the header row to select all comparisons and click Select again.
  3. Open Feature selection, set Heatmap Y-axis levels to Feature list collections and select the collection Wikipathways. The analysis method switches to Fisher.
  4. Open Heatmap options and set Show feature to Names, so that the rows show pathway names instead of IDs.

Comparisons with too few significant features, here Monocytes and Mast_Cells, are left out.

Check your result: Comparison Selector
Comparison Selector with all comparisons of the group
Check your result: heatmap

The heatmap shows the 50 most significant pathways (rows) across the cell types (columns); the darker the color, the lower the p-value. Both axes are clustered, so cell types with similar pathway changes are placed next to each other.

  • The strongest signals are energy metabolism pathways such as Electron transport chain (OXPHOS), Oxidative phosphorylation and Glycolysis and gluconeogenesis, mainly in endothelium, fibroblasts and pericytes.
  • Angiogenesis (WP1539) is enriched almost only in the endocardium. VEGFA VEGFR2 signaling is enriched in the endocardium and in pericytes.

Hover over a cell of the heatmap to see the full pathway name and the p-value; long names are cut off on the axis. Angiogenesis in the endocardium is the starting point for the next step.

Enrichment heatmap across cell types

Check your result: heatmap options
Heatmap options

Step 7: Look at a pathway in one cell type

  1. Open the Pathway Mapping app from the start page.
  2. Click into Comparison 1. In the Comparison Selector, open Comparisons from Groups, check your run and click Select. Type Endocardium into the filter of the Name column, press Enter, check the comparison and click Select.
  3. In Select pathway, type Angiogenesis and select Angiogenesis (Hs, WP1539).

For coloring options and the table view, see Pathway Visualization.

Check your result

Blue genes are upregulated, red genes downregulated in the endocardium of DCM hearts. The growth factor PDGFB and the receptor FGFR2 are up, while the receptors VEGFR2 and TIE2 and the nitric oxide synthase NOS are down: a pattern that points to disturbed formation and maintenance of blood vessels.

Angiogenesis pathway in the endocardium

Troubleshooting

My pseudobulk study does not appear in the Sample Selector.
The creation runs in the background and can take a while for large studies. Reload the app after some minutes. If the study still does not appear, contact your PanHunter administrator.
The validation removes comparisons.
A comparison needs samples of both conditions. Cell types that occur in only one condition, or whose profiles were dropped because of the minimum number of cells, are removed with a warning. The remaining comparisons are calculated normally.
I cannot find the column CellTypes in New Comparison [v2].
In pseudobulk studies, the cell type is stored in the column scOriginalCluster and the donor sample in scOriginalSample.

Next steps