EBI-Metabolights/SAFERnmr

results browser doesn't allow zoom past a certain point

Closed this issue · 1 comments

browse_evidence() errors (albeit gracefully) when zooming in too much on feature plots. This is since adding interpolation filling of lines.

The issue was: in a set of relevant backfits for a given region, there is often there is a backfit which is indexed for that region but only contains NA values in the coordinates currently being displayed. For example, consider the following set of peaks (^) and backfits (o----oo, where the 'o' is the actual value and '-' is NA):
image

If we zoom in to region [3,5], which is indicated between the pipes, we'll catch the following part of each backfit:
image
When this region gets passed to the plotting function fastStack() (and its accessory, addpoints_as_needed()), it will try to interpolate to fill the following vectors:
image
As you can see, the first two are all - NA and cannot be interpolated as such. Additionally, when the x inds are calculated at the beginning of the addpoints_as_needed() internal loop, the range() function is used and returns Inf.

This is fixed by adding the following at the beginning of the loop:

    if (all(is.na(v))){
      return(list(new.xvals = new.xvals,
                        new.vals = new.vals))
    }