# HG changeset patch # User proteore # Date 1521550791 14400 # Node ID 710414ebb6dbe73db7ea8d8a62cbda737af77eff # Parent ad1244024bd8f60833ec7808fb8054999fc25f26 planemo upload commit 0a42c3d46be24406936ca0036bb436e6e2524fd2-dirty diff -r ad1244024bd8 -r 710414ebb6db GO-enrich.R --- a/GO-enrich.R Wed Mar 14 12:40:35 2018 -0400 +++ b/GO-enrich.R Tue Mar 20 08:59:51 2018 -0400 @@ -4,20 +4,21 @@ library(org.Hs.eg.db) library(org.Mm.eg.db) -# Read file and return file content as data.frame? +# Read file and return file content as data.frame readfile = function(filename, header) { if (header == "true") { - # Read only the first line of the files as data (without headers): - headers <- read.table(filename, nrows = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE) - #Read the data of the files (skipping the first row): - file <- read.table(filename, skip = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE) + # Read only first line of the file as header: + headers <- read.table(filename, nrows = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE, quote = "") + #Read the data of the files (skipping the first row) + file <- read.table(filename, skip = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE, quote = "") # Remove empty rows file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE] - #And assign the headers of step two to the data: + #And assign the header to the data names(file) <- headers } else { - file <- read.table(filename, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE) + file <- read.table(filename, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE, quote = "") + # Remove empty rows file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE] } return(file) @@ -92,7 +93,7 @@ input_type = args$input_type if (input_type == "text") { - input = args$input + input = strsplit(args$input, "[ \t\n]+")[[1]] } else if (input_type == "file") { filename = args$input diff -r ad1244024bd8 -r 710414ebb6db cluster_profiler.xml --- a/cluster_profiler.xml Wed Mar 14 12:40:35 2018 -0400 +++ b/cluster_profiler.xml Tue Mar 20 08:59:51 2018 -0400 @@ -13,7 +13,7 @@ Rscript "$__tool_directory__/GO-enrich.R" #if $input.ids == "text" --input_type="text" - --input="$input.text" + --input="$input.txt" #else --input_type="file" --input="$input.file"