gs_fast_bayesian: Fast Bayesian Cross Validation for Genomic Selection

View source: R/gs_fast_bayesian.R

gs_fast_bayesianR Documentation

Fast Bayesian Cross Validation for Genomic Selection

Description

This function performs a cross validation using the Fast Bayesian method which requires to fit only one model per trait.

Usage

gs_fast_bayesian(
  Pheno,
  Geno,
  traits,
  folds,
  predictors = c("Env", "Line", "EnvxLine"),
  is_multitrait = FALSE,
  iterations_number = 1500,
  burn_in = 500,
  thinning = 5,
  seed = NULL,
  verbose = TRUE
)

Arguments

Pheno

(data.frame) The phenotypic data. Env and Line columns are required.

Geno

(matrix) The genotypic data. It must be a square matrix with the row and column names set to the line names in Pheno.

traits

(character) The columns' names in Pheno to be used as traits.

folds

(list) A list of folds. Each fold is a named list with two entries: training, with a vector of indices for training set, and testing, with a vector of indices for testing set. Note that this is default format for ⁠cv_*⁠ functions of SKM libraries.

predictors

(character) (case not sensitive) The predictors to be used in the model. "Env" stans for the environment effect, "Line" stands for the line effect and "EnvxLine" stands for the interaction between environment and line. "Env" and "Line" are required. ⁠c(⁠"Env"⁠, ⁠"Line"⁠, "EnvxLine")⁠ by default.

is_multitrait

(logical(1)) Is multitrait analysis? FALSE by default.

iterations_number

(numeric(1)) Number of iterations to fit the model. 1500 by default.

burn_in

(numeric(1)) Number of items to burn at the beginning of the model. 500 by default.

thinning

(numeric(1)) Number of items to thin the model. 5 by default.

seed

(numeric(1)) A value to be used as internal seed for reproducible results. NULL by default.

verbose

(logical(1)) Should the progress information be printed? TRUE by default.

validate_params

(logical(1)) Should the parameters be validated? It is not recommended to set this parameter to FALSE because if something fails a non meaningful error is going to be thrown. TRUE by default.

Value

A GSFastBayesian object with the following attributes:

  • Pheno: (data.frame) The phenotypic data.

  • Geno: (matrix) The genotypic data.

  • traits: (character) The traits' names.

  • is_multitrait: (logical(1)) Is multitrait analysis?

  • Predictions: (data.frame) The predictions of cross validation. This data.frame contains the Trait, Fold, Line, Env, Predicted and Observed columns.

  • execution_time: (difftime) The execution time taken for the analysis.

  • folds: (list) The folds used in the analysis.

  • model: (BayesianModel) The model fitted.

  • model_name: (character(1)) The name of the model.

  • iterations_number: (numeric(1)) Number of iterations to fit the model.

  • burn_in: (numeric(1)) Number of items to burn at the beginning of the model.

  • thinning: (numeric(1)) Number of items to thin the model.

See Also

Other gs_models: gs_bayesian()

Examples

data(Maize)

folds <- cv_kfold(nrow(Maize$Pheno), k = 5)

results <- gs_fast_bayesian(
  Maize$Pheno,
  Maize$Geno,

  traits = "Y",
  folds = folds,

  is_multitrait = FALSE,

  iterations_number = 10,
  burn_in = 5,
  thinning = 5,

  seed = NULL,
  verbose = TRUE
)

print(results)
#> $Predictions
#> # A tibble: 2,888 × 6
#>   Trait Fold  Line      Env   Observed Predicted
#>   <fct> <fct> <fct>     <fct>    <dbl>     <dbl>
#> 1 Y     1     L001_L003 1      -0.0274      7.11
#> 2 Y     1     L001_L012 1       0.574       3.89
#> 3 Y     1     L001_L023 1      -0.0636      3.95
#> 4 Y     1     L001_L033 1       0.215       2.05
#> 5 Y     1     L001_L034 1       0.299       2.70
#> # … with 2,883 more rows
#> # ℹ Use `print(n = ...)` to see more rows
#>
#> $traits: Y
#>
#> $is_multitrait: FALSE
#>
#> $folds: 5
#>
#> $execution_time: 0.841673 mins
#>
#> $Pheno
#>         envs_num: 4
#>         lines_num: 722
#>         rows_num: 2888
#>
#> $Geno
#>         rows_num: 722
#>         cols_num: 722
#>
#> $model_name: BGBLUP
#>
#> $iterations_number: 10
#>
#> $burn_in: 5
#>
#> $thinning: 5

brandon-mosqueda/SKM documentation built on Feb. 8, 2025, 5:24 p.m.