コード例 #1
0
def plotNormalProbability(vals=None, RISet='', title=None, showstrains=0, specialStrains=[None], size=(750,500)):
		
	dataXZ = vals[:]
	dataXZ.sort(webqtlUtil.cmpOrder)
	dataLabel = []
	dataX = map(lambda X: X[1], dataXZ)

	showLabel = showstrains
	if len(dataXZ) > 50:
		showLabel = 0
	for item in dataXZ:
		strainName = webqtlUtil.genShortStrainName(RISet=RISet, input_strainName=item[0])
		dataLabel.append(strainName)					

	dataY=Plot.U(len(dataX))
	dataZ=map(Plot.inverseCumul,dataY)
	c = pid.PILCanvas(size=(750,500))
	Plot.plotXY(c, dataZ, dataX, dataLabel = dataLabel, XLabel='Expected Z score', connectdot=0, YLabel='Trait value', title=title, specialCases=specialStrains, showLabel = showLabel)

	filename= webqtlUtil.genRandStr("nP_")
	c.save(webqtlConfig.IMGDIR+filename, format='gif')

	img=HT.Image('/image/'+filename+'.gif',border=0)
	
	return img	
コード例 #2
0
    def screePlot(self, NNN=0, pearsonEigenValue=None):

        c1 = pid.PILCanvas(size=(700,500))
        Plot.plotXY(canvas=c1, dataX=range(1,NNN+1), dataY=pearsonEigenValue, rank=0, labelColor=pid.blue,plotColor=pid.red, symbolColor=pid.blue, XLabel='Factor Number', connectdot=1,YLabel='Percent of Total Variance %', title='Pearson\'s R Scree Plot')
        filename= webqtlUtil.genRandStr("Scree_")
        c1.save(webqtlConfig.IMGDIR+filename, format='gif')
        img=HT.Image('/image/'+filename+'.gif',border=0)
        
        return img
コード例 #3
0
 def factorLoadingsPlot(self, pearsonEigenVectors=None, traitList=None):
     
     traitname = map(lambda X:str(X.name), traitList)
     c2 = pid.PILCanvas(size=(700,500))
     Plot.plotXY(c2, pearsonEigenVectors[0],pearsonEigenVectors[1], 0, dataLabel = traitname, labelColor=pid.blue, plotColor=pid.red, symbolColor=pid.blue,XLabel='Factor (1)', connectdot=1, YLabel='Factor (2)', title='Factor Loadings Plot (Pearson)', loadingPlot=1)
     filename= webqtlUtil.genRandStr("FacL_")
     c2.save(webqtlConfig.IMGDIR+filename, format='gif')
     img = HT.Image('/image/'+filename+'.gif',border=0)
  
     return img
コード例 #4
0
 def factorLoadingsPlot(self, pearsonEigenVectors=None, traitList=None):
     traitname = map(lambda X:str(X.name), traitList)
     c2 = pid.PILCanvas(size=(700,500))
     if type(pearsonEigenVectors[0][0]).__name__ == 'complex':
         pearsonEigenVectors_0 = self.removeimag_array(values=pearsonEigenVectors[0])
     else:
         pearsonEigenVectors_0 = pearsonEigenVectors[0]
     if type(pearsonEigenVectors[1][0]).__name__ == 'complex':
         pearsonEigenVectors_1 = self.removeimag_array(values=pearsonEigenVectors[1])
     else:
         pearsonEigenVectors_1 = pearsonEigenVectors[1]
     Plot.plotXY(c2, pearsonEigenVectors_0,pearsonEigenVectors_1, 0, dataLabel = traitname, labelColor=pid.blue, plotColor=pid.red, symbolColor=pid.blue,XLabel='Factor (1)', connectdot=1, YLabel='Factor (2)', title='Factor Loadings Plot (Pearson)', loadingPlot=1)
     filename= webqtlUtil.genRandStr("FacL_")
     c2.save(webqtlConfig.IMGDIR+filename, format='gif')
     img = HT.Image('/image/'+filename+'.gif',border=0)
  
     return img
