Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Genes that change in each cell type

Which genes does a treatment change, and in which cell types? This page answers it for the interferon-beta stimulation of Kang et al. Kang et al., 2018: blood cells of eight lupus patients, each donor’s cells split into a culture stimulated with interferon-beta for six hours and an untreated one. The cells of each sample and cell type are pooled into one profile, so that every test compares donors, not cells (Choosing a method says why). The cube is the kang2018 dataset (Datasets), a download of 77 MB that python docs/datasets.py prepare kang2018 makes.

CytePool 0.1.dev54+g3f0cbb52e
Cube with 16 samples x 8 groups x 35,635 features
  layers: counts (uint32, lazy), detected (uint32, lazy)
  filled: 128 of 128 sample x group entries have cells (100.0%)
  samples: sample_id, donor, condition
  groups: group_id
  features: feature_id, symbol
Heatmap of the cells pooled into each of the 16 samples (columns, a control and a stimulated sample of eight donors) and eight cell types (rows), shaded in blue on a logarithmic scale from 10 to about 1,500 cells, with each number written. CD4 T cells and CD14+ monocytes hold the most cells, up to 1,484; dendritic cells and megakaryocytes the fewest. Six entries with fewer than 10 cells are pale: dendritic cells of 1039_ctrl and 107_ctrl, and megakaryocytes of 101_stim, 1016_ctrl, 107_ctrl and 107_stim.

A profile pooled from a handful of cells is noisy, so limma_voom leaves the profiles of fewer than 10 cells out of their cell type’s fit (min_cells=10); they are pale in the heatmap. Two samples of the dendritic cells and four of the megakaryocytes are left out, and every other profile enters.

A paired design

Every donor gives a control and a stimulated sample. The design ~ donor + condition compares each donor’s two samples, so that the differences between donors do not count as noise, and its coefficient conditionstim is the log2 fold change of the stimulation. Name the levels of the condition: the first is the reference. Design.check looks for designs that cannot answer the question before anything is fitted (Designs, linear models and contrasts).

Design: 16 samples x 9 columns, formula '~ donor + condition'
  columns: (Intercept), donor1015, donor1016, donor1039, donor107, donor1244, donor1256, donor1488, conditionstim
  contrasts: stim_vs_ctrl
Design check: 16 samples, 9 columns, rank 9, 7 residual degrees of freedom; no problems found.

Test every cell type

limma_voom runs limma-voom in each cell type in turn: it leaves out the profiles with too few cells, keeps the genes with enough counts for the design, normalizes the libraries by TMM, gives every observation a voom precision weight, fits the design to every gene and moderates the contrast by empirical Bayes Law et al., 2014Ritchie et al., 2015. The figure counts the genes up and down at an adjusted p-value below 0.05 in each cell type, the first figure to look at in a study of many cell types.

DifferentialExpressionResult (limma_voom): 8 groups, 8 fitted; 1 contrast: stim_vs_ctrl
  B cells: 16 samples, 2768 features
  CD14+ Monocytes: 16 samples, 5125 features
  CD4 T cells: 16 samples, 6295 features
  CD8 T cells: 16 samples, 1453 features
  Dendritic cells: 14 samples, 2281 features
  FCGR3A+ Monocytes: 16 samples, 2947 features
  Megakaryocytes: 12 samples, 704 features
  NK cells: 16 samples, 2292 features
Horizontal bars of the genes up (red, to the right) and down (blue, to the left) at an adjusted p-value below 0.05 in each of the eight cell types. CD14+ monocytes have the most, 1,619 up and 1,549 down, followed by CD4 T cells (991 up, 826 down) and FCGR3A+ monocytes (814 up, 663 down); megakaryocytes have the fewest, 63 up and 16 down.

A cell type left with too few samples to estimate a variance is not fitted, and both the printed summary and the figure say so (From cells to results shows one); result.summary gives the reason and result.samples lists every profile with the reason it was left out. Each fit keeps the rows of the design for its own samples, so the megakaryocytes, which have no profile of donor 107, are fitted without that donor’s column.

One cell type in detail

Each cell type and contrast has a table with the columns of limma’s topTable (DifferentialExpressionResult.table). The mean-difference plot shows the log2 fold changes against the average expression, and the volcano plot the p-values against the fold changes, with the genes of the smallest p-values named.

Two panels for the CD14+ monocytes. Left, the mean-difference plot: log2 fold change, from about -4.5 to 9, against average log2 CPM, from 0 to 17; 1,619 genes up in red, 1,549 down in blue and 1,957 not significant in grey near zero. Right, the volcano plot: -log10 p-value, up to about 18, against log2 fold change, in the same colours; the ten genes with the smallest p-values are named, among them TMSB10, DYNLT1, H3F3B, SSB, CCL8, ISG20 and IL1RN, all up.

The table converts to a pandas DataFrame (Table.to_pandas) for sorting and export; here are the ten genes with the smallest p-values.

Loading...

