Skip to content
kalininalabPublic

About

Automated Learning Pipeline for Antimicrobial Resistance

Topics

Resources

Stars

13 stars

Watchers

1 watching

Forks

Repository files navigation

ALPAR - Automated Learning Pipeline for Antimicrobial Resistance

Automated Learning Pipeline for Antimicrobial Resistance

Pipeline

Installation

Single-Reference AMR is installable from conda using mamba:

Note: conda 26.x has a bug that prevents creating environments with pip packages; use conda 24.11. ALPAR supports Python 3.12 and 3.13.

To install it into the new environment:

mamba create -n alpar -c conda-forge -c kalininalab -c bioconda -c etetoolkit alpar
conda activate alpar

Or to install it into the already existing environment:

mamba install -c conda-forge -c kalininalab -c bioconda -c etetoolkit alpar

Tool Environments

The alpar environment only contains the ALPAR package itself. Each external tool runs in its own conda environment, defined in sr_amr/envs/. These are created automatically on first use (conda env create) and ALPAR re-runs the relevant step inside them with conda run, so you do not need to install the tools yourself.

Environment Used by Key pinned versions
alpar-snippy variant calling snippy 4.6.0
alpar-prokka annotation prokka 1.14.6, perl-xml-simple
alpar-bakta annotation bakta 1.12.0, diamond 2.1.25
alpar-panaroo gene presence-absence panaroo 1.6.0
alpar-cd-hit gene presence-absence cd-hit 4.8.1
alpar-mashtree phylogenetic_tree mashtree 1.4.6, mash 2.3
alpar-panacota panacota PanACoTA 1.4.0, prokka 1.14.6, Python 3.7
alpar-pyseer gwas pyseer 1.4.0
alpar-prps prps ete3 3.1.3
alpar-ml ml scikit-learn 1.8.0, xgboost 3.2.0
alpar-datasail train/test splitting datasail 1.3.0

Notes:

  • Versions are pinned so results do not change between rebuilds. To rebuild an environment, remove it (conda env remove -n alpar-prokka) and run ALPAR again.
  • Use conda 24.11; conda 26.x cannot create environments containing pip packages.
  • The main alpar environment must use Python 3.12 or 3.13. alpar-panacota runs Python 3.7 and cannot read pickle protocol 5 files written by Python 3.14.

Example Files

Example files can be downloaded from:

Example files

Automatic Pipeline

From genomic files, creates binary mutation and phenotype tables, applies thresholds, creates phylogenetic tree, conducts GWAS analysis, calculates PRPS score and trains machine learning models with conducting feature importance analysis and splitting data aginst information leakage with DataSAIL against all the given antibiotics.

  • Input, -i: Path of folder that have structure: input_folder -> antibiotic -> [Resistant, Susceptible]

    📦input_folder
    ┣ 📂antibiotic1
    ┃ ┣ 📂Resistant
    ┃ ┃ ┣ 📜fasta1.fna
    ┃ ┃ ┗ 📜fasta2.fna
    ┃ ┃ ┗ ...
    ┃ ┗ 📂Susceptible
    ┃ ┃ ┣ 📜fasta3.fna
    ┃ ┃ ┗ 📜fasta4.fna
    ┃ ┃ ┗ ...
    ┗ 📂antibiotic2
    ┃ ┣ 📂Resistant
    ┃ ┃ ┣ 📜fasta2.fna
    ┃ ┃ ┗ 📜fasta5.fna
    ┃ ┃ ┗ ...
    ┃ ┗ 📂Susceptible
    ┃ ┃ ┣ 📜fasta2.fna
    ┃ ┃ ┗ 📜fasta3.fna
    ┃ ┃ ┗ ...
    ┗ 📂...
  • Output, -o: Output folder path, where the output will be stored. If path exist, --overwrite option can be used to overwrite existing output.

  • Reference, --reference: Reference file path, accepted file formats are: .gbk .gbff

  • Custom database (Optional), --custom_database: Fasta file path for protein database creation, can be downloaded from UniProt accepted file formats are: .fasta

Basic usage:

alpar automatix -i example/example_files/ -o example/example_output/ --reference example/reference.gbff

Create Binary Tables

