bed-reader 0.2.11

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

bed-reader

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

Features

Examples

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?

Links

cmk update