Single-cell RNA-seq: finding the cell types in blood, one cell at a time

Load 2,700 blood cells measured one by one, filter out the damaged ones, cluster the rest on a UMAP in RBAi and name each cluster from its marker genes. In our run the 2,638 cells that passed fell into eight clusters, from 667 T cells to 13 platelets.

Lesson 1 ended on a problem. ACE2 looked low in the lung because each GTEx sample is a piece of tissue, and its RNA is an average over every cell in it. A rare cell type that matters can vanish in that average. Single-cell RNA-seq solves this by measuring the RNA of each cell on its own, thousands of cells at a time.

In this lesson you will take one of the most-used single-cell data sets, PBMC 3k from 10x Genomics: about 2,700 peripheral blood mononuclear cells (PBMCs), the white blood cells with a single rounded nucleus, such as lymphocytes and monocytes, from the blood of one healthy donor. You will remove damaged cells, group the rest by their RNA, draw them on a map, and work out which cell type each group is, the way a researcher annotates a new data set. RBAi runs it all with scanpy, a widely used Python toolkit for single-cell analysis.

Start a new chat. Every prompt goes into the RBAi main chat, except one change to a figure in step 2.

What you will make

A UMAP of 2,638 blood cells as coloured dots in eight groups, each labelled with a cell type: IL7R+ T, CCR7+ T and Cytotoxic T/NK at the upper left, B cells at the lower left, CD14+ monocytes, FCGR3A+ monocytes and cDC2 on the right, and a tiny group of platelets in the middle.

2,638 blood cells, one dot each, named by their genes. Cells with similar RNA sit close together on this UMAP, and colours mark the eight clusters the Leiden algorithm found. The names are putative: RBAi gave them from each cluster's marker genes, and the next figure shows the evidence. The three T and NK cell clusters touch at the upper left; the monocytes and dendritic cells form a second continent on the right. 10x Genomics PBMC 3k, drawn by RBAi.

A dot plot with the eight clusters as rows and fifteen marker genes as columns. Large orange dots mark genes expressed by most cells of a cluster, such as MS4A1 and CD79A in cluster 3, NKG7 and GNLY in cluster 2, LYZ and CD14 in cluster 5, FCGR3A and MS4A7 in cluster 4, FCER1A in cluster 6 and PPBP in cluster 7. Most other dots are small and grey.

The evidence for each name. Each row is a cluster and each column a known marker gene of a blood cell type. Dot size is the share of the cluster's cells in which the gene is detected, and colour is its average expression, from light grey (none) to orange (high). B-cell genes (MS4A1, CD79A) light up only cluster 3, and the platelet gene PPBP only cluster 7.

Three violin plots of quality measures for all 2,700 cells before filtering: genes detected per cell, total counts per cell and the percentage of counts from mitochondrial genes. Each cell is a grey dot, and dashed orange lines mark the cut-offs at 200 and 2,500 genes and at 5 percent mitochondrial counts.

Quality control before any biology. Each grey dot is one cell, and each violin's width shows how many cells have that value. The dashed orange lines are the cut-offs: cells outside them are left out, 62 of the 2,700.

1. Load the cells and check their quality Main chat

Load the PBMC 3k single-cell RNA-seq dataset from 10x Genomics (about 2,700 immune cells from the blood of one healthy donor) with scanpy. Show the three quality-control measures for each cell, the number of genes detected, the total counts and the percentage of counts from mitochondrial genes, as three violin plots side by side on a white background. Then remove cells with fewer than 200 or more than 2,500 genes or more than 5% mitochondrial counts, and genes seen in fewer than 3 cells. How many cells and genes are left?

In this kind of experiment each cell is caught in its own tiny droplet with a unique barcode, a short DNA tag that marks every RNA molecule from that cell. Each molecule also gets its own tag, so every count is one RNA molecule, not one read. A violin plot is a smoothed histogram turned on its side and mirrored: wide where many cells have that value. Mitochondrial genes are the few genes carried in a cell's mitochondria. A damaged cell leaks the RNA in its cytoplasm but keeps the RNA inside its mitochondria, so a high mitochondrial share marks a broken or dying cell. Too few genes means an empty or broken droplet. Too many can mean two cells caught in one droplet, a doublet.

What you should see: the data set loads with 2,700 cells and 32,738 genes. After filtering, 2,638 cells and 13,656 genes are left: 62 cells fail the cut-offs, and most genes are never seen in three or more cells. It took under a minute in our run. RBAi's first figure showed the three violins in plain blue.

