Next changeset 1:c8ba405ffd13 (2016-10-21) |
Commit message:
Uploaded |
added:
computeR2.R |
b |
diff -r 000000000000 -r 61780259e2fb computeR2.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/computeR2.R Fri Oct 21 06:24:00 2016 -0400 |
[ |
@@ -0,0 +1,24 @@ +######################################################## +# +# creation date : 27/06/16 +# last modification : 27/06/16 +# author : Dr Nicolas Beaume +# owner : IRRI +# +######################################################## + +log <- file(paste(getwd(), "log_computeR2.txt", sep="/"), open = "wt") +sink(file = log, type="message") + +library("miscTools") +library(randomForest) + +computeR2 <- function(phenotype, prediction) { + return(rSquared(phenotype, (phenotype - prediction))[1,1]) +} +############################ main ############################# +cmd <- commandArgs(trailingOnly = T) +source(cmd[1]) +phenotype <- read.table(phenotype, sep="\t", h=T)[,1] +predicted <- read.table(predicted, sep = "\t", h=T)[,2] +cat(computeR2(phenotype, predicted), file=out) \ No newline at end of file |