Mercurial > repos > sblanck > smagexp
annotate MetaRNASeq.R @ 30:4048dae6ace8 draft
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 904ac44909a062b118757205861451a3007158b6
author | sblanck |
---|---|
date | Thu, 21 Jun 2018 08:03:02 -0400 |
parents | 102e4ef8fed2 |
children | 8191cc63589c |
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"), |
29
102e4ef8fed2
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 808ffb34e11a74cd2396e32868ea56f7ce8d83ff
sblanck
parents:
28
diff
changeset
|
13 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
|
14 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
|
15 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
|
16 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
|
17 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
|
18 ); |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
19 |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
20 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
|
21 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
|
22 |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
23 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
|
24 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
|
25 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
|
26 } |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
27 |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
28 #loading libraries |
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 suppressPackageStartupMessages(require(affy)) |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
31 suppressPackageStartupMessages(require(annaffy)) |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
32 suppressPackageStartupMessages(require(VennDiagram)) |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
33 suppressPackageStartupMessages(require(GEOquery)) |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
34 |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
35 listInput <- trimws( unlist( strsplit(trimws(opt$input), ",") ) ) |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
36 |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
37 listfiles=vector() |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
38 listfilenames=vector() |
29
102e4ef8fed2
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 808ffb34e11a74cd2396e32868ea56f7ce8d83ff
sblanck
parents:
28
diff
changeset
|
39 nbreplicates=vector() |
14
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
40 |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
41 for (i in 1:length(listInput)) |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
42 { |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
43 inputFileInfo <- unlist( strsplit( listInput[i], ';' ) ) |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
44 listfiles=c(listfiles,inputFileInfo[1]) |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
45 listfilenames=c(listfilenames,inputFileInfo[2]) |
29
102e4ef8fed2
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 808ffb34e11a74cd2396e32868ea56f7ce8d83ff
sblanck
parents:
28
diff
changeset
|
46 nbreplicates[i]=inputFileInfo[3] |
14
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
47 } |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
48 |
29
102e4ef8fed2
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 808ffb34e11a74cd2396e32868ea56f7ce8d83ff
sblanck
parents:
28
diff
changeset
|
49 |
14
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
50 outputfile <- opt$result |
e5a94bc69bd6
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit da1436252b5db4e90c39c95140558f0f93544160
sblanck
parents:
2
diff
changeset
|
51 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
|
52 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
|
53 result.template=opt$htmltemplate |
2 | 54 |
30
4048dae6ace8
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 904ac44909a062b118757205861451a3007158b6
sblanck
parents:
29
diff
changeset
|
55 alpha=as.numeric(opt$fdr) |
2 | 56 |
57 #print(comparison) | |
58 | |
59 listData=lapply(listfiles,read.table) | |
60 orderData=lapply(listData, function(x) x[order(x[1]), ]) | |
61 rawpval=lapply(orderData,function(x) x[6]) | |
62 rawpval=lapply(rawpval, function(x) as.numeric(unlist(x))) | |
63 | |
64 DE=list() | |
65 DE=lapply(orderData, function(x) ifelse(x[7]<=0.05,1,0)) | |
66 | |
67 FC=list() | |
68 FC=lapply(orderData, function(x) x[3]) | |
69 | |
70 DE=as.data.frame(DE) | |
71 colnames(DE)=listfilenames | |
72 FC=as.data.frame(FC) | |
73 colnames(FC)=listfilenames | |
74 # the comparison must only have two values and the conds must | |
75 # be a vector from those values, at least one of each. | |
76 | |
77 #if (length(comparison) != 2) { | |
78 # stop("Comparison type must be a tuple: ", cargs[length(cargs) - 8]) | |
79 #} | |
80 | |
81 sink("/dev/null") | |
82 dir.create(html.files.path, recursive=TRUE) | |
83 #library(DESeq) | |
84 #library(HTSFilter) | |
85 | |
86 #DE=list() | |
87 #FC=list() | |
88 #i=1 | |
89 | |
90 # Open the html output file | |
91 #file.conn = file(diag.html, open="w") | |
92 | |
93 #writeLines( c("<html><body>"), file.conn) | |
94 | |
95 # Perform deseq analysis on each study | |
96 #for(i in 1:length(listfiles)) | |
97 #{ | |
98 # f=listfiles[i] | |
99 # fname=listfilenames[i] | |
100 # study_name=unlist(strsplit(fname,"[.]"))[1] | |
101 # print(paste0("study.name ",study_name)) | |
102 # d <- read.table(f, sep=" ", header=TRUE, row.names=1) | |
103 # conds<-sapply(strsplit(colnames(d),"[.]"),FUN=function(x) x[1]) | |
104 # if (length(unique(conds)) != 2) { | |
105 # warning(as.data.frame(strsplit(colnames(d),"[.]"))) | |
106 # stop("You can only have two columns types: ", paste(conds,collapse=" ")) | |
107 # } | |
108 # if (!identical(sort(comparison), sort(unique(conds)))) { | |
109 # stop("Column types must use the two names from Comparison type, and vice versa. Must have at least one of each in the Column types.\nColumn types: ", cargs[2], "\n", "Comparison type: ", cargs[3]) | |
110 # } | |
111 # if (length(d) != length(conds)) { | |
112 # stop("Number of total sample columns in counts file must correspond to the columns types field. E.g. if column types is 'kidney,kidney,liver,liver' then number of sample columns in counts file must be 4 as well.") | |
113 # } | |
114 # | |
115 # cds <- newCountDataSet(d, conds) | |
116 # cds <- estimateSizeFactors(cds) | |
117 # | |
118 # cdsBlind <- estimateDispersions( cds, method="blind" ) | |
119 # | |
120 # if (length(conds) != 2) { | |
121 # cds <- estimateDispersions( cds ) | |
122 # norep = FALSE | |
123 # } | |
124 # | |
125 # if (length(conds) == 2) { | |
126 # cds <- estimateDispersions( cds, method=method, sharingMode=mod, fitType="parametric" ) | |
127 # norep = TRUE | |
128 # } | |
129 # | |
130 # filter<-HTSFilter(cds, plot=FALSE) | |
131 # cds.filter<-filter$filteredData | |
132 # on.index<-which(filter$on==1) | |
133 # | |
134 # res<-as.data.frame(matrix(NA,nrow=nrow(cds),ncol=ncol(cds))) | |
135 # nbT <- nbinomTest(cds.filter, comparison[1], comparison[2]) | |
136 # colnames(res)<-colnames(nbT) | |
137 # res[on.index,]<-nbT | |
138 # #write.table(res[order(res$padj), ], file=outputfile, quote=FALSE, row.names=FALSE, sep="\t") | |
139 # | |
140 # | |
141 # temp.pval.plot = file.path( html.files.path, paste("PvalHist",i,".png",sep="")) | |
142 # png( temp.pval.plot, width=500, height=500 ) | |
143 # hist(res$pval, breaks=100, col="skyblue", border="slateblue", main="") | |
144 # dev.off() | |
145 # | |
146 # writeLines( c("<h2>P-value histogram for ",study_name,"</h2>"), file.conn) | |
147 # writeLines( c("<img src='PvalHist",i,".png'><br/><br/>"), file.conn) | |
148 # | |
149 # #on enregistre la p-value | |
150 # rawpval[[study_name]]<-res$pval | |
151 # DE[[study_name]]<-ifelse(res$padj<=alpha,1,0) | |
152 # FC[[study_name]]<-res$log2FoldChange | |
153 # | |
154 # i=i+1 | |
155 #} | |
156 | |
157 | |
158 # combinations | |
159 library(metaRNASeq) | |
28
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
160 library(UpSetR) |
2 | 161 fishcomb<-fishercomb(rawpval, BHth=alpha) |
162 warning(length(rawpval)) | |
28
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
163 |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
164 #nrep=c(length(listFiles)) |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
165 |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
166 |
29
102e4ef8fed2
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 808ffb34e11a74cd2396e32868ea56f7ce8d83ff
sblanck
parents:
28
diff
changeset
|
167 invnormcomb<-invnorm(rawpval, nrep=nbreplicates, BHth=alpha) |
2 | 168 #DE[["fishercomb"]]<-ifelse(fishcomb$adjpval<=alpha,1,0) |
169 #DE[["invnormcomb"]]<-ifelse(invnormcomb$adjpval<=alpha,1,0) | |
170 | |
171 signsFC<-mapply(FC,FUN=function(x) sign(x)) | |
172 sumsigns<-apply(signsFC,1,sum) | |
173 commonsgnFC<-ifelse(abs(sumsigns)==dim(signsFC)[2],sign(sumsigns),0) | |
174 | |
175 DEresults <- data.frame(DE=DE,"DE.fishercomb"=ifelse(fishcomb$adjpval<=alpha,1,0),"DE.invnorm"=ifelse(invnormcomb$adjpval<=alpha,1,0)) | |
176 | |
177 unionDE <- unique(c(fishcomb$DEindices,invnormcomb$DEindices)) | |
178 FC.selecDE <- data.frame(DEresults[unionDE,],FC[unionDE,],signFC=commonsgnFC[unionDE]) | |
179 keepDE <- FC.selecDE[which(abs(FC.selecDE$signFC)==1),] | |
180 | |
181 fishcomb_de <- rownames(keepDE)[which(keepDE[,"DE.fishercomb"]==1)] | |
182 invnorm_de <- rownames(keepDE)[which(keepDE[,"DE.invnorm"]==1)] | |
183 indstudy_de = list() | |
184 for (i in 1:length(listfiles)) { | |
185 currentIndstudy_de = rownames(keepDE)[which(keepDE[,i]==1)] | |
186 indstudy_de[[listfilenames[i]]]=currentIndstudy_de | |
187 } | |
188 | |
189 IDDIRRfishcomb=IDD.IRR(fishcomb_de,indstudy_de) | |
190 IDDIRRinvnorm=IDD.IRR(invnorm_de,indstudy_de) | |
191 | |
192 #conflits<-data.frame(ID=listData[[1]][rownames(DEresults),1],Fishercomb=DEresults[["DE.fishercomb"]],Invnormcomb=DEresults[["DE.invnorm"]],sign=commonsgnFC) | |
193 conflits<-data.frame(ID=listData[[1]][rownames(DEresults),1],DE=DEresults,FC=FC,signFC=commonsgnFC) | |
194 #write DE outputfile | |
195 write.table(conflits, outputfile,sep="\t",,row.names=FALSE) | |
196 library(VennDiagram) | |
28
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
197 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
|
198 #DE_num=apply(DEresults, 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
|
199 if (length(listfiles<=2)) { |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
200 title="VENN DIAGRAM" |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
201 width=500 |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
202 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
|
203 temp.venn.plot = file.path( html.files.path, paste("venn.png")) |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
204 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
|
205 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
|
206 dev.off() |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
207 } else { |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
208 title="UPSETR DIAGRAM" |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
209 width=1000 |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
210 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
|
211 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
|
212 dev.off() |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
213 |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
214 } |
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
215 |
2 | 216 |
217 library(jsonlite) | |
218 matrixConflits=as.matrix(conflits) | |
219 datajson=toJSON(matrixConflits,pretty = TRUE) | |
220 summaryFishcombjson=toJSON(as.matrix(t(IDDIRRfishcomb)),pretty = TRUE) | |
221 summaryinvnormjson=toJSON(as.matrix(t(IDDIRRinvnorm)),pretty = TRUE) | |
222 | |
223 | |
224 #vennsplit=strsplit(result.venn,split="/")[[1]] | |
225 #venn=paste0("./",vennsplit[length(vennsplit)]) | |
226 | |
227 | |
228 vennFilename="venn.png" | |
229 vennFile=file.path(html.files.path,vennFilename) | |
230 htmlfile=readChar(result.template, file.info(result.template)$size) | |
231 htmlfile=gsub(x=htmlfile,pattern = "###DATAJSON###",replacement = datajson, fixed = TRUE) | |
232 htmlfile=gsub(x=htmlfile,pattern = "###FISHSUMMARYJSON###",replacement = summaryFishcombjson, fixed = TRUE) | |
233 htmlfile=gsub(x=htmlfile,pattern = "###INVSUMMARYJSON###",replacement = summaryinvnormjson, fixed = TRUE) | |
234 htmlfile=gsub(x=htmlfile,pattern = "###VENN###",replacement = vennFilename, fixed = TRUE) | |
28
49ce6fbe11de
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit cb90fdea2a64908e301355aef89de403e107764d
sblanck
parents:
24
diff
changeset
|
235 htmlfile=gsub(x=htmlfile,pattern = "###WIDTH##",replacement = as.character(width), fixed = TRUE) |
29
102e4ef8fed2
planemo upload for repository https://github.com/sblanck/smagexp/tree/master/smagexp_tools commit 808ffb34e11a74cd2396e32868ea56f7ce8d83ff
sblanck
parents:
28
diff
changeset
|
236 htmlfile=gsub(x=htmlfile,pattern = "###TITLE##",replacement = title, fixed = TRUE) |
2 | 237 write(htmlfile,result.html) |
238 | |
239 #library(VennDiagram) | |
240 #flog.threshold(ERROR) | |
241 # | |
242 ##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") | |
243 #dir.create(result.path, showWarnings = TRUE, recursive = FALSE) | |
244 # | |
245 #showVenn<-function(liste,file) | |
246 #{ | |
247 # venn.plot<-venn.diagram(x = liste, | |
248 # filename = vennFilename, col = "black", | |
249 # fill = 1:length(liste)+1, | |
250 # margin=0.05, alpha = 0.6,imagetype = "png") | |
251 ## png(file); | |
252 ## grid.draw(venn.plot); | |
253 ## dev.off(); | |
254 # | |
255 #} | |
256 # | |
257 #l=list() | |
258 #for(i in 1:length(esets)) | |
259 #{ | |
260 # l[[paste("study",i,sep="")]]<-res[[i]] | |
261 #} | |
262 #l[["Meta"]]=res[[length(res)-1]] | |
263 #showVenn(l,vennFile) | |
264 #file.copy(vennFilename,result.path) | |
265 | |
266 | |
267 #writeLines( c("<h2>Venn Plot</h2>"), file.conn) | |
268 #writeLines( c("<img src='venn.png'><br/><br/>"), file.conn) | |
269 #writeLines( c("</body></html>"), file.conn) | |
270 #close(file.conn) | |
271 #print("passe6") | |
272 #sink(NULL) |