Mercurial > repos > labis-app > galaxy_proteomics
comparison read_util.R @ 0:ba070efb6f78 draft
planemo upload commit 13e72e84c523bda22bda792bbebf4720d28542d5-dirty
author | labis-app |
---|---|
date | Tue, 03 Jul 2018 17:34:13 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ba070efb6f78 |
---|---|
1 # auxiliar script to help with the read of all R scripts | |
2 read_function <- function(options) { | |
3 | |
4 # reads the table from input | |
5 table <- read.delim(options$inputfile_name, header=TRUE, fill=TRUE); | |
6 | |
7 # get the defined regex from the requested type | |
8 if (options$type == "lfqlog2") { | |
9 regexpr <- "LFQ[.]intensity[.]([^[:digit:]]+)[[:digit:]]+"; | |
10 code <- "LFQ"; | |
11 } else if (options$type == "intensity") { | |
12 regexpr <- "Intensity[.]([^[:digit:]]+)[[:digit:]]+"; | |
13 code <- "INT"; | |
14 } else { | |
15 regexpr <- "MS[.]MS[.]Count[.]([^[:digit:]]+)[[:digit:]]+"; | |
16 code <- "MS"; | |
17 } | |
18 if (!(TRUE %in% grepl(regexpr, colnames(table)))) { | |
19 print (sprintf("Error: No columns of type %s in input table", code)); | |
20 q(1,save="no"); | |
21 } | |
22 | |
23 # define the columns that will be taken in account for the t-test | |
24 columns_names <- grep(regexpr, colnames(table), value=TRUE); | |
25 | |
26 # here I extract the different experiment names in an array for easier | |
27 # manipulation, ordering them | |
28 experiment_names <- mixedsort(gsub(".*[.]([^[:digit:]]+[[:digit:]]+).*", "\\1", | |
29 columns_names)); | |
30 | |
31 # extract from the experiment names all the different categories in the table | |
32 different_categories <- unique(gsub("([^[:digit:]]+).*", "\\1", | |
33 experiment_names)); | |
34 | |
35 read_list <- list(table=table, regex=regexpr, code=code, col_names=columns_names, ex_names=experiment_names, diff_cat=different_categories); | |
36 | |
37 return(read_list); | |
38 } |