Computes EBVs using one of two modes:
software = "blupf90"— runs the BLUPF90 suite (renumf90+blupf90+). Both binaries must be on PATH. Writes all input/output files to a timestamped subfolder ofrun_dirfor inspection and reproducibility.parent_avg = TRUE— simple average of parent EBVs already stored inind_ebvfor the givenmodel. ReturnsNAfor any animal whose parents do not both have EBVs.
The first argument is a tidybreed_table (from get_table() and
optionally dplyr::filter()). The filter controls which animals' phenotypic
records are included in the evaluation; ancestors are traced back
automatically for the pedigree via n_gen_pedigree.
Usage
add_ebv(
tbl,
trait_name,
software = NULL,
parent_avg = FALSE,
model = "model_1",
overwrite_trait = FALSE,
delete_all = FALSE,
n_gen_pedigree = 2L,
chip_name = NULL,
run_dir = ".",
eval_id = NULL,
estimate_var = FALSE,
update_covars = FALSE,
phenotype = NULL,
...
)Arguments
- tbl
A
tidybreed_tablefromget_table()(optionally filtered). Must contain anid_indcolumn.- trait_name
Character vector of trait name(s) to evaluate.
- software
Character or
NULL(default). Set to"blupf90"to run the BLUPF90 suite (currently the only supported value). Exactly one ofsoftware = "blupf90"orparent_avg = TRUEmust be supplied — leaving both at their defaults, or setting both, is an error.- parent_avg
Logical. If
TRUE, compute EBVs as the average of parent EBVs fromind_ebv(for the givenmodel). Cannot be combined withsoftware; seesoftwareabove. DefaultFALSE.- model
Character. Label stored in
ind_ebv$model. Must be a valid SQL identifier. Default"model_1".- overwrite_trait
Logical. If
TRUE, all existingind_ebvrows for the traits being added are deleted before inserting; new rows receiveeval_number = 1. DefaultFALSE.- delete_all
Logical. If
TRUE, all rows inind_ebvare deleted before inserting; new rows receiveeval_number = 1. Takes precedence overoverwrite_trait. DefaultFALSE.- n_gen_pedigree
Integer. Generations to trace back from the filtered candidates when building the pedigree file. Default
2. Used only insoftware = "blupf90"mode; ignored underparent_avg = TRUE.- chip_name
Character or
NULL. Name of a SNP chip defined viadefine_chip()(e.g."HD"). When provided, genotype file is written and single-step GBLUP (ssGBLUP) is requested viaSNP_FILEinrenum.par. Animals must havehas_{chip_name} = TRUEinind_meta(validated up front regardless of mode). Used only insoftware = "blupf90"mode; silently unused underparent_avg = TRUE.- run_dir
Character. Base directory for evaluation sub-folders. Default
"."(working directory). Ignored whenpop$run_dirsis non-empty (i.e. whenopen_pop()was called with atoolsargument) — the managed output folder structure is used instead. Applies only insoftware = "blupf90"mode.- eval_id
Character or
NULL. Sub-folder name suffix appended to"eval_". Auto-generated frommodel+ timestamp whenNULL. Ignored in managed output mode (seerun_dirabove); the run directory name generated by.create_run_dir()is used as the identifier. Applies only insoftware = "blupf90"mode.- estimate_var
Logical. If
TRUE, request variance component estimation (OPTION method VCE) instead of BLUP-only. DefaultFALSE. Applies only insoftware = "blupf90"mode.- update_covars
Logical. If
estimate_var = TRUE, attempt to write estimated variance components back totrait_var_comp. DefaultFALSE. Not yet implemented: the current writeback step (update_covars_from_blupf90()) is a stub that only prints a message pointing you toblupf90.outanddefine_effect_cov_matrix()for a manual update — no rows are written automatically yet. Applies only insoftware = "blupf90"mode.- phenotype
Optional
tidybreed_tablefromget_table("ind_phenotype") |> filter(...). When supplied, only phenotype records matching the filter are included in the BLUPF90 data file. The pedigree is unaffected — all traced ancestors remain in the pedigree file regardless of this filter. Ignored (with a warning) inparent_avgmode. Applies only insoftware = "blupf90"mode.- ...
Optional extra columns written to
ind_ebv(scalars only; broadcast to all records). Supply per-record vectors withmutate_table()after the call.
Value
The modified tidybreed_pop (invisibly). EBVs are appended to
ind_ebv with an auto-incrementing eval_number per trait. Use
overwrite_trait = TRUE or delete_all = TRUE to clear previous records
instead of accumulating them.
Examples
if (FALSE) { # \dontrun{
# Parent average (parents must already have EBVs in ind_ebv for model
# "pa_v1" -- see the versioning example below for how eval_number accrues)
# Model / eval_number versioning: each call for the same `model` label
# appends a new eval_number rather than overwriting (ind_ebv's logical key
# is id_ind x trait_name x model x eval_number). Re-running as new data
# arrives builds up a history of evaluations you can compare over time;
# `overwrite_trait = TRUE` instead clears prior rows for the trait(s) and
# restarts eval_number at 1 for that model.
pop <- pop |>
get_table("ind_meta") |>
dplyr::filter(gen == 2L) |>
add_ebv("ADG", parent_avg = TRUE, model = "pa_v1") # eval_number = 1
pop <- pop |>
get_table("ind_meta") |>
dplyr::filter(gen == 3L) |>
add_ebv("ADG", parent_avg = TRUE, model = "pa_v1") # eval_number = 2
pop <- pop |>
get_table("ind_meta") |>
dplyr::filter(gen == 2L) |>
add_ebv("ADG", parent_avg = TRUE, model = "pa_v1", overwrite_trait = TRUE) # back to 1
# BLUPF90 — renumf90 and blupf90+ must be on PATH
pop <- pop |>
get_table("ind_meta") |>
dplyr::filter(gen >= 3L) |>
add_ebv(c("ADG", "BW"),
software = "blupf90",
model = "blup_v1",
run_dir = "./eval_runs",
n_gen_pedigree = 2)
# BLUPF90 with a phenotype filter (e.g. excluding a custom-added date
# column's future/incomplete records) -- `pheno_date` here is a user-added
# column (e.g. via add_phenotype(..., pheno_date = Sys.Date())), not a
# built-in ind_phenotype column
pop <- pop |>
get_table("ind_meta") |>
dplyr::filter(gen >= 3L) |>
add_ebv(c("ADG", "BF"),
software = "blupf90",
model = "blup_v1",
phenotype = pop |>
get_table("ind_phenotype") |>
dplyr::filter(pheno_date < Sys.Date()))
} # }
