Metadata-Version: 2.3
Name: inbreeding_calculator
Version: 1.0.0
Summary: Calculate the inbreeding coefficient of a pedigree in Python.
Project-URL: Homepage, https://github.com/Owen-Dechow/inbreeding-python
Author-email: Owen Dechow <owen.dechow@gmail.com>
License: MIT
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.0
Description-Content-Type: text/markdown

# inbreeding-python
Inbreeding Coefficient Calculator for Pedigrees in Python

## How to use

1. Create a python dictionary containing a pedigree.
    ```python
    # 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.
    ```python
    calculator = InbreedingCalculator(pedigree)
    ```
    or
    ```python
    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.
    ```python
    pedigree = {
    "Father": None,
    "Mother": None,
    "Name": "Billy"
    }
    
    calculator = InbreedingCalculator(pedigree, "Father", "Mother", "Name")
    ```
    or
    ```python
    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
    ```python
    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
    ```sh
    Inbreeding Coefficient: 0.25 (25.0%)
    ````

**If you use this code please give proper credit.**


**Thank you, [Owen Dechow](https://github.com/Owen-Dechow)!**
