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.5.tar.gz
(2.4 MB
view hashes)
Built Distributions
Close
Hashes for bed_reader-0.2.5-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30fbfcd49231cd306ab8a7fa3e0d2555284ba1a885e2fbb0bedfc8648eb936e7 |
|
MD5 | 72cdfd6c70d5b7c60228c8b2ab78f402 |
|
BLAKE2b-256 | 038e7ea383c85bebfff30cfbbd7c15c8f9de231aed3a3b0199a742f3aea5c2c3 |
Close
Hashes for bed_reader-0.2.5-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f6dd1d00f0cc83a1343555c34fbf49b7a8a24b208ba2ec7d8674cda3348f45f |
|
MD5 | 078df7fd1fdca5451a8a083ff67f4c33 |
|
BLAKE2b-256 | 54b6e5eb365dd9f5547eb7c96f1dd64756a0d45d1401e9a777e49b10c0858310 |
Close
Hashes for bed_reader-0.2.5-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b13bc61dd5db97bf8f93d2bd5a9dbeec8326f63b30b1665eb7dfb6e3f172a8e |
|
MD5 | 6a465e90f854db04ea9c9187daf0cb17 |
|
BLAKE2b-256 | 7f7df5a34741e1d5b701eefca6a64c15f5281b4b93ab9aca73a51ec102c2384a |
Close
Hashes for bed_reader-0.2.5-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb37663881a21bd753ab2ef545d290d47c22549d0cb90c0fbe7a48b8365fd478 |
|
MD5 | 300f3614a69aa36b2defc1ebb0d54169 |
|
BLAKE2b-256 | 8caef4ffb26d00fb42096fbac2d080227af85b50facb97771d20cfca71b32545 |
Close
Hashes for bed_reader-0.2.5-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f899c8e4ee6c9ce9d6170184c484d75fde6fcd1d9e13809f2ff005be226b7271 |
|
MD5 | 97947f04a33bccf3429ead5474ed1639 |
|
BLAKE2b-256 | 606d16d42a5f7e68d87d9decbf913883a132f3a8d018b4f2d1b881e150f12cc5 |
Close
Hashes for bed_reader-0.2.5-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 855c73642c615315d78a725392dbe6771dc17bf04d88c13c796d3e78a13e260d |
|
MD5 | afea36c67a6a808f101146b51ab5973b |
|
BLAKE2b-256 | f0e888099f32d2acab3d88399e2e145f8e8d643ef955a290fe3601747d1d24da |
Close
Hashes for bed_reader-0.2.5-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f77130b0c599b9a1a77b9a6abffe34535e703879b1e7765879df968f6bf79dd3 |
|
MD5 | 8553ed93a58a94e7e73fad1ed825b2b8 |
|
BLAKE2b-256 | 0a6cd15eaf91a2ab822da6eec0cb9fc7b793f89a52ab927e46da97dd7c0553ad |
Close
Hashes for bed_reader-0.2.5-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7030abac583a4942132e5bc453c747eaf17746ef7b1bb66f42505ceddfd6043 |
|
MD5 | cc865b4592798ff6086fb65933dd4120 |
|
BLAKE2b-256 | 22393f2428b7caf88a8383170ff45e60703c43a07dc2b1c104c51c49d34a1fea |
Close
Hashes for bed_reader-0.2.5-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df78b9002ad66b9eea11a193fbbcf9acbc083ca80a1c5d0f34f6d61013daa906 |
|
MD5 | fc8e6268ea93278794981a843518b7ef |
|
BLAKE2b-256 | 669909fbac90a14b902bf79999fe8b9c9e48bda5a0cb182cd1adf0f9eed571d9 |