Skip to main content

lineage

ci codecov docs pypi python downloads license ruff

lineage

tools for analyzing and exploring genetic relationships 🧬

lineage strives to be an easy-to-use and accessible open-source library for genetic genealogy

Features

Shared DNA Analysis

  • Find shared DNA between individuals using genetic maps from the HapMap Project and 1000 Genomes Project
  • Compute centiMorgans (cMs) of shared DNA with configurable thresholds
  • Detect IBD1 (half-identical) and IBD2 (fully identical) regions
  • Visualize shared DNA segments across all chromosomes
  • Find discordant SNPs inconsistent with Mendelian inheritance patterns

Shared Gene Analysis

  • Identify genes shared between individuals with the same genetic variations
  • Determine which genes produce the same proteins across related individuals

Synthetic Data Generation

  • Generate realistic synthetic genotype data for related individuals
  • Create parent-child pairs with proper single-allele inheritance
  • Create sibling pairs with realistic meiotic recombination patterns

Supported Genotype Files

lineage supports all genotype files supported by snps.

Installation

lineage is available on the Python Package Index. Install lineage (and its required Python dependencies) via pip:

$ pip install lineage

Examples

The examples below demonstrate the core features of lineage. For detailed explanations of genetic concepts like IBD (Identity By Descent), centiMorgans, and how to interpret results, see the Concepts Guide.

Optional: To see file save notifications, configure logging before running examples:

import logging
logging.basicConfig(level=logging.INFO, format='%(message)s')

To try these examples, first generate some sample data:

>>> from lineage import Lineage
>>> l = Lineage()
>>> paths = l.create_example_datasets()

Load Individuals

Load genotype files and create Individual objects:

>>> parent = l.create_individual('Parent', paths['parent'])
>>> child = l.create_individual('Child', paths['child'])

Each Individual inherits from snps.SNPs, providing access to all SNPs properties and methods:

>>> parent.build
37
>>> parent.assembly
'GRCh37'
>>> parent.count
899992

Find Discordant SNPs

Identify SNPs inconsistent with Mendelian inheritance between parent and child:

>>> discordant_snps = l.find_discordant_snps(parent, child, save_output=True)  # doctest: +SKIP

The example datasets include a small number of simulated genotyping errors (~0.01%) to demonstrate discordant SNP detection.

Find Shared DNA

Parent-Child Example

Compute shared DNA segments and generate a visualization:

>>> results = l.find_shared_dna([parent, child])  # doctest: +SKIP

For parent-child relationships, all shared DNA appears on one chromosome only (IBD1), representing the chromosome inherited from that parent (~3400-3700 cM total):

Parent-Child shared DNA

Sibling Example

Analyze siblings using a population-specific genetic map:

>>> sibling1 = l.create_individual('Sibling1', paths['sibling1'])  # doctest: +SKIP
>>> sibling2 = l.create_individual('Sibling2', paths['sibling2'])  # doctest: +SKIP
>>> results = l.find_shared_dna([sibling1, sibling2], shared_genes=True, genetic_map="CEU")  # doctest: +SKIP

Siblings share DNA on one chromosome (IBD1) and both chromosomes (IBD2), reflecting segments where they inherited the same DNA from one or both parents:

Sibling shared DNA

Documentation

Documentation is available here.

Acknowledgements

Thanks to Whit Athey, Ryan Dale, Binh Bui, Jeff Gill, Gopal Vashishtha, CS50. This project was historically validated using data from openSNP.

lineage incorporates code and concepts generated with the assistance of various generative AI tools (including but not limited to ChatGPT, Grok, and Claude). ✨

License

lineage is licensed under the MIT License.

Metadata

Release files for lineage 4.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lineage 4.5.0
File Size Uploaded
lineage-4.5.0.tar.gz 71.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lineage 4.5.0
File Interpreter ABI Platform
lineage-4.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 98.9 kB

Release files / lineage-4.5.0.tar.gz

Download URL lineage-4.5.0.tar.gz
Size 71.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5f756d3b4057600604c41847bd918b46f4180d54df6cae674345cf335bd39f13
BLAKE2b-256 checksum
How to use checksums
f13ba444acf043639b595c112f5af8e520a5457d5df53f4c397a7490aa4f7d70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / lineage-4.5.0-py3-none-any.whl

Download URL lineage-4.5.0-py3-none-any.whl
Size 27.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60c2e1c3b50771c54f18620ab76882dab0b1ae36ef8edd57f60aab5392f090a6
BLAKE2b-256 checksum
How to use checksums
9dbab97d3c59af1ff9815a4dc27227e57d86b47a59d7b08f4e2a8c5be32079c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page