Read and write the PLINK BED format, simply and efficiently.
Project description
Read and write the PLINK BED format, simply and efficiently.
Features:
- Fast multi-threaded Rust engine.
- Supports all Python indexing methods. Slice data by individuals (samples) and/or SNPs (variants).
- Used by PySnpTools, FaST-LMM, and PyStatGen.
- Supports PLINK 1.9.
Install
pip install bed-reader
Usage
Read genomic data from a .bed file.
>>> import numpy as np
>>> from bed_reader import open_bed, sample_file
>>>
>>> file_name = sample_file("small.bed")
>>> bed = open_bed(file_name)
>>> val = bed.read()
>>> print(val)
[[ 1. 0. nan 0.]
[ 2. 0. nan 2.]
[ 0. 1. 2. 0.]]
>>> del bed
Read every second individual and SNPs (variants) from 20 to 30.
>>> file_name2 = sample_file("some_missing.bed")
>>> bed2 = open_bed(file_name2)
>>> val2 = bed2.read(index=np.s_[::2,20:30])
>>> print(val2.shape)
(50, 10)
>>> del bed2
List the first 5 individual (sample) ids, the first 5 SNP (variant) ids, and every unique chromosome. Then, read every value in chromosome 5.
>>> with open_bed(file_name2) as bed3:
... print(bed3.iid[:5])
... print(bed3.sid[:5])
... print(np.unique(bed3.chromosome))
... val3 = bed3.read(index=np.s_[:,bed3.chromosome=='5'])
... print(val3.shape)
['iid_0' 'iid_1' 'iid_2' 'iid_3' 'iid_4']
['sid_0' 'sid_1' 'sid_2' 'sid_3' 'sid_4']
['1' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '2' '20' '21' '22'
'3' '4' '5' '6' '7' '8' '9']
(100, 6)
Project Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bed_reader-0.2.7.tar.gz
(2.4 MB
view hashes)
Built Distributions
Close
Hashes for bed_reader-0.2.7-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aec05db02fa51840ae73bca7f179f5ee53e73768c5576df9d4eb9d3f7f4622ac |
|
MD5 | 546389b0a8208441b0dba40cd86a0c9b |
|
BLAKE2b-256 | 7c733670eeb336dd3a482af17d3755606a63c5eaf2ec27daf487c47dff3fb917 |
Close
Hashes for bed_reader-0.2.7-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4eddfd1451b16b2b944d87fde9707448790392c4fcd336cb1bb937fc9b392569 |
|
MD5 | 9f8c0318832da3708569c28b2ad644b2 |
|
BLAKE2b-256 | 6b70a7c74e5da8985bffc713f36ba5cbbe09ddd2a394341cea6a8110673d68f4 |
Close
Hashes for bed_reader-0.2.7-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1863190fc51279a72dd9ed1f5b3222a3f92afa3ebc61d056eaaa89fbce3648f6 |
|
MD5 | daee227c5abf33ce8fa3bae0ff63c36f |
|
BLAKE2b-256 | 80b4b143d5b1a50658b836fae94463c425c4048b259257dd3c3f3e44b4a7ed78 |
Close
Hashes for bed_reader-0.2.7-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 248a240cb5033a304a57f7a0f02e801c5f7b8e584a2d70c3fce95c57211c9340 |
|
MD5 | b1f0cbd8c87cfa2e5ad0f1943fac56f2 |
|
BLAKE2b-256 | 9fe763b6a4b88af5195f9b943381237039b4b3233bc3606e18d5f15e052456dd |
Close
Hashes for bed_reader-0.2.7-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c10e0e951f860b04be3abb2442cf0af5804d14ac9817696caf734c9a9b4399f0 |
|
MD5 | 86c40f790113f8fac09e8f4da28451f1 |
|
BLAKE2b-256 | a15f7472fc5bbd40fe6a119e4ccf54dd5b0ebad00dbf165ee593f37dabe959b4 |
Close
Hashes for bed_reader-0.2.7-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e8d189d09d52211a20cd365c94f9584a9971787cb9ee9b5e1e9770369e9e06e |
|
MD5 | 364d568042868653d9196eeddb366371 |
|
BLAKE2b-256 | 85a94423341da08b7f6cd529596167807a409452f86655531b3752a494b3e52a |
Close
Hashes for bed_reader-0.2.7-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64a4264b77e74e39ec5e0e096cec71b38a84ed65a9ea20bd6c4a673115a7d321 |
|
MD5 | 844ca5cf6a17b9d34e58ea55bdf3858c |
|
BLAKE2b-256 | f04c70d026bf27ccb5a50ee25d832e378aa5c715c41d00cd274b09e824d78094 |
Close
Hashes for bed_reader-0.2.7-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 261b83077c3a048d677af51769f58e16faa7c7e5e5bce8e8d92a137eb0a70f39 |
|
MD5 | 5d665d524005a877c2954bccc1f866ca |
|
BLAKE2b-256 | 079d23235b4488e56629c5afcc69c2d96b3c2ec7c4b51b72cffa2c86eadac5fc |
Close
Hashes for bed_reader-0.2.7-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1550e8b7d76d63c2e5d54d0b16f9cc380ef5aa4aecbe7a599347daccc42b26e |
|
MD5 | c21d558e0ddf2518afe730bb39840d1d |
|
BLAKE2b-256 | 4f35edb0cb1ae813fe9a035f1df89ab1085bdd2f63719967e96a31b629831ea0 |