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.8.tar.gz
(2.4 MB
view hashes)
Built Distributions
Close
Hashes for bed_reader-0.2.8-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb3be747877ec861dac9094c470f7b12f64a5f0fba17495e69a5f732e8ac4c72 |
|
MD5 | 3ae6c46a5fe7af385436ffde8fa1508a |
|
BLAKE2b-256 | fe3af15702fdcbbcb88b06b0a567dc99d60791a6127fe851a7b4b94708f29079 |
Close
Hashes for bed_reader-0.2.8-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49a3c82f539143569d99b4213572b963244d02311da28a6ebac258dcbf26a35c |
|
MD5 | 9d8172d7cce5f43c5fcf431fb5f724c0 |
|
BLAKE2b-256 | a735293881cd95a599fa905113bfedd8eccf8d969131b17e4aa943b8ea0ba524 |
Close
Hashes for bed_reader-0.2.8-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b3d0fd04d93ed6c9a309b8b66a11fb0d8f375a38669786d428c80ae243646ed |
|
MD5 | 17a7c37492f824c475454c447e515833 |
|
BLAKE2b-256 | 8aee3aa4f5ba4207072460497d33f5b37965ae2f676c98c649709fc9f16c3beb |
Close
Hashes for bed_reader-0.2.8-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48c4a6554190fe8b736ba753df7f6bd2ef137bd5b3652e9c382f4e3f4612c91c |
|
MD5 | c02db4d4f6ca89d6be2c399916370c93 |
|
BLAKE2b-256 | 965c81e2f157b3433b0bea17c4ab6944fa702c60c121ccbdb88c5152222d2188 |
Close
Hashes for bed_reader-0.2.8-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e29c344b8521fbe0d8d4ab2f980b99a6ab78e8dfe38862241f35224184caf3de |
|
MD5 | b50cdd29e70f2dd1aea53947c0ac5e6f |
|
BLAKE2b-256 | 9284abe237b523f2a1fb5441c6d918ea09e210cfc75cf73362ffb59d256c102b |
Close
Hashes for bed_reader-0.2.8-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82314a99a1581e13d9c83c41e76c4779f99e8156a80398128c2f6f29881c7ec5 |
|
MD5 | 446321e4a690cbc2a471c6cbdd955e94 |
|
BLAKE2b-256 | 916f2932a86ec7f27074992698cf429efc427d79a79e49a128d73ca4dc3d6630 |
Close
Hashes for bed_reader-0.2.8-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be1a023f38ee9659500cf2d5e4dae000665428db13d9af43d0613e5399a2446e |
|
MD5 | 5710555a66d4593f4b9159cd2876f255 |
|
BLAKE2b-256 | 71f2ee8415c3cdb359b321efd9b028b8152fe7d4e939cab010b76a4210c4b417 |
Close
Hashes for bed_reader-0.2.8-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2fd3761b01f63a3588869304529c492bda0f4c09e86ff3005462a5c52716934 |
|
MD5 | bc2cc6b0176d5498d90cf297b9372662 |
|
BLAKE2b-256 | f2955e9f8ecb41000d2b6eddd8bfa1a3ba2a34d1f2717c3b65d1ca9df9ca0e52 |
Close
Hashes for bed_reader-0.2.8-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75a900d3fc9e6bc985d22ed551d0b2d683b16dbd29e31fdbb4cea5ff33fd2449 |
|
MD5 | 8417f1d66a091ee0afb0f7b62dc00deb |
|
BLAKE2b-256 | f8e10237d30d783ffabd92c4f6af4331d1b2291f31acacc4bac859d2be2d9cc0 |
Close
Hashes for bed_reader-0.2.8-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e29b4a69ac6c187a15aea31069652fee59144d8f63883bd01b42826dee0330e |
|
MD5 | 13ac08811459fb18c3191f9d0800e336 |
|
BLAKE2b-256 | e1485e50847ca3cd2e3d77d98e4908d76edc84ab3fd6f3178288c7715f8bbc3e |
Close
Hashes for bed_reader-0.2.8-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41e122db4a85cd09ca2714ae7080c3c62ccf16d3750b690d268a7ae97421bc77 |
|
MD5 | c4572eb33e4350170809ef90d26d36aa |
|
BLAKE2b-256 | 9176daec8b0f44725fdf3b78c717a725febad2e7bc7b8d4d846482a9a0ff62a1 |
Close
Hashes for bed_reader-0.2.8-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2f2af04de451493b2744b8244b78a515f5b8e62fefcd562970087ecf6a76166 |
|
MD5 | 4db30f753105738d08fdae89ae6ecc51 |
|
BLAKE2b-256 | dcbcfd8c6fbcfa0fa0c307dc552192d754fb251871833b463ce1e56e47a9f8a6 |