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