Documentation for pandas-genomics¶
- Version
0.11.0
Pandas ExtensionArray for working with genomics data
Quickstart¶
Variant objects holds information about a particular variant:
>>> from pandas_genomics.scalars import Variant
>>> variant = Variant('12', 112161652, id='rs12462', ref='A', alt=['C', 'T'], score=30)
>>> print(variant)
rs12462(n2)[chr=12;pos=112161652;ref=A;alt=C,T]Q30
Genotype objects are associated with a particular Variant:
>>> gt = variant.make_genotype("A", "C")
>>> print(gt)
A/C
The GenotypeArray stores genotypes with an associated variant and has useful methods and properties. The genotype Series accessor allows those methods and properties to be accessed from a Series.
>>> from pandas_genomics.scalars import Variant
>>> from pandas_genomics.arrays import GenotypeArray
>>> variant = Variant('12', 112161652, id='rs12462', ref='A', alt=['C'])
>>> gt_array = GenotypeArray([variant.make_genotype_from_str(s) for s in ["C/C", "A/C", "A/A"]])
>>> print(gt_array)
<GenotypeArray>
[Genotype(variant=rs12462[chr=12;pos=112161652;ref=A;alt=C])[C/C],
Genotype(variant=rs12462[chr=12;pos=112161652;ref=A;alt=C])[A/C],
Genotype(variant=rs12462[chr=12;pos=112161652;ref=A;alt=C])[A/A]]
Length: 3, dtype: genotype(2n)[12; 112161652; rs12462; A; C]
>>> print(gt_array.astype(str))
['C/C' 'A/C' 'A/A']
>>> print(gt_array.encode_dominant())
<IntegerArray>
[1.0, 1.0, 0.0]
Length: 3, dtype: float
>>> print(pd.Series(gt_array).genotype.encode_dominant())
0 1.0
1 1.0
2 0.0
Name: rs12462_C, dtype: float
>>> print(pd.Series(gt_array).genotype.variant)
rs12462[chr=12;pos=112161652;ref=A;alt=C]
>>> print(pd.Series(gt_array).genotype.gt_scores)
[nan nan nan]
>>> import pandas as pd
>>> print(pd.Series(gt_array).genotype.encode_codominant())
0 Hom
1 Het
2 Ref
Name: rs12462_C, dtype: category
Categories (3, object): ['Ref' < 'Het' < 'Hom']
Contents:
API Reference¶
If you are looking for information on a specific function, class or method, this part of the documentation is for you.
Additional Notes¶
Release History, etc
- Notes
- Release History
- v0.11.0 (2021-07-21)
- v0.10.1 (2021-07-16)
- v0.10.0 (2021-07-16)
- v0.9.1 (2021-07-13)
- v0.9.0 (2021-07-12)
- v0.8.0 (2021-07-09)
- v0.7.0 (2021-07-06)
- v0.6.1 (2021-06-26)
- v0.6.0 (2021-06-25)
- v0.5.2 (2021-06-24)
- v0.5.1 (2021-06-23)
- v0.5.0 (2021-06-23)
- v0.4.0 (2021-03-30)
- v0.3.0 (2020-10-23)
- v0.2.0 (2020-10-09)
- v0.1.0 (2020-09-18)