From genomic files, creates binary mutation and phenotype tables

  • Input, -i: Path of file that contains path of genomic fasta files per line or path of folder that have structure: input_folder -> antibiotic -> [Resistant, Susceptible]

    📦input_folder
    ┣ 📂antibiotic1
    ┃ ┣ 📂Resistant
    ┃ ┃ ┣ 📜fasta1.fna
    ┃ ┃ ┗ 📜fasta2.fna
    ┃ ┃ ┗ ...
    ┃ ┗ 📂Susceptible
    ┃ ┃ ┣ 📜fasta3.fna
    ┃ ┃ ┗ 📜fasta4.fna
    ┃ ┃ ┗ ...
    ┗ 📂antibiotic2
    ┃ ┣ 📂Resistant
    ┃ ┃ ┣ 📜fasta2.fna
    ┃ ┃ ┗ 📜fasta5.fna
    ┃ ┃ ┗ ...
    ┃ ┗ 📂Susceptible
    ┃ ┃ ┣ 📜fasta2.fna
    ┃ ┃ ┗ 📜fasta3.fna
    ┃ ┃ ┗ ...
    ┗ 📂...
  • Output, -o: Output folder path, where the output will be stored. If path exist, --overwrite option can be used to overwrite existing output.

  • Reference, --reference: Reference file path, accepted file formats are: .gbk .gbff

  • Custom database (Optional), --custom_database: Fasta file path for protein database creation, can be downloaded from UniProt accepted file formats are: .fasta

  • Creation of phenotype table (Optional):

    • --create_phenotype_from_folder should be used
    • Genomes_folder_path should have a structure: input_folder -> antibiotic -> [Resistant, Susceptible] -> genomic fasta files
    📦input_folder
    ┣ 📂antibiotic1
    ┃ ┣ 📂Resistant
    ┃ ┃ ┣ 📜fasta1.fna
    ┃ ┃ ┗ 📜fasta2.fna
    ┃ ┃ ┗ ...
    ┃ ┗ 📂Susceptible
    ┃ ┃ ┣ 📜fasta3.fna
    ┃ ┃ ┗ 📜fasta4.fna
    ┃ ┃ ┗ ...
    ┗ 📂antibiotic2
    ┃ ┣ 📂Resistant
    ┃ ┃ ┣ 📜fasta2.fna
    ┃ ┃ ┗ 📜fasta5.fna
    ┃ ┃ ┗ ...
    ┃ ┗ 📂Susceptible
    ┃ ┃ ┣ 📜fasta2.fna
    ┃ ┃ ┗ 📜fasta3.fna
    ┃ ┃ ┗ ...
    ┗ 📂...

Basic usage:

alpar create_binary_tables -i example/example_files/ -o example/example_output/ --reference example/reference.gbff

Binary Table Threshold

Applies threshold to binary mutation table, and drops columns that has less than threshold percentage, useful to reduce sequencing errors in the data.

  • Input, -i: Binary mutation table path

  • Output, -o: Output folder path, where the output will be stored. If path exist, --overwrite option can be used to overwrite existing output.

  • Threshold percentage, --threshold_percentage: Threshold percentage value to be used to drop columns. If column sum is less than this value, columns will be deleted from table

Basic usage:

alpar binary_tables_threshold -i example/example_output/binary_mutation_table.tsv -o example/example_output/ 

Phylogenetic Tree

Runs Phylogeny pipeline to create phylogenetic tree. (Alignment free)

  • Input, -i: Text file that contains path of each strain per line. It can be found in create_binary_tables output path as strains.txt

  • Output, -o: Output folder path, where the output will be stored. If path exist, --overwrite option can be used to overwrite existing output.

  • Random names dictionary path, --random_names_dict: Random names text file path. If not provided, strain's original names will be used for phylogenetic tree

Basic usage:

alpar phylogenetic_tree -i example/example_output/strains.txt -o example/example_output/ --random_names_dict example/example_output/random_names.txt 

Panacota

Runs PanACoTA pipeline to create phylogenetic tree. (Alignment based)

  • Input, -i: Text file that contains path of each strain per line. It can be found in create_binary_tables output path as strains.txt

  • Output, -o: Output folder path, where the output will be stored. If path exist, --overwrite option can be used to overwrite existing output.

  • Random names dictionary path, --random_names_dict: Random names text file path. If not provided, strain's original names will be used for phylogenetic tree

Basic usage:

alpar panacota -i example/example_output/strains.txt -o example/example_output/

GWAS

