Skip to main content

Read and write the PLINK BED format, simply and efficiently.

Project description

PyPI version Build Status PyPI

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


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.6.tar.gz (2.8 MB view details)

Uploaded Source

Built Distributions

bed_reader-1.0.6-cp313-none-win_amd64.whl (5.6 MB view details)

Uploaded CPython 3.13 Windows x86-64

bed_reader-1.0.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

bed_reader-1.0.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.2 MB view details)

Uploaded CPython 3.13 manylinux: glibc 2.17+ ARM64

bed_reader-1.0.6-cp312-none-win_amd64.whl (5.6 MB view details)

Uploaded CPython 3.12 Windows x86-64

bed_reader-1.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

bed_reader-1.0.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

bed_reader-1.0.6-cp312-cp312-macosx_11_0_arm64.whl (5.8 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

bed_reader-1.0.6-cp312-cp312-macosx_10_12_x86_64.whl (6.0 MB view details)

Uploaded CPython 3.12 macOS 10.12+ x86-64

bed_reader-1.0.6-cp311-none-win_amd64.whl (5.6 MB view details)

Uploaded CPython 3.11 Windows x86-64

bed_reader-1.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

bed_reader-1.0.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

bed_reader-1.0.6-cp311-cp311-macosx_11_0_arm64.whl (5.8 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

bed_reader-1.0.6-cp311-cp311-macosx_10_12_x86_64.whl (6.0 MB view details)

Uploaded CPython 3.11 macOS 10.12+ x86-64

bed_reader-1.0.6-cp310-none-win_amd64.whl (5.6 MB view details)

Uploaded CPython 3.10 Windows x86-64

bed_reader-1.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

bed_reader-1.0.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

bed_reader-1.0.6-cp310-cp310-macosx_11_0_arm64.whl (5.8 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

bed_reader-1.0.6-cp310-cp310-macosx_10_12_x86_64.whl (6.0 MB view details)

Uploaded CPython 3.10 macOS 10.12+ x86-64

bed_reader-1.0.6-cp39-none-win_amd64.whl (5.6 MB view details)

Uploaded CPython 3.9 Windows x86-64

bed_reader-1.0.6-cp38-none-win_amd64.whl (5.6 MB view details)

Uploaded CPython 3.8 Windows x86-64

bed_reader-1.0.6-cp37-none-win_amd64.whl (5.6 MB view details)

Uploaded CPython 3.7 Windows x86-64

File details

Details for the file bed_reader-1.0.6.tar.gz.

File metadata

  • Download URL: bed_reader-1.0.6.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for bed_reader-1.0.6.tar.gz
Algorithm Hash digest
SHA256 d6b439730d422590b6608908f049afd35113be562a41e70e4f06acf1375f11b1
MD5 7e4767eedad54b44dc82f04117f58592
BLAKE2b-256 19e507c60f12dbdc0169295e0ef3ff58a2db4209021bf3e09260ea3e4e3e18ad

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp313-none-win_amd64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp313-none-win_amd64.whl
Algorithm Hash digest
SHA256 77bb57b565a9bb30ec8adcd952e4973774b80e12ba51895286e7751372d58892
MD5 180ab6ddb9bc6fba7fbf19c48d64beb7
BLAKE2b-256 269b517d80d3dcbc956be18f198be8f303f963353185344931ec01171a84f483

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aa5ae0474fbdee2097de7f6cee76b7b8baa8158c63e8e0b59440e663c164eacd
MD5 0f572abd61a565b0a3a3ad63ed61a0f9
BLAKE2b-256 50f1190bfa353a29d1870fafa486d22d8cb7b09c2f191a588fd35df07c801e52

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c49afb7beb8e8b6264f8654f4ffabb10eba5bd4c4804f0c4831f8962e54fa9b5
MD5 dda4b6f07e6db44fd9bc6e987222a716
BLAKE2b-256 3dbc7e7fcee5e132cfba9e5ebda749b6f9fcbd4ab6acb5435d151c1e68aadd5f

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp312-none-win_amd64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 a2d75855e2bf0f7f209a2085c30bcbc2c712d0f0aa978078d57d07d7ff6c424c
MD5 9eab1acaae59550edd35af4393b930f2
BLAKE2b-256 60f6e34966e8675b61fc981ada92945c80ca83ef5daacc88ec90b5e20c20e8b8

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4452a2a07de8f35a7395ae0257f46faf0493998a232cda54011ed59e41243afc
MD5 9ffc6766ddcd374a4ab3aebf2d5c50f0
BLAKE2b-256 ea396e29e8cb2ce015663b1e8320d395b8002b4fee87f4194d7da3a9b954881f

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e74ba041f0ca1a7abcde5db6024a2f83668dee73d4e620b74bfbcebae776c022
MD5 551fb7afcac630b806a4f9d055add1ad
BLAKE2b-256 13639b89a644768e46afea5d02a3eb5ae64ad8af70ebb9e4383e442da30aac99

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a770eb69067558528bedbb19768c6006e0837c826d31703031b6c29cfd27f29
MD5 d42c6cbdcfaef32e8c7d5cc706ef4383
BLAKE2b-256 2800257cc888edd3d207d5f2133352bf301b9b0f51687e7ff22ff4c5e8cbcdef

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e04914691064f6d575ce8c9b5faa6f40ee97a26254658ccd156d354a13ca0ee6
MD5 25e3305c57598f49177408af37cb85f7
BLAKE2b-256 562adae7870e011599501761e8f863d7c1a0a7a61bf73f253e5e7cee82c9ca3e

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 c506b7e97262788a64ae6ff6a8e8b4bfc25b2193375b23074f27695a57b6af55
MD5 21b395e01d093e1ab5d1c97b04ebebdf
BLAKE2b-256 24422d526fdd2420fcc4e3a8e5addced7a11f6e7ce68943e111b7d2106d69428

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 19091f5401921897b19522d96595c7372aae946ea9707fcee579f4c0b2c754f1
MD5 5d89a898d3eaefc51dfbbb81eead99f4
BLAKE2b-256 eb8892e66a95c952478b8bdfd94cbc9abb3072d3a16447f9465f565845931d5f

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cb0dd7fc1a85cd442cc12a0d2d5dbc060372c0a28db2a7018146d99d549c58ef
MD5 9cf9b741e03d0acebd79c31e4d4c1011
BLAKE2b-256 b965fd8f061624a7f14d3f876e8ef83d99f5c8aea2154d4935758409ff7da03d

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d58f5f6a8fd1206a46428ca047a1c42043d2034f706acf318cbabaea25249e6d
MD5 4518d1233a64552b4cb28b8956dad472
BLAKE2b-256 eb188ce1a8abdd2d4b9b853e8c5bd088d0490fb7bdfff12260054445220de590

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0fde94c3ca944fa0691c0e6ffb7e79c50c53a7cefb296e644715843604e9d3a1
MD5 f13cffe163fc1bf34344001f4abea57b
BLAKE2b-256 60d3e236a3e576e51b8cb315674fb3f3035dcc51e6e4b825ed70ded43ee0694b

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 34b65289f1fea7dc84acad9d1c73c33829b4328baf80a5889a195a6c9e650b8d
MD5 3aa840a047853b31a1f761e8e895bd52
BLAKE2b-256 84f69080b71a3d338e2c5095e1758c3e7581323205da01b5bd00741f6b8c8c6f

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c03a90c9efb828a4dbdbf31890b5bc946a67bb32e0d192c6585081774053aea2
MD5 db0ad04be064222060452770cc65d275
BLAKE2b-256 3e1e3b60724452031af6f7123a071968efbd048807721d8d6c183abab64590e1

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e8138196648e662ab5ea69a6fd06e551f0d1b2b55344094e240726f97eeaaa41
MD5 79a6de765e253f2e55eb4b5966c30849
BLAKE2b-256 ac3062d68db9be4673da4e42e673e78cabf703a1ba068a13f97c7b3622fd726b

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7753e3e9dcd4210aadfc071ece22264c4fef1bd53b31d34bd63ce11f217954d5
MD5 8d9878056fb56446a5ce2cb6d35a838f
BLAKE2b-256 00a596657283d77dbac4efdb28802655bc44205fe7fe3ecddafe1c5eedaeced0

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5f2e812dea71cf9aebbf8b1bf00149600948fdbf4bbdb8805c4a4ed4b1597aba
MD5 930e08b2d83ff179d25cd069cd5953b9
BLAKE2b-256 173c89c7f6c1a44bc19b7af8799d2e49f590e32f06cba38b020db955274420f8

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp39-none-win_amd64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 907111f11c96525c3cf807bef1c0c519a1a80333981aa015a7345b8c1d29f9cf
MD5 f6895d0102691411c09c89fafa3cfc78
BLAKE2b-256 717e6437644dfaf52d6e0385fe91da250d21514c770c8dd7d6d66faff4b1f55d

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp38-none-win_amd64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 fc0b15b04b18790fa5d13411252bce648dee4984ad57365ba81120f370fa2485
MD5 aeaf1fb4f2d26b6b87a2e209c5a1b49d
BLAKE2b-256 00d39c55880eacd24b0653e1e724c0b565d3f7745fc8a873f10f5c8d111f56c6

See more details on using hashes here.

File details

Details for the file bed_reader-1.0.6-cp37-none-win_amd64.whl.

File metadata

File hashes

Hashes for bed_reader-1.0.6-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 4fb3cbfd9ed82f6a656ee09fca031ae8971293fd0b5c396440f5022dd3b58710
MD5 937ab18f7cd4e685da45bd60e1d068d4
BLAKE2b-256 8f6bcb238b39afa80c22d67187251ebd683058331a0e3be8a35d146fff475c39

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page