bed-reader
Read and write the PLINK BED format, simply and efficiently.
Highlights
- Fast and multi-threaded
- Supports many indexing methods. Slice data by individuals (samples) and/or SNPs (variants).
- The Python-facing APIs for this library is used by PySnpTools, FaST-LMM, and PyStatGen.
- Supports PLINK 1.9.
- Read data locally or from the cloud, efficiently and directly.
Install
Full version: Can read local and cloud files
Minimal version: Can read local files, only
Examples
Read all genotype data from a .bed file.
use ndarray as nd;
use ;
let file_name = sample_bed_file?;
let mut bed = new?;
let val = builder.f64.read?;
assert_eq_nan;
# use BedErrorPlus; // '#' needed for doctest
# Ok::
Read every second individual (samples) and SNPs (variants) 20 to 30.
use s;
let file_name = sample_bed_file?;
let mut bed = new?;
let val = builder
.iid_index
.sid_index
.f64
.read?;
assert!;
# use ; // '#' needed for doctest
# Ok::
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.
# use s; // '#' needed for doctest
# use ;
# let file_name = sample_bed_file?;
use HashSet;
let mut bed = new?;
println!; // Outputs ndarray: ["iid_0", "iid_1", "iid_2", "iid_3", "iid_4"]
println!; // Outputs ndarray: ["sid_0", "sid_1", "sid_2", "sid_3", "sid_4"]
println!;
// Outputs: {"12", "10", "4", "8", "19", "21", "9", "15", "6", "16", "13", "7", "17", "18", "1", "22", "11", "2", "20", "3", "5", "14"}
let val = builder
.sid_index
.f64
.read?;
assert!;
# use BedErrorPlus; // '#' needed for doctest
# Ok::
From the cloud: open a file and read data for one SNP (variant)
at index position 2. (See "Cloud URLs and CloudFile Examples"
for details specifying a file in the cloud.)
use ndarray as nd;
use ;
# new.unwrap.block_on.unwrap;
# use ;