oncoprintjs 6.1.2 → 6.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oncoprintjs",
3
- "version": "6.1.2",
3
+ "version": "6.1.4",
4
4
  "description": "A data visualization for cancer genomic data.",
5
5
  "types": "./dist/js/oncoprint.d.ts",
6
6
  "main": "dist/index.js",
@@ -57,5 +57,5 @@
57
57
  "tayden-clusterfck": "^0.7.0",
58
58
  "typescript": "4.0.3"
59
59
  },
60
- "gitHead": "727d3a488de0851176ae5660769364e276b94bc7"
60
+ "gitHead": "e7abcbd899e0d4b0252fa3f9b1d955c296dd111a"
61
61
  }
@@ -1708,9 +1708,14 @@ export default class OncoprintModel {
1708
1708
  return null;
1709
1709
  }
1710
1710
 
1711
- // Next, see if it's in a track
1711
+ // Next, see if it's in a track.
1712
+ // Try binary search first for performance, but fall back to linear
1713
+ // scan if the result is invalid. cell_tops may not be monotonically
1714
+ // ordered relative to the tracks array during async clustering
1715
+ // transitions, which causes binary search to return wrong results.
1712
1716
  const tracks = this.getTracks();
1713
1717
  const cell_tops = this.getCellTops() as TrackProp<number>;
1718
+ let nearest_track: TrackId | undefined;
1714
1719
  const nearest_track_index = binarysearch(
1715
1720
  tracks,
1716
1721
  y,
@@ -1719,12 +1724,29 @@ export default class OncoprintModel {
1719
1724
  },
1720
1725
  true
1721
1726
  );
1722
- if (nearest_track_index === -1) {
1723
- return null;
1727
+ if (nearest_track_index !== -1) {
1728
+ const candidate = tracks[nearest_track_index];
1729
+ if (
1730
+ y >= cell_tops[candidate] &&
1731
+ y < cell_tops[candidate] + this.getCellHeight(candidate)
1732
+ ) {
1733
+ nearest_track = candidate;
1734
+ }
1735
+ }
1736
+ if (nearest_track === undefined) {
1737
+ // Binary search failed (tracks out of order) - linear fallback
1738
+ for (let t = 0; t < tracks.length; t++) {
1739
+ const top = cell_tops[tracks[t]];
1740
+ if (
1741
+ y >= top &&
1742
+ y < top + this.getCellHeight(tracks[t])
1743
+ ) {
1744
+ nearest_track = tracks[t];
1745
+ break;
1746
+ }
1747
+ }
1724
1748
  }
1725
- const nearest_track = tracks[nearest_track_index];
1726
- if (y >= cell_tops[nearest_track] + this.getCellHeight(nearest_track)) {
1727
- // we know y is past the top of the track (>= cell_tops[nearest_track]), so this checks if y is past the bottom of the track
1749
+ if (nearest_track === undefined) {
1728
1750
  return null;
1729
1751
  }
1730
1752