Kinship graph visualizer for PLINK .genome and KING .kin0 with PNG/TIFF and interactive HTML outputs
Project description
kinship-vis
Visualize pairwise kinship from PLINK .genome or KING .kin0 as connected components, with
- Static images (PNG/TIFF/JPEG, Matplotlib): edges colored by relationship class, nodes filled by MT haplogroup and outlined by Y haplogroup.
- Interactive HTML (Plotly): the same color scheme with hover tooltips and an optional legend.
Designed for quick QC and teaching. Works with projects like 1000 Genomes and your own pipelines (PLINK/KING).
Installation
1) PyPI (recommended)
pip install kinship-vis
2) From GitHub (latest main)
pip install "git+https://github.com/YOUR_GITHUB_USERNAME/kinship-vis.git"
Python/NumPy note: until the scientific Python stack fully supports NumPy 2, this package pins numpy<2 to avoid ABI issues.
Command-line usage
Basic help:
kinship-vis -h
Key inputs:
- Pairs table: PLINK
.genome(IID1 IID2 PI_HAT [Z1]) or KING.kin0(ID1 ID2 Kinship). - Haplogroups (optional): two-column text files without header:
<sample><tab><haplogroup>--haplogroup-Y— Y haplogroups (node border color)--haplogroup-MT— MT haplogroups (node fill color)
- Samplesheet (optional): TSV/CSV/whitespace-delimited, must contain
sample_id; you can select a label column via--label-col.
Important thresholds (defaults):
--threshold1 0.75(close relatives)--threshold2 0.40(distant relatives)--z1-threshold 0.75--drop-below-threshold2— drop edges withPI_HAT<threshold2to reduce noise.
Outputs:
- Static PNG/TIFF/JPEG:
<prefix>_component_<N>.<ext> - Interactive HTML:
<prefix>_component_<N>.html
Examples (using the files in examples/)
KING .kin0 → separate output folder:
kinship-vis G1000_31S.kin0 --haplogroup-Y G1000_31S_chrY.hapresult.hg --haplogroup-MT G1000_31S_chrMT_haplogrep.txt --output kin0/kinship --legend --drop-below-threshold2
PLINK .genome → separate output folder:
kinship-vis G1000_31S.genome --haplogroup-Y G1000_31S_chrY.hapresult.hg --haplogroup-MT G1000_31S_chrMT_haplogrep.txt --output genome/kinship --legend --drop-below-threshold2
Tip: pre-create the output directories if needed:
mkdir -p kin0 genome
Minimal, reproducible example
# Create a tiny demo of two related pairs
cat > demo.genome <<EOF
IID1 IID2 PI_HAT Z1
A B 0.90 0.95
A C 0.45 0.80
D E 0.10 0.00
EOF
echo -e "A R1a" > y.tsv
echo -e "B R1a" >> y.tsv
echo -e "A H" > mt.tsv
echo -e "B H" >> mt.tsv
kinship-vis demo.genome --haplogroup-Y y.tsv --haplogroup-MT mt.tsv --output demo/out --legend
API (Python)
import pandas as pd
from kinship_vis.io import read_pairs_table
from kinship_vis.graph import build_graph
df = read_pairs_table("your.genome") # or .kin0
G = build_graph(df, threshold1=0.75)
Citation
- PLINK: Purcell et al. (2007) Am J Hum Genet.
- KING: Manichaikul et al. (2010) Bioinformatics.
License
MIT
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 kinship_vis-0.1.2.tar.gz.
File metadata
- Download URL: kinship_vis-0.1.2.tar.gz
- Upload date:
- Size: 20.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46859ee0449c40ec8f610068c49b48df128a964239b91ef537b5ebe94a6895a2
|
|
| MD5 |
24a2742714c005ffe9a66e43e9b557e4
|
|
| BLAKE2b-256 |
487cb56af30d2ee182860ec72a07ff09d586fc681338b728be2f4f348fd8ffaa
|
File details
Details for the file kinship_vis-0.1.2-py3-none-any.whl.
File metadata
- Download URL: kinship_vis-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0368bd62e608424d0629e5b5f5837395b3e919de5993e5c57d2f2f1ab4220c96
|
|
| MD5 |
fa84f0fa0839e8e26ab4a579f0e05e3c
|
|
| BLAKE2b-256 |
62d4264b0c4e0cfba8d3a36f65761834907da589921fe3039536f667d401f3d7
|