コード例 #5
0
	def __init__(self, fd):

		templatePage.__init__(self, fd)

		self.initializeDisplayParameters(fd)

		if not fd.genotype:
			fd.readGenotype()

		if fd.allstrainlist:
			mdpchoice = fd.formdata.getvalue('MDPChoice')
			if mdpchoice == "1":
				strainlist = fd.f1list + fd.strainlist
			elif mdpchoice == "2":
				strainlist = []
				strainlist2 = fd.f1list + fd.strainlist
				for strain in fd.allstrainlist:
					if strain not in strainlist2:
						strainlist.append(strain)
				#So called MDP Panel
				if strainlist:
					strainlist = fd.f1list+fd.parlist+strainlist
			else:
				strainlist = fd.allstrainlist
			fd.readData(fd.allstrainlist)
		else:
			mdpchoice = None
			strainlist = fd.strainlist
			fd.readData()

		#if fd.allstrainlist:
		#	fd.readData(fd.allstrainlist)
		#	strainlist = fd.allstrainlist
		#else:
		#	fd.readData()
		#	strainlist = fd.strainlist
		
		
		if not self.openMysql():
			return

		isSampleCorr = 0 #XZ: initial value is false
		isTissueCorr = 0 #XZ: initial value is false

		#Javascript functions (showCorrelationPlot2, showTissueCorrPlot) have made sure the correlation type is either sample correlation or tissue correlation.
		if (self.database and (self.ProbeSetID != 'none')):
			isSampleCorr = 1
		elif (self.X_geneSymbol and self.Y_geneSymbol):
			isTissueCorr = 1
		else:
			heading = "Correlation Type Error"
			detail = ["For the input parameters, GN can not recognize the correlation type is sample correlation or tissue correlation."]
			self.error(heading=heading,detail=detail)
			return


        	TD_LR = HT.TD(colspan=2,height=200,width="100%",bgColor='#eeeeee', align="left", wrap="off")


		dataX=[]
		dataY=[]
		dataZ=[] # shortname
		fullTissueName=[]

		if isTissueCorr:
			dataX, dataY, xlabel, ylabel, dataZ, fullTissueName = self.getTissueLabelsValues(X_geneSymbol=self.X_geneSymbol, Y_geneSymbol=self.Y_geneSymbol, TissueProbeSetFreezeId=self.TissueProbeSetFreezeId)
			plotHeading = HT.Paragraph('Tissue Correlation Scatterplot')
			plotHeading.__setattr__("class","title")

			if self.xAxisLabel == '':
				self.xAxisLabel = xlabel

			if self.yAxisLabel == '':
				self.yAxisLabel = ylabel
			
		if isSampleCorr:
			plotHeading = HT.Paragraph('Sample Correlation Scatterplot')
                        plotHeading.__setattr__("class","title")

			#XZ: retrieve trait 1 info, Y axis
			trait1_data = [] #trait 1 data
			trait1Url = ''

			try:
				Trait1 = webqtlTrait(db=self.database, name=self.ProbeSetID, cellid=self.CellID, cursor=self.cursor)
				Trait1.retrieveInfo()
				Trait1.retrieveData()
			except:
				heading = "Retrieve Data"
				detail = ["The database you just requested has not been established yet."]
				self.error(heading=heading,detail=detail)
				return
	
			trait1_data = Trait1.exportData(strainlist)
			if Trait1.db.type == 'Publish' and Trait1.confidential:
				trait1Url = Trait1.genHTML(dispFromDatabase=1, privilege=self.privilege, userName=self.userName, authorized_users=Trait1.authorized_users)
			else:
				trait1Url = Trait1.genHTML(dispFromDatabase=1)
			
			if self.yAxisLabel == '':
				self.yAxisLabel= '%s : %s' % (Trait1.db.shortname, Trait1.name)
				if Trait1.cellid:
					self.yAxisLabel += ' : ' + Trait1.cellid


			#XZ, retrieve trait 2 info, X axis
			traitdata2 = [] #trait 2 data
			_vals = [] #trait 2 data
			trait2Url = ''

			if ( self.database2 and (self.ProbeSetID2 != 'none') ):
				try:
					Trait2 = webqtlTrait(db=self.database2, name=self.ProbeSetID2, cellid=self.CellID2, cursor=self.cursor)
					Trait2.retrieveInfo()
					Trait2.retrieveData()
				except:
					heading = "Retrieve Data"
					detail = ["The database you just requested has not been established yet."]
					self.error(heading=heading,detail=detail)
					return

				if Trait2.db.type == 'Publish' and Trait2.confidential:
					trait2Url = Trait2.genHTML(dispFromDatabase=1, privilege=self.privilege, userName=self.userName, authorized_users=Trait2.authorized_users)
				else:
					trait2Url = Trait2.genHTML(dispFromDatabase=1)
				traitdata2 = Trait2.exportData(strainlist)
				_vals = traitdata2[:]
				
				if self.xAxisLabel == '':
					self.xAxisLabel = '%s : %s' % (Trait2.db.shortname, Trait2.name)
					if Trait2.cellid:
						self.xAxisLabel += ' : ' + Trait2.cellid
			else:
				for item in strainlist:
					if fd.allTraitData.has_key(item):
						_vals.append(fd.allTraitData[item].val)
					else:
						_vals.append(None)

				if self.xAxisLabel == '':
					if fd.identification:
						self.xAxisLabel = fd.identification
					else:
						self.xAxisLabel = "User Input Data"

				try:
					Trait2 = webqtlTrait(fullname=fd.formdata.getvalue('fullname'), cursor=self.cursor)
					trait2Url = Trait2.genHTML(dispFromDatabase=1)
				except:
					trait2Url = self.xAxisLabel

			if (_vals and trait1_data):
				if len(_vals) != len(trait1_data):
					errors = HT.Blockquote(HT.Font('Error: ',color='red'),HT.Font('The number of traits are inconsistent, Program quit',color='black'))
					errors.__setattr__("class","subtitle")
					TD_LR.append(errors)
					self.dict['body'] = str(TD_LR)
					return

				for i in range(len(_vals)):
					if _vals[i]!= None and trait1_data[i]!= None:
						dataX.append(_vals[i])
						dataY.append(trait1_data[i])
						strainName = strainlist[i]
						if self.showstrains:
							dataZ.append(webqtlUtil.genShortStrainName(RISet=fd.RISet, input_strainName=strainName))
			else:
				heading = "Correlation Plot"
				detail = ['Empty Dataset for sample correlation, please check your data.']
				self.error(heading=heading,detail=detail)
				return


		#XZ: We have gotten all data for both traits.
		if len(dataX) >= self.corrMinInformative:

			if self.rankOrder == 0:
				rankPrimary = 0
				rankSecondary = 1
			else:
				rankPrimary = 1
				rankSecondary = 0

			lineColor = self.setLineColor();
			symbolColor = self.setSymbolColor();
			idColor = self.setIdColor();					
				
			c = pid.PILCanvas(size=(self.plotSize, self.plotSize*0.90))
			data_coordinate = Plot.plotXY(canvas=c, dataX=dataX, dataY=dataY, rank=rankPrimary, dataLabel = dataZ, labelColor=pid.black, lineSize=self.lineSize, lineColor=lineColor, idColor=idColor, idFont=self.idFont, idSize=self.idSize, symbolColor=symbolColor, symbolType=self.symbol, filled=self.filled, symbolSize=self.symbolSize, XLabel=self.xAxisLabel, connectdot=0, YLabel=self.yAxisLabel, title='', fitcurve=self.showline, displayR =1, offset= (90, self.plotSize/20, self.plotSize/10, 90), showLabel = self.showIdentifiers)
				
			if rankPrimary == 1:
				dataXlabel, dataYlabel = webqtlUtil.calRank(xVals=dataX, yVals=dataY, N=len(dataX))
			else:
				dataXlabel, dataYlabel = dataX, dataY
					
			gifmap1 = HT.Map(name='CorrelationPlotImageMap1')
				
			for i, item in enumerate(data_coordinate):
				one_rect_coordinate = "%d, %d, %d, %d" % (item[0] - 5, item[1] - 5, item[0] + 5, item[1] + 5)
				if isTissueCorr:
					one_rect_title = "%s (%s, %s)" % (fullTissueName[i], dataXlabel[i], dataYlabel[i])
				else:
					one_rect_title = "%s (%s, %s)" % (dataZ[i], dataXlabel[i], dataYlabel[i])
				gifmap1.areas.append(HT.Area(shape='rect',coords=one_rect_coordinate, title=one_rect_title) )

			filename= webqtlUtil.genRandStr("XY_")
			c.save(webqtlConfig.IMGDIR+filename, format='gif')
			img1=HT.Image('/image/'+filename+'.gif',border=0, usemap='#CorrelationPlotImageMap1')

			mainForm_1 = HT.Form( cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), enctype='multipart/form-data', name='showDatabase', submit=HT.Input(type='hidden'))
			hddn = {'FormID':'showDatabase','ProbeSetID':'_','database':'_','CellID':'_','RISet':fd.RISet, 'ProbeSetID2':'_', 'database2':'_', 'CellID2':'_', 'allstrainlist':string.join(fd.strainlist, " "), 'traitList': fd.formdata.getvalue("traitList")}
			if fd.incparentsf1:
				hddn['incparentsf1'] = 'ON'		
			for key in hddn.keys():
				mainForm_1.append(HT.Input(name=key, value=hddn[key], type='hidden'))
			
			if isSampleCorr:
					mainForm_1.append(HT.P(), HT.Blockquote(HT.Strong('X axis:'),HT.Blockquote(trait2Url),HT.Strong('Y axis:'),HT.Blockquote(trait1Url), style='width: %spx;' % self.plotSize, wrap="hard"))
			
			graphForm = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), name='MDP_Form',submit=HT.Input(type='hidden'))
			graph_hddn = self.setHiddenParameters(fd, rankPrimary)
			webqtlUtil.exportData(graph_hddn, fd.allTraitData) #XZ: This is necessary to replot with different groups of strains
							
			for key in graph_hddn.keys():
				graphForm.append(HT.Input(name=key, value=graph_hddn[key], type='hidden'))			

			options = self.createOptionsMenu(fd, mdpchoice)	
			
			if (self.showOptions == '0'):
					showOptionsButton = HT.Input(type='button' ,name='optionsButton',value='Hide Options', onClick="showHideOptions();", Class="button")
			else:
					showOptionsButton = HT.Input(type='button' ,name='optionsButton',value='Show Options', onClick="showHideOptions();", Class="button")
					
			# updated by NL: 12-07-2011 add variables for tissue abbreviation page
			if isTissueCorr: 
				graphForm.append(HT.Input(name='shortTissueName', value='', type='hidden'))
				graphForm.append(HT.Input(name='fullTissueName', value='', type='hidden'))
				shortTissueNameStr=string.join(dataZ, ",")
				fullTissueNameStr=string.join(fullTissueName, ",")
		
				tissueAbbrButton=HT.Input(type='button' ,name='tissueAbbrButton',value='Show Abbreviations', onClick="showTissueAbbr('MDP_Form','%s','%s')" % (shortTissueNameStr,fullTissueNameStr), Class="button")
				graphForm.append(showOptionsButton,'    ',tissueAbbrButton, HT.BR(), HT.BR())
			else:
				graphForm.append(showOptionsButton, HT.BR(), HT.BR())

			graphForm.append(options, HT.BR())				
			graphForm.append(HT.HR(), HT.BR(), HT.P())
						
			TD_LR.append(plotHeading, HT.BR(),graphForm, HT.BR(), gifmap1, HT.P(), img1, HT.P(), mainForm_1)
			TD_LR.append(HT.BR(), HT.HR(color="grey", size=5, width="100%"))



			c = pid.PILCanvas(size=(self.plotSize, self.plotSize*0.90))
			data_coordinate = Plot.plotXY(canvas=c, dataX=dataX, dataY=dataY, rank=rankSecondary, dataLabel = dataZ, labelColor=pid.black,lineColor=lineColor, lineSize=self.lineSize, idColor=idColor, idFont=self.idFont, idSize=self.idSize, symbolColor=symbolColor, symbolType=self.symbol, filled=self.filled, symbolSize=self.symbolSize, XLabel=self.xAxisLabel, connectdot=0, YLabel=self.yAxisLabel,title='', fitcurve=self.showline, displayR =1, offset= (90, self.plotSize/20, self.plotSize/10, 90), showLabel = self.showIdentifiers)

			if rankSecondary == 1:
				dataXlabel, dataYlabel = webqtlUtil.calRank(xVals=dataX, yVals=dataY, N=len(dataX))
			else:
				dataXlabel, dataYlabel = dataX, dataY
				
			gifmap2 = HT.Map(name='CorrelationPlotImageMap2')
				
			for i, item in enumerate(data_coordinate):
				one_rect_coordinate = "%d, %d, %d, %d" % (item[0] - 6, item[1] - 6, item[0] + 6, item[1] + 6)
				if isTissueCorr:
					one_rect_title = "%s (%s, %s)" % (fullTissueName[i], dataXlabel[i], dataYlabel[i])
				else:
					one_rect_title = "%s (%s, %s)" % (dataZ[i], dataXlabel[i], dataYlabel[i])
					
				gifmap2.areas.append(HT.Area(shape='rect',coords=one_rect_coordinate, title=one_rect_title) )

			filename= webqtlUtil.genRandStr("XY_")
			c.save(webqtlConfig.IMGDIR+filename, format='gif')
			img2=HT.Image('/image/'+filename+'.gif',border=0, usemap='#CorrelationPlotImageMap2')

			mainForm_2 = HT.Form( cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), enctype='multipart/form-data', name='showDatabase2', submit=HT.Input(type='hidden'))
			hddn = {'FormID':'showDatabase2','ProbeSetID':'_','database':'_','CellID':'_','RISet':fd.RISet, 'ProbeSetID2':'_', 'database2':'_', 'CellID2':'_', 'allstrainlist':string.join(fd.strainlist, " "), 'traitList': fd.formdata.getvalue("traitList")}
			if fd.incparentsf1:
				hddn['incparentsf1'] = 'ON'
			for key in hddn.keys():
				mainForm_2.append(HT.Input(name=key, value=hddn[key], type='hidden'))
				
			if isSampleCorr:
				mainForm_2.append(HT.P(), HT.Blockquote(HT.Strong('X axis:'),HT.Blockquote(trait2Url),HT.Strong('Y axis:'),HT.Blockquote(trait1Url), style='width:%spx;' % self.plotSize))

	
			TD_LR.append(HT.BR(), HT.P())
			TD_LR.append('\n', gifmap2, HT.P(), HT.P(), img2, HT.P(), mainForm_2)

			self.dict['body'] = str(TD_LR)
		else:
			heading = "Correlation Plot"
			detail = ['Fewer than %d strain data were entered for %s data set. No statitical analysis has been attempted.' % (self.corrMinInformative, fd.RISet)]
			self.error(heading=heading,detail=detail)
			return
