comparison GO-enrich.R @ 4:710414ebb6db draft

planemo upload commit 0a42c3d46be24406936ca0036bb436e6e2524fd2-dirty
author proteore
date Tue, 20 Mar 2018 08:59:51 -0400
parents bd052861852b
children 8a91f58782df
comparison
equal deleted inserted replaced
3:ad1244024bd8 4:710414ebb6db
2 2
3 #library(org.Sc.sgd.db) 3 #library(org.Sc.sgd.db)
4 library(org.Hs.eg.db) 4 library(org.Hs.eg.db)
5 library(org.Mm.eg.db) 5 library(org.Mm.eg.db)
6 6
7 # Read file and return file content as data.frame? 7 # Read file and return file content as data.frame
8 readfile = function(filename, header) { 8 readfile = function(filename, header) {
9 if (header == "true") { 9 if (header == "true") {
10 # Read only the first line of the files as data (without headers): 10 # Read only first line of the file as header:
11 headers <- read.table(filename, nrows = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE) 11 headers <- read.table(filename, nrows = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE, quote = "")
12 #Read the data of the files (skipping the first row): 12 #Read the data of the files (skipping the first row)
13 file <- read.table(filename, skip = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE) 13 file <- read.table(filename, skip = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE, quote = "")
14 # Remove empty rows 14 # Remove empty rows
15 file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE] 15 file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE]
16 #And assign the headers of step two to the data: 16 #And assign the header to the data
17 names(file) <- headers 17 names(file) <- headers
18 } 18 }
19 else { 19 else {
20 file <- read.table(filename, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE) 20 file <- read.table(filename, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE, quote = "")
21 # Remove empty rows
21 file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE] 22 file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE]
22 } 23 }
23 return(file) 24 return(file)
24 } 25 }
25 26
90 args <- as.list(as.character(argsDF$V2)) 91 args <- as.list(as.character(argsDF$V2))
91 names(args) <- argsDF$V1 92 names(args) <- argsDF$V1
92 93
93 input_type = args$input_type 94 input_type = args$input_type
94 if (input_type == "text") { 95 if (input_type == "text") {
95 input = args$input 96 input = strsplit(args$input, "[ \t\n]+")[[1]]
96 } 97 }
97 else if (input_type == "file") { 98 else if (input_type == "file") {
98 filename = args$input 99 filename = args$input
99 ncol = args$ncol 100 ncol = args$ncol
100 # Check ncol 101 # Check ncol