Skip to main content

Convert PED and MPED pedigree files to Pedigree Studio session JSON

Project description

ped2studio

Convert standard PED pedigree files into Pedigree Studio session JSON files.

Installation

pip install ped2studio

Or use the standalone script (ped2studio_standalone.py) with no installation required — it needs only Python 3.9+.

Usage

Command line

# Basic conversion (standard PED)
ped2studio family.ped family.json

# MPED file (auto-detected, each phenotype gets its own colour)
ped2studio family.mped family.json

# Use a specific colour for affected individuals (single-phenotype only)
ped2studio family.ped family.json --colour "#c0392b"

# Use left-half fill instead of full shape
ped2studio family.ped family.json --fill half

# Combine half fill with a colour
ped2studio family.ped family.json --fill half --colour "#c0392b"

# Use shading pattern instead of colour
ped2studio family.ped family.json --shading --pattern stripes

# Use half-shape dot shading
ped2studio family.ped family.json --shading --pattern dots --fill half

Python API

import ped2studio

# From a PED string (default: full solid black)
session = ped2studio.convert(ped_text)

# From an MPED string (auto-detected, multi-colour)
session = ped2studio.convert(mped_text)

# From file to file (works with both .ped and .mped)
ped2studio.convert_file("family.mped", "family.json")

# With options (single-phenotype files only)
session = ped2studio.convert(
    ped_text,
    affected_color="#c0392b",   # colour for affected (when not using shading)
    fill_type="half",           # 'full' or 'half'
    use_shading=True,           # use pattern instead of colour
    shading_pattern="stripes",  # 'stripes' or 'dots'
)

Standalone script

python ped2studio_standalone.py family.ped family.json
python ped2studio_standalone.py family.ped family.json --fill half --colour "#c0392b"
python ped2studio_standalone.py family.ped family.json --shading --pattern dots --fill half

MPED Support

MPED (Multi-Phenotype PED) files are automatically detected and handled. When an MPED file has multiple phenotype columns, each phenotype is assigned a distinct colour from the Pedigree Studio palette and a legend is generated mapping colours to phenotype names.

Visual mapping for multi-phenotype files:

Individual Status Pedigree Studio Rendering
Affected for 1 phenotype Solid fill with that phenotype's colour
Affected for 2-4 phenotypes Quartered fill with each phenotype's colour
Carrier for 1 phenotype Half fill (left) with that phenotype's colour
Carrier column = 3 Centre dot (●)
Unaffected No fill

For single-phenotype MPED files, the --color, --fill, and --shading options work as normal.

PED file format

The tool reads the standard 6-column PED format:

FamilyID  IndividualID  FatherID  MotherID  Sex  Phenotype
Column Description
FamilyID Family identifier (preserved but not used for grouping)
IndividualID Unique identifier for the individual
FatherID Father's IndividualID, or 0 if unknown
MotherID Mother's IndividualID, or 0 if unknown
Sex 1 = male, 2 = female, 0 = unknown
Phenotype 2 = affected, 1 = unaffected, 0 or -9 = unknown

Additional columns beyond column 6 (e.g. genotype data) are ignored. Lines starting with # are treated as comments. Both tab and space delimiters are supported.

How it works

  1. Parse the PED file into individuals with parent references
  2. Build mating units (each unique father+mother pair with their children)
  3. Assign generations (founders = generation 0, children = max parent generation + 1)
  4. Layout individuals using Pedigree Studio's default spacing (partner gap = 104px, child height = 130px, sibling spacing = 104px)
  5. Emit a Pedigree Studio v4 session JSON with persons, partnerships, child links, and legend

The output can be imported directly into Pedigree Studio via the Import JSON button. Positions may need manual adjustment for complex pedigrees.

Mapping to Pedigree Studio features

PED field Pedigree Studio feature
Sex = 1 male shape (square)
Sex = 2 female shape (circle)
Sex = 0 unknown shape (diamond)
Phenotype = 2 Solid colour fill, half colour fill, or shading pattern (configurable via --fill, --color, --shading, --pattern)
Phenotype = 1 No fill
Father+Mother pair Partnership line
Child of a pair Child link from partnership to individual

License

MIT

Project details


Download files

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

Source Distribution

ped2studio-0.2.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

ped2studio-0.2.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file ped2studio-0.2.0.tar.gz.

File metadata

  • Download URL: ped2studio-0.2.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for ped2studio-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c530c12ee0be347ec4302a8cdd3eee92ed9fbc889023762c5d5f920996ec7cf1
MD5 dea16f592356b179027987fba28f7cc0
BLAKE2b-256 4b11da4235136f5378386b3cba9f37c1b964437b8ba328e60e5d4d421cfc7cfa

See more details on using hashes here.

File details

Details for the file ped2studio-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ped2studio-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for ped2studio-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e2008d70df038d871edfef5fc86a0a5e7f6d088b774348922456b520525fdc1
MD5 61dd398ad7839569bddbd465fce9505e
BLAKE2b-256 64af00c5735ac8d1b028ab78fa92aba00b02e4986a13446e3f000a49934fc1be

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