diff computeR2.R @ 0:61780259e2fb draft

Uploaded
author nicolas
date Fri, 21 Oct 2016 06:24:00 -0400
parents
children 40664d2d295f
line wrap: on
line diff
--- /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