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.9.tar.gz
(2.4 MB
view hashes)
Built Distributions
Close
Hashes for bed_reader-0.2.9-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0519402da9794b73f49c6b10a4ce58077e7c17661d8dade96028f643de15245 |
|
MD5 | 8184412233a321445f0b3dfae4ca25aa |
|
BLAKE2b-256 | ddcc911558a9de0dcec325875c100c7ae3ec86bc3d7f2c4d9e3896ab368c51e6 |
Close
Hashes for bed_reader-0.2.9-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df4f7224c3b6a2e2fde20539c66ae0bd929c05e67f124b08e28b34878517cf9a |
|
MD5 | 2c730ffcc5120e6ecd01334c3cd21064 |
|
BLAKE2b-256 | 9a9f991e81ff50bbe1f757ba11f4c1978bda42e5933a9d72f127b81a5267277a |
Close
Hashes for bed_reader-0.2.9-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1073e48cc69a11dc3b9ad59b635e048a4153974b6e352fa0853184d82c9ee95e |
|
MD5 | fe930976fdfd43f6d93579d83f7ba1af |
|
BLAKE2b-256 | 037d2fa05e6621048381965101285656b37ecd065f6e5e5653b92ef412216041 |
Close
Hashes for bed_reader-0.2.9-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd04a9bcc52ce801a435bbe3f683dce44085e4f09fdcaa818c0bb1d75c81a6b0 |
|
MD5 | e9513ab24866e51d04efb0d79c36c780 |
|
BLAKE2b-256 | a22e032dd1f4616982f14be858531e469fc795d999d99c3fe550834231ca1297 |
Close
Hashes for bed_reader-0.2.9-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c4b98ea406ed647e6fb5433bdef52724c18c6186d339f57e69e604ec9b41e1c |
|
MD5 | bac921b2f25facae284883728904c349 |
|
BLAKE2b-256 | ad842288fd7fc5ae551e69acc96f6590dd8f9217262f30819aefdd9b8d95a077 |
Close
Hashes for bed_reader-0.2.9-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b8366aef6c07bada444ba1a3d42b380d022c4c5ec4f47940dc981f29ffe87e2 |
|
MD5 | d6f92a5ccc06691225e5a448f349bd03 |
|
BLAKE2b-256 | 252f50035b6c9c5224368d54359a200903ae44adfdc536d9c22b4c92df21d106 |
Close
Hashes for bed_reader-0.2.9-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60799d1e6f9d9b5fd96c0024db539abbb53bd256b7e9a3e8f3d124fea519b337 |
|
MD5 | ae6cbbc9fe9ceb6aa5f30ef44cc6f65e |
|
BLAKE2b-256 | 343a6ecbcaaef4df1efd3fdbc2228722fe24bfef0a3af2e4fd8c26f6b0e5ba72 |
Close
Hashes for bed_reader-0.2.9-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90c7ca86f9442afe5f71459a877ae280aee5dc6edaab734746d3362c926d3cd2 |
|
MD5 | 0f887265d11330ce33f4d164e74b4f7c |
|
BLAKE2b-256 | 2dc46592c34dfe305a4276549ab0e545a39939ad11db41f996dae3cb80d48638 |
Close
Hashes for bed_reader-0.2.9-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80c9b7e17d61721875c78d1f9d4750b170ca560541d92b3b9f7189f9e16db3dc |
|
MD5 | 5684640aea7e32fa5d5a44ea804ff064 |
|
BLAKE2b-256 | c990c00225073d531a3b47d060e81ec50342a8f2b66966fd665d82c4f1fc7969 |
Close
Hashes for bed_reader-0.2.9-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7406e3ea8706fc69c8382df0e616a5e198b461c439fa9b80423f1611a2d3894e |
|
MD5 | c2566da0bdab5a4d59ebbf0cbd95e6df |
|
BLAKE2b-256 | 604e5b3e61ea63cf4701d0a7b80175eabd3a853b75ad096cb51328a54dcc1035 |
Close
Hashes for bed_reader-0.2.9-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7674949468fabbb246a4df74e6b71025a26044b48b0879049150e8dbad3d355f |
|
MD5 | 55bef1343e273f48dd9b06836eab74ff |
|
BLAKE2b-256 | b9e4bf7163553e64fc5d1ec69a248eb678d54343f317645222a32a1022c9fb66 |
Close
Hashes for bed_reader-0.2.9-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f20da571f22e95b986f16bf92fe0346a76e87f532fe4c0e1185e1be2be04e71a |
|
MD5 | f761ab203466aba44341678ab00a3deb |
|
BLAKE2b-256 | f3c6ba000ba60f53f614e28daee5d2e6208b6678e803e88d4e10cc1724edb3d4 |