Calculate the inbreeding coefficient of a pedigree in Python.
Project description
inbreeding-calculator
Inbreeding Coefficient Calculator for Pedigrees in Python
Installation
pip install inbreeding-calculator
How to use
-
Create a python dictionary containing a pedigree.
# Pedigree example with 0.25 inbreeding coefficient (25%) pedigree = { "sire": { "sire": None, "dam": None, "id": "2834", }, "dam": { "sire": { "sire": None, "dam": None, "id": "2834", }, "dam": None, "id": "781", }, "id": "622", }
All animals in pedigree must have a unique id. If the sire/dam of an animal is unknown the value can be set to
Noneor the key can be omitted all together. -
Import the
InbreedingCalculator.from inbreeding_calculator import InbreedingCalculator
-
Create an instance of the
InbreedingCalculatorclass and load the pedigree.calculator = InbreedingCalculator(pedigree)
or
calculator = InbreedingCalculator() calculator.pedigree = pedigree
-
Configure Calculator
If you used keys other than
sire,dam&idensure you configure yourInbreedingCalculatorobject for them.pedigree = { "Father": None, "Mother": None, "Name": "Billy" } calculator = InbreedingCalculator(pedigree, "Father", "Mother", "Name")
or
calculator = InbreedingCalculator(pedigree) calculator.sire_key = "Father" calculator.dam_key = "Mother" calculator.id_key = "Name"
-
Use the
get_coefficientmethod to find the inbreeding percentagepedigree = { "sire": { "sire": None, "dam": None, "id": "2834", }, "dam": { "sire": { "sire": None, "dam": None, "id": "2834", }, "dam": None, "id": "781", }, "id": "622", } calculator = InbreedingCalculator(pedigree) ic = calculator.get_coefficient() print(f"Inbreeding Coefficient: {ic} ({ic * 100}%)")
Output
Inbreeding Coefficient: 0.25 (25.0%)
If you use this code please give proper credit.
Thank you, Owen Dechow!
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file inbreeding_calculator-1.0.1.tar.gz.
File metadata
- Download URL: inbreeding_calculator-1.0.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b73105fa9e30669b18aa804b0850ceab4c6984b23667e483f4da37ce777b096f
|
|
| MD5 |
87195c3afa9606f59ff69cf8566e868c
|
|
| BLAKE2b-256 |
b524c30e42a4e72eb8eb564bc6406962d752940b9e0613fe3a2073f676b430b2
|
File details
Details for the file inbreeding_calculator-1.0.1-py3-none-any.whl.
File metadata
- Download URL: inbreeding_calculator-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
478547c650005d6557a3565f21dda0d764d5b4faf3b8db64cb8231ea5a379b5f
|
|
| MD5 |
80e773b0120e8d368524c58ce5c7a9c5
|
|
| BLAKE2b-256 |
7044c8b7824cb53fcd8e652a9abf5d3f166c53f627200b9952522925fff0ea8e
|