
Updated 17 June 2025: Latest Release on pip! v1.5.2
GenoML (Genomics + Machine Learning) is an automated Machine Learning (autoML) for genomics data. In general, use a Linux or Mac with Python 3.9-3.12 for best results. This repository and pip package are under active development!
This README is a brief look into how to structure arguments and what arguments are available at each phase for the GenoML CLI.
If you are using GenoML for your own work, please cite the following papers: - Makarious, M. B., Leonard, H. L., Vitale, D., Iwaki, H., Saffo, D., Sargent, L., ... & Faghri, F. (2021). GenoML: Automated Machine Learning for Genomics. arXiv preprint arXiv:2103.03221 - Makarious, M. B., Leonard, H. L., Vitale, D., Iwaki, H., Sargent, L., Dadu, A., ... & Nalls, M. A. (2021). Multi-Modality Machine Learning Predicting Parkinson’s Disease. bioRxiv.
git clone https://github.com/GenoML/genoml2.git
pip install genoml2
OR
pip install genoml2 --upgrade
examples/ directory (~315 KB), you can use SVN (pre-installed on most Macs)svn export https://github.com/GenoML/genoml2.git/trunk/examples
Note: When you pip install this package, the examples/ folder is also downloaded! However, if you still want to download the directory and SVN is not pre-installed, you can download it via Homebrew if you have that installed using
brew install svn
README updated to reflect these changes.README updated to reflect these changes.You can create a virtual environment to run GenoML, if you prefer. If you already have the Anaconda Distribution, this is fairly simple.
To create and activate a virtual environment:
# To create a virtual environment
conda create -n GenoML python=3.12
# To activate a virtual environment
conda activate GenoML
# To install requirements via pip
pip install -r requirements.txt
# If issues installing xgboost from requirements - (3 options)
# Option 1: use Homebrew to
# xcode-select --install
# brew install gcc@7
# or Option 2: conda install -c conda-forge xgboost
# or Option 3: pip install xgboost==2.0.3
# If issues installing umap
# pip install umap-learn
# If issues installing pytables/dependency issue
# conda install -c conda-forge pytables
## MISC
# To deactivate the virtual environment
# conda deactivate GenoML
# To delete your virtual environment
# conda env remove -n GenoML
To install the GenoML in the user's path in a virtual environment, you can do the following:
# Install the package at this path
pip install .
# MISC
# To save out the environment requirements to a .txt file
# pip freeze > requirements.txt
# Removing a conda virtualenv
# conda remove --name GenoML --all
Note: The following examples are for discrete data, but if you substitute following commands with
continuousormulticlassinstead of discrete, you can munge, harmonize, train, tune, and test your continuous/multiclass data!
Munging with GenoML will, at minimum, do the following:
- Prune your genotypes using PLINK v2 (if --geno flag is used)
- Impute per column using median or mean (can be changed with the --impute flag)
- Z-scaling of features and removing columns with a std dev = 0
Required arguments for GenoML munging are --prefix and --pheno
- data : Are the data continuous, discrete, or multiclass?
- method: Do you want to use supervised or unsupervised machine learning? (unsupervised currently under development)
- mode: would you like to munge, harmonize, train, tune, or test your model? Here, you will use munge.
- --prefix : Where would you like your outputs to be saved?
- --pheno : Where is your phenotype file? This file only has 2 columns, ID in one, and PHENO in the other (0 for controls and 1 for cases when using the discrete module, 0, ..., n-1 when using the multiclass module for n distinct phenotypes, or numeric values when using the continuous module).
Be sure to have your files formatted the same as the examples, key points being: - Your phenotype file consisting only of the "ID" and "PHENO" columns - Your sample IDs matching across all files - Your sample IDs not consisting with only integers (add a prefix or suffix to all sample IDs ensuring they are alphanumeric if this is the case prior to running GenoML) - Please avoid the use of characters like commas, semi-colons, etc. in the column headers (it is Python after all!)
If you would like to munge just with genotypes (in PLINK binary format), the simplest command is the following:
# Running GenoML munging on discrete data using PLINK genotype binary files and a phenotype file
genoml discrete supervised munge \
--prefix outputs \
--geno examples/discrete/training \
--pheno examples/discrete/training_pheno.csv
If you would like a more detailed log printed to your console, you may use the --verbose flag as follows:
# Running GenoML munging on discrete data using PLINK genotype binary files and a phenotype file with a detailed log printed to the console
genoml discrete supervised munge \
--prefix outputs \
--geno examples/discrete/training \
--pheno examples/discrete/training_pheno.csv \
--verbose
Note: The
--verboseflag may be used like this for any GenoML command, not just munging.
To properly evaluate your model, it must be applied to a dataset it's never seen before (testing data). If you have both training and testing data, GenoML allows you to munge them together upfront. To do this with your training and testing phenotype/genotype data, the simplest command is the following:
# Running GenoML munging on discrete data using PLINK genotype binary files and phenotype files for both the training and testing datasets.
genoml discrete supervised munge \
--prefix outputs \
--geno examples/discrete/training \
--pheno examples/discrete/training_pheno.csv \
--geno_test examples/discrete/validation \
--pheno_test examples/discrete/validation_pheno.csv
If you would like to control the pruning stringency in genotypes:
# Running GenoML munging on discrete data using PLINK genotype binary files and a phenotype file
genoml discrete supervised munge \
--prefix outputs \
--geno examples/discrete/training \
--r2_cutoff 0.3 \
--pheno examples/discrete/training_pheno.csv
You can choose to skip pruning your SNPs at this stage by including the --skip_prune flag
# Running GenoML munging on discrete data using PLINK genotype binary files and a phenotype file
genoml discrete supervised munge \
--prefix outputs \
--geno examples/discrete/training \
--skip_prune \
--pheno examples/discrete/training_pheno.csv
You can choose to impute on mean or median by modifying the --impute flag, like so (default is median):
# Running GenoML munging on discrete data using PLINK genotype binary files and a phenotype file and specifying impute
genoml discrete supervised munge \
--prefix outputs \
--geno examples/discrete/training \
--pheno examples/discrete/training_pheno.csv \
--impute mean
If you suspect collinear variables, and think this will be a problem for training the model moving forward, you can use variance inflation factor (VIF) filtering:
# Running GenoML munging on discrete data using PLINK genotype binary files and a phenotype file while using VIF to remove multicollinearity
genoml discrete supervised munge \
--prefix outputs \
--geno examples/discrete/training \
--pheno examples/discrete/training_pheno.csv \
--vif 5 \
--vif_iter 1
--vif flag specifies the VIF threshold you would like to use (5 is recommended) --vif_iter flag (if you have or anticipate many collinear variables, it's a good idea to increase the iterations)Well, what if you had GWAS summary statistics handy, and would like to just use the same SNPs outlined in that file? You can do so by running the following:
# Running GenoML munging on discrete data using PLINK genotype binary files, a phenotype file, and a GWAS summary statistics file
genoml discrete supervised munge \
--prefix outputs \
--geno examples/discrete/training \
--pheno examples/discrete/training_pheno.csv \
--gwas examples/discrete/example_GWAS.csv
Note: When using the GWAS flag, the PLINK binaries will be pruned to include matching SNPs to the GWAS file.
And if you have more than one GWAS summary statistics file, we support that too! Just use the same --gwas flag for each of the files you would like to include, as follows:
# Running GenoML munging on discrete data using PLINK genotype binary files, a phenotype file, and two GWAS summary statistics files
genoml discrete supervised munge \
--prefix outputs \
--geno examples/discrete/training \
--pheno examples/discrete/training_pheno.csv \
--gwas examples/discrete/example_GWAS.csv \
--gwas examples/discrete/example_GWAS_2.csv
Note: This is particularly helpful when using the
multiclassmodule when you have multiple phenotypes of interest and would like to include SNPs that are relevant for each phenotype.
...and if you wanted to add a p-value cut-off...
# Running GenoML munging on discrete data using PLINK genotype binary files, a phenotype file, and a GWAS summary statistics file with a p-value cut-off
genoml discrete supervised munge \
--prefix outputs \
--geno examples/discrete/training \
--pheno examples/discrete/training_pheno.csv \
--gwas examples/discrete/example_GWAS.csv \
--p 0.01
Do you have additional data you would like to incorporate? Perhaps clinical, demographic, or transcriptomics data? If coded and all numerical, these can be added as an --addit file by doing the following:
# Running GenoML munging on discrete data using PLINK genotype binary files, a phenotype file, and an addit file
genoml discrete supervised munge \
--prefix outputs \
--geno examples/discrete/training \
--pheno examples/discrete/training_pheno.csv \
--addit examples/discrete/training_addit.csv
You also have the option of not using PLINK binary files if you would like to just preprocess (and then, later train) on a phenotype and addit file by doing the following:
# Running GenoML munging on discrete data using PLINK genotype binary files, a phenotype file, and an addit file
genoml discrete supervised munge \
--prefix outputs \
--pheno examples/discrete/training_pheno.csv \
--addit examples/discrete/training_addit.csv
Are you interested in selecting and ranking your features? If so, you can use the --feature_selection flag and specify like so...:
# Running GenoML munging on discrete data using PLINK genotype binary files, a phenotype file, and running feature selection
genoml discrete supervised munge \
--prefix outputs \
--geno examples/discrete/training \
--pheno examples/discrete/training_pheno.csv \
--addit examples/discrete/training_addit.csv \
--feature_selection 50
The --feature_selection flag uses extraTrees (classifier for discrete data; regressor for continuous data) to output a *.approx_feature_importance.txt file with the features most contributing to your model at the top.
Do you have additional covariates and confounders you would like to adjust for in the munging step prior to training your model and/or would like to reduce your data? To adjust, use the --adjust_data flag with the following necessary flags:
- --target_features: A .txt file, one column, with a list of features to adjust (no header). These should correspond to features in the munged dataset
- --confounders: A .csv of confounders to adjust for with ID column and header. Numeric,
$ claude mcp add genoml2 \
-- python -m otcore.mcp_server <graph>