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.6.tar.gz
(2.4 MB
view hashes)
Built Distributions
Close
Hashes for bed_reader-0.2.6-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4fa314706641746f787a9000695a137a7a5acc1e1ae2819226b46857a69ec32 |
|
MD5 | 81ad8597e90a31e4b0b0f25196ca7503 |
|
BLAKE2b-256 | d5068623cd69d93dc021180f4a2e065c5e49b59ec81ac60027b4725b3cda38ae |
Close
Hashes for bed_reader-0.2.6-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e802b752bcc9ccab76e7a620cbc2f79ee4712d7bb080628fe179d237c28faf66 |
|
MD5 | 6a4ec4a70ef74fc1173d14dd9100d9c4 |
|
BLAKE2b-256 | ecdcdb738aa4d57c23ff6688b6960d47b9e5535f252456eac21a7aaa1ab9282b |
Close
Hashes for bed_reader-0.2.6-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5400da22599f0b5d976851d1f3fc2d57a999094809deabf086f2c330c2340694 |
|
MD5 | bd9195c6690faba4b81f3a07dce072ee |
|
BLAKE2b-256 | 8dc457589a4f4fa845ac70d383c5eec7194d04a847468806af8e772bacd72cc9 |
Close
Hashes for bed_reader-0.2.6-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2d32c3cb3ffbf5104d544575d9624b6d10a61cdf1d2ace7ea9ccc1846948897 |
|
MD5 | 9da5a2c4d95bec2d70a8fd44081333d5 |
|
BLAKE2b-256 | d875a810277ea30e8aadc0593ec24016a983cbcc3190455b406c6636f14ecbd0 |
Close
Hashes for bed_reader-0.2.6-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72c37bbd377eefb537e2114ae4b07d504d9aa48cfd26c9a16ca47e21d788ce64 |
|
MD5 | a1134beb223874250252a89ad02a64c1 |
|
BLAKE2b-256 | a562b12124314146e3e168a3b6ef430fc712fdf263edbb528f6a799ac2423edb |
Close
Hashes for bed_reader-0.2.6-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a74463815344d98cb41eff51262d5472c26516a1ea880ed6abc8b65fa3da960c |
|
MD5 | 4622389152357a6516e279b26e2d2a37 |
|
BLAKE2b-256 | bcedb2580e74cba00e9c89e28a9f827d36ce91201e5c7bfe849f5dca7ddaa969 |
Close
Hashes for bed_reader-0.2.6-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd69ca3e358ce7b2af9d45bbfb65cf5bc95e5bd5c6c9d614e13fe9d6679944bf |
|
MD5 | cb75ae7734664277beab0052186f3203 |
|
BLAKE2b-256 | 8c224fb09db4d8a285330fb7ae16700f689bdf5dd67a765d3bbddb90286e87cf |
Close
Hashes for bed_reader-0.2.6-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d74e2824b68a028c1b07dd1cff156e0bd719bbe895b77e93b33ba82db9abc103 |
|
MD5 | 48de3fea3797d252aa0a2d7933794a4d |
|
BLAKE2b-256 | d776ad2f2c53634f96fefadef4d70002c3e9d85883d2409fc8e57022fca77837 |
Close
Hashes for bed_reader-0.2.6-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab7330c5b510ecda5e2d64456c8cc79ccfa598d90a98e1b546bf008b8a76cbd8 |
|
MD5 | 7ed1bed1b78279a2d0115587f0277f54 |
|
BLAKE2b-256 | 2c23d54e9061bf56cd427b01f07bf93fd2b7814d35b01d0ee5178ac7b80f223e |