meuleman / epilogos

Methods for summarizing and visualizing multi-biosample functional genomic annotations
https://epilogos.net
GNU General Public License v3.0
41 stars 5 forks source link

Plotregion searches region for nearest bin if no exact match found #32

Closed alexpreynolds closed 1 year ago

alexpreynolds commented 1 year ago

Given an input region from one or more regions, a single- or paired-mode plot request will try to find a subset of scores data from exact start and end coordinates.

Previously, if those coordinates did not match, the processEpilogosScoresForDrawing function would throw an IndexError and terminate.

This commit adds some logic to look for the index of the nearest region to the start and end coordinates, if needed. This can be done easily here because the coordinates within a chromosome are sorted numerically, so we just look for the index of the bin with the minimum absolute distance to the specified start (or end).

If the input region does not work, and if a neighboring region can be found, a notice is sent to standard error that the coordinate will be modified. The plotting code that works downstream of this function will use the modified coordinates for drawing.

If the input region does not work, and if a neighboring region cannot be found for some reason, then a ValueError exception is raised, the program terminates and the user is directed to fix the input region(s).