Machine Learning Approaches for Demographic Inference in African Malaria Vector Populations
# demographic-Inference
# MSc Bioinformatics Thesis: Machine Learning Approaches for Demographic Inference in African Malaria Vector Populations
This repository contains code, scripts, and results from my MSc Bioinformatics thesis on **evolutionary dynamics and genomic surveillance of mosquito populations**, with a focus on **site frequency spectrum (SFS) analysis, msprime simulations, and machine learning approaches** for inferring effective population size (Ne).
---
## 📂 Repository Structure
- **`sfs.py`**
Core functions for computing **site frequency spectra (SFS)** from simulated or VCF-based data.
- Generates folded/unfolded spectra.
- Normalises vectors for input into machine learning models.
- **`msprime.py`**
Scripts for **simulating genomic data** under neutral demographic models using `msprime`.
- Simulates allele frequency data under broad and narrow Ne schemes.
- Produces SFS vectors and plots for downstream ML analysis.
- **`svm.py`**
Implements a **Support Vector Machine (SVM) classifier** for Ne inference.
- Input: Folded, normalised SFS vectors.
- Output: Predicted Ne class (broad or narrow).
- Uses RBF kernel, trained with 80/20 train-test split.
- **`random-forest-regressor.py`**
Implements a **Random Forest regressor** for continuous Ne estimation.
- Input: Folded, normalised SFS vectors.
- Output: Continuous Ne predictions.
- Includes a mapping step to nearest class bin for direct accuracy comparison with classifiers.
- **`Permutation-Scenarios.py`**
Performs **paired permutation testing** to compare SVM and Random Forest classifiers.
- Runs both broad (100k, 500k, 1M) and narrow (50k, 225k, 500k) Ne schemes.
- Produces permutation null distributions, p-values, and confusion matrices.
- **`README.md`**
Documentation and usage guide for the repository.
---
## 🧬 Data Preparation
Population-specific mosquito sample IDs were extracted from the *Anopheles gambiae 1000 Genomes Project (Ag1000G, Phase 2 chromosome 3L variant set)* metadata f …