diff options
author | zsloan | 2021-01-12 17:56:52 -0600 |
---|---|---|
committer | zsloan | 2021-01-12 17:56:52 -0600 |
commit | 7d97698ca88460c2f66b67ada31085b02cbc9ee4 (patch) | |
tree | 3a5736b1ba9b14948197e54186851a487482ae5f | |
parent | b3aba44e452fbfeb9f79c91f94b00061057937a4 (diff) | |
download | genenetwork2-7d97698ca88460c2f66b67ada31085b02cbc9ee4.tar.gz |
Fixed a bunch fo remaining issues with positioning legend items on the right side of the mapping figure
-rw-r--r-- | wqflask/wqflask/marker_regression/display_mapping_results.py | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py index 9f778160..bba08f63 100644 --- a/wqflask/wqflask/marker_regression/display_mapping_results.py +++ b/wqflask/wqflask/marker_regression/display_mapping_results.py @@ -860,7 +860,10 @@ class DisplayMappingResults(object): text='%2.1f'%item, font=bootScaleFont, fill=BLACK) if self.legendChecked: - startPosY = 30 + if hasattr(self.traitList[0], 'chr') and hasattr(self.traitList[0], 'mb'): + startPosY = 30 + else: + startPosY = 15 smallLabelFont = ImageFont.truetype(font=TREBUC_FILE, size=12*fontZoom) leftOffset = canvas.size[0] - xRightOffset - 190 im_drawer.rectangle( @@ -942,28 +945,6 @@ class DisplayMappingResults(object): draw_open_polygon(canvas, xy=traitPixel, outline=BLACK, fill=self.TRANSCRIPT_LOCATION_COLOR) - if self.legendChecked: - startPosY = 15 - nCol = 2 - smallLabelFont = ImageFont.truetype(font=TREBUC_FILE, size=12*fontZoom) - if self.manhattan_plot: - leftOffset = xLeftOffset - else: - leftOffset = xLeftOffset+(nCol-1)*200*fontZoom - draw_open_polygon( - canvas, - xy=( - (leftOffset+7, startPosY-7), - (leftOffset, startPosY+7), - (leftOffset+14, startPosY+7)), - outline=BLACK, fill=self.TRANSCRIPT_LOCATION_COLOR - ) - TEXT_Y_DISPLACEMENT = -8 - im_drawer.text( - text="Sequence Site", - xy=(leftOffset+15, startPosY+TEXT_Y_DISPLACEMENT), font=smallLabelFont, - fill=self.TOP_RIGHT_INFO_COLOR) - def drawSNPTrackNew(self, canvas, offset= (40, 120, 80, 10), zoom = 1, startMb = None, endMb = None): im_drawer = ImageDraw.Draw(canvas) if self.plotScale != 'physic' or self.selectedChr == -1 or not self.diffCol: @@ -1060,17 +1041,38 @@ class DisplayMappingResults(object): labelFont=ImageFont.truetype(font=TREBUC_FILE, size=12*fontZoom) startPosY = 15 stepPosY = 12*fontZoom + + startPosX = canvas.size[0] - xRightOffset - 415 + if hasattr(self.traitList[0], 'chr') and hasattr(self.traitList[0], 'mb'): + startPosY = 15 + nCol = 2 + smallLabelFont = ImageFont.truetype(font=TREBUC_FILE, size=12*fontZoom) + + leftOffset = canvas.size[0] - xRightOffset - 190 + draw_open_polygon( + canvas, + xy=( + (leftOffset + 6, startPosY-7), + (leftOffset - 1, startPosY+7), + (leftOffset + 13, startPosY+7)), + outline=BLACK, fill=self.TRANSCRIPT_LOCATION_COLOR + ) + TEXT_Y_DISPLACEMENT = -8 + im_drawer.text( + text="Sequence Site", + xy=(leftOffset + 20, startPosY+TEXT_Y_DISPLACEMENT), font=smallLabelFont, + fill=self.TOP_RIGHT_INFO_COLOR) + if self.manhattan_plot != True: im_drawer.line( - xy=((xLeftOffset, startPosY), (xLeftOffset+32, startPosY)), + xy=((startPosX, startPosY), (startPosX+32, startPosY)), fill=self.LRS_COLOR, width=2) im_drawer.text( - text=self.LRS_LOD, xy=(xLeftOffset+40, startPosY+TEXT_Y_DISPLACEMENT), + text=self.LRS_LOD, xy=(startPosX+40, startPosY+TEXT_Y_DISPLACEMENT), font=labelFont, fill=BLACK) startPosY += stepPosY if self.additiveChecked: - startPosX = canvas.size[0] - xRightOffset - 400 im_drawer.line( xy=((startPosX, startPosY), (startPosX+17, startPosY)), fill=self.ADDITIVE_COLOR_POSITIVE, width=2) @@ -1080,10 +1082,9 @@ class DisplayMappingResults(object): im_drawer.text( text='Additive Effect', xy=(startPosX+40, startPosY+TEXT_Y_DISPLACEMENT), font=labelFont, fill=BLACK) + startPosY += stepPosY if self.genotype.type == 'intercross' and self.dominanceChecked: - startPosX = canvas.size[0] - xRightOffset - 400 - startPosY += stepPosY im_drawer.line( xy=((startPosX, startPosY), (startPosX+17, startPosY)), fill=self.DOMINANCE_COLOR_POSITIVE, width=4) @@ -1093,44 +1094,42 @@ class DisplayMappingResults(object): im_drawer.text( text='Dominance Effect', xy=(startPosX+42, startPosY+5), font=labelFont, fill=BLACK) + startPosY += stepPosY if self.haplotypeAnalystChecked: - startPosY += stepPosY - startPosX = canvas.size[0] - xRightOffset - 400 im_drawer.line( - xy=((startPosX, startPosY), (startPosX+17, startPosY)), + xy=((startPosX-34, startPosY), (startPosX-17, startPosY)), fill=self.HAPLOTYPE_POSITIVE, width=4) im_drawer.line( - xy=((startPosX+18, startPosY), (startPosX+35, startPosY)), + xy=((startPosX-17, startPosY), (startPosX, startPosY)), fill=self.HAPLOTYPE_NEGATIVE, width=4) im_drawer.line( - xy=((startPosX+36, startPosY), (startPosX+53, startPosY)), + xy=((startPosX, startPosY), (startPosX+17, startPosY)), fill=self.HAPLOTYPE_HETEROZYGOUS, width=4) im_drawer.line( - xy=((startPosX+54, startPosY), (startPosX+67, startPosY)), + xy=((startPosX+17, startPosY), (startPosX+34, startPosY)), fill=self.HAPLOTYPE_RECOMBINATION, width=4) im_drawer.text( text='Haplotypes (Pat, Mat, Het, Unk)', - xy=(startPosX+76, startPosY+5), font=labelFont, fill=BLACK) + xy=(startPosX+41, startPosY+TEXT_Y_DISPLACEMENT), font=labelFont, fill=BLACK) + startPosY += stepPosY if self.permChecked and self.nperm > 0: - startPosY += stepPosY - if self.bootChecked and not self.multipleInterval: - startPosX = canvas.size[0] - xRightOffset - 400 - else: - startPosX = canvas.size[0] - xRightOffset - 190 + thisStartX = startPosX + if self.multipleInterval and not self.bootChecked: + thisStartX = canvas.size[0] - xRightOffset - 205 im_drawer.line( - xy=((startPosX, startPosY), ( startPosX + 32, startPosY)), + xy=((thisStartX, startPosY), ( startPosX + 32, startPosY)), fill=self.SIGNIFICANT_COLOR, width=self.SIGNIFICANT_WIDTH) im_drawer.line( - xy=((startPosX, startPosY + stepPosY), ( startPosX + 32, startPosY + stepPosY)), + xy=((thisStartX, startPosY + stepPosY), ( startPosX + 32, startPosY + stepPosY)), fill=self.SUGGESTIVE_COLOR, width=self.SUGGESTIVE_WIDTH) im_drawer.text( text='Significant %s = %2.2f' % (self.LRS_LOD, self.significant), - xy=(startPosX+42, startPosY+TEXT_Y_DISPLACEMENT), font=labelFont, fill=BLACK) + xy=(thisStartX+40, startPosY+TEXT_Y_DISPLACEMENT), font=labelFont, fill=BLACK) im_drawer.text( text='Suggestive %s = %2.2f' % (self.LRS_LOD, self.suggestive), - xy=(startPosX+42, startPosY + TEXT_Y_DISPLACEMENT +stepPosY), font=labelFont, + xy=(thisStartX+40, startPosY + TEXT_Y_DISPLACEMENT +stepPosY), font=labelFont, fill=BLACK) labelFont = ImageFont.truetype(font=VERDANA_FILE, size=12*fontZoom) |