Skip to main content

Polyploid Population Genomics Tool Kit (ppgtk)

CI

Python package for polyploid population genomics analyses and data exploration

Disclaimer

This package is in early developmental stages and a lot of functionality and specific commands are still a work in progress. The classify-ploidy method does work and has been vetted against several test datasets. Publication of the methods are anticipated in the near future but made available in case it is helpful for some exploratory analyses.

Installation

Conda Install

conda env create -f environment.yml
conda activate ppgtk

The environment.yml file was created from the ppgtk development environment with conda env export --from-history > environment.yml.

Pip Install

A pip installation can be done system-wide or within a new conda/venv environment. The recommended install path is to install from package metadata so dependency resolution stays platform-aware. This install path is tested on Python 3.11 and 3.12 across Ubuntu and macOS. The Windows installation is currently not working due to a limitation of a dependency for reading VCF files, but we are working towards a native parser to allow windows compatibility. If Windows is necessary for you, please submit an issue and it will happen faster.

python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel
python -m pip install .

If you need a fully pinned developer environment, requirements.txt is still available, but pinned transitive dependencies can be less portable across operating systems.

Ploidy Classification

The ploidy classification method can be implemented as a single command-line program after successful installation. To bring up the program options, you can look at the help menu:

ppgtk classify-ploidy --help

And an example analysis would look like this:

ppgtk classify-ploidy -v input.vcf -o results metadata.csv

Note that the metadata file comes at the end without a flag. This is by design. All commands in ppgtk require a metadata file, which has a minimal format. Only three columns are needed:

individual, population, ploidy
sample_1, pop_A, 2
sample_2, pop_A, 2
sample_3, pop_A, NA
...
sample_n, pop_B, 4

Missing values are accepted for ploidy. Missing values should only be encoded as "NA". Other numbers that are not an expected ploidy will be treated as a seperate class in the regression model.

The population field is used when calculating population genetic statistics, but it does not matter for the classify-ploidy method. If you do not have a priori or data-driven population assignments, that is fine. You could simply duplicate the individual names or assign all individuals to a single placeholder population, such as "pop_A".

Classifier accuracy metrics

The ploidy classifier (logistic regression) prints and writes several performance artifacts when run via the logistic_regression entrypoint. These are produced by the cross_validate_logistic_regression and evaluate_logistic_regression_model helpers and can be found in the output directory when provided.

  • logistic_regression_cv_accuracy.csv — a single-row table with summary metrics:

    • accuracy: overall fraction of correctly classified samples
    • balanced_accuracy: per-class recall averaged equally across classes (useful for imbalanced label sets)
    • macro_f1: unweighted mean of per-class F1 scores
    • weighted_f1: mean of per-class F1 scores weighted by support (class prevalence)
  • logistic_regression_cv_report.csv — the full sklearn classification report (precision / recall / f1 / support) for each class. Use this to inspect per-ploidy performance.

  • logistic_regression_cv_confusion_matrix.csv — confusion matrix (rows = true labels, columns = predicted labels) showing raw classification counts.

  • logistic_regression_predictions.csv — per-sample results including:

    • known_ploidy (when available), predicted_ploidy
    • probability columns named prob_<class_label> for class-wise predicted probabilities

Interpreting the metrics:

  • Use balanced_accuracy and macro_f1 when classes are imbalanced to avoid dominance by the largest class.
  • weighted_f1 is helpful when you want a single F1 that reflects the dataset's class proportions.
  • The confusion matrix and per-class precision/recall help identify which ploidy levels are being confused by the model.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ppgtk-0.1.0.tar.gz (58.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ppgtk-0.1.0-py3-none-any.whl (62.1 kB view details)

Uploaded Python 3

File details

Details for the file ppgtk-0.1.0.tar.gz.

File metadata

  • Download URL: ppgtk-0.1.0.tar.gz
  • Upload date:
  • Size: 58.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for ppgtk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e466fb7bae2f8fcb44d4f71167feec5ca016fb646b3e53e7148ca52fdf61d950
MD5 5dd493bab4fe54c2655e393549792d5b
BLAKE2b-256 abb5690be7d0e62f57af36068d4c516d063264b8f6e982711a137b4f42aaeda2

See more details on using hashes here.

File details

Details for the file ppgtk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ppgtk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 62.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for ppgtk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ad91381bbd96d2ecf9c80196ad4907f8de527091849834b401192d972c6b071
MD5 8a82ea9bcfa2dd5f4d079c75377f9c34
BLAKE2b-256 170ce383f50e653a0e47babeea6df852120a417b48a460e81efb8f5fe76d311b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page