cv: Evaluate Trait Predictability via Cross Validation

Description Usage Arguments Value Examples

View source: R/cv.r

Description

The cv function evaluates trait predictability based on eight GS methods via k-fold cross validation. The trait predictability is defined as the squared Pearson correlation coefficient between the observed and the predicted trait values.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
cv(
  fix = NULL,
  gena,
  gend = NULL,
  y,
  method = "GBLUP",
  nfold = 5,
  nTimes = 1,
  seed = 123,
  CPU = 1
)

Arguments

fix

a design matrix of the fixed effects.

gena

a matrix (n x m) of additive genotypes for the training population.

gend

a matrix (n x m) of domiance genotypes for the training population. Default is NULL.

y

a vector(n x 1) of the phenotypic values.

method

eight GS methods including "GBLUP", "BayesB", "RKHS", "PLS", "LASSO", "EN", "XGBOOST", "RF". Users may select one of these methods or all of them simultaneously with "ALL". Default is "GBLUP".

nfold

the number of folds. Default is 5.

nTimes

the number of independent replicates for the cross-validation. Default is 1.

seed

the random number. Default is 123.

CPU

the number of CPU.

Value

Trait predictability

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## load example data from hypred package
data(hybrid_phe)
data(input_geno)

## convert original genotype
inbred_gen <- convertgen(input_geno, type = "hmp2")

##additive model infer the additive and dominance genotypes of hybrids
gena <- infergen(inbred_gen, hybrid_phe)$add
gend <- infergen(inbred_gen, hybrid_phe)$dom

##additive model
R2<-cv(fix=NULL,gena,gend=NULL,y=hybrid_phe[,3],method ="GBLUP",nfold=5,nTimes=1,seed=123,CPU=1)

##additive-dominance model
R2<-cv(fix=NULL,gena,gend,y=hybrid_phe[,3],method ="GBLUP",nfold=5,nTimes=1,seed=123,CPU=1)

predhy documentation built on Aug. 16, 2021, 5:07 p.m.

Related to cv in predhy...