Mercurial > repos > nicolas > oghma
comparison computeR2.R @ 0:61780259e2fb draft
Uploaded
| author | nicolas |
|---|---|
| date | Fri, 21 Oct 2016 06:24:00 -0400 |
| parents | |
| children | 40664d2d295f |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:61780259e2fb |
|---|---|
| 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) |
