masgenomics
Genomic prediction with SNP and microhaplotype data
This site documents two companion R packages with Rust backends:
- masreml — REML-based mixed models, BLUP/GBLUP/GWABLUP, GWAS, cross-validation, threshold models for binary traits.
- masbayes — Bayesian genomic prediction (BayesA, BayesR).
Both packages support SNP and microhaplotype genotypes natively.
Why Rust?
I have only understood and implemented Rust for more than 4 years, mostly just for website backends or desktop applications, and yes, this is the largest Rust project I have ever built for the purpose of end-to-end genomic selection — especially based on multi-allelic markers. Indeed, Rust is not yet widely used as a backend for R packages today (the majority use C++), but this is a good opportunity to introduce Rust as a memory-safe programming language for processing large genomic data, which can even be used on laptops/PCs with low- to mid-range specifications. This project is open source and free, so anyone can provide evaluation and improvement.
In practice this means: the heavy numerical kernels (variance-component estimation, MCMC samplers, dense linear algebra for the GRM solve, GWAS scans across hundreds of thousands of markers) run in compiled Rust through the extendr FFI boundary, while the user-facing API stays in idiomatic R. Memory-safety guarantees from Rust’s ownership model also mean no segfaults from out-of-bounds indexing or use-after-free on large genotype matrices — failures surface as recoverable R errors instead of crashing the session.
See Installation for how to set up Rust and both packages on Linux, macOS, and Windows.
Where to go next
| You are… | Start here |
|---|---|
| Setting up for the first time | Installation |
| New to genomic prediction | Theory → Mixed Model & BLUP Family |
| Looking for code examples | Tasks → Genomic Prediction |
| Looking for input-data formats and the bundled demo | Input Data |
| Looking for function docs | Reference → masreml · masbayes |
| Curious about the Rust internals | Internals |
Citation
If you use these packages, please cite — see CITATION.