Mercurial > repos > sblanck > smagexp
annotate MetaMA.R @ 2:f18413a94742 draft
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit b53a3997a880872df62a84370133b9a955e70418
author | sblanck |
---|---|
date | Thu, 22 Feb 2018 09:49:29 -0500 |
parents | 1024245abc70 |
children | 3ce32282f6a4 |
rev | line source |
---|---|
0
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
2 # setup R error handling to go to stderr |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
3 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
4 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
5 # we need that to not crash galaxy with an UTF8 error on German LC settings. |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
6 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
7 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
8 library("optparse") |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
9 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
10 ##### Read options |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
11 option_list=list( |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
12 make_option("--input",type="character",default="NULL",help="List of rdata objects containing eset objects"), |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
13 make_option("--species",type="character",default="NULL",help="Species for annotations"), |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
14 make_option("--htmloutput",type="character",default=NULL,help="Output html report"), |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
15 make_option("--htmloutputpath",type="character",default="NULL",help="Path of output html report"), |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
16 make_option("--htmltemplate",type="character",default=NULL,help="html template)") |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
17 ); |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
18 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
19 opt_parser = OptionParser(option_list=option_list); |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
20 opt = parse_args(opt_parser); |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
21 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
22 if(is.null(opt$input)){ |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
23 print_help(opt_parser) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
24 stop("input required.", call.=FALSE) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
25 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
26 if(is.null(opt$species)){ |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
27 print_help(opt_parser) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
28 stop("input required.", call.=FALSE) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
29 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
30 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
31 #loading libraries |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
32 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
33 suppressPackageStartupMessages(require(metaMA)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
34 suppressPackageStartupMessages(require(affy)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
35 suppressPackageStartupMessages(require(annaffy)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
36 suppressPackageStartupMessages(require(VennDiagram)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
37 suppressPackageStartupMessages(require(GEOquery)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
38 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
39 listInput <- trimws( unlist( strsplit(trimws(opt$input), ",") ) ) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
40 species=opt$species |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
41 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
42 rdataList=list() |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
43 condition1List=list() |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
44 condition2List=list() |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
45 for (input in listInput) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
46 { |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
47 load(input) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
48 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
49 rdataList=c(rdataList,(eset)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
50 condition1List=c(condition1List,saveConditions[1]) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
51 condition2List=c(condition2List,saveConditions[2]) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
52 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
53 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
54 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
55 result.html<-opt$htmloutput |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
56 result.path<-opt$htmloutputpath |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
57 result.template<-opt$htmltemplate |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
58 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
59 showVenn<-function(res,file) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
60 { |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
61 venn.plot<-venn.diagram(x = c(res[c(1:(length(res)-3))],meta=list(res$Meta)), |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
62 filename = NULL, col = "black", |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
63 fill = c(1:(length(res)-2)), |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
64 margin=0.05, alpha = 0.6) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
65 jpeg(file) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
66 grid.draw(venn.plot) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
67 dev.off() |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
68 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
69 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
70 if(!species %in% installed.packages()[,"Package"]) { |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
71 source("https://bioconductor.org/biocLite.R") |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
72 biocLite(species) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
73 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
74 |
2
f18413a94742
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit b53a3997a880872df62a84370133b9a955e70418
sblanck
parents:
0
diff
changeset
|
75 library("org.Hs.eg.db") |
0
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
76 x <- org.Hs.egUNIGENE |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
77 mapped_genes <- mappedkeys(x) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
78 link <- as.list(x[mapped_genes]) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
79 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
80 probe2unigene<-function(expset){ |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
81 #construction of the map probe->unigene |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
82 probes=rownames(exprs(expset)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
83 gene_id=fData(expset)[probes,"ENTREZ_GENE_ID"] |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
84 unigene=link[gene_id] |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
85 names(unigene)<-probes |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
86 probe_unigene=unigene |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
87 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
88 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
89 unigene2probe<-function(map) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
90 { |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
91 suppressWarnings(x <- cbind(unlist(map), names(map))) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
92 unigene_probe=split(x[,2], x[,1]) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
93 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
94 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
95 convert2metaMA<-function(listStudies,mergemeth=mean) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
96 { |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
97 if (!(class(listStudies) %in% c("list"))) { |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
98 stop("listStudies must be a list") |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
99 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
100 conv_unigene=lapply(listStudies, |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
101 FUN=function(x) unigene2probe(probe2unigene(x))) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
102 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
103 id=lapply(conv_unigene,names) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
104 inter=Reduce(intersect,id) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
105 if(length(inter)<=0){stop("no common genes")} |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
106 print(paste(length(inter),"genes in common")) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
107 esets=lapply(1:length(listStudies),FUN=function(i){ |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
108 l=lapply(conv_unigene[[i]][inter], |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
109 FUN=function(x) exprs(listStudies[[i]])[x,,drop=TRUE]) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
110 esetsgr=t(sapply(l,FUN=function(ll) if(is.null(dim(ll))){ll} |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
111 else{apply(ll,2,mergemeth)})) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
112 esetsgr |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
113 }) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
114 return(list(esets=esets,conv.unigene=conv_unigene)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
115 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
116 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
117 normalization<-function(data){ |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
118 ex <- exprs(data) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
119 qx <- as.numeric(quantile(ex, c(0., 0.25, 0.5, 0.75, 0.99, 1.0), na.rm=T)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
120 LogC <- (qx[5] > 100) || |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
121 (qx[6]-qx[1] > 50 && qx[2] > 0) || |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
122 (qx[2] > 0 && qx[2] < 1 && qx[4] > 1 && qx[4] < 2) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
123 if (LogC) { ex[which(ex <= 0)] <- NaN |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
124 return (log2(ex)) } else { |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
125 return (ex) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
126 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
127 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
128 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
129 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
130 filterCondition<-function(gset,condition1, condition2){ |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
131 selected=c(which((tolower(as.character(pData(gset)["source_name_ch1"][,1]))==condition1)), |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
132 which(tolower(as.character(pData(gset)["source_name_ch1"][,1]))==condition2)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
133 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
134 return(gset[,selected]) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
135 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
136 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
137 rdatalist <- lapply(rdataList, FUN=function(datalist) normalization(datalist)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
138 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
139 classes=list() |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
140 filteredRdataList=list() |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
141 for (i in 1:length(rdatalist)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
142 { |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
143 currentData=rdataList[[i]] |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
144 currentCondition1=condition1List[[i]] |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
145 currentCondition2=condition2List[[i]] |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
146 #currentData=filterCondition(currentData,currentCondition1,currentCondition2) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
147 currentClasses=as.numeric(tolower(as.character(pData(currentData)["source_name_ch1"][,1]))==currentCondition1) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
148 filteredRdataList=c(filteredRdataList,currentData) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
149 classes=c(classes,list(currentClasses)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
150 #write(file="~/galaxy-modal/classes.txt",classes) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
151 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
152 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
153 #rdataList=filteredRdataList |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
154 conv=convert2metaMA(rdataList) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
155 esets=conv$esets |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
156 conv_unigene=conv$conv.unigene |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
157 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
158 #write(file="~/galaxy-modal/esets.txt",length(esets)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
159 #write(file="~/galaxy-modal/classes.txt",length(classes)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
160 res=pvalcombination(esets=esets,classes=classes,moderated="limma") |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
161 resIDDIRR=IDDIRR(res$Meta,res$AllIndStudies) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
162 length(res$Meta) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
163 Hs.Meta=rownames(esets[[1]])[res$Meta] |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
164 origId.Meta=lapply(conv_unigene,FUN=function(vec) as.vector(unlist(vec[Hs.Meta]))) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
165 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
166 gpllist <- lapply(rdataList, FUN=function(ann) annotation(ann)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
167 platflist <- lapply(gpllist, FUN=function(gpl) getGEO(gpl, AnnotGPL=TRUE)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
168 ncbifdlist <- lapply(platflist, FUN=function(data) data.frame(attr(dataTable(data), "table"))) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
169 ncbifdresult=lapply(1:length(origId.Meta), FUN=function(i) ncbifdlist[[i]][which(ncbifdlist[[i]]$ID %in% origId.Meta[[i]]),]) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
170 ncbidfannot=do.call(rbind,ncbifdresult) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
171 ncbidfannot <- subset(ncbidfannot, select=c("Platform_SPOTID","ID","Gene.symbol","Gene.title","Gene.ID","Chromosome.annotation","GO.Function.ID")) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
172 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
173 library(jsonlite) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
174 matrixncbidfannot=as.matrix(ncbidfannot) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
175 datajson=toJSON(matrixncbidfannot,pretty = TRUE) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
176 summaryjson=toJSON(as.matrix(t(resIDDIRR)),pretty = TRUE) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
177 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
178 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
179 #vennsplit=strsplit(result.venn,split="/")[[1]] |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
180 #venn=paste0("./",vennsplit[length(vennsplit)]) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
181 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
182 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
183 vennFilename="venn.png" |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
184 vennFile=file.path(result.path,vennFilename) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
185 htmlfile=readChar(result.template, file.info(result.template)$size) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
186 htmlfile=gsub(x=htmlfile,pattern = "###DATAJSON###",replacement = datajson, fixed = TRUE) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
187 htmlfile=gsub(x=htmlfile,pattern = "###SUMMARYJSON###",replacement = summaryjson, fixed = TRUE) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
188 htmlfile=gsub(x=htmlfile,pattern = "###VENN###",replacement = vennFilename, fixed = TRUE) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
189 write(htmlfile,result.html) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
190 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
191 library(VennDiagram) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
192 flog.threshold(ERROR) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
193 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
194 #venn.plot<-venn.diagram(x = c(res[c(1:(length(res)-3))],meta=list(res$Meta)),filename = v, col = "black", fill = c(1:(length(res)-2)), margin=0.05, alpha = 0.6,imagetype = "png") |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
195 dir.create(result.path, showWarnings = TRUE, recursive = FALSE) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
196 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
197 showVenn<-function(liste,file) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
198 { |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
199 venn.plot<-venn.diagram(x = liste, |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
200 filename = vennFilename, col = "black", |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
201 fill = 1:length(liste)+1, |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
202 margin=0.05, alpha = 0.6,imagetype = "png") |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
203 # png(file); |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
204 # grid.draw(venn.plot); |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
205 # dev.off(); |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
206 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
207 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
208 |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
209 l=list() |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
210 for(i in 1:length(esets)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
211 { |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
212 l[[paste("study",i,sep="")]]<-res[[i]] |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
213 } |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
214 l[["Meta"]]=res[[length(res)-1]] |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
215 showVenn(l,vennFile) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
216 file.copy(vennFilename,result.path) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
217 #l=list() |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
218 #for(i in 1:length(esets)) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
219 #{ |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
220 # l[[paste("study",i,sep="")]]<-res[[i]] |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
221 #} |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
222 #l[["Meta"]]=res[[length(res)-1]] |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
223 #showVenn(res,result.venn) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
224 #writeLines(c("<h2>Venn diagram</h2>"),file.conn) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
225 #writeLines(c("<img src='venn.png'><br/><br/>"),file.conn) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
226 #writeLines(c("</body></html>"),file.conn) |
1024245abc70
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 5974f806f344dbcc384b931492d7f023bfbbe03b
sblanck
parents:
diff
changeset
|
227 #close(file.conn) |