clas<-function(h,...){
	r_choice="._."
	children<-as.character(tcl(treeview,"children",""))
	w_analz<-tktoplevel()
	w_analz_frame<-ttkframe(w_analz,padding=c(3,3,50,20),borderwidth=1,relief="groove")
	tkpack(w_analz_frame,expand=TRUE,fill="both",side="left")
	var<-tclVar(tree_prnts[1])
	sapply(tree_prnts,function(i){
		r_but_vals<-ttkradiobutton(w_analz_frame,variable=var,text=i,value=i)
		tkpack(r_but_vals,side="top",anchor="w")
	})
	tkpack(ttklabel(w_analz_frame,text=''))
	tkpack(ttklabel(w_analz_frame,text=''))
	r_but<-ttkbutton(w_analz_frame,text="Ok")
	tkpack(r_but,pady=2)
	tkconfigure(r_but,command=function(){
		r_choice<-tclvalue(var)
		tkwm.withdraw(w_analz)
		tree_slc<-strsplit(r_choice[1],"_")
		ts_name<-tree_slc[[1]][1]
		ts_val<-as.numeric(tree_slc[[1]][2])
	
		if(ts_name=="Affymetrix"){
			DE_Affy<-DE_Affy_2[[ts_val]]
			er_x<-try(DE_Affy<-as.matrix(DE_Affy),silent=TRUE)
			if(length(grep("Error",er_x))!=0)
			{
				rownames(DE_Affy)<-as.character(DE_Affy)
				DE_Affy<-as.matrix(DE_Affy)
			}
			rnames<-rownames(DE_Affy)
			if(length(samp_Affy[[ts_val]]!=0)){
				clas_Affy[[ts_val]]<<-as.matrix(dat2Affy.m2[[ts_val]][rnames,samp_Affy[[ts_val]]])
			} else {
				clas_Affy[[ts_val]]<<-as.matrix(dat2Affy.m2[[ts_val]][rnames,])
			}
			if(is.null(ma_img)==TRUE){
				try(tkpack.forget(tableData,scrX,scrY),silent=TRUE)
				try(tkwm.withdraw(w_legend),silent=TRUE)
				ma_img<<-tkrplot(getToolkitWidget(ma_frame2),function(...){
					heatmap(clas_Affy[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
				ma_img2<<-ma_img
				tkpack(ma_img2)			
			}else{
				ma_img2<<-tkrreplot(ma_img,function(...){
					heatmap(clas_Affy[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
			}
			for(i in 1:length(children)){
				x<-as.character(tcl(treeview,"item",children[i],"-values"))
				if(x==r_choice[1])p_enter_class<-tcl(treeview,"insert",children[i],"end",values=as.tclObj("...Classification"))
			}
		}
		if(ts_name=="Agilent-OneColor"){
			DE_Ag1<-DE_Ag1_2[[ts_val]]
			er_x<-try(DE_Ag1<-as.matrix(DE_Ag1),silent=TRUE)
			if(length(grep("Error",er_x))!=0)
			{
				rownames(DE_Ag1)<-as.character(DE_Ag1)
				DE_Ag1<-as.matrix(DE_Ag1)
			}
			rnames<-rownames(DE_Ag1)
			if(length(samp_Ag1[[ts_val]]!=0)){
				clas_Ag1[[ts_val]]<<-as.matrix(datAgOne2.m2[[ts_val]][rnames,samp_Ag1[[ts_val]]])
			} else {
				clas_Ag1[[ts_val]]<<-as.matrix(datAgOne2.m2[[ts_val]][rnames,])				
			}
			if(is.null(ma_img)==TRUE){
				try(tkpack.forget(tableData,scrX,scrY),silent=TRUE)
				try(tkwm.withdraw(w_legend),silent=TRUE)
				ma_img<<-tkrplot(getToolkitWidget(ma_frame2),function(...){
					heatmap(clas_Ag1[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
				ma_img2<<-ma_img
				tkpack(ma_img2)			
			}else{
				ma_img2<<-tkrreplot(ma_img,function(...){
					heatmap(clas_Ag1[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
			}
			for(i in 1:length(children)){
				x<-as.character(tcl(treeview,"item",children[i],"-values"))
				if(x==r_choice[1])p_enter_class<-tcl(treeview,"insert",children[i],"end",values=as.tclObj("...Classification"))
			}
		}
		if(ts_name=="Agilent-TwoColor"){
			DE_Ag2<-DE_Ag2_2[[ts_val]]
			er_x<-try(DE_Ag2<-as.matrix(DE_Ag2),silent=TRUE)
			if(length(grep("Error",er_x))!=0)
			{
				rownames(DE_Ag2)<-as.character(DE_Ag2)
				DE_Ag2<-as.matrix(DE_Ag2)
			}
			rnames<-rownames(DE_Ag2)
			if(length(samp_Ag2[[ts_val]]!=0)){
				clas_Ag2[[ts_val]]<<-as.matrix(datAgTwo2.m2[[ts_val]][rnames,samp_Ag2[[ts_val]]])
			} else {
				clas_Ag2[[ts_val]]<<-as.matrix(datAgTwo2.m2[[ts_val]][rnames,])
			}
			if(is.null(ma_img)==TRUE){
				try(tkpack.forget(tableData,scrX,scrY),silent=TRUE)
				try(tkwm.withdraw(w_legend),silent=TRUE)
				ma_img<<-tkrplot(getToolkitWidget(ma_frame2),function(...){
					heatmap(clas_Ag2[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
				ma_img2<<-ma_img
				tkpack(ma_img2)			
			}else{
				ma_img2<<-tkrreplot(ma_img,function(...){
					heatmap(clas_Ag2[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
			}
			for(i in 1:length(children)){
				x<-as.character(tcl(treeview,"item",children[i],"-values"))
				if(x==r_choice[1])p_enter_class<-tcl(treeview,"insert",children[i],"end",values=as.tclObj("...Classification"))
			}
		}
		if(ts_name=="Illumina-Beadarray"){
			DE_Il_B<-DE_Il_B_2[[ts_val]]
			er_x<-try(DE_Il_B<-as.matrix(DE_Il_B),silent=TRUE)
			if(length(grep("Error",er_x))!=0)
			{
				rownames(DE_Il_B)<-as.character(DE_Il_B)
				DE_Il_B<-as.matrix(DE_Il_B)
			}
			rnames<-rownames(DE_Il_B)
			if(length(samp_Il_B[[ts_val]]!=0)){
				clas_Il_B[[ts_val]]<<-as.matrix(datIllBA2.m2[[ts_val]][rnames,samp_Il_B[[ts_val]]])
			} else {
				clas_Il_B[[ts_val]]<<-as.matrix(datIllBA2.m2[[ts_val]][rnames,])
			}
			if(is.null(ma_img)==TRUE){
				try(tkpack.forget(tableData,scrX,scrY),silent=TRUE)
				try(tkwm.withdraw(w_legend),silent=TRUE)
				ma_img<<-tkrplot(getToolkitWidget(ma_frame2),function(...){
					heatmap(clas_Il_B[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
				ma_img2<<-ma_img
				tkpack(ma_img2)			
			}else{
				ma_img2<<-tkrreplot(ma_img,function(...){
					heatmap(clas_Il_B[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
			}
			for(i in 1:length(children)){
				x<-as.character(tcl(treeview,"item",children[i],"-values"))
				if(x==r_choice[1])p_enter_class<-tcl(treeview,"insert",children[i],"end",values=as.tclObj("...Classification"))
			}
		}
		if(ts_name=="Illumina-Lumi"){
			DE_Il_L<-DE_Il_L_2[[ts_val]]
			er_x<-try(DE_Il_L<-as.matrix(DE_Il_L),silent=TRUE)
			if(length(grep("Error",er_x))!=0)
			{
				rownames(DE_Il_L)<-as.character(DE_Il_L)
				DE_Il_L<-as.matrix(DE_Il_L)
			}
			rnames<-rownames(DE_Il_L)
			if(length(samp_Il_L[[ts_val]]!=0)){
				clas_Il_L[[ts_val]]<<-as.matrix(lumi_NQ.m2[[ts_val]][rnames,samp_Il_L[[ts_val]]])
			} else {
				clas_Il_L[[ts_val]]<<-as.matrix(lumi_NQ.m2[[ts_val]][rnames,])
			}
			if(is.null(ma_img)==TRUE){
				try(tkpack.forget(tableData,scrX,scrY),silent=TRUE)
				try(tkwm.withdraw(w_legend),silent=TRUE)
				ma_img<<-tkrplot(getToolkitWidget(ma_frame2),function(...){
					heatmap(clas_Il_L[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
				ma_img2<<-ma_img
				tkpack(ma_img2)			
			}else{
				ma_img2<<-tkrreplot(ma_img,function(...){
					heatmap(clas_Il_L[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
			}
			for(i in 1:length(children)){
				x<-as.character(tcl(treeview,"item",children[i],"-values"))
				if(x==r_choice[1])p_enter_class<-tcl(treeview,"insert",children[i],"end",values=as.tclObj("...Classification"))
			}
		}
		if(ts_name=="Nimblegen"){
			DE_N<-DE_N_2[[ts_val]]
			er_x<-try(DE_N<-as.matrix(DE_N),silent=TRUE)
			if(length(grep("Error",er_x))!=0)
			{
				rownames(DE_N)<-as.character(DE_N)
				DE_N<-as.matrix(DE_N)
			}
			rnames<-rownames(DE_N)
			if(length(samp_N[[ts_val]]!=0)){
				clas_N[[ts_val]]<<-as.matrix(data.matrix_Nimblegen2.m2[[ts_val]][rnames,samp_N[[ts_val]]])
			} else {
				clas_N[[ts_val]]<<-as.matrix(data.matrix_Nimblegen2.m2[[ts_val]][rnames,])
			}
			if(is.null(ma_img)==TRUE){
				try(tkpack.forget(tableData,scrX,scrY),silent=TRUE)
				try(tkwm.withdraw(w_legend),silent=TRUE)
				ma_img<<-tkrplot(getToolkitWidget(ma_frame2),function(...){
					heatmap(clas_N[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
				ma_img2<<-ma_img
				tkpack(ma_img2)			
			}else{
				ma_img2<<-tkrreplot(ma_img,function(...){
					heatmap(clas_N[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
			}
			for(i in 1:length(children)){
				x<-as.character(tcl(treeview,"item",children[i],"-values"))
				if(x==r_choice[1])p_enter_class<-tcl(treeview,"insert",children[i],"end",values=as.tclObj("...Classification"))
			}
		}
		if(ts_name=="Series-Matrix"){
			DE_S<-DE_S_2[[ts_val]]
			er_x<-try(DE_S<-as.matrix(DE_S),silent=TRUE)
			if(length(grep("Error",er_x))!=0)
			{
				rownames(DE_S)<-as.character(DE_S)
				DE_S<-as.matrix(DE_S)
			}
			rnames<-rownames(DE_S)
			if(length(samp_S[[ts_val]]!=0)){
				clas_S[[ts_val]]<<-as.matrix(data.matrixNorm.m2[[ts_val]][rnames,samp_S[[ts_val]]])
			} else {
				clas_S[[ts_val]]<<-as.matrix(data.matrixNorm.m2[[ts_val]][rnames,])
			}
			if(is.null(ma_img)==TRUE){
				try(tkpack.forget(tableData,scrX,scrY),silent=TRUE)
				try(tkwm.withdraw(w_legend),silent=TRUE)
				ma_img<<-tkrplot(getToolkitWidget(ma_frame2),function(...){
					heatmap(clas_S[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
				ma_img2<<-ma_img
				tkpack(ma_img2)			
			}else{
				ma_img2<<-tkrreplot(ma_img,function(...){
					heatmap(clas_S[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
			}
			for(i in 1:length(children)){
				x<-as.character(tcl(treeview,"item",children[i],"-values"))
				if(x==r_choice[1])p_enter_class<-tcl(treeview,"insert",children[i],"end",values=as.tclObj("...Classification"))
			}
		}
		if(ts_name=="Online-Data"){
			DE_O<-DE_O_2[[ts_val]]
			er_x<-try(DE_O<-as.matrix(DE_O),silent=TRUE)
			if(length(grep("Error",er_x))!=0)
			{
				rownames(DE_O)<-as.character(DE_O)
				DE_O<-as.matrix(DE_O)
			}
			rnames<-rownames(DE_O)
			if(length(samp_O[[ts_val]]!=0)){
				clas_O[[ts_val]]<<-as.matrix(data.matrix_onlineNorm.m2[[ts_val]][rnames,samp_O[[ts_val]]])
			} else {
				clas_O[[ts_val]]<<-as.matrix(data.matrix_onlineNorm.m2[[ts_val]][rnames,])
			}
			if(is.null(ma_img)==TRUE){
				try(tkpack.forget(tableData,scrX,scrY),silent=TRUE)
				try(tkwm.withdraw(w_legend),silent=TRUE)
				ma_img<<-tkrplot(getToolkitWidget(ma_frame2),function(...){
					heatmap(clas_O[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
				ma_img2<<-ma_img
				tkpack(ma_img2)			
			}else{
				ma_img2<<-tkrreplot(ma_img,function(...){
					heatmap(clas_O[[ts_val]],Rowv=NA,Colv=NA,cexCol=0.8,cexRow=0.8,col=heatcol)
				},hscale=1.7,vscale=1.07)
			}
			for(i in 1:length(children)){
				x<-as.character(tcl(treeview,"item",children[i],"-values"))
				if(x==r_choice[1])p_enter_class<-tcl(treeview,"insert",children[i],"end",values=as.tclObj("...Classification"))
			}
		}
	})
}
pb_ma<-tkProgressBar(title="Loading packages...",label="",min=0,max=1,initial=0,width=500)
setTkProgressBar(pb_ma,0.2,title=NULL,label="")
if(!requireNamespace("gWidgets2tcltk",quietly=TRUE)){install.packages("gWidgets2tcltk");library(gWidgets2tcltk)} else {library(gWidgets2tcltk)}
setTkProgressBar(pb_ma,0.6,title=NULL,label="")
if(!requireNamespace("tkrplot",quietly=TRUE)){install.packages("tkrplot");library(tkrplot)} else {library(tkrplot)}
setTkProgressBar(pb_ma,1,title="Done...",label="")				
close(pb_ma)
clas()
