Skip to main content

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

  1. 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 None or the key can be omitted all together.

  2. Import the InbreedingCalculator.

    from inbreeding_calculator import InbreedingCalculator
    
  3. Create an instance of the InbreedingCalculator class and load the pedigree.

    calculator = InbreedingCalculator(pedigree)
    

    or

    calculator = InbreedingCalculator()
    calculator.pedigree = pedigree
    
  4. Configure Calculator

    If you used keys other than sire, dam & id ensure you configure your InbreedingCalculator object 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"
    
  5. Use the get_coefficient method to find the inbreeding percentage

    pedigree = {
        "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


Download files

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

Source Distribution

inbreeding_calculator-1.0.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

inbreeding_calculator-1.0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

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

Hashes for inbreeding_calculator-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b73105fa9e30669b18aa804b0850ceab4c6984b23667e483f4da37ce777b096f
MD5 87195c3afa9606f59ff69cf8566e868c
BLAKE2b-256 b524c30e42a4e72eb8eb564bc6406962d752940b9e0613fe3a2073f676b430b2

See more details on using hashes here.

File details

Details for the file inbreeding_calculator-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for inbreeding_calculator-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 478547c650005d6557a3565f21dda0d764d5b4faf3b8db64cb8231ea5a379b5f
MD5 80e773b0120e8d368524c58ce5c7a9c5
BLAKE2b-256 7044c8b7824cb53fcd8e652a9abf5d3f166c53f627200b9952522925fff0ea8e

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