Skip to main content
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]

Each variant should have a unique ID, and a random ID is generated if one is not specified.

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:

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.0, 1.0, 0.0]
    Length: 3, dtype: float

There are also genomics accessors for Series and DataFrame

import pandas as pd
print(pd.Series(gt_array).genomics.encode_codominant())
    0    Hom
    1    Het
    2    Ref
    Name: rs12462_C, dtype: category
    Categories (3, object): ['Ref' < 'Het' < 'Hom']

Metadata

Release files for pandas-genomics 1.0.1

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

Source distribution (sdist)

Source distribution for pandas-genomics 1.0.1
File Size Uploaded Provenance
pandas_genomics-1.0.1.tar.gz 34.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pandas-genomics 1.0.1
File Interpreter ABI Platform
pandas_genomics-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 76.8 kB

Release files / pandas_genomics-1.0.1.tar.gz

Download URL pandas_genomics-1.0.1.tar.gz
Size 34.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d84a9c95b89539bcfb5884570b4890ff18e4f777ba90e2f8db8d852702a87547
BLAKE2b-256 checksum
How to use checksums
430d12880263fa9b1a43779e53d69d184933d0d3f17cab7cf4728629f6636a2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.10.3 Darwin/23.4.0

Release files / pandas_genomics-1.0.1-py3-none-any.whl

Download URL pandas_genomics-1.0.1-py3-none-any.whl
Size 42.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aff4eda6b88354cb640313c3c9938a048e5765add245b8e25a4cf036a40e8fda
BLAKE2b-256 checksum
How to use checksums
40b51537d3b5c096b07cd9724e3774c072b733a1e4819a78ebbe8812666cbca0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.10.3 Darwin/23.4.0

Security for pandas-genomics 1.0.1

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.

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