Returns a small, deterministic genomic dataset bundled with the package, intended for examples, vignettes, and tests.
Usage
load_data(size = c("small", "large"))
Arguments
size
character, either “small” (default) or “large”.
Details
Two scales are bundled: size = “large” (n=200, p=500, n_qtl=20) and size = “small” (default; n=100, p=50, n_qtl=5) that run during R CMD check –examples. Both have the same family structure (10 full-sib families) and the same 12-field shape.
The data simulates a small breeding-style population: 10 full-sib families (each from one sire-dam founder pair). The founders are kept in the pedigree only (no genotype, no phenotype). A within-family 80/20 train/test split is bundled so every test individual has its full-sibs in training.
Value
A list with the following elements (dimensions shown for size = “large” / size = “small”):
snp
Integer matrix \(n \times p\) of biallelic SNP dosages (values 0/1/2). Rownames are individual IDs IND001..INDn; colnames are SNP001..SNPp. Dimensions: 200 x 500 (large) / 100 x 50 (small).
mh
Integer matrix \(n \times (2 \cdot n_{blocks})\) of microhaplotype allele codes. Columns alternate strand 1 / strand 2 per block. The attr(mh, “block_id”) attribute maps each column to its block. Consumable directly by construct_wah_matrix(). Dimensions: 200 x 500 with 250 blocks (large) / 100 x 50 with 25 blocks (small).
allele_freq
List with parallel vectors haplotype, allele, freq – the training-style allele frequency table required by construct_wah_matrix(hap, block_id, allele_freq) when no reference_structure is supplied. Pre-computed from the full bundled mh matrix.
pheno
Data frame with n rows. Columns: id, sex (factor F/M, balanced 50/50), y_cont_qtl_snp, y_cont_qtl_mh (continuous traits under two QTL architectures), y_bin_qtl_snp, y_bin_qtl_mh (binary traits, threshold at median), tbv_qtl_snp, tbv_qtl_mh (true breeding values).
pedigree
Data frame with 220 (large) or 120 (small) rows: 10 sire founders + 10 dam founders (all NA parents) plus the offspring with their sire/dam recorded. Columns: id, sire, dam.
qtl
List with snp_idx, mh_idx, effects_snp, effects_mh (each length 20 for large, 5 for small; effects drawn from rnorm, unit-normalised).
meta
List with n, n_snp, n_blocks, n_snp_per_block, n_qtl, n_families, n_per_family, h2_target, sex_beta_snp, sex_beta_mh, seed, split_seed, size.
family_id
Character vector length n, values fam_01..fam_10.
train_idx
Integer vector – row indices into snp/mh/pheno for the training set. Length 160 (large) / 80 (small).
test_idx
Integer vector – row indices for the test set. Length 40 (large) / 20 (small). Every test individual has its full-sibs in train_idx.
map_snp
Data frame with one row per SNP. Columns SNP (character), CHROM (integer 1..5), POS (integer base-pair coordinate). Aligns 1-to-1 with the columns of snp and with the design matrix from construct_snp_matrix(). Ready to pass as the map argument to run_bayesr() for GWAS. Dimensions: 500 x 3 (large) / 50 x 3 (small).
map_mh
Data frame with one row per MH block. Columns block_id (character, matches unique(attr(mh, “block_id”))), chr, start_pos, end_pos, n_snps (integers). Schema matches microhaplotype_coordinates.csv produced by the maspipeline tool, so production pipelines can pass map_mh unchanged into run_bayesr(). Physical positions are synthetic (5 chromosomes, 100 kb intra-chr SNP spacing, 1 Mb chr base offset); each block spans the two consecutive SNPs that built it. Dimensions: 250 x 5 (large) / 25 x 5 (small).
multigen
Nested list with the 3-generation forward-prediction extension. Generated by tools/make_demo_data_3gen.R (AlphaSimR + optiSel OCS) and merged into this RDS. See Multi-generation extension below for the sub-fields.
On the microhaplotype representation in d$mh
In production, microhaplotype genotypes are produced by the maspipeline preprocessing pipeline, where phasing with Beagle or Shapeit, conversion to phased haplotype alleles, LD- or window-based block discovery, then per-strand block encoding. The on-disk output is one tab-separated file per chromosome with header
Each block contributes 4 columns: hap_<b>1 hap<b>1 hap<b>2 hap<b>_2 (the per-strand block name repeated twice, with per-SNP allele codes 1 or 2 inside). Block coordinates and allele frequencies live in companion CSVs (e.g. mh_info_ld_haploblock_G0/stats/microhaplotype_coordinates.csv).
The d$mh stored here is a compact in-memory equivalent for demos: instead of per-SNP allele codes, each strand of each block is collapsed into a single integer haplotype id via a base-3 polynomial encoding of its SNP alleles. Shape becomes \(n \times (2 \cdot n_{blocks})\) (two columns per block, not four), and the per-block frequency table is bundled as d$allele_freq. Both representations encode the same biological information; d$mh skips the file-layout overhead and the recomputation of allele frequencies.
Multi-generation extension (d$multigen)
For forward-prediction examples (examples/05_forward_prediction.R), d$multigen bundles a 3-generation breeding lineage:
Gen-1 phenotyped (training pool).
Gen-2 produced by OCS selection on gen-1, one cohort per QTL architecture (gen2_snp, gen2_mh).
Gen-3 produced by OCS on gen-2, also per architecture (gen3_snp, gen3_mh).
Two evaluation scenarios are supported:
Scenario A
Train on gen-1, predict gen-2. Use multigen$reference_structure_gen1 when building \(W_{\alpha h}\) for the test cohort so columns align with training.
Scenario B
Train on gen-1 + gen-2 (per architecture), predict gen-3. Use multigen$reference_structure_gen1_gen2_snp or multigen$reference_structure_gen1_gen2_mh accordingly.
Sub-fields under d$multigen:
gen1
List(snp, mh, allele_freq, pheno, sire_of, dam_of). pheno carries both y_cont_qtl_snp and y_cont_qtl_mh plus matching tbv_qtl_* columns.
gen2_snp, gen2_mh
Gen-2 cohort lists; same shape as gen1 but pheno only carries the architecture-matching trait + tbv_qtl_*_true ground truth. allele_freq is the gen-1 frequency table (Scenario A invariant).
gen3_snp, gen3_mh
Gen-3 cohort lists, same pattern as gen-2; allele_freq is the gen-1+gen-2 combined frequency table (Scenario B reference).
Full return values of construct_wah_matrix() on the corresponding training set. Pass as reference_structure when building the test \(W_{\alpha h}\).
qtl
List with mh_idx, effects_mh, beta_mh (effect vector anchored to gen-1 \(W_{\alpha h}\) columns), and three SNP centring-mean vectors for Scenario A / B SNP centring.
pedigree
Combined pedigree across founders + gen-1 + two gen-2 cohorts + two gen-3 cohorts.
ocs
Diagnostics for all four OCS calls (current/target/realised average kinship and parent contributions), nested as ocs$<arch>$<gen1_to_gen2|gen2_to_gen3>.
meta
Per-cohort sizes, realised \(h^2\) per generation, target \(\Delta F\), seed, and AlphaSimR/optiSel/masbayes versions used to build the dataset.
Examples
Code
library("masbayes")d<-load_data()str(d, max.level =1)dim(d$snp)head(d$pheno)# Smaller dataset for fast examples / unit tests:d_small<-load_data("small")dim(d_small$snp)# Multi-generation extension: forward-prediction layoutd3<-d$multigenstr(d3, max.level =1)dim(d3$gen1$mh); dim(d3$gen2_mh$mh); dim(d3$gen3_mh$mh)# Scenario A: train gen-1, predict gen-2 (W_alpha-h aligned via gen-1 ref):W_tr<-d3$reference_structure_gen1$W_ahW_te<-construct_wah_matrix(d3$gen2_mh$mh, attr(d3$gen2_mh$mh, "block_id"), reference_structure =d3$reference_structure_gen1)$W_ah