annotate MetaRNASeq.R @ 38:c08b824e40cc draft

planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 86c0c3bb957558f14e9400171640bf5a5c6605c9
author sblanck
date Mon, 25 Jun 2018 05:25:40 -0400
parents a99bbda3cf1f
children 07ac07715f22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
1 #!/usr/bin/env Rscript
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
2 # setup R error handling to go to stderr
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
3 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
4
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
5 # we need that to not crash galaxy with an UTF8 error on German LC settings.
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
6 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
7
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
8 library("optparse")
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
9
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
10 ##### Read options
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
11 option_list=list(
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
12 make_option("--input",type="character",default="NULL",help="list of rdata objects containing eset objects"),
35
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
13 make_option("--inputName",type="character",default=NULL,help="filenames of the Rddata objects"),
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
14 make_option("--nbreplicates",type="character",default=NULL,help="number of replicate per study"),
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
15 make_option("--fdr",type="character",default=NULL,help="Adjusted p-value threshold to be declared differentially expressed"),
14
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
16 make_option("--result",type="character",default=NULL,help="text file containing result of the meta-analysis"),
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
17 make_option("--htmloutput",type="character",default=NULL,help="Output html report"),
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
18 make_option("--htmloutputpath",type="character",default="NULL",help="Path of output html report"),
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
19 make_option("--htmltemplate",type="character",default=NULL,help="html template)")
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
20 );
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
21
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
22 opt_parser = OptionParser(option_list=option_list);
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
23 opt = parse_args(opt_parser);
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
24
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
25 if(is.null(opt$input)){
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
26 print_help(opt_parser)
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
27 stop("input required.", call.=FALSE)
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
28 }
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
29
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
30 #loading libraries
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
31
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
32 suppressPackageStartupMessages(require(affy))
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
33 suppressPackageStartupMessages(require(annaffy))
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
34 suppressPackageStartupMessages(require(VennDiagram))
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
35 suppressPackageStartupMessages(require(GEOquery))
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
36
35
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
37 listfiles <- trimws( unlist( strsplit(trimws(opt$input), ";") ) )
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
38 listfilenames <- trimws( unlist( strsplit(trimws(opt$inputName), ";") ) )
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
39 nbreplicates <- as.numeric(trimws( unlist( strsplit(trimws(opt$nbreplicates), ";") ) ))
14
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
40
35
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
41 listfiles
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
42 listfilenames
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
43 nbreplicates
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
44
14
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
45
35
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
46
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
47 #for (i in 1:length(listInput))
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
48 #{
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
49 # inputFileInfo <- unlist( strsplit( listInput[i], ';' ) )
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
50 # listfiles=c(listfiles,inputFileInfo[1])
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
51 # listfilenames=c(listfilenames,inputFileInfo[2])
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
52 # nbreplicates[i]=as.numeric(inputFileInfo[3])
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
53 #}
14
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
54
29
102e4ef8fed2 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 808ffb34e11a74cd2396e32868ea56f7ce8d83ff
sblanck
parents: 28
diff changeset
55
14
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
56 outputfile <- opt$result
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
57 result.html = opt$htmloutput
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
58 html.files.path=opt$htmloutputpath
e5a94bc69bd6 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents: 2
diff changeset
59 result.template=opt$htmltemplate
2
93451f832736 Uploaded
sblanck
parents:
diff changeset
60
35
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
61
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
62 html.files.path
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
63
30
4048dae6ace8 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 904ac44909a062b118757205861451a3007158b6
sblanck
parents: 29
diff changeset
64 alpha=as.numeric(opt$fdr)
2
93451f832736 Uploaded
sblanck
parents:
diff changeset
65
93451f832736 Uploaded
sblanck
parents:
diff changeset
66 listData=lapply(listfiles,read.table)
93451f832736 Uploaded
sblanck
parents:
diff changeset
67 orderData=lapply(listData, function(x) x[order(x[1]), ])
93451f832736 Uploaded
sblanck
parents:
diff changeset
68 rawpval=lapply(orderData,function(x) x[6])
93451f832736 Uploaded
sblanck
parents:
diff changeset
69 rawpval=lapply(rawpval, function(x) as.numeric(unlist(x)))
93451f832736 Uploaded
sblanck
parents:
diff changeset
70
93451f832736 Uploaded
sblanck
parents:
diff changeset
71 DE=list()
93451f832736 Uploaded
sblanck
parents:
diff changeset
72 DE=lapply(orderData, function(x) ifelse(x[7]<=0.05,1,0))
93451f832736 Uploaded
sblanck
parents:
diff changeset
73
93451f832736 Uploaded
sblanck
parents:
diff changeset
74 FC=list()
93451f832736 Uploaded
sblanck
parents:
diff changeset
75 FC=lapply(orderData, function(x) x[3])
93451f832736 Uploaded
sblanck
parents:
diff changeset
76
93451f832736 Uploaded
sblanck
parents:
diff changeset
77 DE=as.data.frame(DE)
93451f832736 Uploaded
sblanck
parents:
diff changeset
78 colnames(DE)=listfilenames
93451f832736 Uploaded
sblanck
parents:
diff changeset
79 FC=as.data.frame(FC)
93451f832736 Uploaded
sblanck
parents:
diff changeset
80 colnames(FC)=listfilenames
93451f832736 Uploaded
sblanck
parents:
diff changeset
81
93451f832736 Uploaded
sblanck
parents:
diff changeset
82 # combinations
93451f832736 Uploaded
sblanck
parents:
diff changeset
83 library(metaRNASeq)
28
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
84 library(UpSetR)
2
93451f832736 Uploaded
sblanck
parents:
diff changeset
85 fishcomb<-fishercomb(rawpval, BHth=alpha)
93451f832736 Uploaded
sblanck
parents:
diff changeset
86 warning(length(rawpval))
29
102e4ef8fed2 planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 808ffb34e11a74cd2396e32868ea56f7ce8d83ff
sblanck
parents: 28
diff changeset
87 invnormcomb<-invnorm(rawpval, nrep=nbreplicates, BHth=alpha)
2
93451f832736 Uploaded
sblanck
parents:
diff changeset
88 #DE[["fishercomb"]]<-ifelse(fishcomb$adjpval<=alpha,1,0)
93451f832736 Uploaded
sblanck
parents:
diff changeset
89 #DE[["invnormcomb"]]<-ifelse(invnormcomb$adjpval<=alpha,1,0)
93451f832736 Uploaded
sblanck
parents:
diff changeset
90
93451f832736 Uploaded
sblanck
parents:
diff changeset
91 signsFC<-mapply(FC,FUN=function(x) sign(x))
93451f832736 Uploaded
sblanck
parents:
diff changeset
92 sumsigns<-apply(signsFC,1,sum)
93451f832736 Uploaded
sblanck
parents:
diff changeset
93 commonsgnFC<-ifelse(abs(sumsigns)==dim(signsFC)[2],sign(sumsigns),0)
93451f832736 Uploaded
sblanck
parents:
diff changeset
94
93451f832736 Uploaded
sblanck
parents:
diff changeset
95 DEresults <- data.frame(DE=DE,"DE.fishercomb"=ifelse(fishcomb$adjpval<=alpha,1,0),"DE.invnorm"=ifelse(invnormcomb$adjpval<=alpha,1,0))
93451f832736 Uploaded
sblanck
parents:
diff changeset
96
93451f832736 Uploaded
sblanck
parents:
diff changeset
97 unionDE <- unique(c(fishcomb$DEindices,invnormcomb$DEindices))
93451f832736 Uploaded
sblanck
parents:
diff changeset
98 FC.selecDE <- data.frame(DEresults[unionDE,],FC[unionDE,],signFC=commonsgnFC[unionDE])
93451f832736 Uploaded
sblanck
parents:
diff changeset
99 keepDE <- FC.selecDE[which(abs(FC.selecDE$signFC)==1),]
93451f832736 Uploaded
sblanck
parents:
diff changeset
100
93451f832736 Uploaded
sblanck
parents:
diff changeset
101 fishcomb_de <- rownames(keepDE)[which(keepDE[,"DE.fishercomb"]==1)]
93451f832736 Uploaded
sblanck
parents:
diff changeset
102 invnorm_de <- rownames(keepDE)[which(keepDE[,"DE.invnorm"]==1)]
93451f832736 Uploaded
sblanck
parents:
diff changeset
103 indstudy_de = list()
93451f832736 Uploaded
sblanck
parents:
diff changeset
104 for (i in 1:length(listfiles)) {
93451f832736 Uploaded
sblanck
parents:
diff changeset
105 currentIndstudy_de = rownames(keepDE)[which(keepDE[,i]==1)]
93451f832736 Uploaded
sblanck
parents:
diff changeset
106 indstudy_de[[listfilenames[i]]]=currentIndstudy_de
93451f832736 Uploaded
sblanck
parents:
diff changeset
107 }
93451f832736 Uploaded
sblanck
parents:
diff changeset
108
93451f832736 Uploaded
sblanck
parents:
diff changeset
109 IDDIRRfishcomb=IDD.IRR(fishcomb_de,indstudy_de)
93451f832736 Uploaded
sblanck
parents:
diff changeset
110 IDDIRRinvnorm=IDD.IRR(invnorm_de,indstudy_de)
93451f832736 Uploaded
sblanck
parents:
diff changeset
111
93451f832736 Uploaded
sblanck
parents:
diff changeset
112 conflits<-data.frame(ID=listData[[1]][rownames(DEresults),1],DE=DEresults,FC=FC,signFC=commonsgnFC)
93451f832736 Uploaded
sblanck
parents:
diff changeset
113 #write DE outputfile
93451f832736 Uploaded
sblanck
parents:
diff changeset
114 write.table(conflits, outputfile,sep="\t",,row.names=FALSE)
93451f832736 Uploaded
sblanck
parents:
diff changeset
115 library(VennDiagram)
28
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
116 DE_num=apply(keepDE[,1:(length(listfiles)+2)], 2, FUN=function(x) which(x==1))
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
117 #DE_num=apply(DEresults, 2, FUN=function(x) which(x==1))
35
a99bbda3cf1f planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit e956e308e78c1c2d2c5ac7420621527f0d4dad28
sblanck
parents: 34
diff changeset
118 dir.create(html.files.path, showWarnings = TRUE, recursive = FALSE)
32
2c0df656094a planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 071df0c8b84f98fb643b2b9eaa5e238b94ffa254
sblanck
parents: 31
diff changeset
119 temp.venn.plot = file.path( html.files.path, paste("venn.png"))
2c0df656094a planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 071df0c8b84f98fb643b2b9eaa5e238b94ffa254
sblanck
parents: 31
diff changeset
120 if (length(listfiles)<=2) {
28
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
121 title="VENN DIAGRAM"
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
122 width=500
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
123 venn.plot<-venn.diagram(x=as.list(DE_num),filename=NULL, col="black", fill=1:length(DE_num)+1,alpha=0.6)
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
124 png(temp.venn.plot,width=width,height=500)
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
125 grid.draw(venn.plot)
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
126 dev.off()
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
127 } else {
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
128 title="UPSETR DIAGRAM"
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
129 width=1000
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
130 png(temp.venn.plot,width=width,height=500)
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
131 upset(fromList(as.list(DE_num)), order.by = "freq")
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
132 dev.off()
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
133
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
134 }
49ce6fbe11de planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents: 24
diff changeset
135
2
93451f832736 Uploaded
sblanck
parents:
diff changeset
136
93451f832736 Uploaded
sblanck
parents:
diff changeset
137 library(jsonlite)
93451f832736 Uploaded
sblanck
parents:
diff changeset
138 matrixConflits=as.matrix(conflits)
93451f832736 Uploaded
sblanck
parents:
diff changeset
139 datajson=toJSON(matrixConflits,pretty = TRUE)
93451f832736 Uploaded
sblanck
parents:
diff changeset
140 summaryFishcombjson=toJSON(as.matrix(t(IDDIRRfishcomb)),pretty = TRUE)
93451f832736 Uploaded
sblanck
parents:
diff changeset
141 summaryinvnormjson=toJSON(as.matrix(t(IDDIRRinvnorm)),pretty = TRUE)
93451f832736 Uploaded
sblanck
parents:
diff changeset
142
93451f832736 Uploaded
sblanck
parents:
diff changeset
143 vennFilename="venn.png"
93451f832736 Uploaded
sblanck
parents:
diff changeset
144 vennFile=file.path(html.files.path,vennFilename)
93451f832736 Uploaded
sblanck
parents:
diff changeset
145 htmlfile=readChar(result.template, file.info(result.template)$size)
93451f832736 Uploaded
sblanck
parents:
diff changeset
146 htmlfile=gsub(x=htmlfile,pattern = "###DATAJSON###",replacement = datajson, fixed = TRUE)
93451f832736 Uploaded
sblanck
parents:
diff changeset
147 htmlfile=gsub(x=htmlfile,pattern = "###FISHSUMMARYJSON###",replacement = summaryFishcombjson, fixed = TRUE)
93451f832736 Uploaded
sblanck
parents:
diff changeset
148 htmlfile=gsub(x=htmlfile,pattern = "###INVSUMMARYJSON###",replacement = summaryinvnormjson, fixed = TRUE)
93451f832736 Uploaded
sblanck
parents:
diff changeset
149 htmlfile=gsub(x=htmlfile,pattern = "###VENN###",replacement = vennFilename, fixed = TRUE)
32
2c0df656094a planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 071df0c8b84f98fb643b2b9eaa5e238b94ffa254
sblanck
parents: 31
diff changeset
150 htmlfile=gsub(x=htmlfile,pattern = "###WIDTH###",replacement = as.character(width), fixed = TRUE)
2c0df656094a planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 071df0c8b84f98fb643b2b9eaa5e238b94ffa254
sblanck
parents: 31
diff changeset
151 htmlfile=gsub(x=htmlfile,pattern = "###TITLE###",replacement = title, fixed = TRUE)
2
93451f832736 Uploaded
sblanck
parents:
diff changeset
152 write(htmlfile,result.html)
93451f832736 Uploaded
sblanck
parents:
diff changeset
153