GraphPed
A novel graph-based visualization method for large and complex pedigrees
Author: Yin Huang
Citation:
Features
-
It can deal with complex families, wrong pedigrees, and multiple groups in a family.
-
It can help to check pedigrees.
-
It can show multiple traits or status in one pedigree.
-
It can show pedigrees in jupyter notebook and output as common image format (pdf, svg, png).
Install
pip install graphped
How to use
1. In command line
!GraphPed -h
usage: GraphPed [-h] [-p PED] [-o OUTPUT] [-f FORMAT] [-a ATTRIBUTES]
[-e ENGINE]
The arguments of graphped
options:
-h, --help show this help message and exit
-p PED, --ped PED a ped file or an extended ped file (default: None)
-o OUTPUT, --output OUTPUT
output folder (default: ./)
-f FORMAT, --format FORMAT
the format of the output picture (default: svg)
-a ATTRIBUTES, --attributes ATTRIBUTES
the attributes of the output picture (default: None)
-e ENGINE, --engine ENGINE
the engine of graphviz rendering the output picture
(default: dot)
-
- standard pedigrees in the ped file
GraphPed -p data/example_fam.ped -o data/cli/ -f pdf
-
- extended pedigrees in the ped file
GraphPed -p data/example_fam_ext.ped -o data/cli/ -f svg -a data/default.yaml
2.In jupyter notebook
from graphped.plot import *
fam=readped('data/example_fam.ped')
plotped(fam)
Or
show(GraphPed(fam))
GraphPed function can plot all the pedigrees in the fam dataframe.
Adding self-defined attributes. the number of traits in the input file should match with the number of traits in the attribute yaml file.
attrs=load_attributes('data/default.yaml')
famext=readped('data/example_fam_ext.ped',attrs)
plotped(famext,attrs)
Write to output folder with pdf format
plotped(famext,attrs,output='data/jpn',format='pdf')
Or output multiple pedigrees.
GraphPed(famext,attrs,output='data/jpn',format='pdf')
Tutorial
Setting the attribute yaml file
- reference:
For one trait ped file, if the trait values are affected status, which should be coded as follows: -9 or 0 is missing,1 is unaffected, and 2 is affected. you don't need to set the attribute file. Otherwise, you need to set your attribute file by following:
The format of the attribute of yaml file
trait name:
attribute name:
(the pairs of tait value and attribute value)
tait value1: attribute value1
tait value2: attribute value2
...
If you have more than one traits, you need to set each trait separately in the yaml file. The following is an example.
%%writefile data/default.yaml
trait1:
fillcolor:
1: 'white'
2: 'dimgrey'
-9: 'aquamarine3'
trait2:
style:
True: filled,setlinewidth(4)
False: filled
trait3:
fontcolor:
True: darkorange
False: black
Overwriting data/default.yaml
attrs=load_attributes('data/default.yaml')
attrs
{'trait1': {'fillcolor': {1: 'white', 2: 'dimgrey', -9: 'aquamarine3'}},
'trait2': {'style': {True: 'filled,setlinewidth(4)', False: 'filled'}},
'trait3': {'fontcolor': {True: 'darkorange', False: 'black'}}}
Two example pedigrees
one is standard, one is extended with 3 traits.
Standard ped file
%%writefile data/example_fam.ped
Fam F4 P3 F1 1 1
Fam F3 P3 F1 2 1
Fam F2 P3 F1 2 1
Fam F1 P1 P2 2 2
Fam P3 0 0 1 2
Fam P1 0 0 1 -9
Fam P2 0 0 2 -9
Overwriting data/example_fam.ped
fam=readped('data/example_fam.ped')
fam
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
| fid | iid | fathid | mothid | sex | trait | |
|---|---|---|---|---|---|---|
| 0 | Fam | F4 | P3 | F1 | 1 | 1 |
| 1 | Fam | F3 | P3 | F1 | 2 | 1 |
| 2 | Fam | F2 | P3 | F1 | 2 | 1 |
| 3 | Fam | F1 | P1 | P2 | 2 | 2 |
| 4 | Fam | P3 | 0 | 0 | 1 | 2 |
| 5 | Fam | P1 | 0 | 0 | 1 | -9 |
| 6 | Fam | P2 | 0 | 0 | 2 | -9 |
plotped(fam)
plotped(fam)
Extended ped file
%%writefile data/example_fam_ext.ped
Fam1 F4 P3 F1 1 1 True False
Fam1 F3 P3 F1 2 1 True True
Fam1 F2 P3 F1 2 1 True False
Fam1 F1 P1 P2 2 2 True False
Fam1 P3 0 0 1 2 True False
Fam1 P1 0 0 1 -9 False True
Fam1 P2 0 0 2 -9 False True
Overwriting data/example_fam_ext.ped
famext=readped('data/example_fam_ext.ped',attrs)
famext
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
| fid | iid | fathid | mothid | sex | trait1 | trait2 | trait3 | |
|---|---|---|---|---|---|---|---|---|
| 0 | Fam1 | F4 | P3 | F1 | 1 | 1 | True | False |
| 1 | Fam1 | F3 | P3 | F1 | 2 | 1 | True | True |
| 2 | Fam1 | F2 | P3 | F1 | 2 | 1 | True | False |
| 3 | Fam1 | F1 | P1 | P2 | 2 | 2 | True | False |
| 4 | Fam1 | P3 | 0 | 0 | 1 | 2 | True | False |
| 5 | Fam1 | P1 | 0 | 0 | 1 | -9 | False | True |
| 6 | Fam1 | P2 | 0 | 0 | 2 | -9 | False | True |
plotped(famext,attrs)
dots=GraphPed(fam)
show(dots)
Write out plots
plotped(fam,output='data/exampleplots',format='png')
Show the plot from data/exampleplots/Fam.png
Real data examples
all_fam=readped('data/Fig_2_3_fam.ped')
all_fam
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
| fid | iid | fathid | mothid | sex | trait | |
|---|---|---|---|---|---|---|
| 0 | 25_2 | 25_2_33 | 25_2_49 | 25_2_50 | 2 | 2 |
| 1 | 25_2 | 25_2_28c1 | 0 | 0 | 2 | 1 |
| 2 | 25_2 | 25_2_25 | 25_2_49 | 25_2_50 | 1 | 2 |
| 3 | 25_2 | 25_2_28 | 0 | 0 | 1 | 2 |
| 4 | 25_2 | 25_2_29 | 25_2_49 | 25_2_50 | 2 | 2 |
| ... | ... | ... | ... | ... | ... | ... |
| 401 | 10R_R99 | 10R_R99_22 | 10R_R99_29 | 10R_R99_15 | 1 | 1 |
| 402 | 10R_R99 | 10R_R99_29 | 0 | 0 | 1 | 2 |
| 403 | 10R_R99 | 10R_R99_7 | 0 | 0 | 2 | 2 |
| 404 | 10R_R99 | 10R_R99_8 | 0 | 0 | 1 | 1 |
| 405 | 10R_R99 | 10R_R99_8 | 10R_R99_19 | 10R_R99_5 | 2 | 1 |
406 rows × 6 columns
Fig.1 The workflow of GraphPed
show workflow
Fig.2 The pedigrees of complex families
plotped(all_fam[all_fam.fid=='25_2'])
Fig.S2 The largest pedigree in ADSP
plotped(all_fam[all_fam.fid=='4_649'])
Fig.3 The pedigrees with incorrect information
plotped(all_fam[all_fam.fid=='10R_R99'])
Fig.4 The pedigrees with multiple phenotypes
self-defined multiple-trait yaml
%%writefile data/self_defined_mutiple_traits.yaml
ad:
fillcolor:
1: 'white'
2: 'dimgrey'
-9: 'aquamarine3'
vcf:
style:
True: filled,setlinewidth(4)
False: filled
trim:
fontcolor:
True: darkorange
False: black
Writing data/self_defined_mutiple_traits.yaml
attrs=load_attributes('data/self_defined_mutiple_traits.yaml')
ped=readped('data/Fig4_fam_ext.ped',attrs)
ped
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
| fid | iid | fathid | mothid | sex | ad | vcf | trim | |
|---|---|---|---|---|---|---|---|---|
| 0 | 10R_R99 | 10R_R99_10 | 10R_R99_2 | 10R_R99_1 | 2 | 1 | True | False |
| 1 | 10R_R99 | 10R_R99_19 | 10R_R99_2 | 10R_R99_1 | 1 | 1 | True | False |
| 2 | 10R_R99 | 10R_R99_20 | 10R_R99_2 | 10R_R99_1 | 1 | 1 | False | False |
| 3 | 10R_R99 | 10R_R99_21 | 10R_R99_2 | 10R_R99_1 | 1 | 1 | False | False |
| 4 | 10R_R99 | 10R_R99_17 | 10R_R99_29 | 10R_R99_15 | 1 | 1 | True | False |
| 5 | 10R_R99 | 10R_R99_22 | 10R_R99_29 | 10R_R99_15 | 1 | 1 | False | False |
| 6 | 10R_R99 | 10R_R99_15 | 10R_R99_8 | 10R_R99_7 | 2 | 2 | True | False |
| 7 | 10R_R99 | 10R_R99_12 | 10R_R99_8 | 10R_R99_7 | 2 | 2 | True | False |
| 8 | 10R_R99 | 10R_R99_1 | 10R_R99_8 | 10R_R99_7 | 2 | 2 | True | False |
| 9 | 10R_R99 | 10R_R99_5 | 10R_R99_8 | 10R_R99_7 | 1 | 1 | True | False |
| 10 | 10R_R99 | 10R_R99_6 | 10R_R99_8 | 10R_R99_7 | 2 | 1 | True | False |
| 11 | 10R_R99 | 10R_R99_2 | 0 | 0 | 1 | -9 | False | False |
| 12 | 10R_R99 | 10R_R99_29 | 0 | 0 | 1 | 2 | False | False |
| 13 | 10R_R99 | 10R_R99_7 | 0 | 0 | 2 | 2 | False | False |
| 14 | 10R_R99 | 10R_R99_8 | 0 | 0 | 1 | 1 | False | False |
plotped(ped,attrs)
Show multiple figures with self-defined attributes
self-defined single-trait yaml
%%writefile data/self_defined_single_trait.yaml
ad:
fillcolor:
1: 'white'
2: 'dimgrey'
-9: 'aquamarine3'
Writing data/self_defined_single_trait.yaml
attr=load_attributes('data/self_defined_single_trait.yaml')
all_fam=readped('data/Fig_2_3_fam.ped',attr)
all_fam
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
| fid | iid | fathid | mothid | sex | ad | |
|---|---|---|---|---|---|---|
| 0 | 25_2 | 25_2_33 | 25_2_49 | 25_2_50 | 2 | 2 |
| 1 | 25_2 | 25_2_28c1 | 0 | 0 | 2 | 1 |
| 2 | 25_2 | 25_2_25 | 25_2_49 | 25_2_50 | 1 | 2 |
| 3 | 25_2 | 25_2_28 | 0 | 0 | 1 | 2 |
| 4 | 25_2 | 25_2_29 | 25_2_49 | 25_2_50 | 2 | 2 |
| ... | ... | ... | ... | ... | ... | ... |
| 401 | 10R_R99 | 10R_R99_22 | 10R_R99_29 | 10R_R99_15 | 1 | 1 |
| 402 | 10R_R99 | 10R_R99_29 | 0 | 0 | 1 | 2 |
| 403 | 10R_R99 | 10R_R99_7 | 0 | 0 | 2 | 2 |
| 404 | 10R_R99 | 10R_R99_8 | 0 | 0 | 1 | 1 |
| 405 | 10R_R99 | 10R_R99_8 | 10R_R99_19 | 10R_R99_5 | 2 | 1 |
406 rows × 6 columns
dots=GraphPed(all_fam,attr)
show(dots)
Metadata
Release files for GraphPed 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| GraphPed-0.0.5.tar.gz | 16.6 kB | Without provenance | Details for GraphPed-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| GraphPed-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for GraphPed-0.0.5-py3-none-any.whl |
Total release size: 27.7 kB
Release files / GraphPed-0.0.5.tar.gz
| Download URL | GraphPed-0.0.5.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0045d0210489cbc2b7acb7bdb7785a6579fdc21c7d5746d66e65ce2c3d7763f7
|
|
BLAKE2b-256 checksum How to use checksums |
2a5e397cb18007dfc797031634279136db7cee174f4d9d8402ebdacc5fcceb1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.2
|
Release files / GraphPed-0.0.5-py3-none-any.whl
| Download URL | GraphPed-0.0.5-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
39e6cdc14650a74ab294b708520272a0811481329eaac9132a2babb33b61e517
|
|
BLAKE2b-256 checksum How to use checksums |
efa52f03552e959e06ea1820d6f4972c106ae94ea4fc34575d55d4f666cdef85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.2
|
Security for GraphPed 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.