Notes on methods and how they mislead.
Longer pieces on methods I use, each focused on the same question: what is this actually measuring, and what will it let me believe that I shouldn't? Written to think things through rather than to teach. The methods library is the quick reference; these are the arguments.
Method notes
01
What a UMAP plot does and does not preserve
Dimensionality reduction · the distance between two clusters usually means nothing
UMAP and t-SNE are everywhere in single-cell work, and both are read far more literally than they deserve. The useful mental model is that they are optimised to preserve local neighbourhoods — which points are near which other points — and that they make no promise whatsoever about global geometry.
What this rules out
- Distance between clusters is not interpretable. Two blobs sitting far apart on a UMAP are not necessarily more different than two blobs that are close. The spacing is an artefact of the optimisation, not a measurement.
- Cluster size is not abundance or variance. A large sprawling island may just be a region where the algorithm had room to spread points out.
- The number of clusters is a parameter, not a finding. Change the neighbourhood size or the clustering resolution and the count changes. Reporting "we identified 14 cell types" without reporting the resolution you chose is reporting a decision as though it were a result.
What it is good for
Seeing whether structure exists at all; spotting batch effects, where samples separate by processing run rather than biology; and giving a visual handle on a clustering you have validated by other means — marker genes, known biology, or stability across parameters.
02
Why a docking score is not a binding affinity
Computational chemistry · the most common overclaim in computational drug discovery
Docking does two separable things: it generates plausible poses for a ligand in a binding site, and it scores them. It is reasonably good at the first and considerably weaker at the second, and the distinction gets lost whenever a docking score is reported in kcal/mol as though it were a measurement.
Where the scoring functions struggle
- Entropy and desolvation. Binding involves stripping ordered water from both partners and losing conformational freedom. Scoring functions approximate these terms crudely because computing them properly is expensive.
- Protein flexibility. Most docking treats the receptor as rigid. Real binding sites reorganise, and induced fit is exactly the case a rigid model handles worst.
- Ranking versus prediction. A scoring function may order a congeneric series sensibly while being unreliable across chemically diverse compounds — the case where you most want it to work.
What can be said honestly
That docking generated a structural hypothesis: a pose, and a set of interactions the ligand could make if it binds in that orientation. That hypothesis is genuinely useful — it guides which analogue to make next. It is not evidence of activity, and the gap is closed by assay data, not by a better score.
03
Why genome-wide significance is 5 × 10⁻⁸
Statistics · multiple testing, and what a QQ plot is really for
Test a million independent hypotheses at p < 0.05 and you expect around fifty thousand false positives. The genome-wide threshold is a Bonferroni-style correction for roughly a million independent tests — an approximation of the number of effectively independent common variants in the human genome, given the correlation structure of linkage disequilibrium. 0.05 ÷ 10⁶ gives 5 × 10⁻⁸.
What the threshold is not
It is not a line between real and unreal. A variant at p = 6 × 10⁻⁸ is not meaningfully different from one at 4 × 10⁻⁸; the threshold controls a family-wise error rate across a scan, and that is all it does. An effect that misses it may simply be underpowered, which is why effect sizes should be reported alongside p-values rather than instead of being mentioned.
The QQ plot is the diagnostic that matters
- Points on the diagonal: test statistics behaving as the null predicts.
- A tail lifting away at the top: what genuine association looks like.
- The whole line above the diagonal: inflation. Usually population structure or cryptic relatedness, occasionally a technical artefact — and almost never a genome full of real signal.
The genomic inflation factor λ summarises this as the ratio of the median observed chi-square to its null expectation. λ near 1 is what you want; λ above about 1.1 means something needs explaining before the hits are worth discussing.
04
SHAP explains a model, not a mechanism
Interpretability · the gap between feature importance and biology
SHAP values distribute a prediction across the input features, using an approach borrowed from cooperative game theory: each feature's contribution is its average marginal effect across orderings of the features. The mathematics is principled, and the usual interpretation of the output is not.
Three ways the biological reading goes wrong
- Correlated features share credit arbitrarily. Genes in the same pathway are often highly correlated. The model may lean on one and effectively ignore its neighbours; SHAP will faithfully report that, and a reader will conclude the chosen gene is the important one. Swap the correlated partner in and the model performs identically.
- Confounds get attributed as biology. If a batch effect predicts the outcome, the features carrying it will show high attribution. The model is not wrong — that feature genuinely drives its prediction — but the explanation is about the dataset, not the disease.
- Attribution is not causal. SHAP describes a model that was fitted to observational data. Nothing in the procedure licenses an intervention claim.
How I would use it anyway
As a debugging tool first: if the top features are technical covariates or known confounds, the model has learned the wrong thing and the explanation has just saved you from publishing it. As a hypothesis generator second, where a high-attribution feature with a plausible mechanism is worth following up experimentally. Never as a finding in its own right.
05
The reference genome is a sample, not a truth
Sequencing · why variant calling works less well the further you are from the reference
Every short-read workflow starts by mapping reads to a linear reference, and almost every downstream statement inherits whatever that reference happens to contain. GRCh38 is a mosaic assembled from a small number of donors, so it is one particular arrangement of human sequence rather than a neutral coordinate system — and the consequences are systematic rather than random.
How the bias actually arises
A read carrying the alternate allele has at least one mismatch against the reference, so it aligns slightly worse than a read carrying the reference allele. At a heterozygous site that produces an allele balance tilted towards reference. Usually it is a nudge. At a divergent locus — several variants within one read length, or an indel — it can be enough that the alternate reads fail to map at all, and the site is called homozygous reference with apparent confidence.
Why it is an equity problem, not just a technical one
- The cost is not evenly distributed. Divergence from GRCh38 is greatest for populations least represented in it, so under-calling falls hardest on exactly the groups already under-served by genomic medicine.
- It compounds with imputation. Reference panels have the same skew, so a variant poorly captured at the mapping stage is also poorly imputed.
- It is invisible in the output. A missed heterozygote looks identical to a true homozygous reference call. Nothing in the VCF marks it.
What helps
Graph and pangenome references replace the single linear path with the known alternatives, so a read carrying a common alternate allele has somewhere to map that fits it. They are more work and the tooling is younger, but for pharmacogenes sitting in segmental duplications — CYP2D6 being the obvious case — the linear reference is not merely suboptimal, it is the reason the locus is hard.
06
What a gene list is actually for
Enrichment · the background set decides your answer before the statistics start
A differential expression analysis ends with a list, and the list immediately goes into an enrichment test, and the enrichment test produces pathways, and the pathways become the story. Each step is reasonable. The combination routinely produces conclusions that would not survive being asked one question: compared to what?
The background set is the analysis
Over-representation testing asks whether a pathway appears in your list more often than chance. "Chance" is defined by the background — the set of genes that could have been selected. Test against the whole genome when only expressed genes could ever have appeared in your list, and every pathway enriched in expressed genes looks enriched in your result. In tissue-specific data that is most of the interesting ones.
Annotation bias is not noise
Gene sets are built from published work, and publication is not uniform. Well-studied genes carry more annotations, so pathways full of well-studied genes enrich more readily than pathways of equal biological relevance that nobody has got round to characterising. An enrichment result is partly a map of what the field has already found interesting.
Redundancy inflates the apparent findings
Gene sets overlap heavily. Forty significant terms can be four biological statements wearing different names, and a screenshot of forty rows reads as four times more evidence than it is. Clustering terms by member overlap before reporting is the minimum.