2. Show the cut-offs on the picture Edit with AI

A quality figure is far more useful when it shows where the line was drawn. Click Edit with AI on the violin plot and type:

Show each cell as a small grey dot over the violins, and draw the filtering cut-offs as dashed orange lines: 200 and 2,500 genes, and 5% mitochondrial counts.

What you should see: "I overlaid small grey dots for individual cells on each violin and added dashed orange cut-off lines at 200 and 2,500 detected genes and 5% mitochondrial counts." That is the third figure above. Now you can see the handful of cells that fail: a few with more than 2,500 genes at the top of the first panel, and a scatter above 5% in the third.

3. Group the cells and draw a map Main chat

Now normalise each cell to 10,000 counts and log-transform, find the highly variable genes, scale them, run PCA, build the neighbour graph from 40 principal components with 10 neighbours, compute a UMAP and cluster the cells with the Leiden algorithm at resolution 0.9 with random_state 0. Plot the UMAP coloured by cluster with a colour-blind-safe palette, the cluster numbers written on the clusters, and no axis ticks. How many highly variable genes and clusters are there, and how many cells are in each cluster?

This one prompt is the standard single-cell pipeline:

  • Normalise and log-transform: scale every cell to the same total of 10,000 counts, so a cell that was captured better does not look more active, then take logarithms so a few very busy genes do not dominate.
  • Highly variable genes: keep the genes whose expression differs most between cells. They carry the information about cell types.
  • PCA: compress those genes into 40 principal components, as in Lesson 2.
  • Neighbour graph: link each cell to the 10 cells most like it.
  • UMAP: a method that lays that graph out in two dimensions, so similar cells land close together.
  • Leiden clustering: find groups of cells that are more connected to each other than to the rest. The resolution sets how finely it splits them, and random_state fixes the random starting point so the same run gives the same clusters.

What you should see: 1,826 highly variable genes and 8 clusters, numbered 0 to 7. A cluster here is a group of cells with similar RNA. RBAi's first map shows them with numbers; it took about a minute and a half.

Cluster 0 1 2 3 4 5 6 7
Cells 667 519 424 340 215 426 34 13

4. Find each cluster's marker genes Main chat

Find the marker genes of each cluster: compare each cluster with all other cells using a Wilcoxon rank-sum test and list the top five genes per cluster. Then make a dot plot of these well-known blood-cell markers across the clusters: IL7R, CCR7, S100A4, CD8A, MS4A1, CD79A, GNLY, NKG7, CD14, LYZ, FCGR3A, MS4A7, FCER1A, CST3 and PPBP, with dot size for the fraction of cells in the cluster that express the gene and colour from light grey to orange for its mean expression, on a white background.

A marker gene is a gene expressed much more in one cluster than in all the others. The Wilcoxon rank-sum test compares two groups by ranking the values instead of averaging them, which suits single-cell data, where most values are zero. The fifteen genes in the prompt are standard markers of blood cell types, taken from the classic Seurat and scanpy tutorials on this same data set.

What you should see:

Cluster Top five marker genes
0 LDHB, LTB, CD3D, IL32, CD3E
1 RPS12, RPL32, RPS6, RPS25, RPS27
2 NKG7, CST7, GZMA, B2M, CTSW
3 CD74, CD79A, HLA-DRA, CD79B, HLA-DPB1
4 LST1, COTL1, FCER1G, AIF1, FTH1
5 S100A9, S100A8, LYZ, TYROBP, FTL
6 HLA-DPA1, HLA-DPB1, HLA-DRA, HLA-DRB1, CD74
7 PF4, SDPR, GNG11, PPBP, NRGN

In our run the dot plot came back as a blank white image, although RBAi's answer described it. If that happens, just say so in the chat:

The dot plot in the chat is a blank white image. Draw it again so the dots show, with the same genes, sizes and colours.

The redraw took under a minute and is the second figure above.

5. Name the cell types Main chat

From the marker genes and the dot plot, name the most likely cell type of each cluster, give the markers that support each name and say how confident you are. Then redraw the UMAP with the cell-type names written on the clusters instead of numbers, keeping the same colours. Which cluster might hold more than one cell type, and what would you check to find out?

What you should see: a table of names with their evidence, then the first figure above.

