Getting started

What AGENT-P needs, how to install it, and how to download the models of gene expression.

1.Requirements

AGENT-P runs on Linux. It is a Python package that calls a few genetics programs, all of which are installed together with conda in the next step:

SoftwareVersionUsed for
Python3.10AGENT-P itself, with numpy (< 2), pandas, SciPy (≥ 1.11), statsmodels, h5py, matplotlib, and bgen-reader
PLINK 22.00a5.12quality control of genotypes, and preparing genotypes for the models of gene expression
bgenix1.1.7reading genotypes in BGEN format
REGENIE3.6GWAS (optional)
R4.2FUSION models of gene expression (with optparse, RColorBrewer, and plink2R, which comes with AGENT-P)
  • Disk space: about 2 GB for the models of gene expression.
  • Memory: a laptop with 8 GB is enough for the example. For large cohorts (tens of thousands of subjects), use a computing cluster.

Tips for macOS and Windows

  • macOS: follow the same instructions as on Linux. On a Mac with an Apple chip (M1–M4), create the environment with the extra setting in Install: the genetics programs are only available for Intel Macs, and run through Rosetta (if it is not installed, run softwareupdate --install-rosetta). The first run can take a few extra minutes while Rosetta translates the programs.
  • Windows: use WSL (Windows Subsystem for Linux), and follow the Linux instructions inside it.

2.Install

The easiest way to install AGENT-P and everything it needs is with conda (if you do not have conda, install Miniforge first). Open a terminal and run:

Terminal
cd ~                                                      # download AGENT-P into your home folder
git clone -b agentp-update-20261105 https://github.com/nhunghoang/agentp.git
conda env create -f ~/agentp/environment.yml              # takes 5-15 minutes
conda activate agentp
pip install --no-deps -e ~/agentp
R CMD INSTALL ~/agentp/agentp/external/plink2R/plink2R

AGENT-P is now in ~/agentp (~ is your home folder). The commands on this site use this path; if you downloaded AGENT-P elsewhere, change ~/agentp in the commands.

On a Mac with an Apple chip (M1–M4), use these commands instead (the genetics programs are only available for Intel Macs, and run through Rosetta):

Terminal
cd ~
git clone -b agentp-update-20261105 https://github.com/nhunghoang/agentp.git
CONDA_SUBDIR=osx-64 conda env create -f ~/agentp/environment.yml
conda activate agentp
conda config --env --set subdir osx-64
pip install --no-deps -e ~/agentp
R CMD INSTALL ~/agentp/agentp/external/plink2R/plink2R

Each time you open a new terminal, run conda activate agentp before using AGENT-P.

Install with pip (PyPI)

AGENT-P is also on PyPI (Python 3.9 or later):

Terminal
pip install agentp

This installs AGENT-P and its Python packages only. PLINK 2, bgenix, REGENIE, and R (with plink2R, for FUSION) must be installed separately.

3.Download the models of gene expression

The models of gene expression (about 2 GB) are not included in the GitHub repository. Download models.tar.gz and extract it into ~/agentp/agentp, the agentp folder inside the repository:

Terminal
tar -xzf ~/Downloads/models.tar.gz -C ~/agentp/agentp     # change ~/Downloads if you saved the file elsewhere

The models of gene expression are now in ~/agentp/agentp/models: models from four TWAS methods for eight brain regions (GTEx v8). In AGENT-P, each method and region has a short code, and any method can be combined with any region, e.g. SummaryTWAS(project, 'FUS', 'hippocampus'):

Brain regionCode
Dorsolateral prefrontal cortexdlpfc
Anterior cingulate cortexant-cingulate
Amygdalaamygdala
Hippocampushippocampus
Caudatecaudate
Putamenputamen
Nucleus accumbensnuc-accumbens
Cerebellar hemispherecerebellar-hemi

If you installed AGENT-P with pip, extract models.tar.gz into any folder (here ~/agentp_models):

Terminal
mkdir -p ~/agentp_models
tar -xzf ~/Downloads/models.tar.gz -C ~/agentp_models

and tell AGENT-P where the models are at the start of each script:

Python
import os
from agentp import set_models_dir
set_models_dir(os.path.expanduser('~/agentp_models/models'))

The example does not need this download: it uses a small set of example models of gene expression that comes with AGENT-P.

4.Check the installation

Each of these commands should print a version or a message, without errors:

Terminal
conda activate agentp
python -c "import agentp; print('AGENT-P is ready')"
plink2 --version
bgenix -help | head -1
regenie --version
Rscript -e "suppressMessages(library(plink2R)); cat('plink2R is ready\n')"

Then you can either:

  1. run the example on your computer, which uses the small example models of gene expression; or
  2. use the full models of gene expression: test the pipeline with python ~/agentp/tests/test_pipeline.py, which runs every step of AGENT-P (add --fusion to include FUSION), then analyze your own data with the Full run.

5.Troubleshooting

  • git clone fails with an error about "LFS" or "smudge filter". Clone without the large files (the models of gene expression come from the download above anyway): cd ~ && GIT_LFS_SKIP_SMUDGE=1 git clone -b agentp-update-20261105 https://github.com/nhunghoang/agentp.git.
  • conda env create is very slow or runs out of memory. Use micromamba with the same file: micromamba create -f ~/agentp/environment.yml.
  • numpy or h5py errors after installing. AGENT-P was installed without --no-deps, and pip replaced conda's packages. Remove the environment (conda env remove -n agentp) and install again.
  • On a Mac: "incompatible architecture". The environment was created without CONDA_SUBDIR=osx-64. Remove it and create it again as above. The first run on a Mac can take a few extra minutes while Rosetta translates the programs.