Runs every phenotype-dependent step of the HGSI pipeline: loads the pipeline output, builds the genomic relationship matrix, rebuilds the haplotype codes for all tested genes, replays the discovery gate inside each CV fold (M0 / M2 / M3), fits the final model on all phenotyped individuals, and computes the multi-trait selection index. Returns an `hgsi_fit` object that [hbr_cross_design()] consumes. Use this function on its own when the same fit will be reused for several cross-design configurations; otherwise call [hbr_advanced_decision()] which runs both parts end to end.
Usage
hbr_fit_models(
pipeline_result = NULL,
pipeline_results = NULL,
trait_dirs = NULL,
output_dir = NULL,
phenotypes = NULL,
phenotype_id_col = "ID",
gate_params = NULL,
min_concordance = 0.6,
plink_prefix = NULL,
weights = NULL,
cv_repeats = 10L,
cv_folds = 5L,
top_frac = 0.1,
min_count = 5L,
strata = NULL,
n_strata = 3L,
strict = TRUE,
final_model = c("auto", "gblup", "two_kernel"),
top_parents = 25L,
n_cores = 1L,
boot = 2000L,
seed = 1L,
verbose = TRUE
)Arguments
- pipeline_result
A single [haplobreed_analysis()] result.
- pipeline_results
Named list of results; takes precedence over `pipeline_result`.
- trait_dirs
Named character vector of pipeline output directories for traits without an in-memory result.
- output_dir
Directory for `hgsi_fit.rds` and the CV CSVs. `NULL` or `NA` writes nothing.
- phenotypes
Optional wide data.frame (ID + one column per trait, plus PC columns if the pipeline used PCs).
- phenotype_id_col
ID column of `phenotypes`.
- gate_params
Optional gate override list, per trait or shared.
- min_concordance
Minimum Jaccard overlap for the replay to count as faithful.
- plink_prefix
PLINK prefix; default `pipeline_summary$PLINK_Prefix`.
- weights
Named non-negative emphasis per genetic SD.
- cv_repeats, cv_folds
Cross-validation settings.
- top_frac
Fraction selected for realised gain.
- min_count
Minimum training carriers per haplotype indicator.
- strata, n_strata
Fold strata, or number of genotype clusters.
- strict
Recompute GRM allele frequencies inside each training fold.
- final_model
`"auto"`, `"gblup"` or `"two_kernel"`.
- top_parents
Number of parents reported.
- n_cores
Workers for the GRM.
- boot
Bootstrap resamples for the CV comparison.
- seed
Random seed.
- verbose
Print progress.
Examples
toy <- system.file("extdata", "test_data", package = "HaploBreedR")
fit <- try(hbr_fit_models(
trait_dirs = c(trait1 = toy),
plink_prefix = file.path(toy, "test"),
output_dir = tempdir(),
cv_repeats = 1L, cv_folds = 2L, strict = FALSE,
verbose = FALSE))