Runs GWAS analysis to detect important mutations in the data.

  • Input, -i: Binary mutation table path that is created via create_binary_tables command, can be found in create_binary_tables output path as binary_mutation_table_with_gene_presence_absence.tsv or binary_mutation_table.tsv or if threshold applied, can be found in binary_table_threshold output path as binary_mutation_table_threshold_*_percent.tsv

  • Phenotype, -p: Binary phenotype table path, can be found in create_binary_tables output path as phenotype_table.tsv if --create_phenotype_from_folder is used. Can also created manually and used.

  • Tree, -t : Phylogenetic tree path, can be found in panacota output path as phylogenetic_tree.newick or phylogeny output path as phylogenetic_tree.tree

  • Output, -o: Output folder path, where the output will be stored. If path exist, --overwrite option can be used to overwrite existing output.

Basic usage:

alpar gwas -i example/example_output/binary_mutation_table_with_gene_presence_absence.tsv -p example/example_output/phenotype_table.tsv -t example/example_output/phylogeny/phylogenetic_tree.tree -o example_output/

PRPS

Runs PRPS (Phylogeny-Related Parallelism Score) to detect the mutations are more likely associated with phylogeny rather than antimicrobial resistance.

  • Input, -i: Binary mutation table path that is created via create_binary_tables command, can be found in create_binary_tables output path as binary_mutation_table.tsv or if threshold applied, can be found in binary_table_threshold output path as binary_mutation_table_threshold_*_percent.tsv

  • Tree, -t : Phylogenetic tree path, can be found in panacota output path as phylogenetic_tree.newick or phylogeny output path as phylogenetic_tree.tree

  • Output, -o: Output folder path, where the output will be stored. If path exist, --overwrite option can be used to overwrite existing output.

Basic usage:

alpar prps -i example/example_output/binary_mutation_table.tsv -t example/example_output/phylogeny/phylogenetic_tree.tree -o example_output/

ML

Trains machine learning models with classification algorithms on the data and optimizes.
Available Classification algorithms: Random Forest, Support Vector Machine and Gradient Boosting

  • Input, -i: Binary mutation table path that is created via create_binary_tables command, can be found in create_binary_tables output path as binary_mutation_table_with_gene_presence_absence.tsv or binary_mutation_table.tsv

  • Phenotype, -p: Binary phenotype table path, can be found in create_binary_tables output path as phenotype_table.tsv if --create_phenotype_from_folder is used. Can also created manually and used.

  • Output, -o: Output folder path, where the output will be stored. If path exist, --overwrite option can be used to overwrite existing output.

  • Antibiotic, -a: Antibiotic name that model will be trained. Should match the name with column that represents phenotype in binary phenotype table

  • Optional arguments:

    • Machine learning algorithm, --ml_algorithm: Classification algorithm to be used, available selections: [rf, svm, gb]
    • Resampling strategy, --resampling_strategy: Resampling strategy to be used, available selections: [holdout, cv]
    • Parameter optimization, --parameter_optimization: Parameter optimization for model with autosklearn (https://automl.github.io/auto-sklearn/master/index.html)
    • Save model, --save_model: Save model
    • Feature importance analysis, --feature_importance_analysis: Analyze important features in the model with gini importance (for RF & GB) or permutation importance (for SVM, RF and GB)
    • Datasail, --sail: Splits data into training and test sets against information leakage to train better models. Requires text file that contains path of each strain per line. It can be found in create_binary_tables output path as strains.txt

    More optional arguments can be found in help page:

    python alpar/sr_amr.py ml -h

Basic usage:

alpar ml -i example/example_output/binary_mutation_table.tsv -p example/example_output/phenotype_table.tsv -o example_output/ -a amikacin

Citation

If you use ALPAR, please cite:

Yurtseven A, Joeres R, Kalinina OV. ALPAR: automated learning pipeline for antimicrobial resistance. Bioinformatics 2026; 42(8):btag545. doi:10.1093/bioinformatics/btag545
Article: https://doi.org/10.1093/bioinformatics/btag545

Plain text

Yurtseven A, Joeres R, Kalinina OV. ALPAR: automated learning pipeline for antimicrobial resistance. Bioinformatics 2026; 42(8):btag545. doi:10.1093/bioinformatics/btag545

BibTeX

@article{ALPAR_2026,
  title   = {ALPAR: automated learning pipeline for antimicrobial resistance},
  author  = {Yurtseven, Alper and Joeres, Roman and Kalinina, Olga V.},
  year    = {2026},
  journal = {Bioinformatics},
  volume  = {42},
  number  = {8},
  pages   = {btag545},
  doi     = {10.1093/bioinformatics/btag545},
  url     = {https://doi.org/10.1093/bioinformatics/btag545}
}

About

Automated Learning Pipeline for Antimicrobial Resistance

Topics

Resources

Stars

13 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages