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.3.tar.gz
(984.8 kB
view hashes)
Built Distributions
Close
Hashes for bed_reader-0.2.3-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f581a5554067d925d190ecc1a6bb88cf109f90410cd4920c8eff938a4f4fb0d |
|
MD5 | 6c2c0237db81a236b88e5680295b7df0 |
|
BLAKE2b-256 | 785c3a15980c7f0d34e61e0afed1a00f9146e2bfcd2eaa2f635c51e6efa8e1d8 |
Close
Hashes for bed_reader-0.2.3-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e32922c8e63cd99873c4d58f782ff3961a32b4e84823e56b674808e4a11600f |
|
MD5 | 98830d4211966bee914f2a5bdaaa59c5 |
|
BLAKE2b-256 | d4b96104045739d5059345797fa8d0eb9044db3f354038b418d37ab3963679d3 |
Close
Hashes for bed_reader-0.2.3-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2169e77d93e1c1564098695ea9156bef5196f785b3adf131036de6e0f0d25525 |
|
MD5 | cdc6f69042defb5197f75f2d81e84a98 |
|
BLAKE2b-256 | 9ec0d3955d2f4bfeeacb670e1085e3bfa1530a3a11e1f3bd0dcefb3aff426acd |
Close
Hashes for bed_reader-0.2.3-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd0b71b28268bfff139743fa18923dabf6d27d935683482f83bd0659b0045097 |
|
MD5 | 6b17e4825b7e4ca1f4e169ee538f4fd6 |
|
BLAKE2b-256 | 526d7258dc43585dbe8ac18381e3d55384d04d2cf90397bd5213997c46dfee06 |
Close
Hashes for bed_reader-0.2.3-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16ec5e3e97d0fb1af630ec97bec8a12dc73a1d9ffefa7fcdb629b39b019b20f0 |
|
MD5 | 1d188e831cb37c4c70f90d7019276fd9 |
|
BLAKE2b-256 | e970f63dbf9dd24eaff3d60877e8e6c4578ae8d14ef4ee78fbf6b57652421b30 |
Close
Hashes for bed_reader-0.2.3-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 227c82a87b40c14bdbb06555be4551a0733fee3fda47004ea58f5489b39bd77d |
|
MD5 | 833f6c37c66d0dad7436d19c5e741764 |
|
BLAKE2b-256 | 719f4c9b138fc17a7fd887542b69e4b37ebb5ae1905c9380f7bdc7925e528b1c |
Close
Hashes for bed_reader-0.2.3-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d241a7ee0ebdc3fcc965e928b207526ab579294127a1a97542c4d86c8a4c12b |
|
MD5 | 19b403e90032e29f548be914d4c6be4f |
|
BLAKE2b-256 | 00db1e0f7cb431d37f01589b2dc87f5662ae8d110930c71488454417cf0e825d |
Close
Hashes for bed_reader-0.2.3-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b79997d2181c7a73ee0d2542d94d58eb6e5f8a36dfb7f2940db7224573815cf |
|
MD5 | 124bb086f90db40909e9910b75172b0d |
|
BLAKE2b-256 | 29a706d6a34b3f4d9de3f2b609031907cff31a0a86ea8c12979d47199e851194 |
Close
Hashes for bed_reader-0.2.3-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f92e3ae060d544b9136110bfd7d206d78d526dac070ab160d23306081f3f089e |
|
MD5 | d0b8b88b4b1024e2f69133f04dd272cf |
|
BLAKE2b-256 | ca113e8f773bba0ec16e21d1c8d00997a3fb1a4a2936d24c4efe3f47f37235ba |