Skip to main content

No project description provided

Project description

PLINKFORMATTER

plinkformatter transforms genotype and phenotype inputs into PLINK-compatible artifacts for downstream linear mixed-model workflows (primarily PyLMM).

This repository is based on the original R workflow implemented in:

  • plinkformatter/IGNORE_misc/pyLMM_utils.R
  • tests/IGNORE_MISC/hao_v2/pyLMM_analysis_NonDO.R

The Python implementation keeps the same core workflow while improving maintainability, testability, and performance for large PED/MAP datasets.

Prerequisites

  • Python 3.8+
  • Poetry
  • PLINK 2.0 (required for PLINK integration tests and full pipeline runs)

Install dependencies:

poetry install

If plink2 is not on your PATH, set PLINK2_PATH explicitly.

PowerShell example:

$env:PLINK2_PATH = "C:\path\to\plink2.exe"

Running Tests

Run all commands from the repository root.

1) Fast test pass (no external PLINK dependency)

poetry run pytest -q tests/test_generate_pheno_plink_fast.py

2) PLINK utility tests

These include PLINK-facing behavior and may require a working plink2 binary.

poetry run pytest -q tests/test_plink_utils.py

3) Full test suite

poetry run pytest -q tests

Test output flags

  • -q: quiet output (compact summary)
  • -s: show stdout/stderr (print, logs written to console)

Example:

poetry run pytest -s -q tests/test_generate_pheno_plink_fast.py

Workflow Parity with R

The Python pipeline mirrors the same logical stages as the R scripts:

  1. Extract/normalize phenotype rows for selected measure IDs.
  2. Generate per-measure, sex-specific .ped/.map/.pheno files.
  3. Build .bed/.bim/.fam with PLINK.
  4. Align .pheno ordering to .fam and recompute rank-Z on retained samples.
  5. Compute kinship (PyLMM3 or PLINK-based path).

Performance Design (Large PED Files)

A major difference from older dataframe-heavy patterns is how PED is handled in generate_pheno_plink_fast.py:

  • It does not load the full PED into a pandas DataFrame.
  • It builds a compact byte-offset index (strain -> file position) once.
  • It seeks directly to needed PED rows and writes outputs in a streaming manner.

This avoids high memory usage and scales better for large genotype files than pandas.read_csv() on full PED content.

Publishing to PyPI

  1. Update version:
poetry version patch
  1. Build:
poetry build
  1. Configure repository and token:
poetry config repositories.pypi https://upload.pypi.org/legacy/
poetry config pypi-token.pypi pypi-YourActualTokenHere
  1. Publish:
poetry publish

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

plinkformatter-0.1.81.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

plinkformatter-0.1.81-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file plinkformatter-0.1.81.tar.gz.

File metadata

  • Download URL: plinkformatter-0.1.81.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.9.13 Windows/10

File hashes

Hashes for plinkformatter-0.1.81.tar.gz
Algorithm Hash digest
SHA256 7a768cd4db02a26f0fbd037a99049a471241c5566879e60b8d1f87464f2402b2
MD5 64ac62155901dff413cab50e89daa4f1
BLAKE2b-256 4da386a8e026da15116ceb52b7965b55a3cbc39d3f485e72b7f85b4b492c436a

See more details on using hashes here.

File details

Details for the file plinkformatter-0.1.81-py3-none-any.whl.

File metadata

  • Download URL: plinkformatter-0.1.81-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.9.13 Windows/10

File hashes

Hashes for plinkformatter-0.1.81-py3-none-any.whl
Algorithm Hash digest
SHA256 c2c8a3493c2d74e663e8e5c5fb49d2bff8b81a687f76e218fc439a97c222f558
MD5 21d9a2863e68bc4db204110c3c75c9e9
BLAKE2b-256 46ba5da383a1193424a2b88b27262df63e5ae21a165b3dfe1fab1cbd06bab59a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page