Skip to content

Commit

Permalink
Fix bed track when no intervals are in the regions displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
e-sollier committed Nov 5, 2024
1 parent a7e023c commit 088a63f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion figeno/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from figeno.cli import gui, init,make

__version__ = "1.6.1"
__version__ = "1.6.2"

def main():
parser = ArgumentParser("figeno",formatter_class=ArgumentDefaultsHelpFormatter)
Expand Down
2 changes: 1 addition & 1 deletion figeno/gui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "figeno",
"version": "1.6.1",
"version": "1.6.2",
"private": true,
"homepage": "./",
"dependencies": {
Expand Down
10 changes: 6 additions & 4 deletions figeno/track_bed.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def draw(self, regions, box ,hmargin,warnings):

boxes = split_box(box,regions,hmargin)
lines_regions=self.read_records_regions(regions)
if (box["top"]-box["bottom"])/len(lines_regions[0])<3.5 and self.show_names:
number_of_lines=max(1,len(lines_regions[0]))
if (box["top"]-box["bottom"])/number_of_lines<3.5 and self.show_names:
warnings.append("The bed track is very dense ({} lines for a height of {} mm). You might want to increase the height for this track or to not show names.".format(len(lines_regions[0]),self.height))
for i in range(len(regions)):
self.draw_region(regions[i][0],boxes[i],lines_regions[i],warnings)
Expand All @@ -59,12 +60,13 @@ def draw(self, regions, box ,hmargin,warnings):

def draw_region(self,region,box,lines,warnings):
if self.bounding_box: draw_bounding_box(box)
number_of_lines=max(1,len(lines))

if self.show_names:
rect_height = (box["top"]-box["bottom"]) * 0.4 / len(lines)
rect_height = (box["top"]-box["bottom"]) * 0.4 / number_of_lines
#rect_bottom = box["bottom"] + (box["top"]-box["bottom"]) * 0.08
else:
rect_height = (box["top"]-box["bottom"]) * 0.7 / len(lines)
rect_height = (box["top"]-box["bottom"]) * 0.7 / number_of_lines
#rect_bottom = box["bottom"] + (box["top"]-box["bottom"]) * 0.15

# Params for strand
Expand All @@ -76,7 +78,7 @@ def draw_region(self,region,box,lines,warnings):
fontsize = 8*self.fontscale if len(lines)<=1 else 6*self.fontscale

for line_index,line in enumerate(lines):
line_bottom = box["bottom"] + (box["top"]-box["bottom"])/len(lines) * line_index + (box["top"]-box["bottom"]) * 0.15 / len(lines)
line_bottom = box["bottom"] + (box["top"]-box["bottom"])/number_of_lines * line_index + (box["top"]-box["bottom"]) * 0.15 / len(lines)
for bedrect in line:
if region.orientation=="+":
converted_start = box["left"] + (bedrect.start-region.start) / (region.end-region.start) * (box["right"] - box["left"])
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ packages = ["figeno", "figeno.data", "figeno.cli", "figeno.gui"]

[project]
name = 'figeno'
version = "1.6.1"
version = "1.6.2"
description = 'Package for generating genomics figures.'
readme = 'README.md'
authors = [
Expand Down

0 comments on commit 088a63f

Please sign in to comment.