Computational analysis code accompanying A roadmap for enriching rare cell populations from human post-mortem brain, demonstrated by 100% microglial purity.
Isidora Gocmanac 





UK Dementia Research Institute, Imperial College London.
The single-nucleus RNA-seq analyses validate the purity of FANS-sorted nuclei from human post-mortem cortex and cerebellum across a series of antibody-panel configurations. The pipeline ingests gene-by-barcode count matrices, performs per-sample quality control, clustering and reference-based annotation, and produces the per-sample UMAP, feature and composition figures presented in the paper. Experimental detail — donors, antibodies, gating strategy, library preparation — is described in the Methods section of the paper; this README covers only what is needed to reproduce the computational results.
The processed sequencing data are deposited on NCBI GEO under accession GSE333448 (gene-by-barcode count matrices).
The pipeline reads the per-sample filtered_feature_bc_matrix outputs (DRAGEN single-cell RNA / Cell Ranger format). To run end-to-end from GEO:
- Download the processed-matrix archive for
GSE333448and unpack each sample into its own folder underdata/matrices/<cohort>/<sample>/filtered_feature_bc_matrix/containingmatrix.mtx.gz,barcodes.tsv.gzandfeatures.tsv.gz.<cohort>istest(the panel-development sorts) orfinal(the five-population confirmatory sorts, occipital and parietal);<sample>is theSK*identifier as listed in Supplementary Table 3. - Ensure
data/matrices/<cohort>/sample_metadata.tsvis present (tracked in the repo). It maps eachsamplefolder to its brainregionand a displaylabel; rows withNAlabels are skipped on load.
Both data/ and output/ are git-ignored and are not included in this repository.
The pipeline is R-based (Seurat + tidyverse) and runs from the repo root. Each cohort has its own numbered scripts; run them in order:
# Method development experiments (test group)
for f in scripts/test/0*.R; do Rscript "$f"; done
# Final, confirmatory experiments (final group)
for f in scripts/final/0*.R; do Rscript "$f"; doneScripts write checkpoints to output/<cohort>/checkpoints/ between steps, so any individual stage can be re-run without repeating earlier ones. The step between 04a_export_mapmycells.R and 04b_import_mapmycells.R involves a manual round-trip through the Allen Institute MapMyCells web tool — export the H5AD file produced by 04a, upload it using the 10x Whole Human Brain taxonomy (CCN202210140), and place the returned annotation CSV in the location expected by 04b (see the path constant at the top of that script).
A published image bundles R, the analysis scripts and the full software stack (including the Python/anndata environment that zellkonverter needs for the MapMyCells export), pinned to a fixed Bioconductor release for reproducibility. Data and outputs are kept outside the image.
docker pull ghcr.io/neurogenomics/microglia-sorting:latest
docker run -it \
-e PASSWORD=bioc \
-p 8787:8787 \
ghcr.io/neurogenomics/microglia-sorting:latest
# Inside the container: download the GSE333448 matrices into the expected layout,
# data/matrices/<cohort>/<sample>/filtered_feature_bc_matrix/{matrix,barcodes,features}...
# then run a cohort end-to-end:
for f in scripts/final/0*.R; do Rscript "$f"; doneTo keep inputs and outputs on the host instead of inside the container, bind-mount them:
docker run -it \
-v "$PWD/data:/microglia-sorting/data" \
-v "$PWD/output:/microglia-sorting/output" \
-e PASSWORD=bioc \
-p 8787:8787 \
ghcr.io/neurogenomics/microglia-sorting:latestYou can then access Rstudio at localhost:8787 in your browser (user: rstudio, password: bioc) and run the scripts interactively, or run them from the command line as above.
On RAM-tight machines, lower the per-sample clustering parallelism (step 05) with docker run -e MICROGLIA_WORKERS=2 ... (set to 1 to force serial execution). The MapMyCells round-trip between 04a and 04b is still a manual web step as described above.
Running with Docker (above) requires only Docker. To run the scripts directly you need:
- R ≥ 4.6
- Bioconductor = 3.23
- Seurat ≥ 5.0
- tidyverse, DoubletFinder (GitHub-only), and the Bioconductor packages SingleCellExperiment, S4Vectors and zellkonverter, plus their dependencies (see the
library()calls in01_load.R,02_qc.Rand04a_export_mapmycells.R)
If you use this code, please cite:
Gocmanac I, Dash H, Weinert M, Nott A, Nagaeva E & Skene NG. A roadmap for enriching rare cell populations from human post-mortem brain, demonstrated by 100% microglial purity. (citation to be completed on publication)
MIT — see LICENSE.