vcfnp
Load numpy arrays from a VCF (variant call file).
Installation
Installation requires numpy and cython:
$ pip install vcfnp
…or:
$ git clone --recursive git://github.com/alimanfoo/vcfnp.git $ cd vcfnp $ python setup.py build_ext --inplace
Usage
import sys
import vcfnp
import numpy as np
import matplotlib.pyplot as plt
filename = '/path/to/my.vcf'
# load data from fixed fields (except INFO)
v = vcfnp.variants(filename).view(np.recarray)
# print some simple variant metrics
print 'found %s variants (%s SNPs)' % (v.size, np.count_nonzero(v.is_snp))
print 'QUAL mean (std): %s (%s)' % (np.mean(v.QUAL), np.std(v.QUAL))
# load data from INFO field
i = vcfnp.info(filename).view(np.recarray)
# plot a histogram of variant depth
fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.hist(i.DP)
ax.set_title('DP histogram')
ax.set_xlabel('DP')
plt.show()
# load data from sample columns
c = vcfnp.calldata(filename).view(np.recarray)
c = vcfnp.view2d(c)
# print some simple genotype metrics
count_phased = np.count_nonzero(c.is_phased)
count_variant = np.count_nonzero(np.any(c.genotype > 0, axis=2))
count_missing = np.count_nonzero(~c.is_called)
print 'calls (phased, variant, missing): %s (%s, %s, %s)' % (c.flatten().size, count_phased, count_variant, count_missing)
# plot a histogram of genotype quality
fig = plt.figure(2)
ax = fig.add_subplot(111)
ax.hist(c.GQ.flatten())
ax.set_title('GQ histogram')
ax.set_xlabel('GQ')
plt.show()
Acknowledgments
Based on Erik Garrison’s vcflib.
Metadata
Release files for vcfnp 0.7
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 |
|---|---|---|---|---|
| vcfnp-0.7.tar.gz | 391.0 kB | Without provenance | Details for vcfnp-0.7.tar.gz |
Release files / vcfnp-0.7.tar.gz
| Download URL | vcfnp-0.7.tar.gz |
|---|---|
| Size | 391.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8246f0c2ce8fbb11b61458526d6617500535ccc44113e0960bad298823ad1780
|
|
BLAKE2b-256 checksum How to use checksums |
4bc536d47e6dfcd2af1c95ca175e313694b6d3009d903e8b8f1d09cf10887c57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for vcfnp 0.7
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.