Mercurial > repos > proteore > proteore_goprofiles
diff goprofiles.R @ 4:715002a394ec draft
planemo upload commit b36435833bf54f90f62cc240f2cda1c889161b23-dirty
author | proteore |
---|---|
date | Fri, 23 Mar 2018 10:47:17 -0400 |
parents | 58a8ddd58dde |
children | 781072a65600 |
line wrap: on
line diff
--- a/goprofiles.R Wed Mar 14 12:51:53 2018 -0400 +++ b/goprofiles.R Fri Mar 23 10:47:17 2018 -0400 @@ -2,20 +2,22 @@ library(org.Hs.eg.db) library(goProfiles) -# 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) - #Read the data of the files (skipping the first row): - file <- read.table(filename, skip = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = 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),] - #And assign the headers of step two to the data: + file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE] + #And assign the header to the data names(file) <- headers } else { - file <- read.table(filename, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = 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) } @@ -175,7 +177,7 @@ input_type = args$input_type if (input_type == "text") { - input = strsplit(args$input, " ")[[1]] + input = strsplit(args$input, "[ \t\n]+")[[1]] } else if (input_type == "file") { filename = args$input