annotate GO_MWU.R @ 2:5acf9dfdfa27 draft default tip

planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
author cristian
date Wed, 09 Nov 2022 08:57:54 +0000
parents f7287f82602f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
1
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
2 # GO_MWU uses continuous measure of significance (such as fold-change or
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
3 # -log(p-value) ) to identify GO categories that are significantly enriches
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
4 # with either up- or down-regulated genes. The advantage - no need to impose
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
5 # arbitrary significance cutoff.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
6
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
7 # If the measure is binary (0 or 1) the script will perform a typical "GO
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
8 # enrichment" analysis based Fisher's exact test: it will show GO categories
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
9 # over-represented among the genes that have 1 as their measure.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
10
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
11 # On the plot, different fonts are used to indicate significance and color
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
12 # indicates enrichment with either up (red) or down (blue) regulated genes.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
13 # No colors are shown for binary measure analysis.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
14
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
15 # The tree on the plot is hierarchical clustering of GO categories based on
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
16 # shared genes. Categories with no branch length between them are subsets of each other.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
17
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
18 # The fraction next to GO category name indicates the fracton of "good" genes
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
19 # in it; "good" genes being the ones exceeding the arbitrary absValue cutoff
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
20 # (option in gomwuPlot). For Fisher's based test, specify absValue = 0.5.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
21 # This value does not affect statistics and is used for plotting only.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
22
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
23 # Stretch the plot manually to match tree to text
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
24
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
25 # Mikhail V. Matz, UT Austin, February 2015; matz@utexas.edu
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
26
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
27
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
28 # setup R error handling to go to stderr
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
29 options(show.error.messages = F, error = function() {
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
30 cat(geterrmessage(), file = stderr())
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
31 q("no", 1, F)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
32 })
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
33
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
34 # we need that to not crash galaxy with an UTF8 error on German LC settings.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
35 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
36
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
37 library("getopt")
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
38 library("tools")
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
39 options(stringAsFactors = FALSE, useFancyQuotes = FALSE)
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
40
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
41 getScriptPath <- function() {
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
42 cmd.args <- commandArgs()
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
43 m <- regexpr("(?<=^--file=).+", cmd.args, perl = TRUE)
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
44 script.dir <- dirname(regmatches(cmd.args, m))
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
45 if (length(script.dir) == 0) stop("can't determine script dir: please call the script with Rscript")
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
46 if (length(script.dir) > 1) stop("can't determine script dir: more than one '--file' argument detected")
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
47 return(script.dir)
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
48 }
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
49
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
50 args <- commandArgs(trailingOnly = TRUE)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
51
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
52 # get options, using the spec as defined by the enclosed list.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
53 # we read the options from the default: commandArgs(TRUE).
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
54 spec <- matrix(c(
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
55 "help", "h", 0, "logical",
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
56 "input", "i", 1, "character",
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
57 "goAnnotations", "a", 1, "character",
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
58 "goDatabase", "g", 1, "character",
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
59 "goDivision", "d", 1, "character",
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
60 "largest", "o", 1, "numeric",
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
61 "smallest", "m", 1, "numeric",
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
62 "absValue", "k", 1, "numeric",
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
63 "clusterheight", "c", 1, "numeric",
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
64 "textsize", "e", 1, "numeric",
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
65 "pcut", "p", 1, "numeric",
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
66 "hcut", "t", 1, "numeric",
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
67 "l1", "1", 1, "numeric",
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
68 "l2", "2", 1, "numeric",
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
69 "l3", "3", 1, "numeric",
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
70 "version", "v", 0, "character"
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
71 ), byrow = TRUE, ncol = 4)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
72 opt <- getopt(spec)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
73
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
74 # if help was asked for print a friendly message
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
75 # and exit with a non-zero error code
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
76 if (!is.null(opt$help)) {
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
77 cat(getopt(spec, usage = TRUE))
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
78 q(status = 1)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
79 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
80
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
81 if (!is.null(opt$version)) {
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
82 cat("0.3.0\n")
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
83 q(status = 1)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
84 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
85
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
86 scriptdir <- getScriptPath()
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
87
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
88 ### if running in Rstudio ###
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
89 # Uncomment this block, change the values and run from here.
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
90 # opt = list()
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
91 # opt$input = "heats.csv"
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
92 # opt$goAnnotations = "amil_defog_iso2go.tab"
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
93 # opt$goDatabase = "go.obo"
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
94 # opt$goDivision = "BP"
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
95
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
96 ### Optionally uncomment the options below that you want to change and change the default value.
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
97 # opt$clusterheight <- 0.25
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
98 # opt$textsize <- 1.2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
99 # opt$largest <- 0.1
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
100 # opt$smallest <- 5
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
101 # opt$absValue <- -log(0.05,10)
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
102 # opt$l1 <- 0.1
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
103 # opt$l2 <- 0.05
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
104 # opt$l3 <- 0.01
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
105 # opt$pcut <- 1e-2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
106 # opt$hcut <- 0.9
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
107
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
108
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
109 # enforce the following required arguments
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
110 if (is.null(opt$input)) {
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
111 cat("'input' is required\n")
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
112 q(status = 1)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
113 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
114 if (is.null(opt$goDatabase)) {
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
115 cat("'goDatabase' is required\n")
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
116 q(status = 1)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
117 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
118 if (is.null(opt$goAnnotations)) {
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
119 cat("'goAnnotations' is required\n")
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
120 q(status = 1)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
121 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
122 if (is.null(opt$goDivision)) {
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
123 cat("'goDivision' is required\n")
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
124 q(status = 1)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
125 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
126 if (is.null(opt$clusterheight)) {
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
127 opt$clusterheight <- 0.25
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
128 }
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
129 if (is.null(opt$textsize)) {
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
130 opt$textsize <- 1.2
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
131 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
132 if (is.null(opt$largest)) {
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
133 opt$largest <- 0.1
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
134 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
135 if (is.null(opt$smallest)) {
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
136 opt$smallest <- 5
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
137 }
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
138 if (is.null(opt$absValue)) {
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
139 opt$absValue <- -log(0.05, 10)
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
140 }
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
141 if (is.null(opt$l1)) {
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
142 opt$l1 <- 0.1
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
143 }
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
144 if (is.null(opt$l2)) {
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
145 opt$l2 <- 0.05
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
146 }
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
147 if (is.null(opt$l3)) {
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
148 opt$l3 <- 0.01
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
149 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
150 if (is.null(opt$pcut)) {
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
151 opt$pcut <- 1e-2
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
152 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
153 if (is.null(opt$hcut)) {
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
154 opt$hcut <- 0.9
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
155 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
156
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
157 source_local <- function(fname) {
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
158 # argv <- commandArgs(trailingOnly = FALSE)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
159 # base_dir <- dirname(substring(argv[grep("--file = ", argv)], 8))
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
160 base_dir <- scriptdir
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
161 source(paste(base_dir, fname, sep = "/"))
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
162 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
163
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
164 source_local("gomwu.functions.R")
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
165
1
f7287f82602f "planemo upload commit 486235d6560c9e95bd42152ad19bf7c3941cdc1b"
cristian
parents: 0
diff changeset
166
f7287f82602f "planemo upload commit 486235d6560c9e95bd42152ad19bf7c3941cdc1b"
cristian
parents: 0
diff changeset
167 nn <- strsplit(opt$input, "[/.]")
f7287f82602f "planemo upload commit 486235d6560c9e95bd42152ad19bf7c3941cdc1b"
cristian
parents: 0
diff changeset
168 if (length(nn[[1]]) == 3) {
f7287f82602f "planemo upload commit 486235d6560c9e95bd42152ad19bf7c3941cdc1b"
cristian
parents: 0
diff changeset
169 dir <- nn[[1]][1]
f7287f82602f "planemo upload commit 486235d6560c9e95bd42152ad19bf7c3941cdc1b"
cristian
parents: 0
diff changeset
170 name <- nn[[1]][2]
f7287f82602f "planemo upload commit 486235d6560c9e95bd42152ad19bf7c3941cdc1b"
cristian
parents: 0
diff changeset
171 ext <- nn[[1]][3]
f7287f82602f "planemo upload commit 486235d6560c9e95bd42152ad19bf7c3941cdc1b"
cristian
parents: 0
diff changeset
172 } else if (length(nn[[1]]) == 2) {
f7287f82602f "planemo upload commit 486235d6560c9e95bd42152ad19bf7c3941cdc1b"
cristian
parents: 0
diff changeset
173 dir <- "."
f7287f82602f "planemo upload commit 486235d6560c9e95bd42152ad19bf7c3941cdc1b"
cristian
parents: 0
diff changeset
174 name <- nn[[1]][1]
f7287f82602f "planemo upload commit 486235d6560c9e95bd42152ad19bf7c3941cdc1b"
cristian
parents: 0
diff changeset
175 ext <- nn[[1]][2]
f7287f82602f "planemo upload commit 486235d6560c9e95bd42152ad19bf7c3941cdc1b"
cristian
parents: 0
diff changeset
176 }
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
177 # It might take a few minutes for MF and BP. Do not rerun it if you just want
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
178 # to replot the data with different cutoffs, go straight to gomwuPlot. If you
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
179 # change any of the numeric values below, delete the files that were generated
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
180 # in previos runs first.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
181
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
182 gomwuStats(opt$input, opt$goDatabase, opt$goAnnotations, opt$goDivision, scriptdir,
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
183 # replace with full path to perl executable if it is not in your system's PATH already
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
184 perlPath = "perl",
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
185 # a GO category will not be considered if it contains more than this fraction of the total number of genes
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
186 largest = opt$largest,
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
187 smallest = opt$smallest, # a GO category should contain at least this many genes to be considered.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
188 clusterCutHeight = opt$clusterheight, # threshold for merging similar (gene-sharing) terms. See README for details.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
189 # Alternative = "g" # by default the MWU test is two-tailed;
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
190 # specify "g" or "l" of you want to test for "greater" or "less" instead.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
191 # Module = TRUE,Alternative="g" # un-remark this if you are analyzing a
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
192 # SIGNED WGCNA module (values: 0 for not in module genes, kME for in-module genes).
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
193 # In the call to gomwuPlot below, specify absValue=0.001 (count number of "good genes" that fall into the module)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
194 # Module = TRUE # un-remark this if you are analyzing an UNSIGNED WGCNA module
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
195 )
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
196 # do not continue if the printout shows that no GO terms pass 10% FDR.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
197
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
198
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
199 # ----------- Plotting results
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
200
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
201 # change this to a pdf output
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
202 pdf(paste0(dir, "/", "Rplots.pdf"), width = 7, height = 7)
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
203 # png(paste0(dir,"/","Rplots.png"),res=100)
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
204
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
205 results <- gomwuPlot(opt$input, opt$goAnnotations, opt$goDivision,
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
206 # genes with the measure value exceeding this will be counted as "good genes".
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
207 # This setting is for signed log-pvalues. Specify absValue=0.001 if you are doing
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
208 # Fisher's exact test for standard GO enrichment or analyzing a WGCNA module (all non-zero genes = "good genes").
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
209 absValue = opt$absValue,
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
210 # absValue = 1, # un-remark this if you are using log2-fold changes
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
211 # FDR threshold for plotting. Specify level1=1 to plot all GO categories containing genes exceeding the absValue.
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
212 level1 = opt$l1,
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
213 level2 = opt$l2, # FDR cutoff to print in regular (not italic) font.
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
214 level3 = opt$l3, # FDR cutoff to print in large bold font.
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
215 # decrease to fit more on one page, or increase (after rescaling the plot so the tree fits the text)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
216 # for better "word cloud" effect
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
217 txtsize = opt$textsize,
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
218 treeHeight = 0.5, # height of the hierarchical clustering tree
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
219 # colors = c("dodgerblue2","firebrick1","skyblue2","lightcoral")
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
220 # these are default colors, uncomment and change if needed
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
221 )
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
222 dev.off()
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
223 # manually rescale the plot so the tree matches the text
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
224 # if there are too many categories displayed, try make it more stringent with level1 = 0.05,level2=0.01,level3=0.001.
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
225
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
226 # text representation of results, with actual adjusted p-values
1
f7287f82602f "planemo upload commit 486235d6560c9e95bd42152ad19bf7c3941cdc1b"
cristian
parents: 0
diff changeset
227 write.table(results[[1]], paste0(dir, "/", "results.tsv"), sep = "\t")
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
228
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
229
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
230 # ------- extracting representative GOs
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
231
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
232 # this module chooses GO terms that best represent *independent* groups of significant GO terms
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
233
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
234 pcut <- opt$pcut
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
235 hcut <- opt$hcut
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
236
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
237 # plotting the GO tree with the cut level (uncomment the next two lines to plot)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
238 # plot(results[[2]],cex = 0.6)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
239 # abline(h = hcut,col="red")
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
240
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
241 # cutting
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
242 ct <- cutree(results[[2]], h = hcut)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
243 annots <- c()
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
244 ci <- 1
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
245 for (ci in unique(ct)) {
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
246 message(ci)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
247 rn <- names(ct)[ct == ci]
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
248 obs <- grep("obsolete", rn)
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
249 if (length(obs) > 0) {
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
250 rn <- rn[-obs]
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
251 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
252 if (length(rn) == 0) {
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
253 next
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
254 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
255 rr <- results[[1]][rn, ]
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
256 bestrr <- rr[which(rr$pval == min(rr$pval)), ]
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
257 best <- 1
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
258 if (nrow(bestrr) > 1) {
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
259 nns <- sub(" .+", "", row.names(bestrr))
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
260 fr <- c()
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
261 for (i in 1:length(nns)) {
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
262 fr <- c(fr, eval(parse(text = nns[i])))
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
263 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
264 best <- which(fr == max(fr))
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
265 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
266 if (bestrr$pval[best] <= pcut) {
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
267 annots <- c(annots, sub("\\d+\\/\\d+ ", "", row.names(bestrr)[best]))
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
268 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
269 }
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
270
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
271 mwus <- read.table(paste0(dir, "/", paste("MWU", opt$goDivision, name, sep = "_"), ".", ext), header = T)
0
91261b42c07e "planemo upload commit 25eebba0c98dd7a5a703412be90e97f13f66b5bc"
cristian
parents:
diff changeset
272 best_GOs <- mwus[mwus$name %in% annots, ]
2
5acf9dfdfa27 planemo upload commit 66a856bcce69986d9a6f1a39820dd9b3f4f6b0db
cristian
parents: 1
diff changeset
273 write.table(best_GOs, paste0(dir, "/", "best_go.tsv"), sep = "\t", row.names = FALSE)