Skip to main content

Calculate the inbreeding coefficient of a pedigree in Python.

Project description

inbreeding-python

Inbreeding Coefficient Calculator for Pedigrees in Python

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. Create an instance of the InbreedingCalculator class and load the pedigree.

    calculator = InbreedingCalculator(pedigree)
    

    or

    calculator = InbreedingCalculator()
    calculator.pedigree = pedigree
    
  3. 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"
    
  4. 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.0.tar.gz (4.5 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.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file inbreeding_calculator-1.0.0.tar.gz.

File metadata

  • Download URL: inbreeding_calculator-1.0.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for inbreeding_calculator-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f5b1d519ceeae98b6570d7cd60ee7699fd0722d36bbc9f8c8f8a733c1839328e
MD5 ba5199f6e1aac384d880eff8c74201a0
BLAKE2b-256 549dede72f485284557a9a80c86b049c97524f1839ea750b4977b3d093286908

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for inbreeding_calculator-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a00b4e2694c106804c412abf495f58ece8fe3bc7bd59a4db20d787eef99d11f
MD5 779b6986c717efee5eff3332c0416387
BLAKE2b-256 d05ae2d02628d491adf6706de4d688d14e182b57ba4583453a7cb507a92117a8

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