Read and write the PLINK BED format, simply and efficiently.
Project description
Read and write the PLINK BED format, simply and efficiently.
This is the Python README. For Rust, see README-rust.md.
Highlights
- 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.
- Read data locally or from the cloud, efficiently and directly.
Install
Full version: With all optional dependencies:
pip install bed-reader[samples,sparse]
Minimal version: Depends only on numpy
:
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 genomic 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)
From the cloud: open a file and read data for one SNP (variant) at index position 2.
>>> with open_bed("https://raw.githubusercontent.com/fastlmm/bed-sample-files/main/small.bed") as bed:
... val = bed.read(index=np.s_[:,2], dtype="float64")
... print(val)
[[nan]
[nan]
[ 2.]]
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-1.0.6a1.tar.gz
(2.8 MB
view hashes)
Built Distributions
Close
Hashes for bed_reader-1.0.6a1-cp313-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a35469e27290b6136a37c0418697b3b3065dc028f3f7ddf6fc66b9c099c4b10 |
|
MD5 | 994d5e5d4d1b316abc00cea63f65e8dc |
|
BLAKE2b-256 | 365755cf97297497ace712017a27e1297938ca878fcb6afe52bdfd82e6ccee54 |
Close
Hashes for bed_reader-1.0.6a1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9dfaf6d3ce10828befea4e3fe450b2938b325b854f845755291c557cb5f7ada |
|
MD5 | ecb482c16718056301358d60a1dfe16f |
|
BLAKE2b-256 | 824575a0dfd694777f0ac8704886a427e97df363d2da5013b9a86792857972e7 |
Close
Hashes for bed_reader-1.0.6a1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 047ec8753f00f3d963d3c48227bc4e531eb225083b29f91651fdefb338a5205b |
|
MD5 | 62357d98b0674cea0f25a59538c34a3e |
|
BLAKE2b-256 | 7204f255e3a1f60b315ed5d306eb6b41f53e5a7ae50f07d245392a7e6d84dafe |
Close
Hashes for bed_reader-1.0.6a1-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c8847b7fff703e4dc9ee2d0086b3012d3ec37ec9b05f4c767ac4cd63bf4d862 |
|
MD5 | 7055543e6a4c742b0b50c85f566f10ac |
|
BLAKE2b-256 | a900ac5377386a3f13a7d61a17b812de2fdc00c430a9c760d69d59026db39252 |
Close
Hashes for bed_reader-1.0.6a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6626efde2c526107ecf437ea85eec162a2a751f35c7859ef65edb5ed109f389 |
|
MD5 | 733249cfe0411d0db9e4de703a1f18a3 |
|
BLAKE2b-256 | 1230af7a9391fafde610f72dc49033456ab75a7a467d1153443ac414b1e6c794 |
Close
Hashes for bed_reader-1.0.6a1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6c1b9ff28de5289de41e2938d1a8fc402a2fcb10c732133abebf21355345df1 |
|
MD5 | f1895ad5c133fd38a5329573282b7b4a |
|
BLAKE2b-256 | 3392440b6891c1c00cdb6be9961509529a498e1470bc470f8c6ca44d70cc9cde |
Close
Hashes for bed_reader-1.0.6a1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3f174cf96bfdf87da075967aa766dc1fa7b71da4a866c5bb8f9db2268c2c937 |
|
MD5 | bc5573937f8ae8c8491429fd15f3b866 |
|
BLAKE2b-256 | 191eea17baebfc4a76c868c25da4a57ddb106ad56c1e619a0ecc5c02c9691f12 |
Close
Hashes for bed_reader-1.0.6a1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c2904e461cfc8c2683198b7dd5ac4f136eb453fd9c29150af95c489049a4d6f |
|
MD5 | 97352bd4e33a7b9a33e78abb0c925e70 |
|
BLAKE2b-256 | cfb91e70142e4a1a21b0c1447a34285238445103b12089dc955687e040242bc3 |
Close
Hashes for bed_reader-1.0.6a1-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfd073893d6c1b366b829ff7e9449351d8f9bd9bfcbf448bff1dc98067b6445f |
|
MD5 | 1ed3ec58f257951b7d47707a9ea44052 |
|
BLAKE2b-256 | e563d1abb1de4dd4791e7699d04d3e21fa121e2cf28aafde11acd8147925386b |
Close
Hashes for bed_reader-1.0.6a1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0f724e181a989220fa395b01edfd2d253a1b1cf9dc77d53af481622d04a9f8e |
|
MD5 | 550347c2e104c7adfcee8d0f91be5ca9 |
|
BLAKE2b-256 | 8350cc9c59c9b0dd86500677fe137555680dad4ac5ded252ca0b8b45a8b10075 |
Close
Hashes for bed_reader-1.0.6a1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfde05d3c7e8ed5d56818c37ba873a0022b13130f14e0fe3225299b460d1f754 |
|
MD5 | bcd7f9ee4b54f414656e4240b8ef695b |
|
BLAKE2b-256 | adc5550efa39c8490a7e684597928470308769fc9671eafdafbba1dc88c06421 |
Close
Hashes for bed_reader-1.0.6a1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e805e5d9d000583bc4194604705f77e7832194d4cabc7a03485a81766043b064 |
|
MD5 | 8ee0a59c7e56f3c37c85558face7131b |
|
BLAKE2b-256 | 75e7b45e07fa0b4c408b3d98ebd59b256345202b24ee28fbff23a95369a38a77 |
Close
Hashes for bed_reader-1.0.6a1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a7cf167098570ffc2d442dcb8b70a173fe0fe32d01b246285e48d8d92568486 |
|
MD5 | 1e29b6569a2078befb74347acaeb4967 |
|
BLAKE2b-256 | 9c1ba716b7bb7d18deb6c8b4a5c51b94165913fa43fea273c3330e8b9a81f439 |
Close
Hashes for bed_reader-1.0.6a1-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f3cb043255a22e94864699d1f0e80e65e30697d679fc0a7268101b57f67935d |
|
MD5 | 7570258b0f6ecd4c26bbacf7f13d9156 |
|
BLAKE2b-256 | 0614a4a5b5349547ac305f53555eb49ce8bda86156374baa009e6cbaa74e13b4 |
Close
Hashes for bed_reader-1.0.6a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 596e9e8912913744586b13297fd31bfb327ba012a1732af75b1437a78e3e19e7 |
|
MD5 | 43f0de8de6b62bb99eaf9d819f9dbfac |
|
BLAKE2b-256 | c7e402c244d08eb8c4f22947566f2059bc56f249813f32e1e449cc4403a13f35 |
Close
Hashes for bed_reader-1.0.6a1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2335d3c9976fb4fcd238850fc0445bb13793c193e4c29347fa2cec5f16c6dce7 |
|
MD5 | 8756fe9f628830c700a7715b5860120f |
|
BLAKE2b-256 | 59634ccd298e84e60e71543655e82147222354c1ef0b0435306cc533f85bb778 |
Close
Hashes for bed_reader-1.0.6a1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1db12290dd90b66b5ad283430020511319a0ba5aac04e0fd6540b1799f9d380 |
|
MD5 | 7d04216ab63695cf665fa747fffac25a |
|
BLAKE2b-256 | 1e0d2970a5633b8bbfa05639fc9d687f0c04ee69404a396be2c6193d14220a41 |
Close
Hashes for bed_reader-1.0.6a1-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3775081397c4b673decc0669be5d235965b35306fdb6785b88f0261f2d1590e0 |
|
MD5 | da98e17d45afd93bdc47b560cdb0690e |
|
BLAKE2b-256 | b0e7661a78c8a2e9b709a06506a4a9eedc06a4d692e79a60ec98e962fbf4a9e2 |
Close
Hashes for bed_reader-1.0.6a1-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49772300021b3ee0c676d2bdd475f76a9188b6e84c38d5d6a8bec6cb334bc081 |
|
MD5 | 2c21cd78054180791cc259d5f852df45 |
|
BLAKE2b-256 | e19936a804ac5b8eb7a692a2b8d19f9af46d16b1c783678988ab8e2248448dca |
Close
Hashes for bed_reader-1.0.6a1-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d3d9e0b78208b9c27aaaa06cf24971c0da9f53994a3319a0980c29a1f26b3d6 |
|
MD5 | 93f8d5992c471be1b53decf7d37033a8 |
|
BLAKE2b-256 | 698f7987c0275c884bbb8e5d4e955902b9ea3e9aa7bb4c73ea01905e6c64d530 |
Close
Hashes for bed_reader-1.0.6a1-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 397bf59a631060baa3d186ef589464d0ff1e5c87ead3d738fcc4e11796822b6a |
|
MD5 | 2d699a032746b549254a2289e5c00a45 |
|
BLAKE2b-256 | 4a7ac6137065fd9d0fe9d190f879a7acc5039e6fc8862cdd6988fcc304a7ec5e |