run_cv: Cross validated prediction

Description Usage Arguments Value Examples

View source: R/run_cv.R

Description

run_cv returns a data frame with predicted values.

Usage

1
2
run_cv(Pheno, ETA, cv, father_idx, mother_idx, split_char, trait, iter,
  speed_tst, run, verbose = FALSE, out_loc)

Arguments

Pheno

A matrix with phenotypic BLUES.

ETA

A list with ETA-objects for BGLR.

cv

A data.frame with the cross validation scheme.

father_idx

NULL. A numeric or integer indicating the position of the parental ID in hybrid.

mother_idx

NULL. A numeric or integer indicating the position of the maternal ID in hybrid.

split_char

Character, which splits paternal and maternals IDs in hybrid.

trait

Character vector with the name of the trait in Pheno.

iter

Integer with the number of BGLR iterations.

speed_tst

Boolean. Indicates whether a speed test (TRUE) or actual predictions (FALSE) shall be run.

run

Integer specifying the current run corresponding to the predicted genotype in Pheno.

verbose

Boolean. Shall BGLR output be printed to the console?

out_loc

Path to the directory where temporary BGLR-output will be stored.

Value

Predicted values based on leave-one-out cross validation (LOOCV).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
data("hybrid_nms", "mrna", "imp_snps", "Pheno")
geno <- vapply(strsplit(hybrid_nms, split = "_"), FUN = "[[", 1,
               FUN.VALUE = character(1))
x <- imp_snps[rownames(imp_snps) %in% geno, ]
y <- mrna[rownames(mrna) %in% geno, ]
# BGLR ETA objects
eta <- impute_eta(x = x, y = y, as_kernel = TRUE, is_pedigree = FALSE,
                  geno = geno, bglr_model = "BRR")
eta[] <- lapply(seq_along(eta), FUN = function(i) {
  dat <- eta[[i]]
  x <- dat[["X"]]
  rownames(x) <- hybrid_nms
  dat[["X"]] <- x
  dat
})
# CV scheme generation
cv_mat <- sample_cv(hybrid_nms, n_mother = 39, n_father = 33,
                    n_hyb_trn = 200, min_size = 20, rounds = 2L,
                    hybrid_split = "_")
cv_mat <- cv_mat[[1]]
colnames(cv_mat) <- seq_len(ncol(cv_mat))
rownames(cv_mat) <- gsub("DF_", replacement = "", x = rownames(cv_mat))
cv <- as.data.frame(cv_mat)
cv$Sample_ID <- rownames(cv)
cv <- tidyr::gather(cv, Run, Set, -Sample_ID)
dir.create("./bglr_out")
# Run the prediction
run_cv(Pheno = Pheno, ETA = eta, cv = cv, father_idx = 2, mother_idx = 1,
       split_char = "_", trait = "gtm", iter = 2500L,
       speed_tst = FALSE, run = 1L, verbose = FALSE,
       out_loc = "./bglr_out/")
unlink("./bglr_out", recursive = TRUE)

mwesthues/sspredr documentation built on May 23, 2019, 10:56 a.m.