Abstract
Background Macrophages change their gene expression depending on what they are exposed to. A model that recognizes the exposure from expression can look accurate just because it has learned the donor, when the test samples come from people it already saw in training. This project asks whether a small gene panel identifies the stimulation condition in donors left out of training, and how a five-gene panel taken from the author's thesis compares with panels picked from the data.
Methods From the public series GSE46903 (Illumina HumanHT-12 v3), GM-CSF-differentiated macrophages at 72 hours were kept under four conditions (control, IFN-gamma, IL-4, and TNF-alpha with PGE2 and Pam3CSK4). Only donors with exactly one profile per condition were included: 28 profiles from 7 donors. Models were evaluated in three outer folds grouped by donor, with two donor-grouped inner folds for tuning. Gene ranking (ANOVA F), scaling and hyperparameter choice used only the training donors. The procedures were a class-frequency baseline, the fixed thesis panel (ABCA1, ABCG1, NR1H3, TNF, IL1B), logistic regression on a learned panel of 5, 10, 20 or 50 genes, elastic-net regression on the 1,500 most variable genes, shallow gradient-boosted trees and a 124-parameter PyTorch network. The intervals are 95% donor bootstrap intervals computed from the saved predictions, without refitting.
Results The learned-panel logistic regression classified all 28 held-out profiles correctly (balanced accuracy 1.00). Inner tuning chose 50, 50, 20 genes in the three folds. With the size fixed at five genes the score was 0.93, and at ten it was 1.00. The thesis panel scored 0.79 (0.57–0.96), and the baseline 0.25. In every fold the same 13 genes were picked, most of them interferon-response genes. On the thesis panel's errors, the gap between the top two class probabilities averaged 0.09, against 0.42 on correct predictions, and 3 of its 6 errors came from one donor.
Conclusions Within this dataset the four conditions are easy to separate once donors are held out. Tuning preferred panels of 20 to 50 genes, but a fixed ten-gene panel did as well. Five genes were not quite enough, and the thesis genes, which were not chosen for this task, fell well short. The matrix was quantile-normalized upstream, possibly with the held-out donors included, and there are only seven donors. The results therefore show the approach can work. They don't show that any panel would transfer to another lab or cohort. Everything on the page is read from the verified result files listed at the end.
Keywords macrophage activation, transcriptomics, donor-grouped cross-validation, nested cross-validation, gene panel selection, calibration, GSE46903
At a glance
I trained models to name a macrophage sample's stimulation condition from its gene expression, testing each one only on donors it hadn't seen. The three results below are read from the files listed at the end.
- Held-out donors are classified correctly. A logistic regression on a panel picked inside the training folds labeled all 28 profiles from 7 donors correctly. Guessing from class frequencies gets 0.25. Several other procedures also reach 1.00, so within this dataset the task is fairly easy.
- Ten genes are enough here; five are not quite. Tuning picked 50, 50, 20 genes across the folds. With the size fixed at ten the score stays at 1.00, but at five it drops to 0.93. The five genes from my thesis score 0.79.
- Mistakes are less confident, and they cluster. When the thesis panel is wrong, the gap between its top two classes shrinks from 0.42 to 0.09. Donor BC58 accounts for 3 of its 6 errors.
Try it yourself in the sample explorer, or download the metrics and held-out predictions.
The question and the data
My M.D. thesis involved macrophages, probiotic bacteria, qPCR and cytokine assays. Here I ask a narrower question: given one macrophage sample's gene expression, can a model tell which of four stimulation conditions it received, if that donor was left out of training? And how many genes does it need?
I used GSE46903 from Xue and colleagues (Immunity, 2014). The series covers several cell types and stimulation schedules. I kept GM-CSF-differentiated macrophages at 72 hours under four recorded conditions:
con: unstimulated controlIFNg: interferon-gammaIL4: interleukin-4TNFa+PGE2+P3C: TNF-alpha, prostaglandin E2 and Pam3CSK4 together
The series has 384 arrays, and 299 of them are labeled macrophage profiles. I kept only donors with exactly one profile per condition, which leaves 7 donors and 28 profiles, seven per class. I dropped probes with a missing or ambiguous gene symbol. Where several probes map to one gene, I took their median within each sample. That leaves 19,235 genes and no missing values. This selection rule was fixed before I compared any models.
The labels are laboratory exposures, not diseases or outcomes. TNF and IL1B here are transcript levels. My thesis measured the secreted proteins by ELISA, which is a different quantity.
Holding donors out
All four samples from a donor share that person's biology and lab handling. If I split them at random, the model could learn the donor and still look good. So each donor's samples stay together, either all in training or all in testing.
There are three outer folds. Inside each one, gene ranking, imputation, scaling and hyperparameter tuning see only the training donors, and two inner donor-grouped folds handle the tuning. Every profile is predicted exactly once, by a model that never saw its donor.
| Fold | Training donors | Training profiles | Held-out donors |
|---|---|---|---|
| 1 | BC11, BC13, BC76, BC78 | 16 | BC52, BC58, BC9 |
| 2 | BC11, BC52, BC58, BC78, BC9 | 20 | BC13, BC76 |
| 3 | BC13, BC52, BC58, BC76, BC9 | 20 | BC11, BC78 |
The main limit is size: each model trains on four or five donors, so 16 or 20 profiles, and a careful pipeline can't make up for that.
Choosing genes
I started with genes I knew from my thesis: ABCA1, ABCG1,
NR1H3 (LXR-alpha), TNF and IL1B. This five-gene panel
was fixed in advance and acts as the benchmark.
The learned-panel procedure picks its own genes. In each training fold it ranks genes by how strongly they separate the four conditions (an ANOVA F-test), then uses the inner folds to choose a panel size of 5, 10, 20 or 50.
In practice it never chose a small panel. It picked 50, 50, 20 genes in the three folds. Inner folds with four or five donors can't tell those sizes apart, so the choice says little. Fixing the size answers the question more directly:
Ten genes is enough here: the fixed ten-gene panel scores 1.00. With five genes, the panel the procedure learned scores 0.93, while the five genes from my thesis score 0.79. So at equal size, picking genes from the data beats picking them from prior knowledge, at least for this task.
13 genes were picked in every fold:
ACKR3 AIM2 ANKRD22 CXCL10 CXCL9 FOXQ1 GBP1 GBP4 GBP5 HEY1 PPP1R14A SERPING1 SOD2
Most of these are interferon-response genes (the GBP family, CXCL9, CXCL10), so the IFNg class is probably the easiest to separate. The panels also include a pseudogene and an unannotated locus. They are computational lists, and turning any of them into an assay would need separate wet-lab work.
How the models did
| Procedure | Balanced accuracy | Donor bootstrap 95% | Log loss |
|---|---|---|---|
| Class-frequency baselinePredicts from training class frequencies; no genes. | 0.25 | 0.25–0.25 | 1.39 |
| Thesis five-gene panelABCA1, ABCG1, NR1H3, TNF, IL1B; fixed in advance. | 0.79 | 0.57–0.96 | 0.70 |
| Learned panel, tuned sizeRanks genes by ANOVA F in training folds; inner folds pick 5, 10, 20 or 50. | 1.00 | 1.00–1.00 | 0.52 |
| Learned panel, 5 genesSame ranking, size fixed at 5. | 0.93 | 0.82–1.00 | 0.50 |
| Learned panel, 10 genesSame ranking, size fixed at 10. | 1.00 | 1.00–1.00 | 0.63 |
| Learned panel, 20 genesSame ranking, size fixed at 20. | 1.00 | 1.00–1.00 | 0.50 |
| Learned panel, 50 genesSame ranking, size fixed at 50. | 1.00 | 1.00–1.00 | 0.61 |
| All genes, regularizedElastic-net logistic regression on the 1,500 most variable genes. | 1.00 | 1.00–1.00 | 0.20 |
| Learned panel, shallow treesGradient-boosted trees, depth 1 or 2, on a learned panel. | 0.93 | 0.86–1.00 | 0.17 |
| Small network, 10 genesPyTorch 10-8-4 network on a 10-gene learned panel. | 1.00 | 1.00–1.00 | 0.01 |
The intervals resample donors from the saved predictions and do not retrain anything. When every prediction is correct there is nothing to resample, so the interval collapses to 1.00–1.00. That tells you nothing about accuracy in another cohort.
Many procedures reach 1.00, which suggests that within this dataset the task is fairly easy. They differ in log loss. The tuned learned panel is right every time, but it gives the winning class only about 60% on average, because it chose strong regularization. The network is right with near-certain confidence. Neither one shows how well its probabilities would hold up on new data.
Confusion matrices
Rows are recorded conditions; columns are predictions. The diagonal is correct.
| Recorded \ Predicted | con | IFNg | IL4 | TNFa+PGE2+P3C |
|---|---|---|---|---|
| con | 7 | 0 | 0 | 0 |
| IFNg | 0 | 7 | 0 | 0 |
| IL4 | 0 | 0 | 7 | 0 |
| TNFa+PGE2+P3C | 0 | 0 | 0 | 7 |
| Recorded \ Predicted | con | IFNg | IL4 | TNFa+PGE2+P3C |
|---|---|---|---|---|
| con | 5 | 0 | 2 | 0 |
| IFNg | 1 | 5 | 1 | 0 |
| IL4 | 0 | 1 | 6 | 0 |
| TNFa+PGE2+P3C | 1 | 0 | 0 | 6 |
The thesis panel's 6 errors are spread across classes, and that's expected, since those genes weren't chosen to separate these conditions. Two of them are controls called IL4, which is also the only mistake the five-gene learned panel makes. Control versus IL4 seems to be the hardest pair.
Try a held-out sample
Choose a procedure and a sample to see the probabilities it gave. Then reveal the condition that was recorded. These are the saved predictions; nothing is retrained in the browser. Choose the thesis five-gene panel and filter to incorrect predictions to see where it fails.
A small PyTorch network
I also trained a small network on each fold's top ten ranked genes. It has
10 → 8 → 4 units: eight ReLU units, then one output score per
condition. That is 124 parameters, under two kilobytes. It trains in about forty seconds on
one CPU thread.
Training is full-batch AdamW with cross-entropy for 150 epochs. I fixed that schedule in code before evaluation and didn't tune anything against the held-out results. It scored 1.00 on the first and only run.
| Epoch | Fold 1 | Fold 2 | Fold 3 |
|---|---|---|---|
| 1 | 1.5445 | 1.3555 | 1.5285 |
| 10 | 1.1583 | 1.0435 | 1.0881 |
| 25 | 0.4860 | 0.4079 | 0.4765 |
| 50 | 0.1105 | 0.0776 | 0.2218 |
| 100 | 0.0077 | 0.0114 | 0.0116 |
| 150 | 0.0042 | 0.0061 | 0.0052 |
By epoch 150 the training loss is about 0.004. On 16 to 20 training profiles, that is close to memorization, and the schedule has no early stopping. The held-out score held up anyway, and a regularized logistic regression on ten genes also scores 1.00. Nothing here favors deep learning for this task. I built it to practice a reproducible PyTorch workflow with donors kept out of training.
Confidence on mistakes
I wanted to check whether a model is less confident when it is wrong. The network makes no mistakes, so there are none to examine. Temperature scaling doesn't help either, because with zero errors its fit has no optimum. The thesis panel does make mistakes (6 of 28), so I used its saved predictions.
| When correct | When wrong | |
|---|---|---|
| Mean probability of the predicted class | 0.64 | 0.39 |
| Mean gap to the runner-up class | 0.42 | 0.09 |
The gap between the top two classes is much smaller on mistakes, so a sample-level confidence score carries some signal. The panel is still overconfident overall: its expected calibration error is 0.20, meaning stated confidence and actual accuracy differ by about that much on average.
All of this uses the frozen prediction file, with no refitting. I haven't followed up on the margin signal.
Limitations
- Normalization saw every sample. GEO describes the deposited matrix as quantile-normalized, possibly across all 384 arrays, including the donors I hold out. Fold-level processing can't undo that. This is evaluation inside one processed dataset, not an independent validation.
- Seven donors are too few to settle which genes belong in a panel or how stable the panel is, let alone any clinical use.
- All profiles come from one lab and one study on Illumina HumanHT-12 v3 arrays. Another lab, protocol or qPCR readout could behave differently.
- The labels are what was added to the dish. They are not disease states, and macrophages in tissue rarely see a single clean stimulus.
- The perfect score used 20 to 50 genes. The question of how few genes are enough is still open.
The next step I'd find convincing is to freeze one panel now and test it on a separate macrophage stimulation series, processed from raw data.
Check it yourself
The series matrix and platform annotation are public. The pipeline downloads them, checks their SHA-256 hashes, freezes the sample selection, then runs the nested donor-grouped evaluation:
python -m macrophage_ml.cli download
python -m macrophage_ml.cli prepare
python -m macrophage_ml.cli evaluate --seed 42
python -m macrophage_ml.cli verify-release --run-id gse46903_34b8b8ec86_s42
This page loads one verified run at startup and serves its saved predictions. It doesn't train anything in response to requests.
- Run manifest: versions, seed, file hashes
- Splits: which donors were in which fold
- Held-out predictions: every procedure, every sample
- Selected genes: per procedure and fold
- PyTorch training trace
- Uncertainty report