Skip to main content

Pandas ExtensionDtypes and ExtensionArray for working with genomics data

Project description

pandas_genomics logo


Pandas ExtensionDtypes and 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'])
print(variant)
rs12462[chr=12;pos=112161652;ref=A;alt=C,T]

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:

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], allele1=1, allele2=1),
Genotype(variant=rs12462[chr=12;pos=112161652;ref=A;alt=C], allele1=0, allele2=1),
Genotype(variant=rs12462[chr=12;pos=112161652;ref=A;alt=C], allele1=0, allele2=0)]
Length: 3, dtype: genotype[12; 112161652; rs12462; A; C]
print(gt_array.astype(str))
    ['C/C' 'A/C' 'A/A']
print(gt_array.encode_dominant())
    <IntegerArray>
    [1, 1, 0]
    Length: 3, dtype: UInt8

There is also a SeriesAccessor named genotype

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']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pandas-genomics-0.4.0.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pandas_genomics-0.4.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file pandas-genomics-0.4.0.tar.gz.

File metadata

  • Download URL: pandas-genomics-0.4.0.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.2 CPython/3.9.0 Darwin/20.3.0

File hashes

Hashes for pandas-genomics-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c87bb48664a98f50bae34a97e70df057e37d9194475c294e9541e2b1f80a6e7f
MD5 5afd97effc75faa2bf301344bd8868bb
BLAKE2b-256 e15e98e574f3e50bbcb5a42fdef34e9be650c7ebbaafac43d21efb1aeee99f76

See more details on using hashes here.

File details

Details for the file pandas_genomics-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pandas_genomics-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.2 CPython/3.9.0 Darwin/20.3.0

File hashes

Hashes for pandas_genomics-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11fb80e7f958b806665e87d308ab43d989932aae0037db8ce6f86d373a3500f0
MD5 a1b400f8403d2bd40f5555b8068ef9db
BLAKE2b-256 264db32fd6ac576d089ffde4470ce5a26af0e3a0a9a622262c96649400fc34d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page