Nothing
#set of functions, directly/indirectly involved, in oneChannelGUI Modelling stat Menu
#oneChannelGUI rawpCheck check the raw p-value distribution within a specific contrast
#contains affylmGUI ChooseContrastParameterization
#oneChannelGUI showTopTable allows the definition of the toptable output. The function is a modification of the original affylmGUI showTopTable
#contains affylmGUI ChooseContrastParameterization
# calling SaveTopTable present inside the function
#oneChannelGUI VennDiagram making a venn diagram starting for lists of probesets
#contains oneChannelGUI calling plotFunction present inside the function
# calling SaveTopTable present inside the function
#oneChannelGUI masigpro.edesign is present in targetmenu.R
#oneChannelGUI this function allows to run masigpro from the oneChannelGUI
#oneChannelGUI masigpro.view getting outputs from masigpro results
#contains oneChannelGUI calling plotFunction present inside the function
#oneChannelGUI ComputeLinearModelFit modification of the affylmGUI to handle ExpressionSet
#contains oneChannelGUI NormalizeNow present in normalizemenu.R
#oneChannelGUI ComputeContrasts modification of the affylmGUI to handle ExpressionSet
#contains oneChannelGUI ComputeLinearModelFit
# affylmGUI GetContrastParameterizationName
#oneChannelGUI limma2paired limma model for two groups paired samples
#oneChannelGUI edgerInterface a graphical interface to edgeR package
#oneChannelGUI bayseqInterface a graphical interface to baySeq package
#oneChannelGUI deseqInterface a graphical interface to deseq package
#oneChannelGUI degseqInterface a graphical interface to degseq package
################################################################################
#this function will show the distribution of raw pvalues after bayes regularization
"rawpCheck"<- function(){
Try(NumContrastParameterizations <- get("NumContrastParameterizations",envir=affylmGUIenvironment))
Try(ContrastParameterizationList <- get("ContrastParameterizationList",envir=affylmGUIenvironment))
Try(ContrastParameterizationTREEIndexVec <- get("ContrastParameterizationTREEIndexVec",envir=affylmGUIenvironment))
Try(ArraysLoaded <- get("ArraysLoaded", envir=affylmGUIenvironment))
Try(if(ArraysLoaded==FALSE)
{
Try(tkmessageBox(title="Top Table",message="No arrays have been loaded. Please try New or Open from the File menu.",type="ok",icon="error"))
Try(tkfocus(.affylmGUIglobals$ttMain))
return()
})
Try(if(NumContrastParameterizations==0)
{
Try(tkmessageBox(title="Top Table",message="There are no contrast parameterizations available. Select \"Compute Contrasts\" from the \"Linear Model\" menu.",type="ok",icon="error"))
Try(tkfocus(.affylmGUIglobals$ttMain))
return()
})
Try(contrastParameterizationIndex <- ChooseContrastParameterization())
Try(if(contrastParameterizationIndex==0) return()) # Cancel
#Try(.affylmGUIglobals$ContrastParameterizationTREEIndex <- ContrastParameterizationTREEIndexVec[contrastParameterizationIndex])
#Try(ContrastNamesVec <- colnames(as.matrix(ContrastParameterizationList[[contrastParameterizationIndex]]$contrastsMatrixInList$contrasts)))
#Try(GetContrastReturnVal <- GetContrast(contrastParameterizationIndex))
#Try(if(GetContrastReturnVal$contrastIndex==0) return()) # Cancel
#Try(contrast <- GetContrastReturnVal$contrastIndex)
#Try(ContrastParameterizationNameNode <- paste("ContrastParameterizationName.",.affylmGUIglobals$ContrastParameterizationTREEIndex,sep=""))
Try(tkmessageBox(title="raw P-values",message=paste("Plot will be displayed in the main R window")))
#p.values plots
n.contrasts<-dim(ContrastParameterizationList[[contrastParameterizationIndex]]$eb$p.value)
names.contrasts<-dimnames(ContrastParameterizationList[[contrastParameterizationIndex]]$eb$p.value)[[2]]
my.plots<-which(names.contrasts!="(NA)-(NA)")
par(mfrow=c(1,length(my.plots)))
for(i in my.plots){
hist(ContrastParameterizationList[[contrastParameterizationIndex]]$eb$p.value[,i], main=names.contrasts[i], xlab="")
}
}
################################################################################
#showTopTable has been modified to get as geneNames the subset of genes available in the normalized data set
#if this is not done there is an incongruence in topTable geneNames after the normalized data set is filtered
#and used for differential expression analysis
showTopTable <- function(...,export=FALSE)
{
# Try(require("annotate", character.only = TRUE) || stop("need data package: annotate"))
Try(NumContrastParameterizations <- get("NumContrastParameterizations",envir=affylmGUIenvironment))
Try(ContrastParameterizationList <- get("ContrastParameterizationList",envir=affylmGUIenvironment))
Try(ContrastParameterizationTREEIndexVec <- get("ContrastParameterizationTREEIndexVec",envir=affylmGUIenvironment))
Try(ArraysLoaded <- get("ArraysLoaded", envir=affylmGUIenvironment))
Try(if(ArraysLoaded==FALSE)
{
Try(tkmessageBox(title="Top Table",message="No arrays have been loaded. Please try New or Open from the File menu.",type="ok",icon="error"))
Try(tkfocus(.affylmGUIglobals$ttMain))
return()
})
Try(if(NumContrastParameterizations==0)
{
Try(tkmessageBox(title="Top Table",message="There are no contrast parameterizations available. Select \"Compute Contrasts\" from the \"Linear Model\" menu.",type="ok",icon="error"))
Try(tkfocus(.affylmGUIglobals$ttMain))
return()
})
Try(contrastParameterizationIndex <- ChooseContrastParameterization())
Try(if(contrastParameterizationIndex==0) return()) # Cancel
Try(.affylmGUIglobals$ContrastParameterizationTREEIndex <- ContrastParameterizationTREEIndexVec[contrastParameterizationIndex])
Try(ContrastNamesVec <- colnames(as.matrix(ContrastParameterizationList[[contrastParameterizationIndex]]$contrastsMatrixInList$contrasts)))
Try(GetContrastReturnVal <- GetContrast(contrastParameterizationIndex))
Try(if(GetContrastReturnVal$contrastIndex==0) return()) # Cancel
Try(contrast <- GetContrastReturnVal$contrastIndex)
Try(ContrastParameterizationNameNode <- paste("ContrastParameterizationName.",.affylmGUIglobals$ContrastParameterizationTREEIndex,sep=""))
Try(fit <- (ContrastParameterizationList[[ContrastParameterizationNameNode]])$fit)
# Try(eb <- (ContrastParameterizationList[[ContrastParameterizationNameNode]])$eb)
Try(if(("eb" %in% names(ContrastParameterizationList[[contrastParameterizationIndex]]))&&
length(ContrastParameterizationList[[contrastParameterizationIndex]]$eb)>0)
Try(ebayesAvailable <- TRUE)
else
Try(ebayesAvailable <- FALSE))
# This is a bit silly, calculating it again. This should be tidied up later. But basically, we're
# checking whether we had degrees of freedom > 0 from the linear model fit (i.e. were there any
# replicate arrays?) If so, eBayes should work, and we can use Gordon's new method (adding new
# attributes to the fit object rather than using eb), because this seems to work best with topTable,
# affy data etc.
Try(if(ebayesAvailable==TRUE)
Try(fit <- eBayes(fit)))
Try(ttToptableDialog<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttToptableDialog))
Try(tkgrab.set(ttToptableDialog))
Try(tkfocus(ttToptableDialog))
Try(tkwm.title(ttToptableDialog,"Toptable Options"))
Try(tkgrid(tklabel(ttToptableDialog,text=" ")))
#Try(frame1 <- tkframe(ttToptableDialog,relief="groove",borderwidth=2))
#Try(HowManyQuestion1 <- tklabel(frame1,text= "Number of genes in table:",font=.affylmGUIglobals$affylmGUIfont2))
#Try(tkgrid(HowManyQuestion1))
#Try(tkgrid.configure(HowManyQuestion1,columnspan=2,sticky="w"))
#Try(if(export)
# Try(numberOfGenesTcl <- tclVar("5"))
#else
# Try(numberOfGenesTcl <- tclVar("5")))
# Try(Ten.but <- tkradiobutton(frame1,text="10",variable=numberOfGenesTcl,value="1",font=.affylmGUIglobals$affylmGUIfont2))
# Try(Thirty.but <- tkradiobutton(frame1,text="30",variable=numberOfGenesTcl,value="2",font=.affylmGUIglobals$affylmGUIfont2))
# Try(Fifty.but <- tkradiobutton(frame1,text="50",variable=numberOfGenesTcl,value="3",font=.affylmGUIglobals$affylmGUIfont2))
# Try(Hundred.but <- tkradiobutton(frame1,text="100",variable=numberOfGenesTcl,value="4",font=.affylmGUIglobals$affylmGUIfont2))
#Try(AllGenes.but <- tkradiobutton(frame1,text="All genes",variable=numberOfGenesTcl,value="5",font=.affylmGUIglobals$affylmGUIfont2))
# Try(tkgrid(Ten.but,sticky="w"))
# Try(tkgrid(Thirty.but,sticky="w"))
# Try(tkgrid(Fifty.but,sticky="w"))
# Try(tkgrid(Hundred.but,sticky="w"))
# Try(tkgrid(AllGenes.but,sticky="w"))
# Try(tkgrid.configure(HowManyQuestion1,AllGenes.but,sticky="w"))
Try(frame2 <- tkframe(ttToptableDialog,relief="groove",borderwidth=2))
Try(sortByLabel <- tklabel(frame2,text="Sort by:",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(sortByLabel,sticky="w"))
Try(tkgrid.configure(sortByLabel,sticky="w"))
Try(if(ebayesAvailable==TRUE)
Try(sortByTcl <- tclVar("B"))
else
Try(sortByTcl <- tclVar("M")))
Try(M.but <- tkradiobutton(frame2,text="M",variable=sortByTcl,value="M",font=.affylmGUIglobals$affylmGUIfont2))
Try(A.but <- tkradiobutton(frame2,text="A",variable=sortByTcl,value="A",font=.affylmGUIglobals$affylmGUIfont2))
Try(T.but <- tkradiobutton(frame2,text="t statistic",variable=sortByTcl,value="T",font=.affylmGUIglobals$affylmGUIfont2))
Try(P.but <- tkradiobutton(frame2,text="P value",variable=sortByTcl,value="P",font=.affylmGUIglobals$affylmGUIfont2))
Try(B.but <- tkradiobutton(frame2,text="B statistic",variable=sortByTcl,value="B",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(M.but,sticky="w"))
Try(tkgrid(A.but,sticky="w"))
Try(tkgrid(T.but,sticky="w"))
Try(tkgrid(P.but,sticky="w"))
Try(tkgrid(B.but,sticky="w"))
Try(if(ebayesAvailable==FALSE)
{
Try(tkconfigure(T.but,state="disabled"))
Try(tkconfigure(P.but,state="disabled"))
Try(tkconfigure(B.but,state="disabled"))
})
Try(frame3 <- tkframe(ttToptableDialog,relief="groove",borderwidth=2))
Try(adjustMethodLabel <- tklabel(frame3,text="Adjust method:",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(adjustMethodLabel,sticky="w"))
Try(tkgrid.configure(adjustMethodLabel,sticky="w"))
Try(if(ebayesAvailable==TRUE)
Try(adjustMethodTcl <- tclVar("BH"))
else
Try(adjustMethodTcl <- tclVar("none")))
Try(none.but <- tkradiobutton(frame3,text="None",variable=adjustMethodTcl,value="none",font=.affylmGUIglobals$affylmGUIfont2))
Try(bh.but <- tkradiobutton(frame3,text="BH" ,variable=adjustMethodTcl,value="BH" ,font=.affylmGUIglobals$affylmGUIfont2))
Try(by.but <- tkradiobutton(frame3,text="BY" ,variable=adjustMethodTcl,value="BY" ,font=.affylmGUIglobals$affylmGUIfont2))
Try(holm.but <- tkradiobutton(frame3,text="Holm",variable=adjustMethodTcl,value="holm",font=.affylmGUIglobals$affylmGUIfont2))
##Try(bonferroni.but <- tkradiobutton(frame3,text="Bonferroni",variable=adjustMethodTcl,value="bonferroni",font=.affylmGUIglobals$affylmGUIfont2))
##Try(hochberg.but <- tkradiobutton(frame3,text="Hochberg" ,variable=adjustMethodTcl,value="hochberg" ,font=.affylmGUIglobals$affylmGUIfont2))
##Try(hommel.but <- tkradiobutton(frame3,text="Hommel" ,variable=adjustMethodTcl,value="hommel" ,font=.affylmGUIglobals$affylmGUIfont2))
##Try(fdr.but <- tkradiobutton(frame3,text="FDR" ,variable=adjustMethodTcl,value="fdr" ,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(none.but,sticky="w"))
Try(tkgrid(bh.but ,sticky="w"))
Try(tkgrid(by.but ,sticky="w"))
Try(tkgrid(holm.but,sticky="w"))
##Try(tkgrid(bonferroni.but,sticky="w"))
##Try(tkgrid(holm.but,sticky="w"))
##Try(tkgrid(hochberg.but,sticky="w"))
##Try(tkgrid(hommel.but,sticky="w"))
##Try(tkgrid(fdr.but,sticky="w"))
##Try(tkgrid(none.but,sticky="w"))
Try(if(ebayesAvailable==FALSE)
{
Try(tkconfigure(none.but,state="disabled"))
Try(tkconfigure(bh.but ,state="disabled"))
Try(tkconfigure(by.but ,state="disabled"))
Try(tkconfigure(holm.but,state="disabled"))
##Try(tkconfigure(bonferroni.but,state="disabled"))
##Try(tkconfigure(holm.but ,state="disabled"))
##Try(tkconfigure(hochberg.but ,state="disabled"))
##Try(tkconfigure(hommel.but ,state="disabled"))
##Try(tkconfigure(fdr.but ,state="disabled"))
##Try(tkconfigure(none.but ,state="disabled"))
})
Try(totalGenes <- nrow(fit$coefficients))
Try(Abort <- 1)
Try(numberOfGenes <- 0)
Try(sortBy <- "B")
Try(adjustMethod <- "BH")
Try(onOK <- function()
{
#Try(NumGenesChoice <- as.numeric(tclvalue(numberOfGenesTcl)))
Try(tkgrab.release(ttToptableDialog))
Try(tkdestroy(ttToptableDialog))
Try(tkfocus(.affylmGUIglobals$ttMain))
#Try(NumbersOfGenes <- c(10,30,50,100,totalGenes))
Try(numberOfGenes <<- totalGenes)
Try(sortBy <<- tclvalue(sortByTcl))
Try(adjustMethod <<- tclvalue(adjustMethodTcl))
Try(Abort <<- 0)
})
Try(onHelp <- function() Try(help("topTable",htmlhelp=TRUE)))
Try(frame4 <- tkframe(ttToptableDialog,borderwidth=2))
Try(onCancel <- function() {Try(tkgrab.release(ttToptableDialog));Try(tkdestroy(ttToptableDialog));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(Help.but <-tkbutton(frame4,text=" Help ",command=onHelp,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(frame4,text=" "),OK.but,Cancel.but,Help.but,tklabel(frame4,text=" ")))
Try(tkgrid(tklabel(ttToptableDialog,text=" "),frame2,tklabel(ttToptableDialog,text=" ")))
Try(tkgrid(tklabel(ttToptableDialog,text=" ")))
Try(tkgrid(tklabel(ttToptableDialog,text=" "),frame3,frame4,tklabel(ttToptableDialog,text=" ")))
Try(tkgrid(tklabel(ttToptableDialog,text=" ")))
Try(tkgrid.configure(frame3,sticky="w"))
Try(tkgrid.configure(frame4,sticky="s"))
Try(tkfocus(ttToptableDialog))
Try(tkbind(ttToptableDialog, "<Destroy>", function() {Try(tkgrab.release(ttToptableDialog));Try(tkfocus(.affylmGUIglobals$ttMain));}))
Try(tkwait.window(ttToptableDialog))
Try(if(Abort==1)
return())
Try(if(numberOfGenes==totalGenes)
{
tkconfigure(.affylmGUIglobals$ttMain,cursor="watch")
Try(tkfocus(.affylmGUIglobals$ttMain))
})
Try(options(digits=3))
####this part refer to 3' IVT arrays and ILLU
Try(whichArrayPlatform <- get("whichArrayPlatform",envir=affylmGUIenvironment))
Try(whichLib <- get("whichLib",envir=affylmGUIenvironment))
getDataEnv <- function(name, lib) {
get(paste(lib, name, sep = ""), mode = "environment")
}
Try(NormalizedAffyData.Available <- get("NormalizedAffyData.Available",envir=affylmGUIenvironment))
if((whichArrayPlatform == "AFFY" || whichArrayPlatform == "ILLU" || whichArrayPlatform == "GENE") & NormalizedAffyData.Available){
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(annLib <- .annotation(NormalizedAffyData))
if(annLib=="mogene10stv1"){
Try(annLib <- "mogene10sttranscriptcluster")
}
if(annLib=="mogene20stv1"){
Try(annLib <- "mogene20sttranscriptcluster")#
}
if(annLib=="hugene10stv1"){
Try(annLib <- "hugene10sttranscriptcluster")
}
if(annLib !=""){
if(length(as.character(unlist(strsplit(annLib, "\\."))))< 2 ){
annLib <- paste(annLib, ".db", sep="")
}
Try(require(annLib, character.only = TRUE) || stop("need data package: ", annLib))
# Try(require("annotate", character.only = TRUE) || stop("need data package: annotate"))
}
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
if(annLib=="ath1121501.db"){
Try(annlib <- as.character(unlist(strsplit(annLib, ".db"))))
Try(geneNames <- lookUp(featureNames(NormalizedAffyData), annlib, "ACCNUM"))
Try(geneNames.n <- names(geneNames))
Try(geneNames <- as.character(unlist(geneNames)))
Try(names(geneNames) <- geneNames.n)
#Try(geneSymbols <- as.character(unlist(mget(featureNames(NormalizedAffyData), env=getDataEnv("SYMBOL", annLib), ifnotfound=NA))))
Try(geneSymbols <- lookUp(featureNames(NormalizedAffyData), annlib, "SYMBOL"))
Try(geneSymbols.n <- names(geneSymbols))
Try(geneSymbols <- as.character(unlist(geneSymbols)))
Try(names(geneSymbols) <- geneSymbols.n)
if(length(geneNames)!=length(geneSymbols)){
common <- intersect(names(geneNames),names(geneSymbols))
geneSymbols <- geneSymbols[which(names(geneSymbols) %in% common)]
if(!identical(names(geneSymbols), names(geneNames))){
geneSymbols <- rep(NA, length(geneNames))
names(geneSymbols) <- names(geneNames)
}
}
} else if(annLib=="yeast2.db"){
Try(annlib <- as.character(unlist(strsplit(annLib, ".db"))))
Try(geneNames <- as.character(unlist(mget(featureNames(NormalizedAffyData), env=getDataEnv("ORF", annLib), ifnotfound=NA))))
Try(geneSymbols <- as.character(unlist(mget(featureNames(NormalizedAffyData), env=getDataEnv("GENENAME", annLib), ifnotfound=NA))))
} else if(annLib==""){
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(geneNames <- rep("-", dim(genelist)[1]))
Try(geneSymbols <- rep("-", dim(genelist)[1]))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)),as.matrix(geneNames),as.matrix(geneSymbols)))
Try(colnames(genelist) <- c("geneID","EG","SYMBOL"))
}else {
#Try(geneNames <- as.character(unlist(mget(featureNames(NormalizedAffyData), env=getDataEnv("ENTREZID", annLib), ifnotfound=NA))))
Try(annlib1 <- as.character(unlist(strsplit(annLib, ".db"))))
Try(geneNames <- lookUp(featureNames(NormalizedAffyData), annlib1, "ENTREZID"))
Try(geneNames.n <- names(geneNames))
Try(geneNames <- as.character(unlist(geneNames)))
Try(names(geneNames) <- geneNames.n)
#Try(geneSymbols <- as.character(unlist(mget(featureNames(NormalizedAffyData), env=getDataEnv("SYMBOL", annLib), ifnotfound=NA))))
Try(geneSymbols <- lookUp(featureNames(NormalizedAffyData), annlib1, "SYMBOL"))
Try(geneSymbols.n <- names(geneSymbols))
Try(geneSymbols <- as.character(unlist(geneSymbols)))
Try(names(geneSymbols) <- geneSymbols.n)
}
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)),as.matrix(geneNames),as.matrix(geneSymbols)))
Try(colnames(genelist) <- c("AffyID","EG","SYMBOL"))
} else if(whichArrayPlatform == "EXON" & whichLib[[1]][2]=="core"){
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
#extracting the library
#Try(annlibloc <- grep(paste("^",whichLib[[1]][1],sep=""), as.vector(unlist(data(package="oneChannelGUI"))), ignore.case = T))
#Try(annlibname <- as.vector(unlist(data(package="oneChannelGUI")))[annlibloc])
#Try(data(list=annlibname,package="oneChannelGUI"))
#Try(exonannlib<- get(annlibname,envir=.GlobalEnv))
#Try(data("huex10stv2na22hg18", package="oneChannelGUI"))
if(whichLib[[1]][1] == "HuEx"){
Try(libDirLocation <- get("libDirLocation", envir=affylmGUIenvironment))
Try(load(paste(libDirLocation, "huex.annotation.rda", sep="/")))
Try(exonannlib <- huex.annotation)
Try(rm(huex.annotation))
}else if(whichLib[[1]][1] == "MoEx"){
Try(libDirLocation <- get("libDirLocation", envir=affylmGUIenvironment))
Try(load(paste(libDirLocation, "moex.annotation.rda", sep="/")))
Try(exonannlib <- moex.annotation)
Try(rm(moex.annotation))
}else if(whichLib[[1]][1] == "RaEx"){
Try(libDirLocation <- get("libDirLocation", envir=affylmGUIenvironment))
Try(load(paste(libDirLocation, "raex.annotation.rda", sep="/")))
Try(exonannlib <- raex.annotation)
Try(rm(raex.annotation))
}
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(tmpNames <- as.character(exonannlib[,2]))#acc
Try(names(tmpNames) <- as.character(exonannlib[,1]))
#Try(position <- rep(0, dim(genelist)[1]))#corrispondence between genelist an annotation
#Try(names(position) <- genelist[,1])
#making identical the position of the genelist versus that of the annotation
#Try(for(i in 1:dim(genelist)[1]){position[i] <- which(names(tmpNames)==genelist[i,1])})
Try(position <- apply(genelist, 1, function(x, mynames){return(which(mynames==x))}, mynames=names(tmpNames)))
Try(position <- sapply(position, function(x){return(x[1])}))
Try(geneNames <- as.character(tmpNames[position]))
Try(tmpNames <- as.character(exonannlib[,3]))#symbol
Try(geneSymbols <- as.character(tmpNames[position]))
Try(tmpNames <- as.character(exonannlib[,5]))#cytoband
Try(geneCytoband <- as.character(tmpNames[position]))
Try(tmpNames <- as.character(exonannlib[,4]))#description
Try(geneDescription <- as.character(tmpNames[position]))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)), as.matrix(geneNames), as.matrix(geneSymbols), as.matrix(geneCytoband),as.matrix(geneDescription)))
Try(colnames(genelist) <- c("AffyID","ACC", "SYMBOL", "CYTOBAND", "DESCRIPTION"))
} else if(whichArrayPlatform == "EXON" & whichLib[[1]][2]!="core"){
Try(tkmessageBox(title="TopTable",message=paste("oneChannelGUI embedded annotation for", whichLib[[1]][2], "is not provided, yet!\nYou will retrieve a Top Table without annotations.", collapse=" "),type="ok",icon="error"))
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
#extracting the library
#Try(annlibloc <- grep(paste("^",whichLib[[1]][1],sep=""), as.vector(unlist(data(package="oneChannelGUI"))), ignore.case = T))
#Try(annlibname <- as.vector(unlist(data(package="oneChannelGUI")))[annlibloc])
#Try(data(list=annlibname,package="oneChannelGUI"))
#Try(exonannlib<- get(annlibname,envir=.GlobalEnv))
#Try(data("huex10stv2na22hg18", package="oneChannelGUI"))
if(whichLib[[1]][1] == "HuEx"){
Try(libDirLocation <- get("libDirLocation", envir=affylmGUIenvironment))
Try(load(paste(libDirLocation, "huex.annotation.rda", sep="/")))
Try(exonannlib <- huex.annotation)
Try(rm(huex.annotation))
}else if(whichLib[[1]][1] == "MoEx"){
Try(libDirLocation <- get("libDirLocation", envir=affylmGUIenvironment))
Try(load(paste(libDirLocation, "moex.annotation.rda", sep="/")))
Try(exonannlib <- moex.annotation)
Try(rm(moex.annotation))
}else if(whichLib[[1]][1] == "RaEx"){
Try(libDirLocation <- get("libDirLocation", envir=affylmGUIenvironment))
Try(load(paste(libDirLocation, "raex.annotation.rda", sep="/")))
Try(exonannlib <- raex.annotation)
Try(rm(raex.annotation))
}
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)), rep("-", length(featureNames(NormalizedAffyData))), rep("-", length(featureNames(NormalizedAffyData))), rep("-", length(featureNames(NormalizedAffyData))),rep("-", length(featureNames(NormalizedAffyData)))))
Try(colnames(genelist) <- c("AffyID","ACC", "SYMBOL", "CYTOBAND", "DESCRIPTION"))
} else if(whichArrayPlatform == "LARGE" & NormalizedAffyData.Available){
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(annLib <- .annotation(NormalizedAffyData))
if(annLib != ""){
if(length(as.character(unlist(strsplit(annLib, "\\.")))) < 2 ){
annLib <- paste(annLib, ".db", sep="")
}
Try(require(annLib, character.only = TRUE) || stop("need data package: ", annlib))
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(annlib1 <- as.character(unlist(strsplit(annLib, ".db"))))
Try(geneNames <- lookUp(featureNames(NormalizedAffyData), annlib1, "ENTREZID"))
Try(geneNames.n <- names(geneNames))
Try(geneNames <- as.character(unlist(geneNames)))
Try(names(geneNames) <- geneNames.n)
#Try(geneSymbols <- as.character(unlist(mget(featureNames(NormalizedAffyData), env=getDataEnv("SYMBOL", annLib), ifnotfound=NA))))
Try(geneSymbols <- lookUp(featureNames(NormalizedAffyData), annlib1, "SYMBOL"))
Try(geneSymbols.n <- names(geneSymbols))
Try(geneSymbols <- as.character(unlist(geneSymbols)))
Try(names(geneSymbols) <- geneSymbols.n)
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)),as.matrix(geneNames),as.matrix(geneSymbols)))
Try(colnames(genelist) <- c("AffyID","EG","SYMBOL"))
} else {
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(geneNames <- rep("-", dim(genelist)[1]))
Try(geneSymbols <- rep("-", dim(genelist)[1]))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)),as.matrix(geneNames),as.matrix(geneSymbols)))
Try(colnames(genelist) <- c("geneID","EG","SYMBOL"))
}
} else if(whichArrayPlatform == "GENE" & NormalizedAffyData.Available){
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(annLib <- .annotation(NormalizedAffyData))
if(annLib != ""){
if(length(as.character(unlist(strsplit(annLib, "\\."))))< 2 ){
annLib <- paste(annLib, ".db", sep="")
}
Try(require(annLib, character.only = TRUE) || stop("need data package: ", annlib))
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(annlib1 <- as.character(unlist(strsplit(annLib, ".db"))))
Try(geneNames <- lookUp(featureNames(NormalizedAffyData), annlib1, "ENTREZID"))
Try(geneNames.n <- names(geneNames))
Try(geneNames <- as.character(unlist(geneNames)))
Try(names(geneNames) <- geneNames.n)
Try(geneSymbols <- lookUp(featureNames(NormalizedAffyData), annlib1, "SYMBOL"))
Try(geneSymbols.n <- names(geneSymbols))
Try(geneSymbols <- as.character(unlist(geneSymbols)))
Try(names(geneSymbols) <- geneSymbols.n)
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)),as.matrix(geneNames),as.matrix(geneSymbols)))
Try(colnames(genelist) <- c("AffyID","EG","SYMBOL"))
} else {
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(geneNames <- rep("-", dim(genelist)[1]))
Try(geneSymbols <- rep("-", dim(genelist)[1]))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)),as.matrix(geneNames),as.matrix(geneSymbols)))
Try(colnames(genelist) <- c("geneID","EG","SYMBOL"))
}
}
Try(fit$genes <- genelist)
Try(if(!("Amean" %in% names(fit)))
fit$Amean <- rowMeans(exprs(NormalizedAffyData)))
# Note that it is difficult to use the limma toptable/topTable functions if you don't have ebayes statistics, so
# in the case of no replicate arrays (no residual degrees of freedom) we will just do our own sorting.
Try(if(ebayesAvailable==FALSE)
{
Try(M <- as.matrix(fit$coef)[,contrast])
Try(A <- fit$Amean)
Try(ord <- switch(sortBy, M = order(abs(M), decreasing = TRUE), A = order(A, decreasing = TRUE)))
Try(top <- ord[1:numberOfGenes])
Try(table1 <- data.frame(genelist[top, ,drop=FALSE], M = M[top], A=A[top]))
Try(rownames(table1) <- as.character(1:length(M))[top])
})
# The 2's in front of toptables mean that they use the drop=FALSE option (even if the user hasn't upgraded limma since the 1.3 BioC release.)
# Try(table1 <- toptable2(coef=contrast,number=numberOfGenes,fit=fit,eb=eb,genelist=genelist,adjust.method=adjustMethod,sort.by=sortBy))
Try(if(ebayesAvailable==TRUE)
Try(table1 <- topTable2(coef=contrast,number=numberOfGenes,fit=fit,genelist=genelist,adjust.method=adjustMethod,sort.by=sortBy)))
# Try(colnames(table1)[ncol(table1)-1] <- sprintf("%-10s",colnames(table1)[ncol(table1)-1]))
Try(nrows <- nrow(table1))
Try(ncols <- ncol(table1))
#######################
#inserting the filtering of the topTable data by mena of plots
dfMAplot(table1)#starting for the full top table
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
}
######################sub routine
#this function produces a M vs A plot and a vulcano plot.
#diff exprs genes after BH correction are labelled in red
#abline to p=0.01 is shown in blue
#x is a tab delimited files derived from the top table of affylmGUI
#pvalue is the threshold value of differentially expressed genes
#fc is the absolute threshold for fold change of the differentially expressed genes
#table1 is the ful top table
"dfMAplot"<-function(table1){
tmp <- table1
tmp.RmiR <- data.frame(table1$SYMBOL,table1$M)
#defining p-value and fc thresholds
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="FC threshold",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(HowManyQuestion1))
Try(tkgrid.configure(HowManyQuestion1,columnspan=2,sticky="w"))
Try(thresholdTcl <- tclVar("1"))
Try(I0.but <- tkradiobutton(frame1,text="none",variable=thresholdTcl,value="0",font=.affylmGUIglobals$affylmGUIfont2))
Try(I1.but <- tkradiobutton(frame1,text="0.5",variable=thresholdTcl,value="0.5",font=.affylmGUIglobals$affylmGUIfont2))
Try(I2.but <- tkradiobutton(frame1,text="1",variable=thresholdTcl,value="1",font=.affylmGUIglobals$affylmGUIfont2))
Try(I3.but <- tkradiobutton(frame1,text="1.5",variable=thresholdTcl,value="1.5",font=.affylmGUIglobals$affylmGUIfont2))
Try(I4.but <- tkradiobutton(frame1,text="2",variable=thresholdTcl,value="2",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="Adj p-value threshold",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(fractionLabel,sticky="w"))
Try(tkgrid.configure(fractionLabel,sticky="w"))
Try(fractionTcl <- tclVar("0.05"))
Try(F0.but <- tkradiobutton(frame2,text="none",variable=fractionTcl,value="1",font=.affylmGUIglobals$affylmGUIfont2))
Try(F1.but <- tkradiobutton(frame2,text="0.05",variable=fractionTcl,value="0.05",font=.affylmGUIglobals$affylmGUIfont2))
Try(F2.but <- tkradiobutton(frame2,text="0.01",variable=fractionTcl,value="0.01",font=.affylmGUIglobals$affylmGUIfont2))
Try(F3.but <- tkradiobutton(frame2,text="0.005",variable=fractionTcl,value="0.005",font=.affylmGUIglobals$affylmGUIfont2))
Try(F4.but <- tkradiobutton(frame2,text="0.001",variable=fractionTcl,value="0.001",font=.affylmGUIglobals$affylmGUIfont2))
Try(F5.but <- tkradiobutton(frame2,text="0.0005",variable=fractionTcl,value="0.0005",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(F0.but,sticky="w"))
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(F5.but,sticky="w"))
Try(tkgrid.configure(fractionLabel,F0.but,F1.but,F2.but,F3.but,F4.but,F5.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(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))
##Filtering routine
tmpVal<-strsplit(ReturnVal, ";")
fc= as.numeric(tmpVal[[1]][1])
pvalue= as.numeric(tmpVal[[1]][2])
#desabling the quote avoid the problem of errors induced by 3' or 5' where ' is considered a quote
Try(par(mfrow=c(1,2)))
Try(plot(tmp$A, tmp$M, xlab="A", ylab="M", type="n", main=paste("MA plot", "\nabsolute fc=",fc,", p-value=",pvalue, sep="")))
Try(points(tmp$A, tmp$M, pch="."))
Try(for.plot<-intersect(which(abs(tmp$M)>=fc),which(tmp$P.Value <= pvalue)))
Try(points(tmp$A[for.plot],tmp$M[for.plot], pch=19, col="red"))
Try(plot(tmp$M, -log10(tmp$P.Value), type="n", xlab="M", ylab="-log10(p.value)", main=paste("Volcano plot", "\nabsolute fc=",fc,", p-value=",pvalue, sep="")))
Try(points(tmp$M, -log2(tmp$P.Value), pch="."))
Try(points(tmp$M[for.plot],-log10(tmp$P.Value[for.plot]), pch=19, col="red"))
Try(abline(h=-log10(pvalue), col="blue"))
Try(abline(v=fc, col="red"))
Try(abline(v=-fc, col="green"))
Try(subtopTable<-tmp[for.plot,])
Try(subtopTable1<-tmp.RmiR[for.plot,])
Try(names(subtopTable1) <- c("genes","expr"))
#saving the filtered subset
SaveTopTable <- function()
{
Try(FileName <- tclvalue(tkgetSaveFile(initialfile=paste("topTable",".fc.",fc,".p.",pvalue,".xls",sep=""),filetypes="{{Tab-Delimited Text Files} {.txt .xls}} {{All files} *}")))
Try(if(!nchar(FileName))
return())
Try(write.table(subtopTable,file=FileName,quote=FALSE, sep="\t", row.names=F))
}
.SaveTopTableRmiR <- function()
{
Try(FileName <- tclvalue(tkgetSaveFile(initialfile=paste("topTable",".RmiRonly.p.threshold",pvalue,".xls",sep=""),filetypes="{{Tab-Delimited Text Files} {.txt .xls}} {{All files} *}")))
Try(if(!nchar(FileName))
return())
Try(write.table(subtopTable1,file=FileName,quote=FALSE, sep="\t", row.names=F))
}
#Try(tkmessageBox(title="topTable MA plot",message=paste("Plots are displayed in the main R window\nDo you want to save this data subset in a new toptable?")))
Try(mbVal <- tkmessageBox(title="topTable MA plot",
message="Plots are displayed in the main R window\nDo you want to save this data subset in a new toptable?",
icon="question",type="yesno",default="yes"))
try(if(tclvalue(mbVal)=="yes") SaveTopTable())
Try(mbVal1 <- tkmessageBox(title="RmiR export data",
message="Do you wish to save differentially expressed genes in a \nformat suitable to investigate miRNA-gene expression relationship?",
icon="question",type="yesno",default="yes"))
try(if(tclvalue(mbVal1)=="yes") .SaveTopTableRmiR())
}
################################################################################
#this function is used to perform Ven Diagram between two/3 files containing only list of probesets
#Modificare lo script in modo che
#l'overlap sia analizzato a livello dei geni!
VennDiagram <- function()
{
#defining a venn diagram of two or three lists
Try(ttGetFilterMethod <- tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttGetFilterMethod))
Try(tkgrab.set(ttGetFilterMethod))
Try(tkfocus(ttGetFilterMethod))
Try(tkwm.title(ttGetFilterMethod,"How many lists?"))
Try(tkgrid(tklabel(ttGetFilterMethod,text=" ")))
Try(ttGetFilterMethodTcl <- tclVar("Two lists"))
Try(rbIQR.5 <- tkradiobutton(ttGetFilterMethod,text="Two lists",variable=ttGetFilterMethodTcl,value=2,font=.affylmGUIglobals$affylmGUIfont2))
Try(rbIQR.25<-tkradiobutton(ttGetFilterMethod,text="Three lists",variable=ttGetFilterMethodTcl,value=3,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(ttGetFilterMethod,text=" "),rbIQR.5))
Try(tkgrid(tklabel(ttGetFilterMethod,text=" "),rbIQR.25))
Try(tkgrid.configure(rbIQR.5,rbIQR.25,columnspan=2,sticky="w"))
Try(tkgrid(tklabel(ttGetFilterMethod,text=" "),tklabel(ttGetFilterMethod,text=" ")))
Try(ReturnVal <- "")
Try(onCancel <- function() {Try(ReturnVal <<- "");Try(tkgrab.release(ttGetFilterMethod));Try(tkdestroy(ttGetFilterMethod));Try(tkfocus(.affylmGUIglobals$ttMain))})
Try(onOK <- function() {Try(ReturnVal <<- tclvalue(ttGetFilterMethodTcl));Try(tkgrab.release(ttGetFilterMethod));Try(tkdestroy(ttGetFilterMethod));Try(tkfocus(.affylmGUIglobals$ttMain))})
Try(OK.but <- tkbutton(ttGetFilterMethod,text="OK",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(Cancel.but <- tkbutton(ttGetFilterMethod,text="Cancel",command=onCancel,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(ttGetFilterMethod,text=" "),OK.but,Cancel.but,tklabel(ttGetFilterMethod,text=" ")))
Try(tkgrid.configure(OK.but,sticky="e"))
Try(tkgrid.configure(Cancel.but,sticky="w"))
Try(tkgrid(tklabel(ttGetFilterMethod,text=" ")))
Try(tkbind(ttGetFilterMethod,"<Destroy>",function() {ReturnVal <- "";Try(tkgrab.release(ttGetFilterMethod));Try(tkfocus(.affylmGUIglobals$ttMain));}))
Try(tkbind(OK.but, "<Return>",onOK))
Try(tkbind(Cancel.but, "<Return>",onCancel))
Try(tkwait.window(ttGetFilterMethod))
#defining comparison at level of probe sets or EGs
Try(ttCompMethod <- tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttCompMethod))
Try(tkgrab.set(ttCompMethod))
Try(tkfocus(ttCompMethod))
Try(tkwm.title(ttCompMethod,"Venn diagrams between Probe sets or Entrez Genes?"))
Try(tkgrid(tklabel(ttCompMethod,text=" ")))
Try(ttCompMethodTcl <- tclVar("probesets"))
Try(rbPS <- tkradiobutton(ttCompMethod,text="Probe sets",variable=ttCompMethodTcl,value="probesets",font=.affylmGUIglobals$affylmGUIfont2))
Try(rbEG<-tkradiobutton(ttCompMethod,text="Entrez Genes",variable=ttCompMethodTcl,value="entrezgenes",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(ttCompMethod,text=" "),rbPS))
Try(tkgrid(tklabel(ttCompMethod,text=" "),rbEG))
Try(tkgrid.configure(rbPS,rbEG,columnspan=2,sticky="w"))
Try(tkgrid(tklabel(ttCompMethod,text=" "),tklabel(ttCompMethod,text=" ")))
Try(CompVal <- "")
Try(onCancel <- function() {Try(CompVal <<- "");Try(tkgrab.release(ttCompMethod));Try(tkdestroy(ttCompMethod));Try(tkfocus(.affylmGUIglobals$ttMain)); Try(return())})
Try(onOK <- function() {Try(CompVal <<- tclvalue(ttCompMethodTcl));Try(tkgrab.release(ttCompMethod));Try(tkdestroy(ttCompMethod));Try(tkfocus(.affylmGUIglobals$ttMain))})
Try(OK.but <- tkbutton(ttCompMethod,text="OK",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(Cancel.but <- tkbutton(ttCompMethod,text="Cancel",command=onCancel,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(ttCompMethod,text=" "),OK.but,Cancel.but,tklabel(ttCompMethod,text=" ")))
Try(tkgrid.configure(OK.but,sticky="e"))
Try(tkgrid.configure(Cancel.but,sticky="w"))
Try(tkgrid(tklabel(ttCompMethod,text=" ")))
Try(tkbind(ttCompMethod,"<Destroy>",function() {CompVal <- "";Try(tkgrab.release(ttCompMethod));Try(tkfocus(.affylmGUIglobals$ttMain));}))
Try(tkbind(OK.but, "<Return>",onOK))
Try(tkbind(Cancel.but, "<Return>",onCancel))
Try(tkwait.window(ttCompMethod))
# cat("\n", ReturnVal, "\n")
#function
if(CompVal=="probesets"){
myLists<-list()
for(i in 1:as.numeric(ReturnVal)){
Try(tempFileName <- tclvalue(tkgetOpenFile(filetypes="{{Text Files} {.txt}} {{All files} *}")))
if(!nchar(tempFileName))
{
tkfocus(.affylmGUIglobals$ttMain)
return()
}
mySel<-read.table(tempFileName, sep="\t", header=F, as.is=TRUE)
if(dim(mySel)[2]==1){
myLists[[i]]<-mySel[,1]
} else Try(tkmessageBox(title="Venn Diagram",message=paste("File should contain\nonly a column with\nAffymetrix ids")))
}
allProbes<-unique(unlist(myLists))
if(as.numeric(ReturnVal)==2){
clas <- matrix(data=rep(0, (2*length(allProbes))), ncol=2)
for(i in 1:as.numeric(ReturnVal)){
clas[which(allProbes%in%myLists[[i]]),i] <- 1
}
} else {
clas <- matrix(data=rep(0, (3*length(allProbes))), ncol=3)
for(i in 1:as.numeric(ReturnVal)){
clas[which(allProbes%in%myLists[[i]]),i] <- 1
}
}
} else {
Try(x <- get("NormalizedAffyData",envir=affylmGUIenvironment))
# if(x==0){
# Try(tkmessageBox(title="Venn Diagram",message=paste("A normalized data set is not loaded\nVenn Diagrams cannot be created using EG")))
# return()
# } else {
x <- as(x, "ExpressionSet")
lib= .annotation(x)
getDataEnv <- function(name, lib) {
get(paste(lib, name, sep = ""), mode = "environment")
}
require(lib, character.only = TRUE) || stop("need data package: ", lib)
myLists<-list()
for(i in 1:as.numeric(ReturnVal)){
Try(tempFileName <- tclvalue(tkgetOpenFile(filetypes="{{Text Files} {.txt}} {{All files} *}")))
if(!nchar(tempFileName))
{
tkfocus(.affylmGUIglobals$ttMain)
return()
}
mySel<-read.table(tempFileName, sep="\t", header=F, as.is=TRUE)
if(dim(mySel)[2]==1){
myLists[[i]]<-as.character(unique(unlist(mget(mySel[,1], env=getDataEnv("ENTREZID", lib), ifnotfound=NA))))
} else Try(tkmessageBox(title="Venn Diagram",message=paste("File should contain\nonly a column with\nAffymetrix ids")))
}
allProbes<-unique(unlist(myLists))
if(as.numeric(ReturnVal)==2){
clas <- matrix(data=rep(0, (2*length(allProbes))), ncol=2)
for(i in 1:as.numeric(ReturnVal)){
clas[which(allProbes%in%myLists[[i]]),i] <- 1
}
} else {
clas <- matrix(data=rep(0, (3*length(allProbes))), ncol=3)
for(i in 1:as.numeric(ReturnVal)){
clas[which(allProbes%in%myLists[[i]]),i] <- 1
}
}
#}
}
#return(clas)
#plotting venn diagram
plotFunction <- function()
{
Try(opar<-par(bg="white"))
Try(vennDiagramaffylmGUI(vc,include=include,names=as.vector(setNames),cex=0.85,mar=rep(1,4)))
Try(TempGraphPar<-par(opar))
}
Try(LocalHScale <- .affylmGUIglobals$Myhscale*1.25)
Try(LocalVScale <- .affylmGUIglobals$Myvscale*1.25)
# FIXME: It'd be nice to list the one, two or three parameters.
Try(plotTitle <- paste("Lists overlap"))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(vc <- vennCounts(clas))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(if (as.numeric(ReturnVal)==2)
Try(setNames <- GetSetNames(numSets=2,set1=colnames(vc)[1],set2=colnames(vc)[2])))
Try(if (as.numeric(ReturnVal)==3)
Try(setNames <- GetSetNames(numSets=3,set1=colnames(vc)[1],set2=colnames(vc)[2],set3=colnames(vc)[3])))
Try(if (length(setNames)==0) return())
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(if (.affylmGUIglobals$graphicsDevice=="tkrplot")
{
Try(ttVennDiagramPlot <- tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.title(ttVennDiagramPlot,plotTitle))
# Try(require("tkrplot"))
Try(img <- tkrplot(ttVennDiagramPlot,plotFunction,hscale=LocalHScale,vscale=LocalVScale))
Try(SetupPlotKeyBindings(tt=ttVennDiagramPlot,img=img))
Try(SetupPlotMenus(tt=ttVennDiagramPlot,initialfile="VennDiagram", plotFunction=plotFunction,img=img))
Try(tkgrid(img))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(if (as.numeric(tclvalue(tkwinfo("reqheight",img)))<10) # Nothing plotted.
Try(tkdestroy(ttVennDiagramPlot))
else
Try(tkfocus(ttVennDiagramPlot)))
}
else
{
Try(plot.new())
Try(plotFunction())
})
SaveTopTable <- function()
{
if(as.numeric(ReturnVal)==3){
toBeSaves <- intersect(allProbes[which(clas[,1]==1)],allProbes[which(clas[,2]==1)])
toBeSaves1 <- intersect(toBeSaves,allProbes[which(clas[,3]==1)])
Try(write.table(toBeSaves1,file="common.txt",quote=FALSE, sep="\t", row.names=F, col.names=F))
toBeSaves <- intersect(allProbes[which(clas[,1]==1)],allProbes[which(clas[,2]==1)])
toBeSaves2 <- setdiff(toBeSaves, toBeSaves1)
Try(write.table(toBeSaves2,file="c1.c2.only.txt",quote=FALSE, sep="\t", row.names=F, col.names=F))
toBeSaves <- intersect(allProbes[which(clas[,1]==1)],allProbes[which(clas[,3]==1)])
toBeSaves2 <- setdiff(toBeSaves, toBeSaves1)
Try(write.table(toBeSaves2,file="c1.c3.only.txt",quote=FALSE, sep="\t", row.names=F, col.names=F))
toBeSaves <- intersect(allProbes[which(clas[,2]==1)],allProbes[which(clas[,3]==1)])
toBeSaves2 <- setdiff(toBeSaves, toBeSaves1)
Try(write.table(toBeSaves2,file="c2.c3.only.txt",quote=FALSE, sep="\t", row.names=F, col.names=F))
}
if(as.numeric(ReturnVal)==2){
toBeSaves <- intersect(allProbes[which(clas[,1]==1)],allProbes[which(clas[,2]==1)])
Try(write.table(toBeSaves,file="common.txt",quote=FALSE, sep="\t", row.names=F, col.names=F))
toBeSaves <- setdiff(allProbes[which(clas[,1]==1)],allProbes[which(clas[,2]==1)])
Try(write.table(toBeSaves,file="c1.only.txt",quote=FALSE, sep="\t", row.names=F, col.names=F))
toBeSaves <- setdiff(allProbes[which(clas[,2]==1)],allProbes[which(clas[,1]==1)])
Try(write.table(toBeSaves,file="c2.only.txt",quote=FALSE, sep="\t", row.names=F, col.names=F))
}
}
Try(mbVal <- tkmessageBox(title="Venn diagram",
message="Do you want to save the probeset specific of each comparison?\nThe resulting files will be saved in your working directory",
icon="question",type="yesno",default="yes"))
try(if(tclvalue(mbVal)=="yes") SaveTopTable())
#saving the filtered subset
}
################################################################################
#modified 5 11 2006
#inserted the assignment of maSigProSigs.Available
#this function allow to run masigpro from the extAffylmGUI
"masigpro"<-function(){
# require(maSigPro) || stop("library maSigPro could not be found !")
#error if no data are loaded
Try(whichArrayPlatform <- get("whichArrayPlatform",envir=affylmGUIenvironment))
if(whichArrayPlatform ==""){
Try(tkmessageBox(title="Time course analysis",message="No arrays have been loaded. Please try New or Open from the File menu.",type="ok",icon="error"))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(return())
}
#########################
Try(mbVal <- tkmessageBox(title="Running maSigPro",
message="Have you created the edesign object?",
icon="question",type="yesno",default="yes"))
Try(if(tclvalue(mbVal)=="yes"){
Try(NormalizedAffyData.Available <- get("NormalizedAffyData.Available" , envir=affylmGUIenvironment))
Try(if(NormalizedAffyData.Available) {
Try(edesign <- affylmGUIenvironment$edesign)
#degree of the model to be applied
Try(degree.n <- length(unique(edesign[,1])) - 1)
Try( design <- make.design.matrix(edesign, degree = degree.n))
} else{
Try(tkmessageBox(title="Running maSigPro",
message="Normalized expression data are missed!",
icon="error",type="ok"))
return()
})
##making the menu for selecting maSigPro parameters
Try(ttmaSigProDialog<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttmaSigProDialog))
Try(tkgrab.set(ttmaSigProDialog))
Try(tkfocus(ttmaSigProDialog))
Try(tkwm.title(ttmaSigProDialog,"maSigPro Parameters"))
Try(tkgrid(tklabel(ttmaSigProDialog,text=" ")))
Try(frame1 <- tkframe(ttmaSigProDialog,relief="groove",borderwidth=2))
Try(HowManyQuestion1 <- tklabel(frame1,text=
"Level of FDR control: Q parameter",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(q4.but <- tkradiobutton(frame1,text="0.001",variable=qTcl,value=0.001,font=.affylmGUIglobals$affylmGUIfont2))
Try(q5.but <- tkradiobutton(frame1,text="0.0005",variable=qTcl,value=0.0005,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(q4.but,sticky="w"))
Try(tkgrid(q5.but,sticky="w"))
Try(tkgrid.configure(HowManyQuestion1,q0.but,q1.but,q2.but,q3.but,q4.but,q5.but,sticky="w"))
Try(frame2 <- tkframe(ttmaSigProDialog,relief="groove",borderwidth=2))
Try(alfaLabel <- tklabel(frame2,text="P-value cut off: alfa",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(alfaLabel,sticky="w"))
Try(tkgrid.configure(alfaLabel,sticky="w"))
Try(alfaTcl <- tclVar("0.1"))
Try(a0.but <- tkradiobutton(frame2,text="0.1",variable=alfaTcl,value=0.1,font=.affylmGUIglobals$affylmGUIfont2))
Try(a1.but <- tkradiobutton(frame2,text="0.05",variable=alfaTcl,value=0.05,font=.affylmGUIglobals$affylmGUIfont2))
Try(a2.but <- tkradiobutton(frame2,text="0.01",variable=alfaTcl,value=0.01,font=.affylmGUIglobals$affylmGUIfont2))
Try(a3.but <- tkradiobutton(frame2,text="0.005",variable=alfaTcl,value=0.005,font=.affylmGUIglobals$affylmGUIfont2))
Try(a4.but <- tkradiobutton(frame2,text="0.001",variable=alfaTcl,value=0.001,font=.affylmGUIglobals$affylmGUIfont2))
Try(a5.but <- tkradiobutton(frame2,text="0.0005",variable=alfaTcl,value=0.0005,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(a0.but,sticky="w"))
Try(tkgrid(a1.but,sticky="w"))
Try(tkgrid(a2.but,sticky="w"))
Try(tkgrid(a3.but,sticky="w"))
Try(tkgrid(a4.but,sticky="w"))
Try(tkgrid(a5.but,sticky="w"))
Try(frame3 <- tkframe(ttmaSigProDialog,relief="groove",borderwidth=2))
Try(r2Label <- tklabel(frame3,text="R-squared threshold of the regression model",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(r2Label,sticky="w"))
Try(tkgrid.configure(r2Label,sticky="w"))
Try(r2Tcl <- tclVar("0.6"))
Try(r1.but <- tkradiobutton(frame3,text="0.9",variable=r2Tcl,value=0.9,font=.affylmGUIglobals$affylmGUIfont2))
Try(r2.but <- tkradiobutton(frame3,text="0.8" ,variable=r2Tcl,value=0.8 ,font=.affylmGUIglobals$affylmGUIfont2))
Try(r3.but <- tkradiobutton(frame3,text="0.7" ,variable=r2Tcl,value=0.7 ,font=.affylmGUIglobals$affylmGUIfont2))
Try(r4.but <- tkradiobutton(frame3,text="0.6",variable=r2Tcl,value=0.6,font=.affylmGUIglobals$affylmGUIfont2))
Try(r5.but <- tkradiobutton(frame3,text="0.4",variable=r2Tcl,value=0.4,font=.affylmGUIglobals$affylmGUIfont2))
Try(r6.but <- tkradiobutton(frame3,text="0.2",variable=r2Tcl,value=0.2,font=.affylmGUIglobals$affylmGUIfont2))
Try(r7.but <- tkradiobutton(frame3,text="0.0",variable=r2Tcl,value=0.0,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(r1.but,sticky="w"))
Try(tkgrid(r2.but ,sticky="w"))
Try(tkgrid(r3.but ,sticky="w"))
Try(tkgrid(r4.but,sticky="w"))
Try(tkgrid(r5.but,sticky="w"))
Try(tkgrid(r6.but,sticky="w"))
Try(tkgrid(r7.but,sticky="w"))
Try(Abort <- 1)
maSigPro.param <- list()
Try(onOK <- function()
{
Try(maSigPro.param[[1]] <<- tclvalue(qTcl))
Try(tkgrab.release(ttmaSigProDialog))
Try(tkdestroy(ttmaSigProDialog))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(maSigPro.param[[2]] <<- tclvalue(alfaTcl))
Try(maSigPro.param[[3]] <<- tclvalue(r2Tcl))
Try(Abort <<- 0)
})
#Try(onHelp <- function() Try(help("topTable",htmlhelp=TRUE)))
Try(frame4 <- tkframe(ttmaSigProDialog,borderwidth=2))
Try(onCancel <- function() {Try(tkgrab.release(ttmaSigProDialog));Try(tkdestroy(ttmaSigProDialog));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(Help.but <-tkbutton(frame4,text=" Help ",command=onHelp,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(frame4,text=" "),OK.but,Cancel.but,tklabel(frame4,text=" ")))
Try(tkgrid(tklabel(ttmaSigProDialog,text=" "),frame1,frame2,tklabel(ttmaSigProDialog,text=" ")))
Try(tkgrid(tklabel(ttmaSigProDialog,text=" ")))
Try(tkgrid(tklabel(ttmaSigProDialog,text=" "),frame3,frame4,tklabel(ttmaSigProDialog,text=" ")))
Try(tkgrid(tklabel(ttmaSigProDialog,text=" ")))
Try(tkgrid.configure(frame1,frame3,sticky="w"))
# Try(tkgrid.configure(frame4,sticky="s"))
Try(tkfocus(ttmaSigProDialog))
Try(tkbind(ttmaSigProDialog, "<Destroy>", function() {Try(tkgrab.release(ttmaSigProDialog));Try(tkfocus(.affylmGUIglobals$ttMain));}))
Try(tkwait.window(ttmaSigProDialog))
Try(if(Abort==1) return())
#executing maSigPro
Try(x <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(mydata <- as.data.frame(exprs(x)))
Try(fit <- p.vector(mydata, design, Q = as.numeric(maSigPro.param[[1]])))
Try(tstep <- T.fit(fit, step.method = "backward", alfa = as.numeric(maSigPro.param[[2]])))
Try(sigs <- get.siggenes(tstep, rsq = as.numeric(maSigPro.param[[3]]), vars = "groups"))
assign("maSigProSigs.Available",TRUE,affylmGUIenvironment)
Try(assign("maSigProSigs",sigs,affylmGUIenvironment))
Try(tkmessageBox(title="maSigPro analysis",message="Differentially expressed probe sets have been defined.\nNow check them with maSigPro visualization tools in the Results Menu.",type="ok",icon="info"))
} else {
Try(tkmessageBox(title="Running maSigPro",
message="To create an edesign object use the function create nn edesign for maSigPro",
icon="info",type="ok"))
})
}
################################################################################
#modified 28 12 2009
#maSigProSigs.Available test have been inserted
"masigpro.view"<-function(){
# require(maSigPro) || stop("need data package: maSigPro")
#error if no data are loaded
Try(whichArrayPlatform <- get("whichArrayPlatform",envir=affylmGUIenvironment))
if(whichArrayPlatform ==""){
Try(tkmessageBox(title="Time course analysis",message="No arrays have been loaded. Please try New or Open from the File menu.",type="ok",icon="error"))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(return())
}
#########################
if(affylmGUIenvironment$maSigProSigs.Available){
Try(ttmaSigProViewMethod <- tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttmaSigProViewMethod))
Try(tkgrab.set(ttmaSigProViewMethod))
Try(tkfocus(ttmaSigProViewMethod))
Try(tkwm.title(ttmaSigProViewMethod,"Plotting maSigPro results"))
#
Try(tkgrid(tklabel(ttmaSigProViewMethod,text=" ")))
Try(maSigProViewTcl <- tclVar("Venn"))
Try(rbVenn <- tkradiobutton(ttmaSigProViewMethod,text="Venn diagrams",variable=maSigProViewTcl,value="Venn",font=.affylmGUIglobals$affylmGUIfont2))
Try(rbGroups<-tkradiobutton(ttmaSigProViewMethod,text="PDF plots",variable=maSigProViewTcl,value="PlotGroups",font=.affylmGUIglobals$affylmGUIfont2))
Try(rbCluster <- tkradiobutton(ttmaSigProViewMethod,text="Table",variable=maSigProViewTcl,value="see.genes",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(ttmaSigProViewMethod,text=" "),rbVenn))
Try(tkgrid(tklabel(ttmaSigProViewMethod,text=" "),rbGroups))
Try(tkgrid(tklabel(ttmaSigProViewMethod,text=" "),rbCluster))
Try(tkgrid.configure(rbVenn,rbGroups,rbCluster,columnspan=2,sticky="w"))
Try(tkgrid(tklabel(ttmaSigProViewMethod,text=" "),tklabel(ttmaSigProViewMethod,text=" ")))
#
Try(ReturnVal <- "")
Try(
onCancel <- function() {
Try(ReturnVal <<- "");
Try(tkgrab.release(ttmaSigProViewMethod));
Try(tkdestroy(ttmaSigProViewMethod));
Try(tkfocus(.affylmGUIglobals$ttMain))
}
)
Try(
onOK <- function() {
Try(ReturnVal <<- tclvalue(maSigProViewTcl));
Try(tkgrab.release(ttmaSigProViewMethod));
Try(tkdestroy(ttmaSigProViewMethod));
Try(tkfocus(.affylmGUIglobals$ttMain))
}
)
#
Try(OK.but <- tkbutton(ttmaSigProViewMethod,text="OK",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(Cancel.but <- tkbutton(ttmaSigProViewMethod,text="Cancel",command=onCancel,font=.affylmGUIglobals$affylmGUIfont2))
#
Try(tkgrid(tklabel(ttmaSigProViewMethod,text=" "),OK.but,Cancel.but,tklabel(ttmaSigProViewMethod,text=" ")))
Try(tkgrid.configure(OK.but,sticky="e"))
Try(tkgrid.configure(Cancel.but,sticky="w"))
Try(tkgrid(tklabel(ttmaSigProViewMethod,text=" ")))
#
Try(tkbind(ttmaSigProViewMethod,"<Destroy>",function() {ReturnVal <- "";Try(tkgrab.release(ttmaSigProViewMethod));Try(tkfocus(.affylmGUIglobals$ttMain));}))
Try(tkbind(OK.but, "<Return>",onOK))
Try(tkbind(Cancel.but, "<Return>",onCancel))
#
Try(tkwait.window(ttmaSigProViewMethod))
#
if(ReturnVal==""){return()}
if(ReturnVal=="Venn"){
Try(sigs <- affylmGUIenvironment$maSigProSigs)
#two different conditions
Try(if(dim(sigs$summary)[2]==3){
allProbes <- unique(as.character(unlist(sigs$summary[, 2:3])))
allProbes <- allProbes[grep('[A-Z,a-z,0-9]', allProbes)]
clas <- matrix(data=rep(0, (2*length(allProbes))), ncol=2)
for(i in 2:3){ clas[which(allProbes%in%as.character(sigs$summary[,i])),(i-1)] <- 1 }
})
#three different conditions
Try(if(dim(sigs$summary)[2]==4){
allProbes <- unique(as.character(unlist(sigs$summary[, 2:4])))
allProbes <- allProbes[grep('[A-Z,a-z,0-9]', allProbes)]
clas <- matrix(data=rep(0, (3*length(allProbes))), ncol=3)
for(i in 2:4){ clas[which(allProbes%in%as.character(sigs$summary[,i])),(i-1)] <- 1 }
})
#more than three
Try(if(dim(sigs$summary)[2]>4){
Try(tkmessageBox(title="maSigPro Venn Diagram",message="Can't plot Venn diagram for more than 3 sets", type="ok", icon="error"))
return()
})
#only one
Try(if(dim(sigs$summary)[2] == 1){
Try(tkmessageBox(title="maSigPro Venn Diagram",message="Can't plot Venn diagram for simple time course without different treatments", type="ok", icon="error"))
return()
})
plotFunction <- function()
{
Try(opar<-par(bg="white"))
Try(vennDiagramaffylmGUI(vc,include=include,names=as.vector(setNames),cex=0.85,mar=rep(1,4)))
Try(TempGraphPar<-par(opar))
}
Try(LocalHScale <- .affylmGUIglobals$Myhscale*1.25)
Try(LocalVScale <- .affylmGUIglobals$Myvscale*1.25)
# FIXME: It'd be nice to list the one, two or three parameters.
Try(plotTitle <- paste("Lists overlap"))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(vc <- vennCounts(clas))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
#the names of the groups are defined by the the size of the sigs$summary
Try(if (dim(sigs$summary)[2]==3)
Try(setNames <- GetSetNames(numSets=2,set1=colnames(vc)[1],set2=colnames(vc)[2])))
Try(if (dim(sigs$summary)[2]==4)
Try(setNames <- GetSetNames(numSets=3,set1=colnames(vc)[1],set2=colnames(vc)[2],set3=colnames(vc)[3])))
Try(if (length(setNames)==0) return())
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(if (.affylmGUIglobals$graphicsDevice=="tkrplot")
{
Try(ttVennDiagramPlot <- tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.title(ttVennDiagramPlot,plotTitle))
# Try(require("tkrplot"))
Try(img <- tkrplot(ttVennDiagramPlot,plotFunction,hscale=LocalHScale,vscale=LocalVScale))
Try(SetupPlotKeyBindings(tt=ttVennDiagramPlot,img=img))
#########
Try(SetupPlotMenus(tt=ttVennDiagramPlot,initialfile="VennDiagram", plotFunction=plotFunction,img=img))
Try(tkgrid(img))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(if (as.numeric(tclvalue(tkwinfo("reqheight",img)))<10) # Nothing plotted.
Try(tkdestroy(ttVennDiagramPlot))
else
Try(tkfocus(ttVennDiagramPlot)))
}
else
{
Try(plot.new())
Try(plotFunction())
})
}
if(ReturnVal=="PlotGroups"){
Try(edesign <- affylmGUIenvironment$edesign)
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(NormalizedAffyData.Available <- get("NormalizedAffyData.Available" , envir=affylmGUIenvironment))
Try(if(NormalizedAffyData.Available) {
if(dim(edesign)[2] > 3){
###########################################################################
#selecting the condition to be plotted
Try(ttGetConditionName<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttGetConditionName))
Try(tkgrab.set(ttGetConditionName))
Try(tkfocus(ttGetConditionName))
Try(tkwm.title(ttGetConditionName,"maSigPro Condition selection"))
Try(tkgrid(tklabel(ttGetConditionName,text=" ")))
Try(ConditionNameText <- "")
Try(Local.ConditionName <- tclVar(init=ConditionNameText))
Try(entry.ConditionName <-tkentry(ttGetConditionName,width="10",font=.affylmGUIglobals$affylmGUIfont2,textvariable=Local.ConditionName,bg="white"))
Try(tkgrid(tklabel(ttGetConditionName,text="Please enter the Condition Name .",font=.affylmGUIglobals$affylmGUIfont2)))
Try(tkgrid(entry.ConditionName))
onOK <- function()
{
Try(ConditionNameText <- tclvalue(Local.ConditionName))
if(nchar(ConditionNameText)==0)
ConditionNameText <- "Unselected"
Try(assign("ConditionNameText",ConditionNameText,affylmGUIenvironment))
Try(tclvalue(.affylmGUIglobals$ConditionNameTcl) <- ConditionNameText)
Try(tkgrab.release(ttGetConditionName));Try(tkdestroy(ttGetConditionName));Try(tkfocus(.affylmGUIglobals$ttMain))
}
Try(OK.but <-tkbutton(ttGetConditionName,text=" OK ",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(ttGetConditionName,text=" ")))
Try(tkgrid(OK.but))
Try(tkgrid.configure(OK.but))
Try(tkgrid(tklabel(ttGetConditionName,text=" ")))
Try(tkfocus(entry.ConditionName))
Try(tkbind(entry.ConditionName, "<Return>",onOK))
Try(tkbind(ttGetConditionName, "<Destroy>", function(){Try(tkgrab.release(ttGetConditionName));Try(tkfocus(.affylmGUIglobals$ttMain));return(0)}))
Try(tkwait.window(ttGetConditionName))
Try(tkfocus(.affylmGUIglobals$ttMain))
}
###########################################################################
Try(x <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(x <- exprs(x))
# Try(edesign <- affylmGUIenvironment$edesign)
if(dim(edesign)[2] > 3){
Try(expCond <- get("ConditionNameText",envir=affylmGUIenvironment))
Try(mycond <- which(names(edesign) == expCond) - 3)#define the column of summary to be evaluated
if(mycond > 0 & mycond <= (length(names(edesign)) - 3)){
Try(sigs <- affylmGUIenvironment$maSigProSigs$summary[,(mycond+1)])
Try(allProbes <- unique(as.character(sigs)))
Try(allProbes <- allProbes[grep('[A-Z,a-z,0-9]', allProbes)])
#selecting the name of the file where saving the plots
Try(ttGetFileName<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttGetFileName))
Try(tkgrab.set(ttGetFileName))
Try(tkfocus(ttGetFileName))
Try(tkwm.title(ttGetFileName,"Filename"))
Try(tkgrid(tklabel(ttGetFileName,text=" ")))
Try(FileNameText <- "")
Try(Local.FileName <- tclVar(init=FileNameText))
Try(entry.FileName <-tkentry(ttGetFileName,width="10",font=.affylmGUIglobals$affylmGUIfont2,textvariable=Local.FileName,bg="white"))
Try(tkgrid(tklabel(ttGetFileName,text="Please enter the filename to save plots in pdf format.",font=.affylmGUIglobals$affylmGUIfont2)))
Try(tkgrid(entry.FileName))
onOK <- function()
{
Try(FileNameText <- tclvalue(Local.FileName))
if(nchar(FileNameText)==0)
FileNameText <- "Unselected"
Try(assign("FileNameText",FileNameText,affylmGUIenvironment))
Try(tclvalue(.affylmGUIglobals$FileNameTcl) <- FileNameText)
Try(tkgrab.release(ttGetFileName));Try(tkdestroy(ttGetFileName));Try(tkfocus(.affylmGUIglobals$ttMain))
}
Try(OK.but <-tkbutton(ttGetFileName,text=" OK ",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(ttGetFileName,text=" ")))
Try(tkgrid(OK.but))
Try(tkgrid.configure(OK.but))
Try(tkgrid(tklabel(ttGetFileName,text=" ")))
Try(tkfocus(entry.FileName))
Try(tkbind(entry.FileName, "<Return>",onOK))
Try(tkbind(ttGetFileName, "<Destroy>", function(){Try(tkgrab.release(ttGetFileName));Try(tkfocus(.affylmGUIglobals$ttMain));return(0)}))
Try(tkwait.window(ttGetFileName))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(pdf.filename <- paste(affylmGUIenvironment$FileNameText, ".pdf", sep=""))
pdf(pdf.filename)
for(i in allProbes) {
mygene <- as.vector(x[which(rownames(x)==i),])
PlotGroups(mygene, edesign = edesign, main=i)
}
dev.off()
Try(tkmessageBox(title="maSigPro PlotGroups",message=paste("Plots are saved in your working directory in file", pdf.filename, sep=" ") , type="ok", icon="info"))
} else {
Try(tkmessageBox(title="View maSigPro plots", message="You have selected a condition name which si not available", icon="error",type="ok"))
return()
}
}else if (dim(edesign)[2] == 3){
Try(tkmessageBox(title="View maSigPro plots", message="Plot groups functionality is not available in maSigPro for simple time course experiments", icon="error",type="ok"))
return()
}
}else{
Try(tkmessageBox(title="Running maSigPro", message="Normalized expression data are missed!", icon="error",type="ok"))
return()
}
)
#STMDE66 <- data.abiotic[rownames(data.abiotic) == "STMDE66",]
#PlotGroups(STMDE66, edesign = edesign.abiotic)
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
}
if(ReturnVal=="see.genes"){
Try(tkmessageBox(title="maSigPro table of differentially expressed genes",message="Select the file to save maSigPro output data."))
Try(FileName <- tclvalue(tkgetSaveFile(initialfile="maSigPr0.table.xls",filetypes="{{Tab-Delimited Text Files} {.txt .xls}} {{All files} *}")))
Try(if(!nchar(FileName))
return())
Try(write.table(affylmGUIenvironment$maSigProSigs$summary,file=FileName,quote=FALSE, sep="\t", row.names=F))
}
} else Try(tkmessageBox(title="maSigpro results",message="maSigPro analysis has not been run yet!"))
#suma2Venn(sigs$summary[, c(2:4)])
#see.genes(sigs$sig.genes$ColdvsControl, main = "ColdvsControl", show.fit = T,
# dis =design$dis, cluster.method="kmeans" ,cluster.data = 1, k = 9)
}
################################################################################
ComputeLinearModelFit <- function()
{
Try(ArraysLoaded <- get("ArraysLoaded", envir=affylmGUIenvironment))
Try(if(ArraysLoaded==FALSE)
{
Try(tkmessageBox(title="Linear Model",message="Error: No arrays have been loaded.",
icon="error",default="ok"))
return()
})
Try(NormalizedAffyData.Available <- get("NormalizedAffyData.Available",envir=affylmGUIenvironment))
Try(if(NormalizedAffyData.Available==FALSE)
NormalizeNow())
Try(NormalizedAffyData.Available <- get("NormalizedAffyData.Available",envir=affylmGUIenvironment))
Try(if(NormalizedAffyData.Available==FALSE)
{
tkmessageBox(title="Linear Model",message="An error occured while trying to normalize the data.")
return()
})
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
#modified form the original affylmGUI 1.10.2
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(NormalizedAffyData.exprs <- exprs(NormalizedAffyData))
#modified form the original affylmGUI 1.10.2
Try(Targets <- get("Targets",envir=affylmGUIenvironment))
Try(design <- as.matrix(as.data.frame(model.matrix(~ -1 + factor(Targets$Target)))))
Try(NumParameters <- ncol(design))
Try(assign("NumParameters",NumParameters,affylmGUIenvironment))
Try(colnames(design) <- gsub("factor\\(Targets\\$Target\\)","",colnames(design)))
Try(rownames(design) <- Targets$FileName)
Try(assign("design",design,affylmGUIenvironment))
#
Try(if(exists("NormMethod",envir=affylmGUIenvironment))
Try(NormMethod <- get("NormMethod",envir=affylmGUIenvironment))
else
{
Try(NormMethod <- "RMA")
Try(assign("NormMethod",NormMethod,affylmGUIenvironment))
})
#
# Try(
# if(NormMethod=="PLM"){
# Try(
# if(length(NormalizedAffyData.se.exprs)>0){
# Try(weights <- 1/pmax(NormalizedAffyData.se.exprs, 1e-05)^2)
# }
# ) #end of Try
# Try(fit <- lm.series(NormalizedAffyData.exprs,design,weights=weights))
# }else{
Try(fit <- lm.series(NormalizedAffyData.exprs,design))
# }
# )#end of Try
Try(assign("LinearModelFit.Available",TRUE,affylmGUIenvironment))
Try(assign("fit",fit,affylmGUIenvironment))
Try(tkdelete(.affylmGUIglobals$mainTree,"LinearModelFit.Status"))
Try(tkinsert(.affylmGUIglobals$mainTree,"end","LinearModelFit","LinearModelFit.Status",text="Available",font=.affylmGUIglobals$affylmGUIfontTree))
Try(NumParameters <- get("NumParameters" , envir=affylmGUIenvironment))
Try(if(NumParameters>0)
Try(for (i in (1:NumParameters))
Try(tkdelete(.affylmGUIglobals$mainTree,paste("Parameters.Status.",i,sep=""))))
else
Try(tkdelete(.affylmGUIglobals$mainTree,"Parameters.Status.1")))
Try(for (i in (1:ncol(design)))
Try(tkinsert(.affylmGUIglobals$mainTree,"end","Parameters",paste("Parameters.Status.",i,sep="") ,
text=colnames(design)[i],font=.affylmGUIglobals$affylmGUIfontTree)))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(tkmessageBox(title="Linear Model Fit Complete",
message=paste("Calculation of the linear model fit is complete. ",
"Contrasts can now be computed (from the Linear Model menu).")))
}#end of function ComputeLinearModelFit
################################################################################
ComputeContrasts <- function(){
# For now, we will assume that the number of contrasts is one less than the number of parameters,
# e.g. with 4 treatments, we estimate 4 parameters, then 3 contrasts.
Try(NumParameters <- get("NumParameters",envir=affylmGUIenvironment))
Try(Targets <- get("Targets",envir=affylmGUIenvironment))
Try(NumContrastParameterizations <- get("NumContrastParameterizations",envir=affylmGUIenvironment))
Try(ContrastParameterizationNamesVec <- get("ContrastParameterizationNamesVec",envir=affylmGUIenvironment))
Try(ContrastParameterizationList <- get("ContrastParameterizationList",envir=affylmGUIenvironment))
Try(ContrastParameterizationTREEIndexVec <- get("ContrastParameterizationTREEIndexVec",envir=affylmGUIenvironment))
Try(ArraysLoaded <- get("ArraysLoaded", envir=affylmGUIenvironment))
Try(LinearModelFit.Available <- get("LinearModelFit.Available", envir=affylmGUIenvironment))
if(ArraysLoaded==FALSE){
Try(tkmessageBox(title="Compute Contrasts",message="No arrays have been loaded. Please try New or Open from the File menu.",type="ok",icon="error"))
Try(tkfocus(.affylmGUIglobals$ttMain))
return()
}#end of if(ArraysLoaded==FALSE)
if(LinearModelFit.Available==FALSE){
Try(ComputeLinearModelFit())
Try(NumParameters <- get("NumParameters",envir=affylmGUIenvironment))
#Try(tkmessageBox(title="Compute Contrasts",message="There is no linear model fit available. Select \"Compute Linear Model Fit\" from the \"Linear Model\" menu.",type="ok",icon="error"))
#Try(tkfocus(.affylmGUIglobals$ttMain))
#return()
}#end of if(LinearModelFit.Available==FALSE)
Try(fit <- get("fit", envir=affylmGUIenvironment))
Try(design <- get("design",envir=affylmGUIenvironment))
#
Try(ParameterNamesVec <- colnames(design))
#
Try(NumContrasts <- NumParameters - 1)
#
Try(
if(NumContrasts<=0){
tkmessageBox(title="Compute Contrasts",message=paste("You need to have two or more treatments in order to compute contrasts."),type="ok",icon="error")
Try(tkfocus(.affylmGUIglobals$ttMain))
return()
}#end of if(NumContrasts<=0)
)#end of Try
Try(NumContrasts <- min(NumContrasts,10))
#
Try(contrastsMatrixInList <- GetContrasts(NumContrasts=NumContrasts))
Try(if(nrow(contrastsMatrixInList$contrasts)==0) return())
Try(contrastsMatrix <- as.matrix(contrastsMatrixInList$contrasts))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(contrastsFit <- contrasts.fit(fit,contrastsMatrix))
#
# NEW
#
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(
if(min(contrastsFit$df)==0){
Try(tkmessageBox(title="No degrees of freedom",message="Empirical Bayes statistics will not be available because of the lack of replicate arrays.",icon="warning"))
Try(ebayesAvailable <- FALSE)
}else{
Try(ebayesAvailable <- TRUE)
}
)#end of Try
#
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(if(ebayesAvailable==TRUE)
Try(contrastsEbayes <- eBayes(contrastsFit)))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(ContrastParameterizationNameText <- GetContrastParameterizationName())
Try(if(ContrastParameterizationNameText=="GetContrastParameterizationName.CANCEL") return())
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(
while (nchar(ContrastParameterizationNameText)==0){
Try(tkmessageBox(title="Contrasts Name",message="Please enter a name for this set of contrasts",type="ok",icon="error"))
Try(ContrastParameterizationNameText <- GetContrastParameterizationName())
if(ContrastParameterizationNameText=="GetContrastParameterizationName.CANCEL"){
Try(tkfocus(.affylmGUIglobals$ttMain))
return()
}#end of if(ContrastParameterizationNameText=="GetContrastParameterizationName.CANCEL")
}#end of while (nchar(ContrastParameterizationNameText)==0)
)#end of Try
#
Try(contrastParameterizationIndex <- 0)
Try(newContrastParameterization <- 1)
Try(
if(ContrastParameterizationNameText %in% ContrastParameterizationNamesVec){
Try(contrastParameterizationIndex <- match(ContrastParameterizationNameText,ContrastParameterizationNamesVec))
Try(mbVal<-tclvalue(tkmessageBox(title="Contrasts Parameterization Name",message="This contrasts parameterization name already exists. Replace?",type="yesnocancel",icon="question")))
Try(if(mbVal=="cancel") return())
Try(if(mbVal=="yes") newContrastParameterization <- 0)
Try(if(mbVal=="no") newContrastParameterization <- 1)
}else{
Try(newContrastParameterization <- 1)
}#end of else/if(ContrastParameterizationNameText %in% ContrastParameterizationNamesVec)
)#end of Try
#
Try(ContrastParameterizationTREEIndexVec <- get("ContrastParameterizationTREEIndexVec",envir=affylmGUIenvironment))
Try(NumContrastParameterizations <- get("NumContrastParameterizations",envir=affylmGUIenvironment))
#
if(newContrastParameterization==1){
Try(
if(length(ContrastParameterizationTREEIndexVec)!=NumContrastParameterizations){
Try(tkmessageBox(title="Contrasts Parameterizations","Length of ContrastParameterizationTREEIndexVec is not equal to NumContrastParameterizations.",type="ok",icon="error"))
Try(tkfocus(.affylmGUIglobals$ttMain))
return()
}#end of if(length(ContrastParameterizationTREEIndexVec)!=NumContrastParameterizations)
)#end of Try
Try(NumContrastParameterizations <- NumContrastParameterizations + 1)
Try(contrastParameterizationIndex <- NumContrastParameterizations)
Try(
if(length(ContrastParameterizationTREEIndexVec)==0){
Try(.affylmGUIglobals$ContrastParameterizationTREEIndex <- 1)
}else{
Try(.affylmGUIglobals$ContrastParameterizationTREEIndex <- max(ContrastParameterizationTREEIndexVec)+1)
}
)#end of Try
Try(ContrastParameterizationTREEIndexVec[contrastParameterizationIndex] <- .affylmGUIglobals$ContrastParameterizationTREEIndex)
Try(ContrastParameterizationNamesVec <- c(ContrastParameterizationNamesVec,ContrastParameterizationNameText))
Try(ContrastParameterizationNameNode <- paste("ContrastParameterizationName.",.affylmGUIglobals$ContrastParameterizationTREEIndex,sep=""))
Try(ContrastParameterizationList[[ContrastParameterizationNameNode]] <- ContrastParameterizationNameText)
}else{ # Replace existing contrasts parameterization with the same name.
Try(.affylmGUIglobals$ContrastParameterizationTREEIndex <- ContrastParameterizationTREEIndexVec[contrastParameterizationIndex])
Try(tkdelete(.affylmGUIglobals$ContrastParameterizationTREE,paste("ContrastParameterizationName.",.affylmGUIglobals$ContrastParameterizationTREEIndex,sep="")))
}#end of else/if(newContrastParameterization==1)
#
Try(ContrastParameterizationNameNode <- paste("ContrastParameterizationName.",.affylmGUIglobals$ContrastParameterizationTREEIndex,sep=""))
Try(ContrastParameterizationList[[ContrastParameterizationNameNode]] <- list())
Try(ContrastParameterizationList[[ContrastParameterizationNameNode]]$NumContrastParameterizations <- NumContrastParameterizations)
###Try(NormalizedAffyData <- get("NormalizedAffyData",affylmGUIenvironment))
Try(NormalizedAffyData.exprs <- get("NormalizedAffyData",affylmGUIenvironment))
Try(contrastsFit$Amean <- rowMeans(exprs(NormalizedAffyData.exprs)))
#
Try(ContrastParameterizationList[[ContrastParameterizationNameNode]]$fit <- contrastsFit)
Try(
if(ebayesAvailable==TRUE){
Try(ContrastParameterizationList[[ContrastParameterizationNameNode]]$eb <- contrastsEbayes)
}else{
Try(ContrastParameterizationList[[ContrastParameterizationNameNode]]$eb <- list())
}
)#end of Try
Try(ContrastParameterizationList[[ContrastParameterizationNameNode]]$contrastsMatrixInList <- contrastsMatrixInList)
Try(ContrastParameterizationList[[ContrastParameterizationNameNode]]$ContrastParameterizationNameText <- ContrastParameterizationNameText)
#
if(NumContrastParameterizations>0){
Try(ContrastsNames <- colnames(contrastsMatrix))
}
Try(tkinsert(.affylmGUIglobals$ContrastParameterizationTREE,"end","root",ContrastParameterizationNameNode,text=ContrastParameterizationNameText,font=.affylmGUIglobals$affylmGUIfontTree))
Try(NumContrastsInContrastParameterization <- length(ContrastsNames))
#
Try(ContrastsNode <- paste("ContrastsNode.",.affylmGUIglobals$ContrastParameterizationTREEIndex))
Try(tkinsert(.affylmGUIglobals$ContrastParameterizationTREE,"end",ContrastParameterizationNameNode,ContrastsNode,text="Contrasts",font=.affylmGUIglobals$affylmGUIfontTree))
#
Try(
for (j in (1:NumContrastsInContrastParameterization)){
Try(tkinsert(.affylmGUIglobals$ContrastParameterizationTREE,"end",ContrastsNode,paste("Contrasts.",.affylmGUIglobals$ContrastParameterizationTREEIndex,".",j,sep=""),text=ContrastsNames[j],font=.affylmGUIglobals$affylmGUIfontTree))
}
)#end of Try
#
Try(LinearModelFitNode <- paste("LinearModelFitNode.",.affylmGUIglobals$ContrastParameterizationTREEIndex))
Try(LinearModelFitStatusNode <- paste("LinearModelFitStatusNode.",.affylmGUIglobals$ContrastParameterizationTREEIndex))
Try(tkinsert(.affylmGUIglobals$ContrastParameterizationTREE,"end",ContrastParameterizationNameNode,LinearModelFitNode,text="Linear Model Fit",font=.affylmGUIglobals$affylmGUIfontTree))
Try(tkinsert(.affylmGUIglobals$ContrastParameterizationTREE,"end",LinearModelFitNode,LinearModelFitStatusNode,text="Available",font=.affylmGUIglobals$affylmGUIfontTree))
Try(EmpiricalBayesNode <- paste("EmpiricalBayesNode.",.affylmGUIglobals$ContrastParameterizationTREEIndex))
Try(EmpiricalBayesStatusNode <- paste("EmpiricalBayesStatusNode.",.affylmGUIglobals$ContrastParameterizationTREEIndex))
Try(tkinsert(.affylmGUIglobals$ContrastParameterizationTREE,"end",ContrastParameterizationNameNode,EmpiricalBayesNode,text="Empirical Bayes Statistics",font=.affylmGUIglobals$affylmGUIfontTree))
Try(if(ebayesAvailable==TRUE)
Try(tkinsert(.affylmGUIglobals$ContrastParameterizationTREE,"end",EmpiricalBayesNode,EmpiricalBayesStatusNode,text="Available",font=.affylmGUIglobals$affylmGUIfontTree))
else
Try(tkinsert(.affylmGUIglobals$ContrastParameterizationTREE,"end",EmpiricalBayesNode,EmpiricalBayesStatusNode,text="Not Available",font=.affylmGUIglobals$affylmGUIfontTree)) )
Try(assign("ContrastParameterizationList",ContrastParameterizationList,affylmGUIenvironment))
Try(assign("NumContrastParameterizations",NumContrastParameterizations,affylmGUIenvironment))
Try(assign("ContrastParameterizationTREEIndexVec",ContrastParameterizationTREEIndexVec,affylmGUIenvironment))
Try(assign("ContrastParameterizationNamesVec",ContrastParameterizationNamesVec,affylmGUIenvironment))
#
Try(
if(NumContrastParameterizations>0){
Try(for (i in (1:NumContrastParameterizations))
Try(tkdelete(.affylmGUIglobals$mainTree,paste("ContrastParameterizations.Status.",i,sep=""))))
}else{
Try(tkdelete(.affylmGUIglobals$mainTree,"ContrastParameterizations.Status.1"))
}
)#end of Try
Try(
if(NumContrastParameterizations>0){
for (contrastParameterizationIndex in (1:NumContrastParameterizations)){
Try(.affylmGUIglobals$ContrastParameterizationTREEIndex <- ContrastParameterizationTREEIndexVec[contrastParameterizationIndex])
Try(ContrastParameterizationNameNode <- paste("ContrastParameterizationName.",.affylmGUIglobals$ContrastParameterizationTREEIndex,sep=""))
Try(ContrastParameterizationsStatusNameNode <- paste("ContrastParameterizations.Status.",.affylmGUIglobals$ContrastParameterizationTREEIndex,sep=""))
Try(tkinsert(.affylmGUIglobals$mainTree,"end","ContrastParameterizations",ContrastParameterizationsStatusNameNode ,text=ContrastParameterizationNamesVec[contrastParameterizationIndex],font=.affylmGUIglobals$affylmGUIfontTree))
}#end of for (contrastParameterizationIndex in (1:NumContrastParameterizations))
}else{
Try(tkinsert(.affylmGUIglobals$mainTree,"end","ContrastParameterizations","ContrastParameterizations.Status.1" ,text="None",font=.affylmGUIglobals$affylmGUIfontTree))
}#end of else/if(NumContrastParameterizations>0)
)#end of Try
#
tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow")
Try(
tkmessageBox(
title="Contrasts Fit Complete",
message=paste("Calculation of the contrasts fit is complete. ",
"You can now view list(s) of differentially expressed genes, using the TopTable menu.")
)#end of tkmessageBox
)#end of Try
}#end of function ComputeContrasts
#################################################################################
"edgerInterface" <- function(){
# require(edgeR) || stop("\nMisssing edgeR package\n")
tt <- ""
assign("firstCovar", tt,affylmGUIenvironment)
assign("secondCovar", tt,affylmGUIenvironment)
if(affylmGUIenvironment$NormalizedAffyData.Available){
Try(NormalizedAffyData <- get("NormalizedAffyData", env=affylmGUIenvironment))
Try(targets <- get("Targets", env=affylmGUIenvironment))
} else Try(tkmessageBox(title="NGS data set",message="NGS data are not available.", type="ok", icon="error"))
Try(NGSscaling.Available <- get("NGSscaling.Available", env=affylmGUIenvironment))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
cat("\ncreating the DGEList")
if(NGSscaling.Available){
Try(scaledReads <- get("NGSscaling", env=affylmGUIenvironment))
Try(mylist <- DGEList(counts= exprs(NormalizedAffyData), group=as.factor(targets$Target), lib.size=scaledReads))
Try(tkmessageBox(title="NGS data set normalization",message="Scaled library size will be used!", type="ok", icon="info"))
} else {Try(mylist <- DGEList(counts= exprs(NormalizedAffyData), group=as.factor(targets$Target)))}
Try(mbVal<-tclvalue(tkmessageBox(title="Dispersion estimation",message="Do you wish to estimate if common or tagwise dispersion is \nsuitable for differential expression analysis?",type="yesnocancel",icon="question")))
Try(if(mbVal=="cancel") {
return()
} else if(mbVal=="yes") {
mylist <- estimateCommonDisp(mylist)
prior.n <- getPriorN(mylist)
mbVal1<-tclvalue(tkmessageBox(title="Weight parameter estimation",message=paste("Your estimated weight parameter is", prior.n,"\nIf weight parameter is a large positive number, select NO, since tagwise dispersion estimation will not be required."),type="yesnocancel",icon="question"))
if(mbVal1=="yes") {
mylist <- estimateTagwiseDisp(mylist, prior.n = 10)
cat("\nThe estimated tagwise dispersion is:\n", names(summary(mylist$tagwise.dispersion)),"\n",summary(mylist$tagwise.dispersion), "\n")
cat("\nCommon dispersion is ", mylist$common.dispersion, "\n")
}
if(mbVal1=="no") {
cat("\nCommon dispersion is ", mylist$common.dispersion, "\n")
}
} else if(mbVal=="no") {
cat("\nCommon dispersion is ")
Try(mylist <- estimateCommonDisp(mylist))
cat(mylist$common.dispersion, "\n")
mbVal1 <- "no"
}
)
######################################################################
#defining the covar
Try(mycovar <- unique(as.character(targets$Target)))
if(length(mycovar) > 2){
Try(
tkmessageBox(
title="edgeR multiple factors desing",
message=paste("You are loading a digital sequence experiment based on multiple factors.\nThe present implementation of oneChannelGUI only support two groups experiment.")
)
)
return()
}
Try(covar.des <- paste(seq(1, length(mycovar)), mycovar, sep="="))
#selecting the first covar
Try(covar1Extract<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(covar1Extract))
Try(tkgrab.set(covar1Extract))
Try(tkfocus(covar1Extract))
Try(tkwm.title(covar1Extract,"Defining the first covariate"))
Try(tkgrid(tklabel(covar1Extract,text=" ")))
Try(colnum <- "1")
Try(Local.colExtract <- tclVar(init=colnum))
Try(entry.colExtract <-tkentry(covar1Extract,width="4",font=.affylmGUIglobals$affylmGUIfont2,textvariable=Local.colExtract,bg="white"))
Try(tkgrid(tklabel(covar1Extract,text=paste("Please enter the number associated to the covariate of interest\n", paste(covar.des,collapse=" ")),font=.affylmGUIglobals$affylmGUIfont2)))
Try(tkgrid(entry.colExtract))
onOK <- function()
{
Try(colnum <- as.numeric(tclvalue(Local.colExtract)))
Try(assign("firstCovar", as.numeric(tclvalue(Local.colExtract)),affylmGUIenvironment))
Try(tkgrab.release(covar1Extract));Try(tkdestroy(covar1Extract));Try(tkfocus(.affylmGUIglobals$ttMain))
}
Try(OK.but <-tkbutton(covar1Extract,text=" OK ",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(covar1Extract,text=" ")))
Try(tkgrid(OK.but))
Try(tkgrid.configure(OK.but))
Try(tkgrid(tklabel(covar1Extract,text=" ")))
Try(tkfocus(entry.colExtract))
Try(tkbind(entry.colExtract, "<Return>",onOK))
Try(tkbind(covar1Extract, "<Destroy>", function(){Try(tkgrab.release(covar1Extract));Try(tkfocus(.affylmGUIglobals$ttMain));return(0)}))
Try(tkwait.window(covar1Extract))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(firstCovar <- get("firstCovar", affylmGUIenvironment))
if(firstCovar > length(mycovar)){
Try(tkmessageBox(title="Covariate selection",message="You have selected a non existing covariate!"))
return()
}
#selecting the second covar
Try(covar2Extract<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(covar2Extract))
Try(tkgrab.set(covar2Extract))
Try(tkfocus(covar2Extract))
Try(tkwm.title(covar2Extract,"Defining the second covariate"))
Try(tkgrid(tklabel(covar2Extract,text=" ")))
Try(colnum <- "2")
Try(Local.colExtract <- tclVar(init=colnum))
Try(entry.colExtract <-tkentry(covar2Extract,width="4",font=.affylmGUIglobals$affylmGUIfont2,textvariable=Local.colExtract,bg="white"))
Try(tkgrid(tklabel(covar2Extract,text=paste("Please enter the number associated to the covariate of interest\n", paste(covar.des,collapse=" ")),font=.affylmGUIglobals$affylmGUIfont2)))
Try(tkgrid(entry.colExtract))
onOK <- function()
{
Try(colnum <- as.numeric(tclvalue(Local.colExtract)))
Try(assign("secondCovar", as.numeric(tclvalue(Local.colExtract)),affylmGUIenvironment))
Try(tkgrab.release(covar2Extract));Try(tkdestroy(covar2Extract));Try(tkfocus(.affylmGUIglobals$ttMain))
}
Try(OK.but <-tkbutton(covar2Extract,text=" OK ",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(covar2Extract,text=" ")))
Try(tkgrid(OK.but))
Try(tkgrid.configure(OK.but))
Try(tkgrid(tklabel(covar2Extract,text=" ")))
Try(tkfocus(entry.colExtract))
Try(tkbind(entry.colExtract, "<Return>",onOK))
Try(tkbind(covar2Extract, "<Destroy>", function(){Try(tkgrab.release(covar2Extract));Try(tkfocus(.affylmGUIglobals$ttMain));return(0)}))
Try(tkwait.window(covar2Extract))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(secondCovar <- get("secondCovar", affylmGUIenvironment))
if(secondCovar > length(mycovar)){
Try(tkmessageBox(title="Covariate selection",message="You have selected a non existing covariate!"))
return()
}
cat("\nCalcolating exact test for the negative binomial distribution\n")
cat("The selected covariates are: ", mycovar[firstCovar], " and ", mycovar[secondCovar],"\n")
#mbVal and mbVal1 refer to the tagwise dispersin estimation few lines above
if(mbVal1=="yes")
de.com <- exactTest(mylist, pair=c(mycovar[firstCovar], mycovar[secondCovar]), common.disp = FALSE)
if(mbVal=="no" || mbVal1=="no")
de.com <- exactTest(mylist, pair=c(mycovar[firstCovar], mycovar[secondCovar]))
################################
Try(ttIfDialog<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttIfDialog))
Try(tkgrab.set(ttIfDialog))
Try(tkfocus(ttIfDialog))
Try(tkwm.title(ttIfDialog,"Selecting the parameters to detect differentially expressed NGS peaks"))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(frame1 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(HowManyQuestion1 <- tklabel(frame1,text="Multiple testing adjustment",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(HowManyQuestion1))
Try(tkgrid.configure(HowManyQuestion1,columnspan=2,sticky="w"))
Try(permutationsTcl <- tclVar("BH"))
Try(I1.but <- tkradiobutton(frame1,text="BH",variable=permutationsTcl,value="BH",font=.affylmGUIglobals$affylmGUIfont2))
Try(I2.but <- tkradiobutton(frame1,text="BY",variable=permutationsTcl,value="BY",font=.affylmGUIglobals$affylmGUIfont2))
Try(I3.but <- tkradiobutton(frame1,text="fdr",variable=permutationsTcl,value="fdr",font=.affylmGUIglobals$affylmGUIfont2))
Try(I4.but <- tkradiobutton(frame1,text="none",variable=permutationsTcl,value="none",font=.affylmGUIglobals$affylmGUIfont2))
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,I1.but,I2.but,I3.but,I4.but,sticky="w"))
Try(frame2 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(cutoffLabel <- tklabel(frame2,text="Cut off threshold",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(cutoffLabel,sticky="w"))
Try(tkgrid.configure(cutoffLabel,sticky="w"))
Try(cutoffTcl <- tclVar("0.05"))
Try(F1.but <- tkradiobutton(frame2,text="none",variable=cutoffTcl,value="1",font=.affylmGUIglobals$affylmGUIfont2))
Try(F2.but <- tkradiobutton(frame2,text="0.05",variable=cutoffTcl,value="0.05",font=.affylmGUIglobals$affylmGUIfont2))
Try(F3.but <- tkradiobutton(frame2,text="0.01",variable=cutoffTcl,value="0.01",font=.affylmGUIglobals$affylmGUIfont2))
Try(F4.but <- tkradiobutton(frame2,text="0.005",variable=cutoffTcl,value="0.005",font=.affylmGUIglobals$affylmGUIfont2))
Try(F5.but <- tkradiobutton(frame2,text="0.001",variable=cutoffTcl,value="0.001",font=.affylmGUIglobals$affylmGUIfont2))
Try(F6.but <- tkradiobutton(frame2,text="0.0005",variable=cutoffTcl,value="0.0005",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(F5.but,sticky="w"))
Try(tkgrid(F6.but,sticky="w"))
Try(tkgrid.configure(cutoffLabel,F1.but,F2.but,F3.but,F4.but,F5.but,F6.but,sticky="w"))
Try(onOK <- function()
{
ReturnVal1 <- as.character(tclvalue(permutationsTcl))
ReturnVal2 <- as.numeric(tclvalue(cutoffTcl))
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==""){
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
return()
}
Try(tmp<-strsplit(ReturnVal, ";"))
Try(correction <- tmp[[1]][1])
Try(threshold <- as.numeric(tmp[[1]][2]))
################################
Try(selected <- sum(p.adjust(de.com$table$PValue, method = correction) < threshold))
if(selected == 0){
Try(tkmessageBox(title="edgeR analysis",message=paste("No differential expression was detected using:\n","correction ",correction, "\nthreshold ",threshold,sep=""),type="ok",icon="info"))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(return())
}
Try(deTable <- topTags(de.com, n=selected, adjust.method=correction, sort.by="p.value"))
Try(detags <- rownames(deTable$table))
Try(par(mfrow=c(1,2)))
Try(hist(de.com$table$PValue, xlab="Uncorrected p-values", main=""))
Try(plotSmear(mylist, pair=c(mycovar[firstCovar], mycovar[secondCovar]),de.tags = detags, cex=0.5, main = "FC plot using common dispersion"))
Try(mbVal <- tkmessageBox(title="Differentially expressed peaks",
message="Do you like the detected differentially expressed peaks?\nAnswering YES data will be saved as tab delimited file.",
icon="question",type="yesno",default="yes"))
Try(if(tclvalue(mbVal)=="yes"){
Try(.SaveNGSTopTable(correction, threshold, deTable))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
} else{
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
})
Try(mbVal1 <- tkmessageBox(title="RmiR export data format",
message="Do you like to export differentially expressed miRNA in a format suitable for RmiR based datamining?\nAnswering YES data will be saved as tab delimited file.",
icon="question",type="yesno",default="yes"))
Try(if(tclvalue(mbVal1)=="yes"){
Try(tmp.ann <-rownames(deTable$table))
Try(tmp.names <- strsplit(tmp.ann, "description: "))
if(length(tmp.names[[1]]) == 2){
Try(tmp.names <- sapply(tmp.names, function(x) x[2]))
}else{
Try(tmp.names <- as.vector(unlist(tmp.names)))
}
Try(tmpTable <- data.frame(tmp.names,deTable$table[,2]))
Try(names(tmpTable) <- c("miRNA","expr"))
Try(deTable <- list("annotation"="", "table"=tmpTable))
Try(.SaveNGS1TopTable(paste("_RmiRonly_",correction, sep=""), threshold, deTable))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
} else{
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
})
}
################################################################################
#saving the filtered subset
.SaveNGSTopTable <- function(correction, threshold, deTable)
{
Try(FileName <- tclvalue(tkgetSaveFile(initialfile=paste("topTable",".p-adjust.",correction,".threshold.",threshold,".xls",sep=""),filetypes="{{Tab-Delimited Text Files} {.txt .xls}} {{All files} *}")))
Try(if(!nchar(FileName))
return())
Try(write.table(deTable$table,file=FileName,quote=FALSE, sep="\t", row.names=T, col.names=NA))
}
#saving the filtered subset
.SaveNGS1TopTable <- function(correction, threshold, deTable)
{
Try(FileName <- tclvalue(tkgetSaveFile(initialfile=paste("topTable",".p-adjust.",correction,".threshold.",threshold,".xls",sep=""),filetypes="{{Tab-Delimited Text Files} {.txt .xls}} {{All files} *}")))
Try(if(!nchar(FileName))
return())
Try(write.table(deTable$table,file=FileName,quote=FALSE, sep="\t", row.names=F))
}
################################################################################
"limma2paired" <- function(){
# require(limma) || stop("library Limma could not be found !")
#error if no data are loaded
Try(whichArrayPlatform <- get("whichArrayPlatform",envir=affylmGUIenvironment))
if(whichArrayPlatform ==""){
Try(tkmessageBox(title="Limma paired sample analysis",message="No arrays have been loaded. Please try New or Open from the File menu.",type="ok",icon="error"))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(return())
}
if(whichArrayPlatform=="AFFY"){
if(!affylmGUIenvironment$NormalizedAffyData.Available)
{
Try(tkmessageBox(title="Limma paired sample analysis",message="Probe set summary is not available!\nNext menu will give options for probe set summarization", type="ok", icon="info"))
Try(NormalizeNow())
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
}
}
if(!affylmGUIenvironment$NormalizedAffyData.Available){
Try(tkmessageBox(title="Limma paired sample analysis",message="Normalized data are not available!", type="ok", icon="error"))
Try(return())
}
#########################
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(targets <- affylmGUIenvironment$Targets$Target)
Try(targets <- strsplit(targets, "_"))
Try(targets <- t(as.data.frame(targets)))
Try(target.unique <- unique(targets[,1]))
if(length(target.unique) == 2){
if(dim(targets)[2]>1){
Try(cl <- rep(1,dim(targets)[1]))
Try(cl[which(targets[,1]==target.unique[2])] <- 2)
Try(origin <- as.numeric(targets[,2]))
Try(mydesign <- cl)
Try(mydesign[which(mydesign == min(mydesign))] <- 0)
Try(mydesign[which(mydesign == max(mydesign))] <- 1)
Try(dupcor <- duplicateCorrelation(exprs(NormalizedAffyData), design=mydesign, block = origin))
Try(fit <- lmFit(exprs(NormalizedAffyData), design=cl, block = origin, correlation = dupcor$cons))
Try(fit <- eBayes(fit))
Try(tkmessageBox(title="raw P-values",message=paste("Plot will be displayed in the main R window")))
Try(hist(fit$p.value))
}else{
Try(tkmessageBox(title="Limma paired sample analysis",message="The target file is not in the right format!\nCovariates should be linked to their origin (a number) by an underscore.\nIf the origin is only one please use the conventional limmma analysis."))
return()
}
}else{
Try(tkmessageBox(title="Limma paired sample analysis",message="Limma paired test is actually only implemented for two groups"))
return()
}
Try(ttToptableDialog<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttToptableDialog))
Try(tkgrab.set(ttToptableDialog))
Try(tkfocus(ttToptableDialog))
Try(tkwm.title(ttToptableDialog,"Toptable Options"))
Try(tkgrid(tklabel(ttToptableDialog,text=" ")))
Try(frame2 <- tkframe(ttToptableDialog,relief="groove",borderwidth=2))
Try(sortByLabel <- tklabel(frame2,text="Sort by:",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(sortByLabel,sticky="w"))
Try(tkgrid.configure(sortByLabel,sticky="w"))
Try(sortByTcl <- tclVar("M"))
Try(M.but <- tkradiobutton(frame2,text="M",variable=sortByTcl,value="M",font=.affylmGUIglobals$affylmGUIfont2))
Try(A.but <- tkradiobutton(frame2,text="A",variable=sortByTcl,value="A",font=.affylmGUIglobals$affylmGUIfont2))
Try(T.but <- tkradiobutton(frame2,text="t statistic",variable=sortByTcl,value="T",font=.affylmGUIglobals$affylmGUIfont2))
Try(P.but <- tkradiobutton(frame2,text="P value",variable=sortByTcl,value="P",font=.affylmGUIglobals$affylmGUIfont2))
Try(B.but <- tkradiobutton(frame2,text="B statistic",variable=sortByTcl,value="B",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(M.but,sticky="w"))
Try(tkgrid(A.but,sticky="w"))
Try(tkgrid(T.but,sticky="w"))
Try(tkgrid(P.but,sticky="w"))
Try(tkgrid(B.but,sticky="w"))
Try(frame3 <- tkframe(ttToptableDialog,relief="groove",borderwidth=2))
Try(adjustMethodLabel <- tklabel(frame3,text="Adjust method:",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(adjustMethodLabel,sticky="w"))
Try(tkgrid.configure(adjustMethodLabel,sticky="w"))
Try(adjustMethodTcl <- tclVar("BH"))
Try(none.but <- tkradiobutton(frame3,text="None",variable=adjustMethodTcl,value="none",font=.affylmGUIglobals$affylmGUIfont2))
Try(bh.but <- tkradiobutton(frame3,text="BH" ,variable=adjustMethodTcl,value="BH" ,font=.affylmGUIglobals$affylmGUIfont2))
Try(by.but <- tkradiobutton(frame3,text="BY" ,variable=adjustMethodTcl,value="BY" ,font=.affylmGUIglobals$affylmGUIfont2))
Try(holm.but <- tkradiobutton(frame3,text="Holm",variable=adjustMethodTcl,value="holm",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(none.but,sticky="w"))
Try(tkgrid(bh.but ,sticky="w"))
Try(tkgrid(by.but ,sticky="w"))
Try(tkgrid(holm.but,sticky="w"))
Try(totalGenes <- nrow(fit$coefficients))
Try(Abort <- 1)
Try(numberOfGenes <- 0)
Try(sortBy <- "B")
Try(adjustMethod <- "BH")
Try(onOK <- function()
{
Try(tkgrab.release(ttToptableDialog))
Try(tkdestroy(ttToptableDialog))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(numberOfGenes <<- totalGenes)
Try(sortBy <<- tclvalue(sortByTcl))
Try(adjustMethod <<- tclvalue(adjustMethodTcl))
Try(Abort <<- 0)
})
Try(onHelp <- function() Try(help("topTable",htmlhelp=TRUE)))
Try(frame4 <- tkframe(ttToptableDialog,borderwidth=2))
Try(onCancel <- function() {Try(tkgrab.release(ttToptableDialog));Try(tkdestroy(ttToptableDialog));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(Help.but <-tkbutton(frame4,text=" Help ",command=onHelp,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(frame4,text=" "),OK.but,Cancel.but,Help.but,tklabel(frame4,text=" ")))
Try(tkgrid(tklabel(ttToptableDialog,text=" "),frame2,tklabel(ttToptableDialog,text=" ")))
Try(tkgrid(tklabel(ttToptableDialog,text=" ")))
Try(tkgrid(tklabel(ttToptableDialog,text=" "),frame3,frame4,tklabel(ttToptableDialog,text=" ")))
Try(tkgrid(tklabel(ttToptableDialog,text=" ")))
Try(tkgrid.configure(frame3,sticky="w"))
Try(tkgrid.configure(frame4,sticky="s"))
Try(tkfocus(ttToptableDialog))
Try(tkbind(ttToptableDialog, "<Destroy>", function() {Try(tkgrab.release(ttToptableDialog));Try(tkfocus(.affylmGUIglobals$ttMain));}))
Try(tkwait.window(ttToptableDialog))
Try(if(Abort==1)
return())
Try(if(numberOfGenes==totalGenes)
{
tkconfigure(.affylmGUIglobals$ttMain,cursor="watch")
Try(tkfocus(.affylmGUIglobals$ttMain))
})
Try(options(digits=3))
####this part refer to 3' IVT arrays and ILLU
Try(whichArrayPlatform <- get("whichArrayPlatform",envir=affylmGUIenvironment))
Try(whichLib <- get("whichLib",envir=affylmGUIenvironment))
getDataEnv <- function(name, lib) {
get(paste(lib, name, sep = ""), mode = "environment")
}
Try(NormalizedAffyData.Available <- get("NormalizedAffyData.Available",envir=affylmGUIenvironment))
if((whichArrayPlatform == "AFFY" || whichArrayPlatform == "ILLU" || whichArrayPlatform == "GENE") & NormalizedAffyData.Available){
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(annLib <- .annotation(NormalizedAffyData))
if(length(as.character(unlist(strsplit(annLib, "\\."))))< 2 ){
annLib <- paste(annLib, ".db", sep="")
}
Try(require(annLib, character.only = TRUE) || stop("need data package: ", annLib))
# Try(require("annotate", character.only = TRUE) || stop("need data package: annotate"))
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
if(annLib=="yeast2"){
Try(geneNames <- as.character(unlist(mget(featureNames(NormalizedAffyData), env=getDataEnv("ORF", annLib), ifnotfound=NA))))
Try(geneSymbols <- as.character(unlist(mget(featureNames(NormalizedAffyData), env=getDataEnv("GENENAME", annLib), ifnotfound=NA))))
} else {
#E' DA CONTROLLARE CHE FUNZIONI!!!!!
#Try(geneNames <- as.character(unlist(mget(featureNames(NormalizedAffyData), env=getDataEnv("ENTREZID", annLib), ifnotfound=NA))))
Try(annlib1 <- as.character(unlist(strsplit(annLib, ".db"))))
Try(geneNames <- lookUp(featureNames(NormalizedAffyData), annlib1, "ENTREZID"))
Try(geneNames.n <- names(geneNames))
Try(geneNames <- as.character(unlist(geneNames)))
Try(names(geneNames) <- geneNames.n)
#Try(geneSymbols <- as.character(unlist(mget(featureNames(NormalizedAffyData), env=getDataEnv("SYMBOL", annLib), ifnotfound=NA))))
Try(geneSymbols <- lookUp(featureNames(NormalizedAffyData), annlib1, "SYMBOL"))
Try(geneSymbols.n <- names(geneSymbols))
Try(geneSymbols <- as.character(unlist(geneSymbols)))
Try(names(geneSymbols) <- geneSymbols.n)
}
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)),as.matrix(geneNames),as.matrix(geneSymbols)))
Try(colnames(genelist) <- c("AffyID","EG","SYMBOL"))
} else if(whichArrayPlatform == "EXON" & whichLib[[1]][2]=="core"){
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
#extracting the library
#Try(annlibloc <- grep(paste("^",whichLib[[1]][1],sep=""), as.vector(unlist(data(package="oneChannelGUI"))), ignore.case = T))
#Try(annlibname <- as.vector(unlist(data(package="oneChannelGUI")))[annlibloc])
#Try(data(list=annlibname,package="oneChannelGUI"))
#Try(exonannlib<- get(annlibname,envir=.GlobalEnv))
if(whichLib[[1]][1] == "HuEx"){
Try(libDirLocation <- get("libDirLocation", envir=affylmGUIenvironment))
Try(load(paste(libDirLocation, "huex.annotation.rda", sep="/")))
Try(exonannlib <- huex.annotation)
Try(rm(huex.annotation))
}else if(whichLib[[1]][1] == "MoEx"){
Try(libDirLocation <- get("libDirLocation", envir=affylmGUIenvironment))
Try(load(paste(libDirLocation, "moex.annotation.rda", sep="/")))
Try(exonannlib <- moex.annotation)
Try(rm(moex.annotation))
}else if(whichLib[[1]][1] == "RaEx"){
Try(libDirLocation <- get("libDirLocation", envir=affylmGUIenvironment))
Try(load(paste(libDirLocation, "raex.annotation.rda", sep="/")))
Try(exonannlib <- raex.annotation)
Try(rm(raex.annotation))
}
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(tmpNames <- as.character(exonannlib[,2]))#acc
Try(names(tmpNames) <- as.character(exonannlib[,1]))
Try(position <- apply(genelist, 1, function(x, mynames){return(which(mynames==x))}, mynames=names(tmpNames)))
Try(position <- sapply(position, function(x){return(x[1])}))
Try(geneNames <- as.character(tmpNames[position]))
Try(tmpNames <- as.character(exonannlib[,3]))#symbol
Try(geneSymbols <- as.character(tmpNames[position]))
Try(tmpNames <- as.character(exonannlib[,5]))#cytoband
Try(geneCytoband <- as.character(tmpNames[position]))
Try(tmpNames <- as.character(exonannlib[,4]))#description
Try(geneDescription <- as.character(tmpNames[position]))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)), as.matrix(geneNames), as.matrix(geneSymbols), as.matrix(geneCytoband),as.matrix(geneDescription)))
Try(colnames(genelist) <- c("AffyID","ACC", "SYMBOL", "CYTOBAND", "DESCRIPTION"))
} else if(whichArrayPlatform == "EXON" & whichLib[[1]][2]!="core"){
Try(tkmessageBox(title="TopTable",message=paste("oneChannelGUI embedded annotation for", whichLib[[1]][2], "is not provided, yet!\nYou will retrieve a Top Table without annotations.", collapse=" "),type="ok",icon="error"))
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
#extracting the library
#Try(annlibloc <- grep(paste("^",whichLib[[1]][1],sep=""), as.vector(unlist(data(package="oneChannelGUI"))), ignore.case = T))
#Try(annlibname <- as.vector(unlist(data(package="oneChannelGUI")))[annlibloc])
#Try(data(list=annlibname,package="oneChannelGUI"))
#Try(exonannlib<- get(annlibname,envir=.GlobalEnv))
if(whichLib[[1]][1] == "HuEx"){
Try(libDirLocation <- get("libDirLocation", envir=affylmGUIenvironment))
Try(load(paste(libDirLocation, "huex.annotation.rda", sep="/")))
Try(exonannlib <- huex.annotation)
Try(rm(huex.annotation))
}else if(whichLib[[1]][1] == "MoEx"){
Try(libDirLocation <- get("libDirLocation", envir=affylmGUIenvironment))
Try(load(paste(libDirLocation, "moex.annotation.rda", sep="/")))
Try(exonannlib <- moex.annotation)
Try(rm(moex.annotation))
}else if(whichLib[[1]][1] == "RaEx"){
Try(libDirLocation <- get("libDirLocation", envir=affylmGUIenvironment))
Try(load(paste(libDirLocation, "raex.annotation.rda", sep="/")))
Try(exonannlib <- raex.annotation)
Try(rm(raex.annotation))
}
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)), rep("-", length(featureNames(NormalizedAffyData))), rep("-", length(featureNames(NormalizedAffyData))), rep("-", length(featureNames(NormalizedAffyData))),rep("-", length(featureNames(NormalizedAffyData)))))
Try(colnames(genelist) <- c("AffyID","ACC", "SYMBOL", "CYTOBAND", "DESCRIPTION"))
} else if(whichArrayPlatform == "LARGE" & NormalizedAffyData.Available){
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(annLib <- .annotation(NormalizedAffyData))
if(annLib != ""){
if(length(as.character(unlist(strsplit(annLib, "\\.")))) < 2 ){
annLib <- paste(annLib, ".db", sep="")
}
Try(require(annLib, character.only = TRUE) || stop("need data package: ", annlib))
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(annlib1 <- as.character(unlist(strsplit(annLib, ".db"))))
Try(geneNames <- lookUp(featureNames(NormalizedAffyData), annlib1, "ENTREZID"))
Try(geneNames.n <- names(geneNames))
Try(geneNames <- as.character(unlist(geneNames)))
Try(names(geneNames) <- geneNames.n)
#Try(geneSymbols <- as.character(unlist(mget(featureNames(NormalizedAffyData), env=getDataEnv("SYMBOL", annLib), ifnotfound=NA))))
Try(geneSymbols <- lookUp(featureNames(NormalizedAffyData), annlib1, "SYMBOL"))
Try(geneSymbols.n <- names(geneSymbols))
Try(geneSymbols <- as.character(unlist(geneSymbols)))
Try(names(geneSymbols) <- geneSymbols.n)
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)),as.matrix(geneNames),as.matrix(geneSymbols)))
Try(colnames(genelist) <- c("AffyID","EG","SYMBOL"))
} else {
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(geneNames <- rep("-", dim(genelist)[1]))
Try(geneSymbols <- rep("-", dim(genelist)[1]))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)),as.matrix(geneNames),as.matrix(geneSymbols)))
Try(colnames(genelist) <- c("geneID","EG","SYMBOL"))
}
} else if(whichArrayPlatform == "GENE" & NormalizedAffyData.Available){
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(annLib <- .annotation(NormalizedAffyData))
if(annLib != ""){
if(length(as.character(unlist(strsplit(annLib, "\\."))))< 2 ){
annLib <- paste(annLib, ".db", sep="")
}
Try(require(annLib, character.only = TRUE) || stop("need data package: ", annlib))
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(annlib1 <- as.character(unlist(strsplit(annLib, ".db"))))
Try(geneNames <- lookUp(featureNames(NormalizedAffyData), annlib1, "ENTREZID"))
Try(geneNames.n <- names(geneNames))
Try(geneNames <- as.character(unlist(geneNames)))
Try(names(geneNames) <- geneNames.n)
Try(geneSymbols <- lookUp(featureNames(NormalizedAffyData), annlib1, "SYMBOL"))
Try(geneSymbols.n <- names(geneSymbols))
Try(geneSymbols <- as.character(unlist(geneSymbols)))
Try(names(geneSymbols) <- geneSymbols.n)
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)),as.matrix(geneNames),as.matrix(geneSymbols)))
Try(colnames(genelist) <- c("AffyID","EG","SYMBOL"))
} else {
Try(NormalizedAffyData <- get("NormalizedAffyData",envir=affylmGUIenvironment))
Try(genelist <- data.frame(ID=I(featureNames(NormalizedAffyData))))
Try(geneNames <- get("geneNames",envir=affylmGUIenvironment))#eg
Try(geneSymbols <- get("geneSymbols",envir=affylmGUIenvironment))#symbol
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(geneNames <- rep("-", dim(genelist)[1]))
Try(geneSymbols <- rep("-", dim(genelist)[1]))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
Try(genelist <- cbind(as.matrix(featureNames(NormalizedAffyData)),as.matrix(geneNames),as.matrix(geneSymbols)))
Try(colnames(genelist) <- c("geneID","EG","SYMBOL"))
}
}
Try(fit$genes <- genelist)
Try(table1 <- toptable(coef=1,number=numberOfGenes,fit=fit,genelist=genelist,adjust.method=adjustMethod,sort.by=sortBy))
Try(Mmean <- rowMeans(exprs(NormalizedAffyData)[,which(cl==2)]) - rowMeans(exprs(NormalizedAffyData)[,which(cl==1)]))
Try(table1 <- cbind(table1, Mmean))
Try(names(table1)[dim(table1)[2]] <- "M")
Try(names(table1)[which(names(table1) == "logFC")] <- "A")
Try(names(table1)[which(names(table1) == "P.Value")] <- "raw.P.Val")
Try(names(table1)[which(names(table1) == "adj.P.Val")] <- "P.Value")
Try(nrows <- nrow(table1))
Try(ncols <- ncol(table1))
#######################
#inserting the filtering of the topTable data by mena of plots
dfMAplot(table1)#starting for the full top table
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
}
################################################################################
"bayseqInterface" <- function(){
# require(baySeq) || stop("\nMisssing baySeq package\n")
Try(mbSnow <- tkmessageBox(title="Multi-cores",
message="Do you wish to use multi-cores?\nAnswering Yes, you will be asked to select the number of cores/threads you wish to use.",
icon="question",type="yesno",default="no"))
cl <- ""
Try(if(tclvalue(mbSnow)=="yes"){
# require(snow) || stop("\nMissing snow package\n")
#selecting the number of socks for snow package
Try(ttSOCKS<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttSOCKS))
Try(tkgrab.set(ttSOCKS))
Try(tkfocus(ttSOCKS))
Try(tkwm.title(ttSOCKS,"How many cores?"))
Try(tkgrid(tklabel(ttSOCKS,text=" ")))
Try(SOCKSnum <- "1")
Try(Local.SOCKS <- tclVar(init=SOCKSnum))
Try(entry.SOCKS <-tkentry(ttSOCKS,width="4",font=.affylmGUIglobals$affylmGUIfont2,textvariable=Local.SOCKS,bg="white"))
Try(tkgrid(tklabel(ttSOCKS,text="Please enter the number of cores you wish \nto use to speed up the analysis.",font=.affylmGUIglobals$affylmGUIfont2)))
Try(tkgrid(entry.SOCKS))
onOK <- function()
{
Try(SOCKSnum <- as.numeric(tclvalue(Local.SOCKS)))
Try(assign("SOCKSnum", as.numeric(tclvalue(Local.SOCKS)),affylmGUIenvironment))
Try(assign("SOCKSnum.available", TRUE,affylmGUIenvironment))
Try(tkgrab.release(ttSOCKS));Try(tkdestroy(ttSOCKS));Try(tkfocus(.affylmGUIglobals$ttMain))
}
Try(OK.but <-tkbutton(ttSOCKS,text=" OK ",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(ttSOCKS,text=" ")))
Try(tkgrid(OK.but))
Try(tkgrid.configure(OK.but))
Try(tkgrid(tklabel(ttSOCKS,text=" ")))
Try(tkfocus(entry.SOCKS))
Try(tkbind(entry.SOCKS, "<Return>",onOK))
Try(tkbind(ttSOCKS, "<Destroy>", function(){Try(tkgrab.release(ttSOCKS));Try(tkfocus(.affylmGUIglobals$ttMain));return(0)}))
Try(tkwait.window(ttSOCKS))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(SOCKSnum <- get("SOCKSnum", env=affylmGUIenvironment))
cat("\nStarting cluster\n")
cl <- makeCluster(SOCKSnum, "SOCK")
} else{
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
})
if(affylmGUIenvironment$NormalizedAffyData.Available){
Try(NormalizedAffyData <- get("NormalizedAffyData", env=affylmGUIenvironment))
Try(targets <- get("Targets", env=affylmGUIenvironment))
Try(totalReads <- get("totalReads",envir=affylmGUIenvironment))
Try(mappedReads <- get("mappedReads",envir=affylmGUIenvironment))
if(is.na(mappedReads[1])) {
totalReads <- esApply(NormalizedAffyData, 2, sum)
cat("\nSince total/mapped reads numbers were not provided in the target,\nlibrary size is given by the sum of the columns of count matrix data\n")
}
} else Try(tkmessageBox(title="NGS data set",message="NGS data are not available.", type="ok", icon="error"))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
cat("\ncreating the countData object")
counts <- exprs(NormalizedAffyData)
rownames(counts) <- seq(1, dim(counts)[1])
names(counts) <- seq(1, dim(counts)[2])
target <- as.character(targets$Target)
target.u <- unique(target)
if(length(target.u) > 2) {
Try(tkmessageBox(title="baySeq analysis",message="baySeq package support only two groups experimental design.", type="ok", icon="error"))
Try(return())
}
replicates <- rep(1, length(target))
replicates[which(target == target.u[2])] <- 2
groups <- list(NDE = rep(1, length(target)), DE = replicates)
CD <- new("countData", data = as.matrix(counts), replicates = replicates, libsizes = as.integer(totalReads), groups = groups)
CD@annotation <- data.frame(name = featureNames(NormalizedAffyData))
#selecting the number of Iterations
Try(ttIterations<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttIterations))
Try(tkgrab.set(ttIterations))
Try(tkfocus(ttIterations))
Try(tkwm.title(ttIterations,"How many iterations?"))
Try(tkgrid(tklabel(ttIterations, text=" ")))
Try(Iterations <- "10000")
Try(Local.Iterations <- tclVar(init=Iterations))
Try(entry.Iterations <-tkentry(ttIterations,width="6",font=.affylmGUIglobals$affylmGUIfont2,textvariable=Local.Iterations,bg="white"))
Try(tkgrid(tklabel(ttIterations,text="Please enter the number of iterations you wish to use to estimate the NB distribution.\nRemember that less then 10000 iterations migth not be \nsufficient for a good estimation of the distribution,\nbut will speed up calculation.",font=.affylmGUIglobals$affylmGUIfont2)))
Try(tkgrid(entry.Iterations))
onOK <- function()
{
Try(Iterations <- as.numeric(tclvalue(Local.Iterations)))
Try(assign("Iterations", as.numeric(tclvalue(Local.Iterations)),affylmGUIenvironment))
Try(assign("Iterations.available", TRUE,affylmGUIenvironment))
Try(tkgrab.release(ttIterations));Try(tkdestroy(ttIterations));Try(tkfocus(.affylmGUIglobals$ttMain))
}
Try(OK.but <-tkbutton(ttIterations,text=" OK ",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(ttIterations,text=" ")))
Try(tkgrid(OK.but))
Try(tkgrid.configure(OK.but))
Try(tkgrid(tklabel(ttIterations,text=" ")))
Try(tkfocus(entry.Iterations))
Try(tkbind(entry.Iterations, "<Return>",onOK))
Try(tkbind(ttIterations, "<Destroy>", function(){Try(tkgrab.release(ttIterations));Try(tkfocus(.affylmGUIglobals$ttMain));return(0)}))
Try(tkwait.window(ttIterations))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(Iterations <- get("Iterations", env=affylmGUIenvironment))
cat("\nStarting NB distribution estimation.....")
if(length(cl) > 0){
CDP.NBML <- getPriors.NB(CD, samplesize = Iterations, estimation = "QL", cl=cl)
} else{
CDP.NBML <- getPriors.NB(CD, samplesize = Iterations, estimation = "QL", cl=NULL)
}
cat("\nStarting NB posterior estimation\n")
if(length(cl) > 0){
CDPost.NBML <- getLikelihoods.NB(CDP.NBML, pET = "BIC", cl=cl)
cat("\nStopping cluster\n")
stopCluster(cl)
}else{
CDPost.NBML <- getLikelihoods.NB(CDP.NBML, pET = "BIC", cl=NULL)
}
deTable <- topCounts(CDPost.NBML, group = 2, number=dim(counts)[1])
tmp <- deTable[,2:dim(deTable)[2]]
meanA <- apply(tmp[,which(replicates == 1)],1, mean)
meanB <- apply(tmp[,which(replicates == 2)],1, mean)
meanAB <- apply(tmp[,c(which(replicates == 1),which(replicates == 2))],1, mean)
fcAB <- log2(meanB) - log2(meanA)
intAB <- log10(meanAB)
# detags <- rownames(deTable)
tmpM <- paste("log2 ", target.u[2],"-",target.u[1], sep="")
stat.data <- cbind("M"=signif(fcAB,2),"log10 average counts"=signif(intAB,2), "FDR"=signif(deTable$FDR,2))
dimnames(stat.data)[[2]][1] <- tmpM
dimnames(stat.data)[[1]] <- as.character(deTable$annotation)
################################
Try(ttIfDialog<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttIfDialog))
Try(tkgrab.set(ttIfDialog))
Try(tkfocus(ttIfDialog))
Try(tkwm.title(ttIfDialog,"Selecting the parameters to detect differentially expressed NGS peaks"))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(frame1 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(HowManyQuestion1 <- tklabel(frame1,text="Multiple testing adjustment",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(HowManyQuestion1))
Try(tkgrid.configure(HowManyQuestion1,columnspan=2,sticky="w"))
Try(permutationsTcl <- tclVar("none"))
# Try(I1.but <- tkradiobutton(frame1,text="BH",variable=permutationsTcl,value="BH",font=.affylmGUIglobals$affylmGUIfont2))
# Try(I2.but <- tkradiobutton(frame1,text="BY",variable=permutationsTcl,value="BY",font=.affylmGUIglobals$affylmGUIfont2))
# Try(I3.but <- tkradiobutton(frame1,text="fdr",variable=permutationsTcl,value="fdr",font=.affylmGUIglobals$affylmGUIfont2))
Try(I4.but <- tkradiobutton(frame1,text="none",variable=permutationsTcl,value="none",font=.affylmGUIglobals$affylmGUIfont2))
# 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,I1.but,I2.but,I3.but,I4.but,sticky="w"))
Try(tkgrid.configure(HowManyQuestion1,I4.but,sticky="w"))
Try(frame2 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(cutoffLabel <- tklabel(frame2,text="FDR",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(cutoffLabel,sticky="w"))
Try(tkgrid.configure(cutoffLabel,sticky="w"))
Try(cutoffTcl <- tclVar("0.1"))
Try(F2.but <- tkradiobutton(frame2,text="none",variable=cutoffTcl,value="1",font=.affylmGUIglobals$affylmGUIfont2))
Try(F3.but <- tkradiobutton(frame2,text="0.2",variable=cutoffTcl,value="0.2",font=.affylmGUIglobals$affylmGUIfont2))
Try(F4.but <- tkradiobutton(frame2,text="0.1",variable=cutoffTcl,value="0.1",font=.affylmGUIglobals$affylmGUIfont2))
Try(F5.but <- tkradiobutton(frame2,text="0.05",variable=cutoffTcl,value="0.05",font=.affylmGUIglobals$affylmGUIfont2))
Try(F6.but <- tkradiobutton(frame2,text="0.01",variable=cutoffTcl,value="0.01",font=.affylmGUIglobals$affylmGUIfont2))
Try(F7.but <- tkradiobutton(frame2,text="0.005",variable=cutoffTcl,value="0.005",font=.affylmGUIglobals$affylmGUIfont2))
Try(F8.but <- tkradiobutton(frame2,text="0.001",variable=cutoffTcl,value="0.001",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(F2.but,sticky="w"))
Try(tkgrid(F3.but,sticky="w"))
Try(tkgrid(F4.but,sticky="w"))
Try(tkgrid(F5.but,sticky="w"))
Try(tkgrid(F6.but,sticky="w"))
Try(tkgrid(F7.but,sticky="w"))
Try(tkgrid(F8.but,sticky="w"))
Try(tkgrid.configure(cutoffLabel,F2.but,F3.but,F4.but,F5.but,F6.but,F7.but,F8.but,sticky="w"))
Try(onOK <- function()
{
ReturnVal1 <- as.character(tclvalue(permutationsTcl))
ReturnVal2 <- as.numeric(tclvalue(cutoffTcl))
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==""){
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
return()
}
Try(tmp<-strsplit(ReturnVal, ";"))
Try(correction <- tmp[[1]][1])
Try(threshold <- as.numeric(tmp[[1]][2]))
################################
#Try(padj <- p.adjust(stat.data[,3], method = correction))
#Try(stat.data <- cbind(stat.data, "adjusted.p"=padj))
Try(mycol <- rep("black", dim(stat.data)[1]))
Try(mycol[which(stat.data[,3] <= threshold )] <- "red")
Try(par(mfrow=c(1,2)))
Try(hist(stat.data[,3], xlab="FDR", main=""))
#MA plot
# Try(samplesA <- which(replicates == 1))
# Try(samplesB <- which(replicates == 2))
# Try(Adata <- colSums(t(CD@data[, samplesA])/CD@libsizes[samplesA])/length(samplesA))
# Try(Bdata <- colSums(t(CD@data[, samplesB])/CD@libsizes[samplesB])/length(samplesB))
Try(M <- stat.data[,1])
Try(A <- stat.data[,2])
Try(plot(A,M, col = mycol, pch=19, cex=0.8, ylab=dimnames(stat.data)[[2]][1], xlab=dimnames(stat.data)[[2]][2]))
Try(abline(h=0))
#Try(.plotMA.CD(CD, samplesA = samplesA, samplesB = samplesB, col = c(mycol[mycol=="black"], mycol[mycol=="red"]), pch=19, cex=0.5))
Try(correction <- "FDR")
Try(stat.data <- stat.data[which(stat.data[,3] <= threshold),])
Try(tmp.ann <- rownames(stat.data))
Try(tmp.names <- strsplit(tmp.ann, "description: "))
if(length(tmp.names[[1]]) == 2){
Try(tmp.names <- sapply(tmp.names, function(x) x[2]))
Try(rownames(stat.data) <- tmp.names)
}
Try(stat.short <- data.frame(rownames(stat.data), stat.data[,1]))
Try(names(stat.short) <- c("mirna","expr"))
Try(deTable <- list("annotation"="", "table"=as.data.frame(stat.data)))
Try(deTable1 <- list("annotation"="", "table"=as.data.frame(stat.short))) #for RmiR usage
################################
Try(mbVal <- tkmessageBox(title="Differentially expressed peaks",
message="Do you like the detected differentially expressed peaks?\nAnswering YES data will be saved as tab delimited file.",
icon="question",type="yesno",default="yes"))
Try(if(tclvalue(mbVal)=="yes"){
Try(.SaveNGSTopTable(correction, threshold, deTable))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
} else{
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
})
Try(mbVal1 <- tkmessageBox(title="RmiR export data format",
message="Do you like to export differentially expressed miRNA in a format suitable for RmiR based datamining?\nAnswering YES data will be saved as tab delimited file.",
icon="question",type="yesno",default="yes"))
Try(if(tclvalue(mbVal1)=="yes"){
Try(deTable <- deTable1)
Try(.SaveNGS1TopTable("_RmiRonly_FDR_", threshold, deTable))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
} else{
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
})
}
################################################################################
"DESeqInterface" <- function(){
# Try(require(DESeq) || stop("\nMissing ESeq package\n"))
Try(tt <- "")
Try(assign("firstCovar", tt,affylmGUIenvironment))
Try(assign("secondCovar", tt,affylmGUIenvironment))
if(affylmGUIenvironment$NormalizedAffyData.Available){
Try(NormalizedAffyData <- get("NormalizedAffyData", env=affylmGUIenvironment))
Try(targets <- get("Targets", env=affylmGUIenvironment))
} else Try(tkmessageBox(title="NGS data set",message="NGS data are not available.", type="ok", icon="error"))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="watch"))
Try(cat("\nCreating the DESobj"))
#defining the covar
Try(mycovar <- unique(as.character(targets$Target)))
if(length(mycovar) > 2){
Try(
tkmessageBox(
title="DESeq multiple factors design",
message=paste("You are loading a digital sequence experiment based on multiple factors.\nThe present implementation of oneChannelGUI only support two groups experiment.")
)
)
return()
}
Try(countsTable <- exprs(NormalizedAffyData))
Try(conds <- factor(targets$Target))
Try(cds <- newCountDataSet(countsTable, conds))
Try(cds <- estimateSizeFactors(cds))
Try(cdsLocal <- newCountDataSet(countsTable, conds))
Try(cdsLocal <- estimateSizeFactors(cdsLocal))
Try(cat("\nEstimating dispersion...\n"))
Try(cds <- estimateDispersions(cds))
Try(cdsLocal <- estimateDispersions(cdsLocal, fitType="local"))
Try(tkmessageBox(title="DESeq estimated dispersion",message=paste("In main R window is plotted data dispersion.")))
Try(.plotDispEsts <- function(cds, main) {
plot(rowMeans( counts( cds, normalized=TRUE ) ), fitInfo(cds)$perGeneDispEsts, pch = '.', log="xy", ylab="Gene Dispersion", xlab="Counts mean", main=main)
xg <- 10^seq( -.5, 5, length.out=300)
lines( xg, fitInfo(cds)$dispFun( xg ), col="red" )
})
Try(par(mfrow=c(1,2)))
Try(.plotDispEsts(cds, main="Parametric fit"))
Try(.plotDispEsts(cdsLocal, main="Local fit"))
#which fitting?
Try(ttGetFilterMethod <- tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttGetFilterMethod))
Try(tkgrab.set(ttGetFilterMethod))
Try(tkfocus(ttGetFilterMethod))
Try(tkwm.title(ttGetFilterMethod,"Which fitting method?"))
Try(tkgrid(tklabel(ttGetFilterMethod,text=" ")))
Try(ttGetFilterMethodTcl <- tclVar("p"))
Try(rbIQR.5 <- tkradiobutton(ttGetFilterMethod,text="Parametric fitting",variable=ttGetFilterMethodTcl,value="p",font=.affylmGUIglobals$affylmGUIfont2))
Try(rbIQR.25<-tkradiobutton(ttGetFilterMethod,text="Local fitting",variable=ttGetFilterMethodTcl,value="l",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(ttGetFilterMethod,text=" "),rbIQR.5))
Try(tkgrid(tklabel(ttGetFilterMethod,text=" "),rbIQR.25))
Try(tkgrid.configure(rbIQR.5,rbIQR.25,columnspan=2,sticky="w"))
Try(tkgrid(tklabel(ttGetFilterMethod,text=" "),tklabel(ttGetFilterMethod,text=" ")))
Try(fitVal <- "")
Try(onCancel <- function() {Try(fitVal <<- "");Try(tkgrab.release(ttGetFilterMethod));Try(tkdestroy(ttGetFilterMethod));Try(tkfocus(.affylmGUIglobals$ttMain))})
Try(onOK <- function() {Try(fitVal <<- tclvalue(ttGetFilterMethodTcl));Try(tkgrab.release(ttGetFilterMethod));Try(tkdestroy(ttGetFilterMethod));Try(tkfocus(.affylmGUIglobals$ttMain))})
Try(onHelp <- function() tkmessageBox(title="Which fitting?", message="....", icon="info"))
Try(Help.but <- tkbutton(ttGetFilterMethod,text=" Help ",command=function()Try(onHelp()),font=.affylmGUIglobals$affylmGUIfont2))
Try(OK.but <- tkbutton(ttGetFilterMethod,text="OK",command=onOK,font=.affylmGUIglobals$affylmGUIfont2))
Try(Cancel.but <- tkbutton(ttGetFilterMethod,text="Cancel",command=onCancel,font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(tklabel(ttGetFilterMethod,text=" "),OK.but,Cancel.but, Help.but,tklabel(ttGetFilterMethod,text=" ")))
Try(tkgrid.configure(OK.but,sticky="e"))
Try(tkgrid.configure(Cancel.but,sticky="w"))
Try(tkgrid.configure(Help.but,sticky="e"))
Try(tkgrid(tklabel(ttGetFilterMethod,text=" ")))
Try(tkbind(ttGetFilterMethod,"<Destroy>",function() {ReturnVal <- "";Try(tkgrab.release(ttGetFilterMethod));Try(tkfocus(.affylmGUIglobals$ttMain));}))
Try(tkbind(OK.but, "<Return>",onOK))
Try(tkbind(Cancel.but, "<Return>",onCancel))
Try(tkbind(Help.but, "<Return>",onCancel))
Try(tkwait.window(ttGetFilterMethod))
if(fitVal == "p"){
conds.u <- unique(as.character(targets$Target))
res <- nbinomTest(cdsLocal, conds.u[1],conds.u[2])
}else{
conds.u <- unique(as.character(targets$Target))
res <- nbinomTest(cds, conds.u[1],conds.u[2])
}
################################
#Filtering results
Try(ttIfDialog<-tktoplevel(.affylmGUIglobals$ttMain))
Try(tkwm.deiconify(ttIfDialog))
Try(tkgrab.set(ttIfDialog))
Try(tkfocus(ttIfDialog))
Try(tkwm.title(ttIfDialog,"Selecting the Threshold for differentially expressed NGS peaks"))
Try(tkgrid(tklabel(ttIfDialog,text=" ")))
Try(frame1 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(HowManyQuestion1 <- tklabel(frame1,text="Log2 Fold Change",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(HowManyQuestion1))
Try(tkgrid.configure(HowManyQuestion1,columnspan=2,sticky="w"))
Try(permutationsTcl <- tclVar(1))
Try(I1.but <- tkradiobutton(frame1,text="none",variable=permutationsTcl,value=0,font=.affylmGUIglobals$affylmGUIfont2))
Try(I2.but <- tkradiobutton(frame1,text="0.5",variable=permutationsTcl,value=0.5,font=.affylmGUIglobals$affylmGUIfont2))
Try(I3.but <- tkradiobutton(frame1,text="1",variable=permutationsTcl,value=1,font=.affylmGUIglobals$affylmGUIfont2))
Try(I4.but <- tkradiobutton(frame1,text="2",variable=permutationsTcl,value=2,font=.affylmGUIglobals$affylmGUIfont2))
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,I1.but,I2.but,I3.but,I4.but,sticky="w"))
Try(frame2 <- tkframe(ttIfDialog,relief="groove",borderwidth=2))
Try(cutoffLabel <- tklabel(frame2,text="Cut off p-value threshold",font=.affylmGUIglobals$affylmGUIfont2))
Try(tkgrid(cutoffLabel,sticky="w"))
Try(tkgrid.configure(cutoffLabel,sticky="w"))
Try(cutoffTcl <- tclVar("0.05"))
Try(F1.but <- tkradiobutton(frame2,text="none",variable=cutoffTcl,value="1",font=.affylmGUIglobals$affylmGUIfont2))
Try(F2.but <- tkradiobutton(frame2,text="0.1",variable=cutoffTcl,value="0.1",font=.affylmGUIglobals$affylmGUIfont2))
Try(F3.but <- tkradiobutton(frame2,text="0.05",variable=cutoffTcl,value="0.05",font=.affylmGUIglobals$affylmGUIfont2))
Try(F4.but <- tkradiobutton(frame2,text="0.005",variable=cutoffTcl,value="0.005",font=.affylmGUIglobals$affylmGUIfont2))
Try(F5.but <- tkradiobutton(frame2,text="0.001",variable=cutoffTcl,value="0.001",font=.affylmGUIglobals$affylmGUIfont2))
Try(F6.but <- tkradiobutton(frame2,text="0.0005",variable=cutoffTcl,value="0.0005",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(F5.but,sticky="w"))
Try(tkgrid(F6.but,sticky="w"))
Try(tkgrid.configure(cutoffLabel,F1.but,F2.but,F3.but,F4.but,F5.but,F6.but,sticky="w"))
Try(onOK <- function()
{
fcVal <- as.character(tclvalue(permutationsTcl))
pVal <- as.numeric(tclvalue(cutoffTcl))
Try(fcpVal <<- paste(fcVal, pVal, sep=";"))
Try(tkgrab.release(ttIfDialog))
Try(tkdestroy(ttIfDialog))
Try(tkfocus(.affylmGUIglobals$ttMain))
})
Try(frame3 <- tkframe(ttIfDialog,borderwidth=2))
Try(onCancel <- function() {Try(fcpVal <<- ""); 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(fcpVal==""){
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
return()
}
Try(tmp<-strsplit(fcpVal, ";"))
Try(fcThreshold <- as.numeric(tmp[[1]][1]))
Try(pThreshold <- as.numeric(tmp[[1]][2]))
################################
Try(selected <- res[res$padj <= pThreshold, ])
Try(selected <- selected[abs(selected$log2FoldChange) >= fcThreshold, ])
if(dim(selected)[1] == 0){
Try(tkmessageBox(title="DESeq analysis",message=paste("No differential expression was detected using:\n","Log2 FC Threshold ",fcThreshold, "\np-value threshold ",pThreshold,sep=""),type="ok",icon="info"))
Try(tkfocus(.affylmGUIglobals$ttMain))
Try(return())
}
#plot de
Try(.plotDE <- function(res, selected, fcThreshold, pThreshold){
plot(log10(res$baseMean), res$log2FoldChange, type="n", ylab="Log2 Fold Change", xlab="Log10 Mean counts")
points(log10(res$baseMean), res$log2FoldChange, pch=19, cex=0.3, col="black")
points(log10(selected$baseMean), selected$log2FoldChange, pch=19, cex=0.5, col="red")
abline(h=0, col="black")
abline(h=fcThreshold, col="red")
abline(h=-fcThreshold, col="green")
})
Try(par(mfrow=c(1,1)))
Try(.plotDE(res=res, selected=selected, fcThreshold=fcThreshold, pThreshold=pThreshold))
Try(correction<-paste("FC_", fcThreshold,"_adj-p_", sep=""))
Try(.SaveNGS2TopTable(correction=correction, threshold=pThreshold, selected))
Try(tkconfigure(.affylmGUIglobals$ttMain,cursor="arrow"))
}
################################################################################
#saving the filtered subset
.SaveNGS2TopTable <- function(correction, threshold, deTable)
{
Try(FileName <- tclvalue(tkgetSaveFile(initialfile=paste("topTable",".p-adjust.",correction,".threshold.",threshold,".xls",sep=""),filetypes="{{Tab-Delimited Text Files} {.txt .xls}} {{All files} *}")))
Try(if(!nchar(FileName))
return())
Try(write.table(deTable,file=FileName,quote=FALSE, sep="\t", row.names=F))
}
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.