A machine learning project exploring whether gene-expression patterns from human brain tissue can be used to distinguish between broad anatomical brain regions.
The project uses real biological data from the Allen Human Brain Atlas (AHBA) and investigates whether transcriptomic patterns can distinguish tissue samples from the Cortex, Hippocampus, and Cerebellum.
The analysis also examines whether the learned patterns generalize across different human donors and which gene-expression features are consistently selected by the machine-learning models.
Different regions of the human brain have different patterns of gene expression.
This project asks:
Can a machine-learning model learn these molecular patterns well enough to distinguish broad brain regions, and do these patterns generalize across different donors?
The final pipeline takes high-dimensional gene-expression data and:
- Identifies samples belonging to the target brain regions.
- Maps anatomical information from the AHBA ontology to broad region labels.
- Creates machine-learning datasets from normalized microarray expression data.
- Selects informative gene/probe features.
- Trains a Logistic Regression classifier.
- Evaluates performance using cross-donor validation.
- Repeats feature selection across different donor combinations to examine feature stability.
- Maps stable probes to their corresponding genes.
- Performs functional enrichment analysis on the stable gene set.
- Uses a label-shuffling test as a sanity check for the classification results.
The classifier distinguishes between three broad anatomical regions:
- Cortex
- Hippocampus
- Cerebellum
The final dataset contains 1,340 labelled tissue samples from three AHBA donors.
| Donor | Total Samples | Cortex | Hippocampus | Cerebellum |
|---|---|---|---|---|
| 9861 | 595 | 481 | 61 | 53 |
| 10021 | 507 | 370 | 54 | 83 |
| 12876 | 238 | 182 | 14 | 42 |
| Total | 1,340 | 1,033 | 129 | 178 |
Each sample contains expression measurements for 58,692 gene/probe features.
The classes are imbalanced, particularly because Cortex samples are more numerous than Hippocampus and Cerebellum samples. Therefore, metrics such as balanced accuracy and macro F1-score are used alongside ordinary accuracy.
The project uses normalized microarray gene-expression data from the Allen Human Brain Atlas.
The original expression data contains thousands of samples and 58,692 probes. Anatomical metadata and ontology information are used to identify samples belonging to the three target brain regions.
The processed machine-learning datasets contain:
- 3 human donors
- 1,340 labelled samples
- 58,692 gene/probe features per sample
- 3 brain-region classes
The raw AHBA datasets are not included in this repository because of their large size.
The repository contains the code, notebooks, and analysis results used to process and analyze the data.
Allen Human Brain Atlas ↓ Normalized microarray expression ↓ Sample + anatomical metadata ↓ AHBA ontology mapping ↓ Brain-region labels ↓ Cortex / Hippocampus / Cerebellum ↓ Feature selection ↓ Logistic Regression ↓ Cross-donor validation ↓ Feature stability analysis ↓ Stable probes → genes ↓ Functional enrichment ↓ Permutation sanity check Brain Region Labelling
Anatomical structures in the AHBA are mapped to three broad regions using the ontology hierarchy:
Cortex Hippocampus Cerebellum
Samples that do not belong to one of these target regions are excluded from the classification dataset.
Feature Selection
The original expression matrix contains 58,692 probe features, which is very high-dimensional compared with the number of samples.
Feature selection is therefore used to identify the most informative probes for distinguishing the brain regions.
For the main cross-donor experiments, 1,000 features are selected for each training experiment.
Classification
A Logistic Regression classifier is used for the final classification experiments.
Class weights are balanced to reduce the effect of the unequal number of samples between brain regions.
A major focus of the project is testing whether the classifier can generalize to an unseen donor.
Instead of randomly splitting samples from the same individual into training and testing sets, the model is trained using two donors and evaluated on a completely separate third donor.
This experiment is repeated so that each donor is used as the held-out test donor.
Train on Donors 1 + 2 ↓ Hold out Donor 3 ↓ Predict Donor 3 ↓ Repeat for each donor ↓ Compare performance
This provides a more meaningful test of whether the model is learning broad regional transcriptomic patterns rather than simply learning donor-specific characteristics.
The final three-class cross-donor experiments produced:
Training Donors Test Donor Accuracy Balanced Accuracy Macro F1 9861 + 12876 10021 99.80% 99.38% 99.49% 10021 + 12876 9861 100.00% 100.00% 100.00% 9861 + 10021 12876 100.00% 100.00% 100.00%
The results show very strong performance when predicting the brain regions of donors that were completely excluded from training.
However, the high performance should be interpreted in the context of the task: Cortex, Hippocampus, and Cerebellum are broad anatomical regions with substantial transcriptomic differences, so this is not intended to represent a difficult clinical classification problem.
A separate binary experiment was performed to examine classification between Cortex and Hippocampus.
One of the cross-donor experiments produced:
Metric Score Accuracy 90.22% Balanced Accuracy 94.49% Macro F1 81.94%
The difference between ordinary accuracy and balanced accuracy highlights the importance of considering class imbalance when evaluating the model.
The other donor splits produced substantially higher performance.
This experiment suggests that although the transcriptomic distinction between these regions is strong, the strength of the classification signal can vary depending on the donor used for testing.
To investigate whether the classifier repeatedly relies on the same molecular features, feature selection was performed independently across the three cross-donor classification experiments.
Each experiment selected 1,000 probes.
The overlap between selected feature sets was:
Comparison Shared Probes Experiment 1 & 2 846 Experiment 1 & 3 812 Experiment 2 & 3 758 Common to all three 726
Therefore, 726 probes were selected in all three experiments, representing 72.6% of the 1,000 selected features in each experiment.
This provides evidence that a substantial portion of the selected transcriptomic signal is reproducible across different donor combinations.
The 726 commonly selected probes represent a broad stable feature set.
A more conservative gene-level analysis was also performed using the stable features from the binary Cortex-vs-Hippocampus experiments.
This produced:
440 stable probes 305 unique genes
Multiple probes can correspond to the same gene, so the number of unique genes is smaller than the number of probes.
The resulting gene list is stored in:
data/processed/stable_305_genes.csv
Some of the genes represented among these stable features include genes involved in neuronal signaling, receptors, ion channels, and other neural functions.
Importantly, a gene appearing among the selected features does not mean that it causes a particular brain region or is a clinically validated biomarker.
The feature analysis is exploratory and is intended to help understand which molecular patterns the classifier is using.
The 305 stable genes were analysed using functional enrichment analysis to investigate whether particular biological functions were represented more strongly than expected.
The analysis identified significant associations with several neuronal and signaling-related categories, including:
Synaptic signaling Neuronal projections Neurotransmitter receptor activity G protein-coupled receptor activity Serotonin receptor activity Potassium ion transport Potassium channel complexes Neuronal development and system development
These results suggest that the genes represented among the repeatedly selected features are associated with biological processes related to neuronal signaling, synaptic activity, neurotransmitter receptors, ion transport, and neuronal structure.
The enrichment analysis provides biological context for the machine-learning results, but it does not establish causality.
A label-shuffling experiment was performed as a simple sanity check.
The original training labels were randomly shuffled while keeping the gene-expression data unchanged. The same feature-selection and classification pipeline was then applied.
Results Training Labels Balanced Accuracy Original labels 99.38% Shuffled labels 38.44% Chance level for 3 classes 33.33%
Randomly shuffling the labels reduced balanced accuracy from 99.38% to 38.44%, which is close to the expected chance level for three classes.
This supports the interpretation that the high performance with the original labels depends on meaningful structure in the data rather than being produced solely by the classification pipeline.
This test is used as a sanity check, not as a formal statistical significance test.
allen-brain-region-classifier/ │ ├── notebooks/ │ └── cross_donor_validation.ipynb │ ├── results/ │ ├── src/ │ └── permutation_test.py │ ├── .gitignore └── README.md
The large raw and processed biological datasets are excluded from Git using .gitignore.
The results should be interpreted with several limitations in mind.
- Limited number of donors
The analysis currently uses three human donors.
Although the cross-donor experiments test generalization to unseen individuals, three donors are not enough to establish population-level generalization.
- Broad anatomical labels
The classification task uses three broad regions:
Cortex Hippocampus Cerebellum
These regions are anatomically and biologically distinct, so high classification performance is not unexpected.
- High accuracy does not mean a biologically difficult task
The results demonstrate strong transcriptomic separability of these broad regions.
They should not be interpreted as evidence that the model has solved a difficult or clinically relevant brain-region prediction problem.
- Gene-expression differences can have multiple sources
Differences in gene expression between regions may reflect factors such as tissue composition, cell populations, anatomical structure, and other biological characteristics.
The machine-learning model identifies predictive patterns but does not determine why those patterns exist.
- Probe-level features
The original microarray dataset contains probe-level measurements.
Multiple probes can map to the same gene, so probe counts and gene counts are not equivalent.
- No clinical interpretation
This project is an exploration of machine learning applied to biological data.
The selected genes should not be interpreted as diagnostic biomarkers or therapeutic targets.
This project investigated whether broad anatomical regions of the human brain can be distinguished using gene-expression data from the Allen Human Brain Atlas.
Using normalized microarray data from three donors, a machine-learning classifier was able to distinguish Cortex, Hippocampus, and Cerebellum with very high performance in cross-donor validation.
Repeated feature-selection experiments identified a substantial set of stable transcriptomic features. Further analysis of stable genes showed associations with biological functions related to neuronal signaling, synaptic activity, neurotransmitter receptors, ion transport, and neuronal projections.
A label-shuffling sanity check also caused classification performance to fall close to chance level, supporting the interpretation that the original results depend on meaningful structure in the gene-expression data.
Overall, the project demonstrates how machine-learning methods can be used to explore transcriptomic patterns in the human brain, while also highlighting the importance of donor-level validation, feature stability, biological interpretation, and careful consideration of limitations.
Python NumPy Pandas Scikit-learn Matplotlib Jupyter Notebook Logistic Regression Feature Selection Functional Enrichment Analysis
Possible future extensions of the project include:
Testing additional donors as more data becomes available. Exploring finer-grained anatomical regions. Comparing different feature-selection strategies. Investigating whether stable features remain consistent across larger donor sets. Exploring more detailed relationships between transcriptomic features and brain anatomy.
This project is primarily an exploration of machine learning applied to real human biological and neuroscience data.
Rather than treating the brain only as an image or neural signal, it explores the brain at the molecular level through gene-expression patterns.
The broader goal is to understand how machine-learning techniques can be applied to complex biological datasets while paying attention to validation, interpretability, generalization, and biological context.