voom or trend

limma_trend fits the log-CPM values without precision weights and lets the prior variance follow the expression level. It suits libraries of similar sizes, within about threefold of each other by the limma User’s Guide (Choosing a method). A pseudobulk library grows with the number of cells pooled, and the libraries of each cell type here differ far more:

B cells            largest library 14.5 times the smallest
CD14+ Monocytes    largest library  5.5 times the smallest
CD4 T cells        largest library  9.8 times the smallest
CD8 T cells        largest library 31.2 times the smallest
Dendritic cells    largest library  3.9 times the smallest
FCGR3A+ Monocytes  largest library  7.1 times the smallest
Megakaryocytes     largest library  8.5 times the smallest
NK cells           largest library 10.1 times the smallest
Two panels of the genes up and down at an adjusted p-value below 0.05 in each cell type, limma-voom on the left and limma-trend on the right. limma-trend calls fewer genes in every cell type: in CD4 T cells 757 up and 497 down against 991 and 826, in CD8 T cells 166 and 76 against 233 and 147. In the CD14+ monocytes the two call about as many, 1,550 up and 1,553 down against 1,619 and 1,549.

limma-trend calls fewer genes than limma-voom in every cell type, and the gap is widest where the libraries differ most, as in the CD8 T cells; where they differ least, as in the dendritic cells and the CD14+ monocytes, the two agree more closely. voom’s weights give the small libraries less say.

Adjusting within or across cell types

The p-values of each cell type and contrast are adjusted over its own genes, as limma’s topTable adjusts them. adjust_across_groups=True adds a column adjusted over the genes of every cell type for the same contrast, one family of tests for the study (Multiple testing).

Two panels of the genes up and down at an adjusted p-value below 0.05 in each cell type, adjusted within each cell type on the left and across all cell types on the right. Across cell types the CD14+ monocytes lose calls, 1,559 up and 1,438 down against 1,619 and 1,549, and every other cell type gains some: the megakaryocytes go from 63 up and 16 down to 86 and 34, the CD4 T cells from 991 and 826 to 1,040 and 891.

Adjusting across cell types is not stricter for every cell type. The many small p-values of the monocytes lower the adjusted p-values of the other cell types’ genes, which gain calls, while the monocytes, now adjusted with genes that respond less, lose some.

Choices

  • voom or trend. limma_voom is the default, and the safer choice when library sizes vary with the number of cells pooled; limma_trend is faster and suits libraries of similar sizes.

  • Profiles with few cells or counts. min_cells (10) and min_counts (0) decide which profiles enter each fit; raise them when small pools look noisy on an MDS plot, or keep every profile and weight it by its number of cells with prior_weights="n_cells" Hoffman et al., 2026. quality_weights=True down-weights the samples that follow the model less closely instead. Normalization, filtering and sample quality shows both.

  • Within or across cell types. Adjust within each cell type to rank its genes; adjust across cell types when the study’s list of genes, of every cell type, is the result.

  • A variable of the donors. The paired design cannot test a variable that is constant within each donor, such as sex or disease: Repeated measures and donors tests it with a random effect for the donor.

  • Other models. edgeR’s quasi-likelihood F-tests and DESeq2 run on one cell type’s counts at a time (Cube.layer), as on bulk RNA-seq.

The responding genes feed the next questions: which pathways and regulators they belong to (Gene sets and pathways) and which regulators are active (Pathway and regulator activity).

References
  1. Kang, H. M., Subramaniam, M., Targ, S., Nguyen, M., Maliskova, L., McCarthy, E., Wan, E., Wong, S., Byrnes, L., Lanata, C. M., Gate, R. E., Mostafavi, S., Marson, A., Zaitlen, N., Criswell, L. A., & Ye, C. J. (2018). Multiplexed droplet single-cell RNA-sequencing using natural genetic variation. Nature Biotechnology, 36(1), 89–94. 10.1038/nbt.4042
  2. Law, C. W., Chen, Y., Shi, W., & Smyth, G. K. (2014). voom: precision weights unlock linear model analysis tools for RNA-seq read counts. Genome Biology, 15(2), R29. 10.1186/gb-2014-15-2-r29
  3. Ritchie, M. E., Phipson, B., Wu, D., Hu, Y., Law, C. W., Shi, W., & Smyth, G. K. (2015). limma powers differential expression analyses for RNA-sequencing and microarray studies. Nucleic Acids Research, 43(7), e47. 10.1093/nar/gkv007
  4. Hoffman, G. E., Lee, D., Bendl, J., Prashant, N. M., Hong, A., Casey, C., Alvia, M., Shao, Z., Argyriou, S., Therrien, K., Venkatesh, S., Voloudakis, G., Haroutunian, V., Fullard, J. F., & Roussos, P. (2026). Efficient differential expression analysis of large-scale single-cell transcriptomics data using Dreamlet. Nature Communications, 17(1), 9597. 10.1038/s41467-026-75680-8