Skip to main content

mpedtools

Tools for working with PED and MPED (multi-phenotype PED) pedigree files. Read, write, validate, extract, merge, split, convert, and query pedigree data.

Installation

pip install mpedtools

Quick Start

Command line

# Show file summary
mpedtools info family.mped

# Validate a file
mpedtools validate family.ped

# Extract one phenotype from an MPED as a standard PED
mpedtools extract family.mped Breast_cancer -o breast_cancer.ped

# Extract all phenotypes as separate PED files
mpedtools extract-all family.mped -d ./output/

# Merge multiple PED files into one MPED
mpedtools merge pheno1.ped pheno2.ped -o combined.mped -n Condition_A Condition_B

# Split multi-family file into one file per family
mpedtools split multi_family.ped -d ./output/

# Convert between formats
mpedtools convert family.mped -f ped -o family.ped --phenotype Breast_cancer
mpedtools convert family.ped -f mped -o family.mped

# Add or remove phenotype columns
mpedtools add-phenotype family.mped New_condition -o updated.mped
mpedtools remove-phenotype family.mped Old_condition -o updated.mped

Python API

import mpedtools

# Read any PED or MPED file
ped = mpedtools.read("family.mped")

# Inspect
print(f"Families: {ped.families}")
print(f"Phenotypes: {ped.phenotype_names}")
print(f"Individuals: {len(ped.individuals)}")

# Summarise
print(mpedtools.summarise(ped))

# Validate
issues = mpedtools.validate(ped)
for issue in issues:
    print(f"[{issue.level}] {issue.message}")

# Query
affected = ped.get_affected("Breast_cancer")
carriers = ped.get_carriers("BRCA1")

# Extract single phenotype
breast = mpedtools.extract_phenotype(ped, "Breast_cancer")
mpedtools.write(breast, "breast.ped", force_format="ped")

# Merge
ped1 = mpedtools.read("condition_a.ped")
ped2 = mpedtools.read("condition_b.ped")
merged = mpedtools.merge([ped1, ped2], ["Condition_A", "Condition_B"])
mpedtools.write(merged, "combined.mped")

# Split families
families = mpedtools.split_families(ped)
for fam in families:
    mpedtools.write(fam, f"{fam.families[0]}.ped")

# Add/remove columns
updated = mpedtools.add_phenotype(ped, "New_condition", default_value=0)
trimmed = mpedtools.remove_phenotype(ped, "Old_condition")

# Parse from string
ped = mpedtools.parse(ped_text_string)

# Format to string
text = mpedtools.format_output(ped, force_format="mped")

MPED Format

The MPED (Multi-Phenotype PED) format extends the standard PED format for tracking multiple conditions. See MPED-SPECIFICATION-v1.0.md for the full specification.

Key differences from PED:

  • Header line declares format version and phenotype column names
  • Multiple phenotype columns (one per condition)
  • Code 3 = carrier (in addition to 0=unknown, 1=unaffected, 2=affected)
  • File extension: .mped

Supported Operations

Command Description
info Summary statistics for a PED or MPED file
validate Check file structure, parent references, sex codes
extract Pull one phenotype column into a standard PED file
extract-all Extract every phenotype as a separate PED file
merge Combine multiple PED files into one MPED
split Separate multi-family files into one file per family
convert Convert between PED and MPED formats
add-phenotype Add a new phenotype column
remove-phenotype Remove a phenotype column

License

MIT

Metadata

Release files for mpedtools 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mpedtools 0.1.0
File Size Uploaded Provenance Actions
mpedtools-0.1.0.tar.gz 13.5 kB Without provenance Details for mpedtools-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mpedtools 0.1.0
File Interpreter ABI Platform Actions
mpedtools-0.1.0-py3-none-any.whl Python 3 none any Details for mpedtools-0.1.0-py3-none-any.whl

Total release size: 27.6 kB

Release files / mpedtools-0.1.0.tar.gz

Download URL mpedtools-0.1.0.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a5222b48058800a84aca2ca1d5cabb01d5c685488ce94d284067971f85d43287
BLAKE2b-256 checksum
How to use checksums
0e9b30b903dbb480c051a7b56c0c8c7bdc02f1f0ebfe8d77657c685dc156006a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / mpedtools-0.1.0-py3-none-any.whl

Download URL mpedtools-0.1.0-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
608ade7306be2ef9a2d3c5af77656ecaada4d685ecff8bf9dc34e0382b484d04
BLAKE2b-256 checksum
How to use checksums
e1bf5609de1304797b5cfa898a928823539b669c066728c68402fc9b0cc0d207
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for mpedtools 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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