annotate read_util.R @ 1:f3fa21cda5f5 draft default tip

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