From 0f7603ef9ae1db7317a2b0763663e848c2f8a11d Mon Sep 17 00:00:00 2001 From: Alexander Bondarev Date: Wed, 9 Mar 2016 16:04:48 +0300 Subject: [PATCH 1/2] Fix matching different group representation for timepoints and data in LineGraph (data groups may be shortened) --- web-app/Rscripts/LineGraph/LineGraphLoader.r | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web-app/Rscripts/LineGraph/LineGraphLoader.r b/web-app/Rscripts/LineGraph/LineGraphLoader.r index b6768a52..1b8f484f 100644 --- a/web-app/Rscripts/LineGraph/LineGraphLoader.r +++ b/web-app/Rscripts/LineGraph/LineGraphLoader.r @@ -33,7 +33,9 @@ LineGraph.loader <- function( scaling.data <- data.frame(GROUP = unique(line.data$GROUP), VALUE = 1:length(unique(line.data$GROUP))) } # assign the X-axis position to each row - line.data$TIME_VALUE <- sapply(line.data$GROUP,FUN = function(groupValue) { scaling.data$VALUE[which(groupValue==scaling.data$GROUP)] }) + line.data$TIME_VALUE <- sapply(line.data$GROUP,FUN = function(groupValue) { + scaling.data$VALUE[which(substring(scaling.data$GROUP, nchar(scaling.data$GROUP)-nchar(groupValue)+1)==groupValue)] + }) # Either plot a single LineGraph (if there are no plot_group values) # or, for each group-value, retrieve rows for that value and plot LineGraph @@ -102,7 +104,7 @@ LineGraph.plotter <- function( #Use a regular expression trim out the timepoint from the concept. #dataOutput$TIMEPOINT <- str_extract(dataOutput$TIMEPOINT,"Week [0-9]+") dataOutput$TIMEPOINT <- as.character(dataOutput$TIMEPOINT) - TIMEPOINT_reducedConceptPath <- str_extract(dataOutput$TIMEPOINT,"(\\\\.+\\\\.+\\\\)+?$") + TIMEPOINT_reducedConceptPath <- str_extract(dataOutput$TIMEPOINT,"(\\\\[^\\\\]+\\\\[^\\\\]+\\\\)$") validReplacements <- which(!is.na(TIMEPOINT_reducedConceptPath)) dataOutput$TIMEPOINT[validReplacements] <- TIMEPOINT_reducedConceptPath[validReplacements] dataOutput$TIMEPOINT <- as.factor(dataOutput$TIMEPOINT) From a3b35d5ff6f8de9597a99c6a66f5f2ab29df944a Mon Sep 17 00:00:00 2001 From: Alexander Bondarev Date: Wed, 9 Mar 2016 17:54:33 +0300 Subject: [PATCH 2/2] Fix default scaling data building for LineGraph --- web-app/Rscripts/LineGraph/LineGraphLoader.r | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-app/Rscripts/LineGraph/LineGraphLoader.r b/web-app/Rscripts/LineGraph/LineGraphLoader.r index 1b8f484f..48378ed8 100644 --- a/web-app/Rscripts/LineGraph/LineGraphLoader.r +++ b/web-app/Rscripts/LineGraph/LineGraphLoader.r @@ -30,7 +30,7 @@ LineGraph.loader <- function( scaling.data <- read.delim(scaling.filename, header=T, stringsAsFactors = FALSE) } } else { # if scaling file is not available, each level of group (concept path) will be plotted at the number of that level - scaling.data <- data.frame(GROUP = unique(line.data$GROUP), VALUE = 1:length(unique(line.data$GROUP))) + scaling.data <- data.frame(GROUP = unique(line.data$GROUP), VALUE = 1:length(unique(line.data$GROUP)), stringsAsFactors = FALSE) } # assign the X-axis position to each row line.data$TIME_VALUE <- sapply(line.data$GROUP,FUN = function(groupValue) {