コード例 #6
0
    def __init__(self, fd):
        templatePage.__init__(self, fd)
        self.initializeDisplayParameters(fd)
        if not fd.genotype:
            fd.readGenotype()
        mdpchoice = None
        strainlist = fd.strainlist
        fd.readData()
        if not self.openMysql():
            return
        isSampleCorr = 1
        isTissueCorr = 0
        TD_LR = HT.TD(colspan=2, height=200, width="100%", bgColor="#eeeeee", align="left", wrap="off")
        dataX = []
        dataY = []
        dataZ = []  # shortname
        fullTissueName = []
        xlabel = ""
        ylabel = ""
        if isSampleCorr:
            plotHeading = HT.Paragraph("Sample Correlation Scatterplot")
            plotHeading.__setattr__("class", "title")

            # XZ: retrieve trait 1 info, Y axis
            trait1_data = []  # trait 1 data
            trait1Url = ""
            try:
                Trait1 = webqtlTrait(db=self.database, name=self.ProbeSetID, cellid=self.CellID, cursor=self.cursor)
                Trait1.retrieveInfo()
                Trait1.retrieveData()
            except:
                heading = "Retrieve Data"
                detail = ["The database you just requested has not been established yet."]
                self.error(heading=heading, detail=detail)
                return
            trait1_data = Trait1.exportData(strainlist)
            trait1Url = Trait1.genHTML(dispFromDatabase=1)
            ylabel = "%s : %s" % (Trait1.db.shortname, Trait1.name)
            if Trait1.cellid:
                ylabel += " : " + Trait1.cellid

                # XZ, retrieve trait 2 info, X axis
            trait2_data = []  # trait 2 data
            trait2Url = ""
            try:
                Trait2 = webqtlTrait(db=self.database2, name=self.ProbeSetID2, cellid=self.CellID2, cursor=self.cursor)
                Trait2.retrieveInfo()
                Trait2.retrieveData()
            except:
                heading = "Retrieve Data"
                detail = ["The database you just requested has not been established yet."]
                self.error(heading=heading, detail=detail)
                return
            trait2_data = Trait2.exportData(strainlist)
            trait2Url = Trait2.genHTML(dispFromDatabase=1)
            xlabel = "%s : %s" % (Trait2.db.shortname, Trait2.name)
            if Trait2.cellid:
                xlabel += " : " + Trait2.cellid

            for strain in Trait1.data.keys():
                if Trait2.data.has_key(strain):
                    dataX.append(Trait2.data[strain].val)
                    dataY.append(Trait1.data[strain].val)
                    if self.showstrains:
                        dataZ.append(webqtlUtil.genShortStrainName(RISet=fd.RISet, input_strainName=strain))

                # XZ: We have gotten all data for both traits.
        if len(dataX) >= self.corrMinInformative:

            if self.rankOrder == 0:
                rankPrimary = 0
                rankSecondary = 1
            else:
                rankPrimary = 1
                rankSecondary = 0

            lineColor = self.setLineColor()
            symbolColor = self.setSymbolColor()
            idColor = self.setIdColor()

            c = pid.PILCanvas(size=(self.plotSize, self.plotSize * 0.90))
            data_coordinate = Plot.plotXY(
                canvas=c,
                dataX=dataX,
                dataY=dataY,
                rank=rankPrimary,
                dataLabel=dataZ,
                labelColor=pid.black,
                lineSize=self.lineSize,
                lineColor=lineColor,
                idColor=idColor,
                idFont=self.idFont,
                idSize=self.idSize,
                symbolColor=symbolColor,
                symbolType=self.symbol,
                filled=self.filled,
                symbolSize=self.symbolSize,
                XLabel=xlabel,
                connectdot=0,
                YLabel=ylabel,
                title="",
                fitcurve=self.showline,
                displayR=1,
                offset=(90, self.plotSize / 20, self.plotSize / 10, 90),
                showLabel=self.showIdentifiers,
            )

            if rankPrimary == 1:
                dataXlabel, dataYlabel = webqtlUtil.calRank(xVals=dataX, yVals=dataY, N=len(dataX))
            else:
                dataXlabel, dataYlabel = dataX, dataY

            gifmap1 = HT.Map(name="CorrelationPlotImageMap1")

            for i, item in enumerate(data_coordinate):
                one_rect_coordinate = "%d, %d, %d, %d" % (item[0] - 5, item[1] - 5, item[0] + 5, item[1] + 5)
                if isTissueCorr:
                    one_rect_title = "%s (%s, %s)" % (fullTissueName[i], dataXlabel[i], dataYlabel[i])
                else:
                    one_rect_title = "%s (%s, %s)" % (dataZ[i], dataXlabel[i], dataYlabel[i])
                gifmap1.areas.append(HT.Area(shape="rect", coords=one_rect_coordinate, title=one_rect_title))

            filename = webqtlUtil.genRandStr("XY_")
            c.save(webqtlConfig.IMGDIR + filename, format="gif")
            img1 = HT.Image("/image/" + filename + ".gif", border=0, usemap="#CorrelationPlotImageMap1")

            mainForm_1 = HT.Form(
                cgi=os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE),
                enctype="multipart/form-data",
                name="showDatabase",
                submit=HT.Input(type="hidden"),
            )
            hddn = {
                "FormID": "showDatabase",
                "ProbeSetID": "_",
                "database": "_",
                "CellID": "_",
                "RISet": fd.RISet,
                "ProbeSetID2": "_",
                "database2": "_",
                "CellID2": "_",
                "allstrainlist": string.join(fd.strainlist, " "),
                "traitList": fd.formdata.getvalue("traitList"),
            }
            if fd.incparentsf1:
                hddn["incparentsf1"] = "ON"
            for key in hddn.keys():
                mainForm_1.append(HT.Input(name=key, value=hddn[key], type="hidden"))

            if isSampleCorr:
                mainForm_1.append(
                    HT.P(),
                    HT.Blockquote(
                        HT.Strong("X axis:"),
                        HT.Blockquote(trait2Url),
                        HT.Strong("Y axis:"),
                        HT.Blockquote(trait1Url),
                        style="width: %spx;" % self.plotSize,
                        wrap="hard",
                    ),
                )

            graphForm = HT.Form(
                cgi=os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE),
                name="MDP_Form",
                submit=HT.Input(type="hidden"),
            )
            graph_hddn = self.setHiddenParameters(fd, rankPrimary)
            webqtlUtil.exportData(
                graph_hddn, fd.allTraitData
            )  # XZ: This is necessary to replot with different groups of strains

            for key in graph_hddn.keys():
                graphForm.append(HT.Input(name=key, value=graph_hddn[key], type="hidden"))

            options = self.createOptionsMenu(fd, mdpchoice)

            if self.showOptions == "0":
                showOptionsButton = HT.Input(
                    type="button",
                    name="optionsButton",
                    value="Hide Options",
                    onClick="showHideOptions();",
                    Class="button",
                )
            else:
                showOptionsButton = HT.Input(
                    type="button",
                    name="optionsButton",
                    value="Show Options",
                    onClick="showHideOptions();",
                    Class="button",
                )

                # updated by NL: 12-07-2011 add variables for tissue abbreviation page
            if isTissueCorr:
                graphForm.append(HT.Input(name="shortTissueName", value="", type="hidden"))
                graphForm.append(HT.Input(name="fullTissueName", value="", type="hidden"))
                shortTissueNameStr = string.join(dataZ, ",")
                fullTissueNameStr = string.join(fullTissueName, ",")

                tissueAbbrButton = HT.Input(
                    type="button",
                    name="tissueAbbrButton",
                    value="Show Abbreviations",
                    onClick="showTissueAbbr('MDP_Form','%s','%s')" % (shortTissueNameStr, fullTissueNameStr),
                    Class="button",
                )
                graphForm.append(showOptionsButton, "    ", tissueAbbrButton, HT.BR(), HT.BR())
            else:
                graphForm.append(showOptionsButton, HT.BR(), HT.BR())

            graphForm.append(options, HT.BR())
            graphForm.append(HT.HR(), HT.BR(), HT.P())

            TD_LR.append(plotHeading, HT.BR(), graphForm, HT.BR(), gifmap1, HT.P(), img1, HT.P(), mainForm_1)
            TD_LR.append(HT.BR(), HT.HR(color="grey", size=5, width="100%"))

            c = pid.PILCanvas(size=(self.plotSize, self.plotSize * 0.90))
            data_coordinate = Plot.plotXY(
                canvas=c,
                dataX=dataX,
                dataY=dataY,
                rank=rankSecondary,
                dataLabel=dataZ,
                labelColor=pid.black,
                lineColor=lineColor,
                lineSize=self.lineSize,
                idColor=idColor,
                idFont=self.idFont,
                idSize=self.idSize,
                symbolColor=symbolColor,
                symbolType=self.symbol,
                filled=self.filled,
                symbolSize=self.symbolSize,
                XLabel=xlabel,
                connectdot=0,
                YLabel=ylabel,
                title="",
                fitcurve=self.showline,
                displayR=1,
                offset=(90, self.plotSize / 20, self.plotSize / 10, 90),
                showLabel=self.showIdentifiers,
            )

            if rankSecondary == 1:
                dataXlabel, dataYlabel = webqtlUtil.calRank(xVals=dataX, yVals=dataY, N=len(dataX))
            else:
                dataXlabel, dataYlabel = dataX, dataY

            gifmap2 = HT.Map(name="CorrelationPlotImageMap2")

            for i, item in enumerate(data_coordinate):
                one_rect_coordinate = "%d, %d, %d, %d" % (item[0] - 6, item[1] - 6, item[0] + 6, item[1] + 6)
                if isTissueCorr:
                    one_rect_title = "%s (%s, %s)" % (fullTissueName[i], dataXlabel[i], dataYlabel[i])
                else:
                    one_rect_title = "%s (%s, %s)" % (dataZ[i], dataXlabel[i], dataYlabel[i])

                gifmap2.areas.append(HT.Area(shape="rect", coords=one_rect_coordinate, title=one_rect_title))

            filename = webqtlUtil.genRandStr("XY_")
            c.save(webqtlConfig.IMGDIR + filename, format="gif")
            img2 = HT.Image("/image/" + filename + ".gif", border=0, usemap="#CorrelationPlotImageMap2")

            mainForm_2 = HT.Form(
                cgi=os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE),
                enctype="multipart/form-data",
                name="showDatabase2",
                submit=HT.Input(type="hidden"),
            )
            hddn = {
                "FormID": "showDatabase2",
                "ProbeSetID": "_",
                "database": "_",
                "CellID": "_",
                "RISet": fd.RISet,
                "ProbeSetID2": "_",
                "database2": "_",
                "CellID2": "_",
                "allstrainlist": string.join(fd.strainlist, " "),
                "traitList": fd.formdata.getvalue("traitList"),
            }
            if fd.incparentsf1:
                hddn["incparentsf1"] = "ON"
            for key in hddn.keys():
                mainForm_2.append(HT.Input(name=key, value=hddn[key], type="hidden"))

            if isSampleCorr:
                mainForm_2.append(
                    HT.P(),
                    HT.Blockquote(
                        HT.Strong("X axis:"),
                        HT.Blockquote(trait2Url),
                        HT.Strong("Y axis:"),
                        HT.Blockquote(trait1Url),
                        style="width:%spx;" % self.plotSize,
                    ),
                )

            TD_LR.append(HT.BR(), HT.P())
            TD_LR.append("\n", gifmap2, HT.P(), HT.P(), img2, HT.P(), mainForm_2)

            self.dict["body"] = str(TD_LR)
        else:
            heading = "Correlation Plot"
            detail = [
                "Fewer than %d strain data were entered for %s data set. No statitical analysis has been attempted."
                % (self.corrMinInformative, fd.RISet)
            ]
            self.error(heading=heading, detail=detail)
            return