Nothing
#oneChannelGUI makeSam function is used to create a samtools for each bam generated by tophat
#oneChannelGUI dexCounts uses the dex python script to generate a count object. Uses the target generated by makeSam
#oneChannelGUI dexExons
#oneChannelGUI desGenes
#oneChannelGUI topTable.exons filtering and saving a topTable for exon-level analysis with dexseq
#oneChannelGUI topTable.genes filtering and saving a topTable for gene-level analysis with deseq
#openPdf, closePdf useful to open connection to pdf under linux system
#make gff
#make.gff <- paste(find.package(package="DEXSeq"),"python_scripts","dexseq_prepare_annotation.py",sep="/")
#system(paste("nohup python ",make.gff," ./mm10_ucsc.gtf ./mm10_ucsc.gff", sep=""),wait=F)
##############################################################################
makeSam <- function(){
Try(my.dir <- getwd())
Try(SetWD())
Try(dir.data <- dir())
if(length(grep("accepted_hits.bam", dir.data))==0){
Try(tkmessageBox(title="Sam to Bam conversion",message=paste("This function assumes that
primary mapping was done using tophat.\nIt seems that the accepted_hits.bam is not present in\n",getwd(), sep=""),
icon="error",type="ok"))
Try(setwd(my.dir))
Try(return())
}
Try(system("nohup samtools view accepted_hits.bam > accepted_hits.sam", wait=F))
Try(tkmessageBox(title="Sam to Bam conversion",message="bam to sam
conversion is running in background.\nWhen finished you can move to the next step\n",icon="info",type="ok"))
Try(setwd(my.dir))
}
##############################################################################
dexCounts <- function(){
# Try(require("tkWidgets") || stop("\ntkWidgets library is not installed\n"))
Try(my.dir <- getwd())
Try(SetWD())
#select.gff
Try(tkmessageBox(title="Selecting the exons gff file",message="With the next widget, please select gff file of the organism you are interested to associate reads to exons.",type="ok",icon="info"))
Try(gff <- fileBrowser())
Try(tmp <- strsplit(gff, "\\."))
Try(tmp <- unlist(tmp))
if(tmp[length(tmp)]!="gff"){
Try(tkmessageBox(title="Selecting the exons gff file",message="It seems that you have selected a file that does not have the right gff extension!",type="ok",icon="error"))
Try(return())
}
#defining if RNAseq is paired and standed
Try(ttIfDialog<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttIfDialog))
Try(tkgrab.set(ttIfDialog))
Try(tkfocus(ttIfDialog))
Try(tkwm.title(ttIfDialog,"Counting Options"))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(frame1 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(HowManyQuestion1 <- tklabel(frame1,text="Is RNAseq paired-end?",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(HowManyQuestion1))
Try(tkgrid.configure(HowManyQuestion1,columnspan=2,sticky="w"))
Try(thresholdTcl <- tclVar("yes"))
Try(I1.but <- tkradiobutton(frame1,text="yes",variable=thresholdTcl,value="yes",font=.affylmGUIglobals$affylmGUIfont2))
Try(I2.but <- tkradiobutton(frame1,text="no",variable=thresholdTcl,value="no",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(I1.but,sticky="w"))
Try(tkgrid.configure(HowManyQuestion1,I1.but,I2.but,sticky="w"))
Try(frame2 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(fractionLabel <- tklabel(frame2,text="Is RNAseq strand specific?",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(fractionLabel,sticky="w"))
Try(tkgrid.configure(fractionLabel,sticky="w"))
Try(fractionTcl <- tclVar("yes"))
Try(F1.but <- tkradiobutton(frame2,text="yes",variable=fractionTcl,value="yes",font=.affylmGUIglobals$affylmGUIfont2))
Try(F2.but <- tkradiobutton(frame2,text="no",variable=fractionTcl,value="no",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(F1.but,sticky="w"))
Try(tkgrid(F2.but,sticky="w"))
Try(tkgrid.configure(fractionLabel,F1.but,F2.but,sticky="w"))
Try(onOK <- function()
{
ReturnVal1 <- as.character(tclvalue(thresholdTcl))
ReturnVal2 <- as.character(tclvalue(fractionTcl))
Try(ReturnVal <<- paste(ReturnVal1, ReturnVal2, sep=";"))
Try(tkgrab.release(ttIfDialog))
Try(tkdestroy(ttIfDialog))
Try(tkfocus(.affylmGUIglobals$ttMain))
})
Try(frame3 <- tkframe(ttIfDialog,borderwidth=2))
Try(onCancel <- function() {Try(ReturnVal <<- ""); Try(tkgrab.release(ttIfDialog));Try(tkdestroy(ttIfDialog));Try(tkfocus(.affylmGUIglobals$ttMain))})
Try(OK.but <-tkbutton(frame3,text=" OK ",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(Cancel.but <-tkbutton(frame3,text=" Cancel ",command=onCancel,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(frame3,text=" "),OK.but,Cancel.but,tklabel(frame3,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" "),frame1,frame2,tklabel(ttIfDialog,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" "),frame3,tklabel(ttIfDialog,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(tkgrid.configure(frame1,frame3,sticky="w"))
Try(tkfocus(ttIfDialog))
Try(tkbind(ttIfDialog, "<Destroy>", function() {Try(tkgrab.release(ttIfDialog));Try(tkfocus(.affylmGUIglobals$ttMain));}))
Try(tkwait.window(ttIfDialog))
if(ReturnVal==""){return()}
Try(tmp <-strsplit(ReturnVal, ";"))
Try(stranded <- as.character(tmp[[1]][2]))
Try(paired <- as.character(tmp[[1]][1]))
######################
Try(make.counts <- paste(find.package(package="DEXSeq"),"python_scripts","dexseq_count.py",sep="/"))
Try(system(paste("nohup python ",make.counts," --paired ",paired," --stranded ",stranded," --order pos ",gff," accepted_hits.sam accepted_hits_dex_counts.txt", sep=""),wait=F))
Try(tkmessageBox(title="Making exons counts",message="Exons
counts python is running in background.\nWhen finished you can move to the next step\n",icon="info",type="ok"))
Try(setwd(my.dir))
}
##############################################################################
dexExons <- function(){
# Try(require("tkWidgets") || stop("\ntkWidgets library is not installed\n"))
Try(my.dir <- getwd())
#opentarget
#select.gff
Try(tkmessageBox(title="Selecting the exons gff file",message="With the next widget, please select gff file of the organism you are interested to associate reads to exons.",type="ok",icon="info"))
Try(gff <- fileBrowser())
Try(tmp <- strsplit(gff, "\\."))
Try(tmp <- unlist(tmp))
if(tmp[length(tmp)]!="gff"){
Try(tkmessageBox(title="Selecting the exons gff file",message="It seems that you have selected a file that does not have the right gff extension!",type="ok",icon="error"))
Try(return())
}
#select target file
Try(tkmessageBox(title="Selecting the target file",message="With the next widget, please select target file of your experiment.",type="ok",icon="info"))
Try(target <- fileBrowser())
Try(targets <- read.table(target, sep="\t", header=T))
if(paste(names(targets),collapse=" ")!="Name FileName Target"){
Try(tkmessageBox(title="Selecting the target file",message="It seems that you have selected a file that does not have the structure expected for a target file!",type="ok",icon="error"))
Try(return())
}
Try(covar <- unique(targets$Target))
if(length(covar)>2){
Try(tkmessageBox(title="Covariates",message="The present implementation only support two covariates.\nPlease, edit your target to include only two experimental conditions.",type="ok",icon="error"))
Try(return())
}
#creating time base name to differentiate the various runs
time <- gsub(" ","_",date())
time <- gsub(":","-",time)
time <- gsub(":","-",time)
#edit batch file to generate an exon level analysis
Try(batch.file <- paste(find.package(package="oneChannelGUI"),"/batch/batch_dexseq_exon.R",sep=""))
Try(zz <- file(paste(batch.file, sep=""), "r"))
Try(batch <- readLines(con=zz))
Try(close(zz))
Try(batch[grep("gff",batch)] <- sub("gff", paste("",gff,"", sep="'"),batch[grep("gff",batch)]))
Try(batch[grep("target.file",batch)] <- sub("target.file", paste("",target,"", sep="'"),batch[grep("target.file",batch)]))
Try(batch[grep("_time", batch)] <- sub("_time", paste("_",time,sep=""), batch[grep("_time",batch)]))
Try(zz <- file(paste(time, "batch.R",sep="_"), "w"))
Try(writeLines(batch,con=zz))
Try(close(zz))
system(paste("nohup R CMD BATCH ",paste(time, "batch.R",sep="_"),sep=""), wait=F)
Try(tkmessageBox(title="DEXSeq exon level DE",message="The DEXSeq analysis is running in background.",type="ok",icon="info"))
}
##############################################################################
desCounts <- function(){
# Try(require("tkWidgets") || stop("\ntkWidgets library is not installed\n"))
Try(my.dir <- getwd())
Try(SetWD())
#select.gff
Try(tkmessageBox(title="Selecting the gtf file",message="With the next widget, please select gtf file of the organism you are interested to associate reads to genes.",type="ok",icon="info"))
Try(gff <- fileBrowser())
Try(tmp <- strsplit(gff, "\\."))
Try(tmp <- unlist(tmp))
if(tmp[length(tmp)]!="gtf"){
Try(tkmessageBox(title="Selecting the gtf file",message="It seems that you have selected a file that does not have the right gtf extension!",type="ok",icon="error"))
Try(return())
}
#defining if RNAseq is ordered and standed
Try(ttIfDialog<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttIfDialog))
Try(tkgrab.set(ttIfDialog))
Try(tkfocus(ttIfDialog))
Try(tkwm.title(ttIfDialog,"Counting Options"))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(frame1 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(HowManyQuestion1 <- tklabel(frame1,text="RNAseq order",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(HowManyQuestion1))
Try(tkgrid.configure(HowManyQuestion1,columnspan=2,sticky="w"))
Try(thresholdTcl <- tclVar("pos"))
Try(I1.but <- tkradiobutton(frame1,text="Genomic position",variable=thresholdTcl,value="pos",font=.affylmGUIglobals$affylmGUIfont2))
Try(I2.but <- tkradiobutton(frame1,text="Read name",variable=thresholdTcl,value="name",font=.affylmGUIglobals$affylmGUIfont2))
Try(I3.but <- tkradiobutton(frame1,text="None, only for htseq-count v0.5.X",variable=thresholdTcl,value="none",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(I1.but,sticky="w"))
Try(tkgrid.configure(HowManyQuestion1,I1.but,I2.but,I3.but,sticky="w"))
Try(frame2 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(fractionLabel <- tklabel(frame2,text="Is RNAseq strand specific?",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(fractionLabel,sticky="w"))
Try(tkgrid.configure(fractionLabel,sticky="w"))
Try(fractionTcl <- tclVar("yes"))
Try(F1.but <- tkradiobutton(frame2,text="yes",variable=fractionTcl,value="yes",font=.affylmGUIglobals$affylmGUIfont2))
Try(F2.but <- tkradiobutton(frame2,text="no",variable=fractionTcl,value="no",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(F1.but,sticky="w"))
Try(tkgrid(F2.but,sticky="w"))
Try(tkgrid.configure(fractionLabel,F1.but,F2.but,sticky="w"))
Try(onOK <- function()
{
ReturnVal1 <- as.character(tclvalue(thresholdTcl))
ReturnVal2 <- as.character(tclvalue(fractionTcl))
Try(ReturnVal <<- paste(ReturnVal1, ReturnVal2, sep=";"))
Try(tkgrab.release(ttIfDialog))
Try(tkdestroy(ttIfDialog))
Try(tkfocus(.affylmGUIglobals$ttMain))
})
Try(frame3 <- tkframe(ttIfDialog,borderwidth=2))
Try(onCancel <- function() {Try(ReturnVal <<- ""); Try(tkgrab.release(ttIfDialog));Try(tkdestroy(ttIfDialog));Try(tkfocus(.affylmGUIglobals$ttMain))})
Try(OK.but <-tkbutton(frame3,text=" OK ",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(Cancel.but <-tkbutton(frame3,text=" Cancel ",command=onCancel,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(frame3,text=" "),OK.but,Cancel.but,tklabel(frame3,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" "),frame1,frame2,tklabel(ttIfDialog,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" "),frame3,tklabel(ttIfDialog,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(tkgrid.configure(frame1,frame3,sticky="w"))
Try(tkfocus(ttIfDialog))
Try(tkbind(ttIfDialog, "<Destroy>", function() {Try(tkgrab.release(ttIfDialog));Try(tkfocus(.affylmGUIglobals$ttMain));}))
Try(tkwait.window(ttIfDialog))
if(ReturnVal==""){return()}
Try(tmp <-strsplit(ReturnVal, ";"))
Try(stranded <- as.character(tmp[[1]][2]))
Try(order <- as.character(tmp[[1]][1]))
######################
# Try(make.counts <- paste(find.package(package="DEXSeq"),"python_scripts","dexseq_count.py",sep="/"))
if(order!="none"){
Try(system(paste("nohup htseq-count --order=",order," --stranded=",stranded," accepted_hits.sam ", gff, sep=""),wait=F))
}else{
Try(system(paste("nohup htseq-count --stranded=",stranded," accepted_hits.sam ",gff, sep=""),wait=F))
}
Try(tkmessageBox(title="Making gene counts",message="Gene
counts python is running in background.\nWhen finished you can move to the next step\n",icon="info",type="ok"))
Try(setwd(my.dir))
}
##############################################################################
desGenes <- function(){
# Try(require("tkWidgets") || stop("\ntkWidgets library is not installed\n"))
Try(my.dir <- getwd())
#select target file
Try(tkmessageBox(title="Selecting the target file",message="With the next widget, please select target file of your experiment.",type="ok",icon="info"))
Try(target <- fileBrowser())
Try(targets <- read.table(target, sep="\t", header=T))
if(paste(names(targets),collapse=" ")!="Name FileName Target"){
Try(tkmessageBox(title="Selecting the target file",message="It seems that you have selected a file that does not have the structure expected for a target file!",type="ok",icon="error"))
Try(return())
}
Try(covar <- unique(targets$Target))
if(length(covar)>2){
Try(tkmessageBox(title="Covariates",message="The present implementation only support two covariates.\nPlease, edit your target to include only two experimental conditions.",type="ok",icon="error"))
Try(return())
}
#creating time base name to differentiate the various runs
time <- gsub(" ","_",date())
time <- gsub(":","-",time)
time <- gsub(":","-",time)
#load count table
Try(sampleTable <- as.data.frame(cbind(as.character(targets$Name),paste(getwd(),as.character(targets$Name),"accepted_hits_des_counts.txt", sep="/"), as.character(targets$Target))))
Try(cat("\nCreating the count table ...be patient\n"))
# Try(tkmessageBox(title="Selecting the counts table file",message="With the next widget, please select gene-level counts table file.\nIt has the rda extension.",type="ok",icon="info"))
# Try(counts.file <- fileBrowser())
# Try(load(counts.file))
Try(cds <- newCountDataSetFromHTSeqCount(sampleTable=sampleTable, directory = ""))
Try(cds <- estimateSizeFactors(cds))
Try(cds <- estimateDispersions(cds))
Try(res.genes <- nbinomTest(cds, covar[1],covar[2]))
Try(save(res.genes, file=paste("res_gene-level_",time, ".rda",sep="")))
Try(tkmessageBox(title="Saving gene-level results",message=paste("Gene-level results are saved in:\n",paste("res_gene-level_",time, ".rda",sep=""),sep=""),type="ok",icon="info"))
}
##############################################################################
topTable.exons <- function(){
#Try(require("tkWidgets") || stop("\ntkWidgets library is not installed\n"))
Try(my.dir <- getwd())
#results
Try(tkmessageBox(title="Selecting the ecs.rda and resexons.rda",message="With the next widget, please select the ecs and resexons rda files you have generated with\ndifferential expression analysis at exon-level\nThe files start with the date at the time the analysis was started.",type="ok",icon="info"))
Try(rda <- fileBrowser())
if(length(grep("ecs_",rda))!=1){
Try(tkmessageBox(title="Selecting the ecs.rda file",message="It seems that you have selected a file is not an ecs.rda file !",type="ok",icon="error"))
Try(return())
}
if(length(grep("resexons_",rda))!=1){
Try(tkmessageBox(title="Selecting the resexons.rda file",message="It seems that you have selected a file is not an resexons.rda file !",type="ok",icon="error"))
Try(return())
}
Try(load(rda[1]))
Try(load(rda[2]))
Try(tmp.rda <- strsplit(rda[grep("ecs_",rda)],"/"))
Try(time <- sub("ecs_","",tmp.rda[[1]][length(tmp.rda[[1]])]))
Try(time <- sub(".rda","",time))
Try(cat(paste("The number of analysed exons is",dim(res.exons)[1],sep=" ")))
Try(res.exons <- res.exons[!is.na(res.exons$padj),])
Try(cat(paste("The number of exons left after removing those without counts is",dim(res.exons)[1],sep=" ")))
#selecting the set of differentially expressed exons
Try(ttIfDialog<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttIfDialog))
Try(tkgrab.set(ttIfDialog))
Try(tkfocus(ttIfDialog))
Try(tkwm.title(ttIfDialog,"Filtering Options"))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(frame1 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(HowManyQuestion1 <- tklabel(frame1,text="FDR threshold",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(HowManyQuestion1))
Try(tkgrid.configure(HowManyQuestion1,columnspan=2,sticky="w"))
Try(thresholdTcl <- tclVar("0.1"))
Try(I0.but <- tkradiobutton(frame1,text="1%",variable=thresholdTcl,value="0.01",font=.affylmGUIglobals$affylmGUIfont2))
Try(I1.but <- tkradiobutton(frame1,text="5%",variable=thresholdTcl,value="0.05",font=.affylmGUIglobals$affylmGUIfont2))
Try(I2.but <- tkradiobutton(frame1,text="10%",variable=thresholdTcl,value="0.1",font=.affylmGUIglobals$affylmGUIfont2))
Try(I3.but <- tkradiobutton(frame1,text="20%",variable=thresholdTcl,value="0.2",font=.affylmGUIglobals$affylmGUIfont2))
Try(I4.but <- tkradiobutton(frame1,text="none",variable=thresholdTcl,value="1",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(I0.but,sticky="w"))
Try(tkgrid(I1.but,sticky="w"))
Try(tkgrid(I2.but,sticky="w"))
Try(tkgrid(I3.but,sticky="w"))
Try(tkgrid(I4.but,sticky="w"))
Try(tkgrid.configure(HowManyQuestion1,I0.but,I1.but,I2.but,I3.but,I4.but,sticky="w"))
Try(frame2 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(fractionLabel <- tklabel(frame2,text="log2(fold change)",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(fractionLabel,sticky="w"))
Try(tkgrid.configure(fractionLabel,sticky="w"))
Try(fractionTcl <- tclVar("1"))
Try(F1.but <- tkradiobutton(frame2,text="none",variable=fractionTcl,value="0",font=.affylmGUIglobals$affylmGUIfont2))
Try(F2.but <- tkradiobutton(frame2,text="0.5",variable=fractionTcl,value="0.5",font=.affylmGUIglobals$affylmGUIfont2))
Try(F3.but <- tkradiobutton(frame2,text="1",variable=fractionTcl,value="1",font=.affylmGUIglobals$affylmGUIfont2))
Try(F4.but <- tkradiobutton(frame2,text="2",variable=fractionTcl,value="2",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(F1.but,sticky="w"))
Try(tkgrid(F2.but,sticky="w"))
Try(tkgrid(F3.but,sticky="w"))
Try(tkgrid(F4.but,sticky="w"))
Try(tkgrid.configure(fractionLabel,F1.but,F2.but,F3.but,F4.but,sticky="w"))
Try(onOK <- function()
{
ReturnVal1 <- as.numeric(tclvalue(thresholdTcl))
ReturnVal2 <- as.numeric(tclvalue(fractionTcl))
Try(ReturnVal <<- paste(ReturnVal1, ReturnVal2, sep=";"))
Try(tkgrab.release(ttIfDialog))
Try(tkdestroy(ttIfDialog))
Try(tkfocus(.affylmGUIglobals$ttMain))
})
Try(frame3 <- tkframe(ttIfDialog,borderwidth=2))
Try(onCancel <- function() {Try(ReturnVal <<- ""); Try(tkgrab.release(ttIfDialog));Try(tkdestroy(ttIfDialog));Try(tkfocus(.affylmGUIglobals$ttMain))})
Try(OK.but <-tkbutton(frame3,text=" OK ",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(Cancel.but <-tkbutton(frame3,text=" Cancel ",command=onCancel,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(frame3,text=" "),OK.but,Cancel.but,tklabel(frame3,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" "),frame1,frame2,tklabel(ttIfDialog,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" "),frame3,tklabel(ttIfDialog,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(tkgrid.configure(frame1,frame3,sticky="w"))
Try(tkfocus(ttIfDialog))
Try(tkbind(ttIfDialog, "<Destroy>", function() {Try(tkgrab.release(ttIfDialog));Try(tkfocus(.affylmGUIglobals$ttMain));}))
Try(tkwait.window(ttIfDialog))
Try(if(ReturnVal==""){return()})
Try(tmp<-strsplit(ReturnVal, ";"))
Try(fc <- as.numeric(tmp[[1]][2]))
Try(fdr <- as.numeric(tmp[[1]][1]))
Try(tmp1 <- paste("FDR threshold ",(fdr*100), "%", sep=""))
Try(tmp2 <- paste("log2FC threshold ", fc, sep=""))
Try(tmp3 <- paste(tmp1, tmp2, sep=" "))
Try(selected <- intersect(which(res.exons$padj <= fdr),which(abs(res.exons[,grep("^log2fold",names(res.exons))]) >= fc)))
Try(write.table(res.exons[selected,], paste("de_exons_",time,".txt", sep=""), sep="\t", row.names=F))
Try(tkmessageBox(title="Saving DE exons data",message=paste("Exons DE table is saved in \n",paste("de_exons_",time,".txt", sep=""), sep=""),type="ok",icon="info"))
#plotDEXSeq(ecs, as.character(res.exons$geneID[selected]), FDR=0.1 ,splicing=T, expression=F, displayTranscripts=T, cex.axis=1.2, cex=1.3, lwd=2, legend=TRUE)
}
##############################################################################
topTable.genes <- function(){
# Try(require("tkWidgets") || stop("\ntkWidgets library is not installed\n"))
Try(my.dir <- getwd())
#results
Try(tkmessageBox(title="Selecting the res_gene-level.rda",message="With the next widget, please select the res_gene-level.rda you have generated with\ndifferential expression analysis at gene-level\nThe files start with the date at the time the analysis was started.",type="ok",icon="info"))
Try(rda <- fileBrowser())
if(length(grep("res_gene-level_",rda))!=1){
Try(tkmessageBox(title="Selecting the res_gene-level.rda file",message="It seems that you have selected a file is not an res_gene-level.rda file !",type="ok",icon="error"))
Try(return())
}
Try(load(rda))
Try(tmp.rda <- strsplit(rda[grep("res_gene-level_",rda)],"/"))
Try(time <- sub(".rda","",tmp.rda[[1]][length(tmp.rda[[1]])]))
Try(time <- sub("res_gene-level_","",time))
Try(cat(paste("The number of analysed genes is ",dim(res.genes)[1],sep=" ")))
#selecting the set of differentially expressed genes
Try(ttIfDialog<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttIfDialog))
Try(tkgrab.set(ttIfDialog))
Try(tkfocus(ttIfDialog))
Try(tkwm.title(ttIfDialog,"Filtering Options"))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(frame1 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(HowManyQuestion1 <- tklabel(frame1,text="P-value threshold",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(HowManyQuestion1))
Try(tkgrid.configure(HowManyQuestion1,columnspan=2,sticky="w"))
Try(thresholdTcl <- tclVar("0.1"))
Try(I0.but <- tkradiobutton(frame1,text="0.005",variable=thresholdTcl,value="0.005",font=.affylmGUIglobals$affylmGUIfont2))
Try(I1.but <- tkradiobutton(frame1,text="0.01",variable=thresholdTcl,value="0.01",font=.affylmGUIglobals$affylmGUIfont2))
Try(I2.but <- tkradiobutton(frame1,text="0.05",variable=thresholdTcl,value="0.05",font=.affylmGUIglobals$affylmGUIfont2))
Try(I3.but <- tkradiobutton(frame1,text="0.1",variable=thresholdTcl,value="0.1",font=.affylmGUIglobals$affylmGUIfont2))
Try(I4.but <- tkradiobutton(frame1,text="none",variable=thresholdTcl,value="1",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(I0.but,sticky="w"))
Try(tkgrid(I1.but,sticky="w"))
Try(tkgrid(I2.but,sticky="w"))
Try(tkgrid(I3.but,sticky="w"))
Try(tkgrid(I4.but,sticky="w"))
Try(tkgrid.configure(HowManyQuestion1,I0.but,I1.but,I2.but,I3.but,I4.but,sticky="w"))
Try(frame2 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(fractionLabel <- tklabel(frame2,text="log2(fold change)",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(fractionLabel,sticky="w"))
Try(tkgrid.configure(fractionLabel,sticky="w"))
Try(fractionTcl <- tclVar("1"))
Try(F1.but <- tkradiobutton(frame2,text="none",variable=fractionTcl,value="0",font=.affylmGUIglobals$affylmGUIfont2))
Try(F2.but <- tkradiobutton(frame2,text="0.5",variable=fractionTcl,value="0.5",font=.affylmGUIglobals$affylmGUIfont2))
Try(F3.but <- tkradiobutton(frame2,text="1",variable=fractionTcl,value="1",font=.affylmGUIglobals$affylmGUIfont2))
Try(F4.but <- tkradiobutton(frame2,text="2",variable=fractionTcl,value="2",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(F1.but,sticky="w"))
Try(tkgrid(F2.but,sticky="w"))
Try(tkgrid(F3.but,sticky="w"))
Try(tkgrid(F4.but,sticky="w"))
Try(tkgrid.configure(fractionLabel,F1.but,F2.but,F3.but,F4.but,sticky="w"))
Try(onOK <- function()
{
ReturnVal1 <- as.numeric(tclvalue(thresholdTcl))
ReturnVal2 <- as.numeric(tclvalue(fractionTcl))
Try(ReturnVal <<- paste(ReturnVal1, ReturnVal2, sep=";"))
Try(tkgrab.release(ttIfDialog))
Try(tkdestroy(ttIfDialog))
Try(tkfocus(.affylmGUIglobals$ttMain))
})
Try(frame3 <- tkframe(ttIfDialog,borderwidth=2))
Try(onCancel <- function() {Try(ReturnVal <<- ""); Try(tkgrab.release(ttIfDialog));Try(tkdestroy(ttIfDialog));Try(tkfocus(.affylmGUIglobals$ttMain))})
Try(OK.but <-tkbutton(frame3,text=" OK ",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(Cancel.but <-tkbutton(frame3,text=" Cancel ",command=onCancel,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(frame3,text=" "),OK.but,Cancel.but,tklabel(frame3,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" "),frame1,frame2,tklabel(ttIfDialog,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" "),frame3,tklabel(ttIfDialog,text=" ")))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(tkgrid.configure(frame1,frame3,sticky="w"))
Try(tkfocus(ttIfDialog))
Try(tkbind(ttIfDialog, "<Destroy>", function() {Try(tkgrab.release(ttIfDialog));Try(tkfocus(.affylmGUIglobals$ttMain));}))
Try(tkwait.window(ttIfDialog))
Try(if(ReturnVal==""){return()})
Try(tmp<-strsplit(ReturnVal, ";"))
Try(fc <- as.numeric(tmp[[1]][2]))
Try(fdr <- as.numeric(tmp[[1]][1]))
Try(tmp1 <- paste("P-value threshold ",fdr, sep=""))
Try(tmp2 <- paste("log2FC threshold ", fc, sep=""))
Try(tmp3 <- paste(tmp1, tmp2, sep=" "))
Try(selected <- intersect(which(res.genes$padj <= fdr),which(abs(res.genes$log2FoldChange) >= fc)))
Try(write.table(res.genes[selected,], paste("de_genes_",time,".txt", sep=""), sep="\t", row.names=F))
Try(cat(paste("\nThe number of differentially expressed genes is ",dim(res.genes[selected,])[1],sep=" ")))
Try(tkmessageBox(title="Saving DE gene data",message=paste("Gene DE table is saved in \n",paste("de_genes_",time,".txt", sep=""), sep=""),type="ok",icon="info"))
}
##############################################################################
plotDE.exons <- function(){
Try(tkmessageBox(title="Selecting the resexons.rda",message="With the next widget, please select the resexons rda file you have generated with\ndifferential expression analysis at exon-level\nThe files start with the date at the time the analysis was started.",type="ok",icon="info"))
Try(rda <- fileBrowser())
if(length(grep("resexons_",rda))!=1){
Try(tkmessageBox(title="Selecting the resexons.rda file",message="It seems that you have selected a file is not an resexons.rda file !",type="ok",icon="error"))
Try(return())
}
cat("loading resexons ... be patient")
load(rda)
#selecting gene to be plotted
Try(ttgene<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttgene))
Try(tkgrab.set(ttgene))
Try(tkfocus(ttgene))
Try(tkwm.title(ttgene,"Gene to be plotted"))
Try(tkgrid(tklabel(ttgene,text=" ")))
Try(geneName<- "")
Try(Local.gene <- tclVar(init=geneName))
Try(entry.gene <-tkentry(ttgene,width="20",font=.affylmGUIglobals$affylmGUIfont2,textvariable=Local.gene,bg="white"))
Try(tkgrid(tklabel(ttgene,text="Please enter the name of the gene to be plotted.",font=.affylmGUIglobals$affylmGUIfont2)))
Try(tkgrid(entry.gene))
onOK <- function()
{
Try(geneName <<- as.character(tclvalue(Local.gene)))
Try(tkgrab.release(ttgene));Try(tkdestroy(ttgene));Try(tkfocus(.affylmGUIglobals$ttMain))
}
Try(OK.but <-tkbutton(ttgene,text=" OK ",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(ttgene,text=" ")))
Try(tkgrid(OK.but))
Try(tkgrid.configure(OK.but))
Try(tkgrid(tklabel(ttgene,text=" ")))
Try(tkfocus(entry.gene))
Try(tkbind(entry.gene, "<Return>",onOK))
Try(tkbind(ttgene, "<Destroy>", function(){Try(tkgrab.release(ttgene));Try(tkfocus(.affylmGUIglobals$ttMain));return(0)}))
Try(tkwait.window(ttgene))
Try(tkfocus(.affylmGUIglobals$ttMain))
#########plotting params
Try(ttplottingDialog<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttplottingDialog))
Try(tkgrab.set(ttplottingDialog))
Try(tkfocus(ttplottingDialog))
Try(tkwm.title(ttplottingDialog,"PLotting Parameters"))
Try(tkgrid(tklabel(ttplottingDialog,text=" ")))
Try(frame1 <- tkframe(ttplottingDialog,relief="groove",borderwidth=2))
Try(HowManyQuestion1 <- tklabel(frame1,text="FDR threshold",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(HowManyQuestion1))
Try(tkgrid.configure(HowManyQuestion1,columnspan=2,sticky="w"))
Try(qTcl <- tclVar("0.1"))
Try(q0.but <- tkradiobutton(frame1,text="0.1",variable=qTcl,value=0.1,font=.affylmGUIglobals$affylmGUIfont2))
Try(q1.but <- tkradiobutton(frame1,text="0.05",variable=qTcl,value=0.05,font=.affylmGUIglobals$affylmGUIfont2))
Try(q2.but <- tkradiobutton(frame1,text="0.01",variable=qTcl,value=0.01,font=.affylmGUIglobals$affylmGUIfont2))
Try(q3.but <- tkradiobutton(frame1,text="0.005",variable=qTcl,value=0.005,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(q0.but,sticky="w"))
Try(tkgrid(q1.but,sticky="w"))
Try(tkgrid(q2.but,sticky="w"))
Try(tkgrid(q3.but,sticky="w"))
Try(tkgrid.configure(HowManyQuestion1,q0.but,q1.but,q2.but,q3.but,sticky="w"))
Try(frame2 <- tkframe(ttplottingDialog,relief="groove",borderwidth=2))
Try(alfaLabel <- tklabel(frame2,text="Gene/exon level",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(alfaLabel,sticky="w"))
Try(tkgrid.configure(alfaLabel,sticky="w"))
Try(alfaTcl <- tclVar("exons"))
Try(a0.but <- tkradiobutton(frame2,text="exons",variable=alfaTcl,value="exons",font=.affylmGUIglobals$affylmGUIfont2))
Try(a1.but <- tkradiobutton(frame2,text="gene",variable=alfaTcl,value="gene",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(a0.but,sticky="w"))
Try(tkgrid(a1.but,sticky="w"))
Try(frame3 <- tkframe(ttplottingDialog,relief="groove",borderwidth=2))
Try(r2Label <- tklabel(frame3,text="Other parameters",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(r2Label,sticky="w"))
Try(tkgrid.configure(r2Label,sticky="w"))
Try(r2Tcl <- tclVar("displayTranscripts"))
Try(r1.but <- tkradiobutton(frame3,text="Normalized Counts",variable=r2Tcl,value="norCounts",font=.affylmGUIglobals$affylmGUIfont2))
Try(r2.but <- tkradiobutton(frame3,text="Display Transcripts" ,variable=r2Tcl,value="displayTranscripts" ,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(r1.but,sticky="w"))
Try(tkgrid(r2.but ,sticky="w"))
Try(Abort <- 1)
plotting.param <- list()
Try(onOK <- function()
{
Try(plotting.param[[1]] <<- tclvalue(qTcl))
Try(tkgrab.release(ttplottingDialog))
Try(tkdestroy(ttplottingDialog))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(plotting.param[[2]] <<- tclvalue(alfaTcl))
Try(plotting.param[[3]] <<- tclvalue(r2Tcl))
Try(Abort <<- 0)
})
Try(frame4 <- tkframe(ttplottingDialog,borderwidth=2))
Try(onCancel <- function() {Try(tkgrab.release(ttplottingDialog));Try(tkdestroy(ttplottingDialog));Try(tkfocus(.affylmGUIglobals$ttMain));Abort <<- 1})
Try(OK.but <-tkbutton(frame4,text=" OK ",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(Cancel.but <-tkbutton(frame4,text=" Cancel ",command=onCancel,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(frame4,text=" "),OK.but,Cancel.but,tklabel(frame4,text=" ")))
Try(tkgrid(tklabel(ttplottingDialog,text=" "),frame1,frame2,tklabel(ttplottingDialog,text=" ")))
Try(tkgrid(tklabel(ttplottingDialog,text=" ")))
Try(tkgrid(tklabel(ttplottingDialog,text=" "),frame3,frame4,tklabel(ttplottingDialog,text=" ")))
Try(tkgrid(tklabel(ttplottingDialog,text=" ")))
Try(tkgrid.configure(frame1,frame3,sticky="w"))
Try(tkfocus(ttplottingDialog))
Try(tkbind(ttplottingDialog, "<Destroy>", function() {Try(tkgrab.release(ttplottingDialog));Try(tkfocus(.affylmGUIglobals$ttMain));}))
Try(tkwait.window(ttplottingDialog))
Try(if(Abort==1) return())
Try(splicing <- FALSE)
Try(expression <- FALSE)
Try(displayTranscripts <- FALSE)
Try(norCounts <- FALSE)
if(plotting.param[[2]]=="exons") splicing <- TRUE
if(plotting.param[[2]]=="gene") expression <- TRUE
if(plotting.param[[3]]=="displayTranscripts") displayTranscripts <- TRUE
if(plotting.param[[3]]=="norCounts") norCounts <- TRUE
Try(plotDEXSeq(res.exons, geneID=geneName, FDR=as.numeric(plotting.param[[1]]) ,splicing=splicing, expression=expression,
norCounts=norCounts, displayTranscripts=displayTranscripts, cex.axis=1.2, cex=1.3, lwd=2, legend=TRUE))
}
##############################################################################
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.