bed-reader 0.2.10

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

cmk badges go here

crates.io

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).
  • Used by PySnpTools, FaST-LMM, and PyStatGen. cmk update
  • Supports PLINK 1.9.

Setup

Add this to your Cargo.toml:

[dependencies]
bed_reader = "0.1.0"

Usage

Read genomic data from a .bed file.

use bed_reader;

fn main() {
    let file_name = sample_file("small.bed");
    mut bed = bed_reader::open_bed(file_name)?;
    let val = bed.read()?;
    println!("{:?}", val);
}

Read every second individual and SNPs (variants) from 20 to 30.

use bed_reader;

fn main() {
    let file_name2 = sample_file("some_missing.bed");
    mut bed2 = bed_reader::open_bed(file_name2)?;
    let val2 = bed2.read(index=(::2,20:30))?;
    println!("{:?}", val2);
}

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;

cmk See slicing macro s! https://docs.rs/ndarray/latest/ndarray/macro.s.html

fn main() {
    let file_name2 = sample_file("some_missing.bed");
    mut bed3 = bed_reader::open_bed(file_name2)?;
    println!("{:?}", bed3.iid[:5]);
    println!("{:?}", bed3.sid[:5]);
    println!("{:?}", bed3.chromosome.unique());
    let val3 = bed.read(index=np.s_[:,bed3.chromosome=='5'])?;
    println!("{:?}", val3);
}

cmk how do you show output?

Project Links

cmk update