Cluster Putative cell type Supporting markers RBAi's confidence
0 IL7R+ T cells, likely memory or helper CD3D, CD3E, LTB, IL7R high (subtype moderate)
1 CCR7+ IL7R+ T cells, naive-like CD3D, CD3E, IL7R, CCR7 high (subtype low to moderate)
2 Cytotoxic lymphocytes: NK cells and cytotoxic T cells NKG7, GZMA, GNLY, CD8A high (mixture moderate)
3 B cells CD79A, CD79B, MS4A1, HLA class II high
4 FCGR3A+ (non-classical) monocytes FCGR3A, MS4A7, LST1, AIF1 high (subtype moderate to high)
5 CD14+ (classical) monocytes CD14, LYZ, S100A8, S100A9 high
6 Dendritic cells, likely cDC2 FCER1A, CD1C, CLEC10A, CST3 moderate to high (34 cells)
7 Platelets PPBP, PF4, SDPR, GNG11 high (13 cells)

RBAi points to cluster 2 as the one most likely to mix two cell types. Only about 20% of its cells have both the T-cell gene CD3D and the NK gene GNLY. About 39% have CD3D without GNLY, and 35% GNLY without CD3D: a mix of cytotoxic T cells and natural killer (NK) cells, both of which kill infected cells. It adds that shared killing genes and genes missed in single cells mean this is a lead, not proof.

The ideas behind the picture

  • Bulk versus single cell. Bulk RNA-seq (Lessons 1 to 3) gives one average per sample. Single-cell RNA-seq gives one profile per cell, so it finds the cell types inside a sample and how many cells each has. Each cell's profile is far sparser, though: most genes read zero in any one cell, because only a small share of its RNA molecules is caught.
  • Quality control comes first. Broken cells, empty droplets and doublets would form clusters of their own. The cut-offs depend on the data set, so look at the distributions before choosing them, and always report them.
  • Clusters are made by you, cell types by biology. Leiden finds groups; you name them from marker genes that decades of immunology have tied to each cell type. Change the resolution and the number of clusters changes, while the cells stay the same. That is why names are called putative until they are tested.
  • Read a UMAP with care. Cells that sit together are similar. The size of a cluster on the map and the distance between clusters mean little: UMAP keeps neighbours, not distances. The T and NK cells touch here because they share many genes, not because they are halfway between each other.
  • Markers are relative. Cluster 1's top genes are ribosomal protein genes (RPS, RPL), which every cell uses. They rank first because cluster 1 has more of them than other cells, not because they define a cell type. The known markers, CCR7 and IL7R, carry the name.

What the result shows, and what it doesn't

  • What it shows: 2,638 cells from one healthy donor fall into eight groups whose markers match known blood cell types: two kinds of T cell, cytotoxic T and NK cells, B cells, two kinds of monocyte, dendritic cells and platelets. The largest group has 667 cells and the smallest 13.
  • What it doesn't show: proof of any name. These are RNA markers, while immunologists define many blood cells by proteins on their surface. The small clusters, 34 dendritic cells and 13 platelets, rest on few cells, and finer subtypes, such as helper versus memory T cells, need more evidence. One donor tells you nothing about how people differ.
  • Cells in the data are not cells in the blood. The share of cells in each cluster depends on how the cells were prepared and captured as well as on the donor, so it is not a blood count.

Your turn

Test RBAi's lead on cluster 2, as a researcher would. Before you ask, write down what you expect: if cluster 2 is two cell types, what should happen when it is clustered again on its own? Then, in the same chat:

Take only the cells of cluster 2, cluster them again on their own at resolution 0.5 with random_state 0, and make a dot plot of CD3D, CD3E, CD8A, GNLY, KLRD1, NKG7 and GZMB across the new sub-clusters. Do the T-cell and NK-cell markers separate?

Write three sentences: whether the markers separate, how many cells of each kind you would report, and one thing that could still mislead you. Bonus, back to Lesson 1: before you ask, predict whether these blood cells express ACE2, then ask RBAi in which clusters it is detected.

Try it

Open RBAi, start a new chat and paste the first prompt. Then try the same pipeline on another public 10x Genomics data set and see whether the same cell types appear.

Start a new chat in RBAi, then paste the lesson’s first prompt:

Load the PBMC 3k single-cell RNA-seq dataset from 10x Genomics (about 2,700 immune cells from the blood of one healthy donor) with scanpy. Show the three quality-control measures for each cell, the number of genes detected, the total counts and the percentage of counts from mitochondrial genes, as three violin plots side by side on a white background. Then remove cells with fewer than 200 or more than 2,500 genes or more than 5% mitochondrial counts, and genes seen in fewer than 3 cells. How many cells and genes are left?

Try this in RBAi