Skip to content

Commit

Permalink
replaced read.table with the more advanced and automated fread from d…
Browse files Browse the repository at this point in the history
…ata.table
  • Loading branch information
pdp10 committed Dec 20, 2017
1 parent 1a556fb commit c0c3fa4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sbpipe/R/sbpipe_ps2.r
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@


library(ggplot2)
library(data.table)

# retrieve SBpipe folder containing R scripts
args <- commandArgs(trailingOnly = FALSE)
Expand Down Expand Up @@ -52,8 +53,7 @@ plot_double_param_scan_data <- function(model, scanned_par1, scanned_par2, input
}

# EXTRACT the tuples of min and max values FROM the complete dataset. Doing so, we don't need to iterate.
df <- read.table(file.path(inputdir, paste(model, "_", run, ".csv", sep="")), header=TRUE,
na.strings="NA", dec=".", sep="\t")
df <- data.frame(fread(file.path(inputdir, paste(model, "_", run, ".csv", sep=""))))

# discard the first column (Time) and the columns of the two scanned parameters
columns2discard <- c(colnames(df)[1], scanned_par1, scanned_par2)
Expand Down Expand Up @@ -81,8 +81,7 @@ plot_double_param_scan_data <- function(model, scanned_par1, scanned_par2, input
df.coordinates <- data.frame()
# Extract the coordinates of the data frame to plot
if(length(files) > 0)
df.tp <- read.table(file.path(inputdir, files[1]), header=TRUE, na.strings="NA", dec=".", sep="\t")
df.coordinates <- subset(df.tp, select=c(scanned_par1, scanned_par2))
df.coordinates <- data.frame(fread(file.path(inputdir, files[1]), select=c(scanned_par1, scanned_par2)))
#print(df.coordinates)

# Construct a generic palette
Expand All @@ -92,7 +91,7 @@ plot_double_param_scan_data <- function(model, scanned_par1, scanned_par2, input
for(j in 1:length(files)) {
print(paste('Processing file:', files[j], sep=" "))
# Read variable
df.tp <- read.table(file.path(inputdir, files[j]), header=TRUE, na.strings="NA", dec=".", sep="\t")
df.tp <- data.frame(fread(file.path(inputdir, files[j])))

for(k in 1:length(columns)) {
# add the column to plot (the colour) to the coordinate data in df.coordinates
Expand Down

0 comments on commit c0c3fa4

Please sign in to comment.