X-Git-Url: https://git.auder.net/variants/%24%7Bvname%7D/current/gitweb.css?a=blobdiff_plain;f=code%2Fstage1%2Fwrapper.R;h=0a957d8062552459fc7a3a2760242e06627bc6c5;hb=73d68777d709e054cf74e806e23b0bdefda9462a;hp=9bbb53b035e27b72f76d1dec1b30d6dda3312ba1;hpb=ebf1280e432d51f47238ce8df86750ba3a7d6d1f;p=epclust.git diff --git a/code/stage1/wrapper.R b/code/stage1/wrapper.R index 9bbb53b..0a957d8 100644 --- a/code/stage1/wrapper.R +++ b/code/stage1/wrapper.R @@ -1,15 +1,35 @@ -ppam_exe = function(path=".", np=parallel::detectCores(), data=NULL, args="DontLetMeEmpty") +ppam_exe = function(path=".", np=parallel::detectCores(), data=NULL, + args="DontLetMeEmptyPlease!") { - command_line = paste("mpirun -np ",np," ",path,"/ppam.exe",sep="") + command_line = paste("mpirun -np ",np," ",path,"/ppam.exe cluster",sep="") #if data provided (as data.frame or matrix...): binarize it, and add it as first argument if (!is.null(data)) { - write.csv(data, "/tmp/data_csv") - system(paste(path,"/ppam.exe serialize /tmp/data_csv /tmp/data_bin 0 0",sep="")) - command_line = paste(command_line," ","/tmp/data_bin",sep="") + if (!is.character(data)) + { + #assuming matrix or data.frame, WITH row names + #( identifiers; could be line number... e.g. data <- cbind(1:nrow(data),data) ) + write.table(data, "/tmp/data_csv", sep=",", row.names=FALSE, col.names=FALSE) + system(paste(path,"/ppam.exe serialize /tmp/data_csv /tmp/data_bin 0 0",sep="")) + } else + { + system(paste(path,"/ppam.exe serialize ",data," /tmp/data_bin 0 0",sep="")) + } + command_line = paste(command_line," /tmp/data_bin",sep="") } command_line = paste(command_line," ",args,sep="") system(command_line) } + +#NOTE: identifiers in first column +getMedoids = function(path=".", xmlResult = "ppamResult.xml", + finalSeries = "ppamFinalSeries.bin") +{ + system(paste(path,"/ppam.exe deserialize ",finalSeries," ppamFinalSeries.csv -1",sep="")) + curves = read.table("ppamFinalSeries.csv", sep=",") + library(XML) + ranks = as.integer( xmlToList( xmlParse(xmlResult) )$ranks ) + return ( curves[ranks,] ) # == medoids +}