| 0 | 1 ######################################################## | 
|  | 2 # | 
|  | 3 # creation date : 27/06/16 | 
|  | 4 # last modification : 27/06/16 | 
|  | 5 # author : Dr Nicolas Beaume | 
|  | 6 # owner : IRRI | 
|  | 7 # | 
|  | 8 ######################################################## | 
|  | 9 | 
|  | 10 log <- file(paste(getwd(), "log_computeR2.txt", sep="/"), open = "wt") | 
|  | 11 sink(file = log, type="message") | 
|  | 12 | 
|  | 13 library("miscTools") | 
|  | 14 library(randomForest) | 
|  | 15 | 
|  | 16 computeR2 <- function(phenotype, prediction) { | 
|  | 17   return(rSquared(phenotype, (phenotype - prediction))[1,1]) | 
|  | 18 } | 
|  | 19 ############################ main ############################# | 
|  | 20 cmd <- commandArgs(trailingOnly = T) | 
|  | 21 source(cmd[1]) | 
|  | 22 phenotype <- read.table(phenotype, sep="\t", h=T)[,1] | 
|  | 23 predicted <- read.table(predicted, sep = "\t", h=T)[,2] | 
|  | 24 cat(computeR2(phenotype, predicted), file=out) |