bed-reader
Read and write the PLINK BED format, simply and efficiently.
Features
- Fast and multi-threaded
- Supports many indexing methods. Slice data by individuals (samples) and/or SNPs (variants).
- The Python-facing API for this library is used by PySnpTools, FaST-LMM, and PyStatGen.
- Supports PLINK 1.9.
Examples
Sample files available here on Github.
Read all genotype data from a .bed file.
use ndarray as nd;
use ;
let file_name = "small.bed";
let mut bed = new?;
let val = builder.f64.read?;
assert_eq_nan;
Read individual (samples) from 20 to 30 and every second SNP (variant).
use s;
let file_name = "some_missing.bed";
let mut bed = new?;
let val = builder
.iid_index
.sid_index
.f64
.read?;
assert!;
List the first 5 individual (sample) ids, the first 5 SNP (variant) ids, and every unique chromosome. Then, read every value in chromosome 5.
use bed_reader;
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!;