Skip to main content

Reconstruct (ancient) pedigrees from pairwise kinship relations.

Project description

🌲 repare is a Python package for (ancient) pedigree reconstruction.

Installation

Recommended

curl -O https://raw.githubusercontent.com/ehuangc/repare/main/repare-environment.yml
conda env create -f repare-environment.yml
conda activate repare

repare uses PyGraphviz to plot reconstructed pedigrees. Since PyGraphviz relies on Graphviz which cannot be installed using pip, we recommend installing repare and its dependencies in a fresh conda environment, as shown above. This conda-based installation method automatically installs Graphviz and ensures PyGraphviz is linked to it.

To install conda, see this page.

Other

If you don't need to plot reconstructed pedigrees, you can install repare directly with pip install repare. If you need to plot reconstructed pedigrees but have your own Graphviz installation, you can install repare and Pygraphviz (and not Graphviz) with pip install repare[plot].

To install PyGraphviz and Graphviz (yourself), see this page.

Usage

We recommend running repare through its command-line interface.

repare -n NODES -r RELATIONS [-o OUTPUT] [-m MAX_CANDIDATE_PEDIGREES] [-e EPSILON] [-s SEED] [-d] [-w] [-v]

[!NOTE] Minimal command:

repare -n nodes.csv -r relations.csv

For example data inputs, see examples/nodes.csv and examples/relations.csv.

Inputs

Nodes (-n) (required): Path to a CSV file that contains information about the individuals to be analyzed by repare.

Nodes CSV file columns
  • id (required): ID of individual. Cannot be fully numeric, as numeric IDs are reserved for placeholder nodes.
  • sex (required): Genetic sex of individual. Value must be "M" or "F".
  • y_haplogroup (required): Y chromosome haplogroup of individual. Can include "*" as a wildcard expansion character at the end if haplogroup is not fully inferred.
  • mt_haplogroup (required): Mitochondrial haplogroup of individual. Can include "*" as a wildcard expansion character at the end if haplogroup is not fully inferred.
  • can_have_children (optional): Whether the individual can have offspring (e.g., as indicated by age of death). If provided, value must be "True" or "False". Defaults to "True".
  • can_be_inbred (optional): Whether the individual can have parents related at the 3rd-degree or closer (e.g., as indicated by ROH). If provided, value must be "True" or "False". Defaults to "True".
  • years_before_present (optional): (Approximate) date of birth of individual, in years before present. If provided, will be used to prune temporally invalid pedigrees. This column should only be used when backed by strong dating evidence.

Relations (-r) (required): Path to a CSV file that contains information about inferred pairwise kinship relations. Methods to infer these kinship relations include KIN and READv2. All individuals included in this file must be specified in the nodes CSV.

Relations CSV file columns
  • id1 (required): ID of individual 1.
  • id2 (required): ID of individual 2.
  • degree (required): Degree of (inferred) kinship relation between individual 1 and individual 2. Value must be "1", "2", or "3". Higher-degree relatives are considered unrelated.
  • constraints (optional): Semicolon-delimited list of possible configurations of kinship relation. For example, a parental 1st-degree relation can be constrained with "parent-child;child-parent". Many kinship inference methods will classify 1st-degree relation types, which can be used as relation constraints. Valid constraints: "parent-child", "child-parent", "siblings", "maternal aunt/uncle-nephew/niece", "maternal nephew/niece-aunt/uncle", "paternal aunt/uncle-nephew/niece", "paternal nephew/niece-aunt/uncle", "maternal grandparent-grandchild", "maternal grandchild-grandparent", "paternal grandparent-grandchild", "paternal grandchild-grandparent" "maternal half-siblings", "paternal half-siblings", "double cousins".
  • force_constraints (optional): Whether the corresponding constraint should be forced. If provided, value must be "True" or "False". If "True", the constraint must be followed. If "False", breaking the constraint counts as one inconsistency. Defaults to "False".

Output (-o) (optional): Path to directory for saving repare outputs. Defaults to the current working directory.

Max Candidate Pedigrees (-m) (optional): Maximum number of candidate pedigrees to keep after each algorithm iteration. Defaults to 1000.

Epsilon (-e) (optional): Parameter for adapted epsilon-greedy sampling at the end of each algorithm iteration. Defaults to 0.2.

Seed (-s) (optional): Random seed for reproducibility. Defaults to 42.

Do Not Plot (-d) (flag): If set, do not plot reconstructed pedigree(s).

Write Alternate Pedigrees (-w) (flag): If set, write outputs for alternate reconstructed pedigrees. These pedigrees share the same number of inconsistencies and 3rd-degree "tiebreaker" inconsistencies as the primary output pedigree. Also write the kinship relations that are constant across the primary and all alternate pedigrees.

Verbose (-v) (flag): If set, enable verbose output (INFO-level logging).

[!TIP] Run repare --print-allowed-constraints to print a list of allowed relation constraint strings directly from the CLI.

Reconstruction Process Diagram
Diagram of repare's pedigree reconstruction process

Reproducibility

We recommend using Pixi to reproduce the results in this repo.

git clone https://github.com/ehuangc/repare.git
cd repare
pixi shell

Once in the Pixi shell, you can run the script(s) corresponding to the results you'd like to reproduce. For example:

python benchmarks/published/run_parameter_experiment.py
exit

To install Pixi, see this page.

Citation

If you use repare in your work, please cite our preprint:

Huang, E. C., Li, K. A., & Narasimhan, V. M. (2025). Fault-tolerant pedigree reconstruction from pairwise kinship relations. bioRxiv. https://doi.org/10.1101/2025.08.21.671608

@article{repare_preprint2025,
  doi     = {10.1101/2025.08.21.671608},
  author  = {Huang, Edward C. and Li, Kevin A. and Narasimhan, Vagheesh M.},
  title   = {Fault-tolerant pedigree reconstruction from pairwise kinship relations},
  journal = {bioRxiv},
  month   = {aug},
  year    = {2025},
  url     = {https://doi.org/10.1101/2025.08.21.671608},
}

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

repare-0.1.7.tar.gz (5.8 MB view details)

Uploaded Source

Built Distribution

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

repare-0.1.7-py3-none-any.whl (28.0 kB view details)

Uploaded Python 3

File details

Details for the file repare-0.1.7.tar.gz.

File metadata

  • Download URL: repare-0.1.7.tar.gz
  • Upload date:
  • Size: 5.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for repare-0.1.7.tar.gz
Algorithm Hash digest
SHA256 9c24608a92eab2f5cf05cdba42743c1269023c35a8dc70ff6ef6638dcea73c1a
MD5 f29e73976232b3a951ed131c4c367b12
BLAKE2b-256 7b0f835522ba68b1d9b4143ad5446143f3a9a5258cf7ef71ed92a62532d078a9

See more details on using hashes here.

File details

Details for the file repare-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: repare-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 28.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for repare-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 fdacc08ffdbb954e6378571ce5a7c1c559612474faeab8a06f44d3b995525a73
MD5 2ec855b9dac5677b0cfbebabdbdf885b
BLAKE2b-256 e332ae8f3947fd2e8ea2bd039ff7cf2d9eb6b893f242947ac99bd12ff57953f4

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