oncoprintjs 6.0.4 → 6.0.6

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.
@@ -1,7 +1,7 @@
1
1
  /// <reference types="jquery" />
2
2
  /// <reference types="jstree" />
3
3
  import './polyfill';
4
- import OncoprintModel, { ColumnId, ColumnLabel, ColumnProp, CustomTrackOption, Datum, SortConfig, TrackGroupHeader, TrackGroupIndex, TrackId, TrackSortDirection, TrackSortSpecification, TrackTooltipFn, UserTrackSpec } from './oncoprintmodel';
4
+ import OncoprintModel, { ColumnId, ColumnLabel, ColumnProp, CustomTrackOption, Datum, GAP_MODE_ENUM, SortConfig, TrackGroupHeader, TrackGroupIndex, TrackId, TrackSortDirection, TrackSortSpecification, TrackTooltipFn, UserTrackSpec } from './oncoprintmodel';
5
5
  import OncoprintWebGLCellView from './oncoprintwebglcellview';
6
6
  import OncoprintLabelView from './oncoprintlabelview';
7
7
  import { RuleSetParams } from './oncoprintruleset';
@@ -129,7 +129,7 @@ export default class Oncoprint {
129
129
  setTrackInfo(track_id: TrackId, msg: string): void;
130
130
  setTrackTooltipFn(track_id: TrackId, tooltipFn: TrackTooltipFn<Datum>): void;
131
131
  setShowTrackSublabels(show: boolean): void;
132
- setTrackShowGaps(track_id: TrackId, showGaps: boolean): void;
132
+ setTrackShowGaps(track_id: TrackId, gap_mode: GAP_MODE_ENUM): void;
133
133
  sort(): void;
134
134
  shareRuleSet(source_track_id: TrackId, target_track_id: TrackId): void;
135
135
  setRuleSet(track_id: TrackId, rule_set_params: RuleSetParams): void;
@@ -5,6 +5,11 @@ import { RuleSet, RuleSetParams, RuleWithId } from './oncoprintruleset';
5
5
  import { InitParams } from './oncoprint';
6
6
  import { ComputedShapeParams } from './oncoprintshape';
7
7
  import { OncoprintGapConfig } from './oncoprintwebglcellview';
8
+ export declare enum GAP_MODE_ENUM {
9
+ SHOW_GAPS = "SHOW_GAPS",
10
+ SHOW_GAPS_PERCENT = "SHOW_GAPS_PERCENT",
11
+ HIDE_GAPS = "HIDE_GAPS"
12
+ }
8
13
  export declare type ColumnId = string;
9
14
  export declare type ColumnIndex = number;
10
15
  export declare type TrackId = number;
@@ -44,7 +49,7 @@ export declare type ActiveRulesCount = {
44
49
  [ruleId: number]: number;
45
50
  };
46
51
  export declare type TrackSortDirectionChangeCallback = (track_id: TrackId, dir: number) => void;
47
- export declare type TrackGapChangeCallBack = (track_id: TrackId, on: boolean) => void;
52
+ export declare type TrackGapChangeCallBack = (track_id: TrackId, mode: GAP_MODE_ENUM) => void;
48
53
  export declare type CustomTrackOption = {
49
54
  label?: string;
50
55
  separator?: boolean;
@@ -238,8 +243,8 @@ export default class OncoprintModel {
238
243
  private unclustered_track_group_order?;
239
244
  private track_group_sort_priority;
240
245
  constructor(params: InitParams);
241
- setTrackShowGaps(trackId: TrackId, show: boolean): void;
242
- getTrackShowGaps(trackId: TrackId): boolean;
246
+ setTrackShowGaps(trackId: TrackId, show: GAP_MODE_ENUM): void;
247
+ getTrackShowGaps(trackId: TrackId): GAP_MODE_ENUM;
243
248
  getTrackCanShowGaps(trackId: TrackId): boolean;
244
249
  getColumnIndexesAfterAGap(): number[];
245
250
  setTrackGroupHeader(index: TrackGroupIndex, header?: TrackGroupHeader): void;
@@ -337,6 +342,7 @@ export default class OncoprintModel {
337
342
  getOncoprintHeight(base?: boolean): number;
338
343
  getOncoprintWidth(base?: boolean): number;
339
344
  showGaps(): boolean;
345
+ gapMode(): GAP_MODE_ENUM | GAP_MODE_ENUM.HIDE_GAPS;
340
346
  getOncoprintWidthNoColumnPaddingNoGaps(): number;
341
347
  getColumnLabels(): ColumnProp<ColumnLabel>;
342
348
  setColumnLabels(labels: ColumnProp<ColumnLabel>): void;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="jquery" />
2
2
  /// <reference types="jstree" />
3
- import OncoprintModel, { TrackId, TrackSortDirection } from './oncoprintmodel';
3
+ import OncoprintModel, { GAP_MODE_ENUM, TrackId, TrackSortDirection } from './oncoprintmodel';
4
4
  export declare const CLOSE_MENUS_EVENT = "oncoprint-track-options-view.do-close-menus";
5
5
  declare type TrackCallback = (trackId: TrackId) => void;
6
6
  export default class OncoprintTrackOptionsView {
@@ -20,7 +20,7 @@ export default class OncoprintTrackOptionsView {
20
20
  private menu_shown;
21
21
  private clickHandler;
22
22
  private interaction_disabled;
23
- constructor($div: JQuery, moveUpCallback: TrackCallback, moveDownCallback: TrackCallback, removeCallback: TrackCallback, sortChangeCallback: (trackId: TrackId, sortDirection: TrackSortDirection) => void, unexpandCallback: TrackCallback, showGapsCallback: (trackId: TrackId, showGaps: boolean) => void);
23
+ constructor($div: JQuery, moveUpCallback: TrackCallback, moveDownCallback: TrackCallback, removeCallback: TrackCallback, sortChangeCallback: (trackId: TrackId, sortDirection: TrackSortDirection) => void, unexpandCallback: TrackCallback, showGapsCallback: (trackId: TrackId, showGaps: GAP_MODE_ENUM) => void);
24
24
  private renderAllOptions;
25
25
  private scroll;
26
26
  private resize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oncoprintjs",
3
- "version": "6.0.4",
3
+ "version": "6.0.6",
4
4
  "description": "A data visualization for cancer genomic data.",
5
5
  "types": "./dist/js/oncoprint.d.ts",
6
6
  "main": "dist/index.js",
@@ -60,5 +60,5 @@
60
60
  "tayden-clusterfck": "^0.7.0",
61
61
  "typescript": "4.0.3"
62
62
  },
63
- "gitHead": "00743bcfb9d752deabdcb1e8235cdb9cc0feb7c5"
63
+ "gitHead": "62335e5640758e0eb98115b13d0867edb81e19d0"
64
64
  }
package/src/index.tsx CHANGED
@@ -9,6 +9,6 @@ export {
9
9
  } from './js/oncoprint';
10
10
 
11
11
  export * from './js/oncoprintruleset';
12
- export { default as OncoprintModel } from './js/oncoprintmodel';
12
+ export { default as OncoprintModel, GAP_MODE_ENUM } from './js/oncoprintmodel';
13
13
  export * from './js/oncoprintmodel';
14
14
  export { default as shapeToSvg } from './js/oncoprintshapetosvg';
@@ -6,9 +6,9 @@ import OncoprintModel, {
6
6
  ColumnProp,
7
7
  CustomTrackOption,
8
8
  Datum,
9
+ GAP_MODE_ENUM,
9
10
  LibraryTrackSpec,
10
11
  SortConfig,
11
- TrackGroup,
12
12
  TrackGroupHeader,
13
13
  TrackGroupIndex,
14
14
  TrackId,
@@ -1234,7 +1234,7 @@ export default class Oncoprint {
1234
1234
 
1235
1235
  if (this.model.getTrackSortDirection(track_id) === 0) {
1236
1236
  if (this.model.getTrackShowGaps(track_id)) {
1237
- this.setTrackShowGaps(track_id, false);
1237
+ this.setTrackShowGaps(track_id, GAP_MODE_ENUM.HIDE_GAPS);
1238
1238
  }
1239
1239
  }
1240
1240
  }
@@ -1292,9 +1292,12 @@ export default class Oncoprint {
1292
1292
  this.resizeAndOrganizeAfterTimeout();
1293
1293
  }
1294
1294
 
1295
- public setTrackShowGaps(track_id: TrackId, showGaps: boolean) {
1296
- this.model.setTrackShowGaps(track_id, showGaps);
1297
- if (this.model.getTrackSortDirection(track_id) === 0 && showGaps) {
1295
+ public setTrackShowGaps(track_id: TrackId, gap_mode: GAP_MODE_ENUM) {
1296
+ this.model.setTrackShowGaps(track_id, gap_mode);
1297
+ if (
1298
+ this.model.getTrackSortDirection(track_id) === 0 &&
1299
+ gap_mode !== GAP_MODE_ENUM.HIDE_GAPS
1300
+ ) {
1298
1301
  this.setTrackSortDirection(track_id, 1);
1299
1302
  }
1300
1303
  this.track_options_view.setTrackShowGaps(
@@ -21,6 +21,12 @@ import PrecomputedComparator from './precomputedcomparator';
21
21
  import { calculateHeaderTops, calculateTrackTops } from './modelutils';
22
22
  import { OncoprintGapConfig } from './oncoprintwebglcellview';
23
23
 
24
+ export enum GAP_MODE_ENUM {
25
+ SHOW_GAPS = 'SHOW_GAPS',
26
+ SHOW_GAPS_PERCENT = 'SHOW_GAPS_PERCENT',
27
+ HIDE_GAPS = 'HIDE_GAPS',
28
+ }
29
+
24
30
  export type ColumnId = string;
25
31
  export type ColumnIndex = number;
26
32
  export type TrackId = number;
@@ -62,7 +68,10 @@ export type TrackSortDirectionChangeCallback = (
62
68
  track_id: TrackId,
63
69
  dir: number
64
70
  ) => void;
65
- export type TrackGapChangeCallBack = (track_id: TrackId, on: boolean) => void;
71
+ export type TrackGapChangeCallBack = (
72
+ track_id: TrackId,
73
+ mode: GAP_MODE_ENUM
74
+ ) => void;
66
75
  export type CustomTrackOption = {
67
76
  label?: string;
68
77
  separator?: boolean;
@@ -318,7 +327,7 @@ export default class OncoprintModel {
318
327
  private track_expansion_parent: TrackProp<TrackId>;
319
328
  private track_custom_options: TrackProp<CustomTrackOption[]>;
320
329
  private track_can_show_gaps: TrackProp<boolean>;
321
- private track_show_gaps: TrackProp<boolean>;
330
+ private track_show_gaps: TrackProp<GAP_MODE_ENUM>;
322
331
 
323
332
  // Rule set properties
324
333
  private rule_sets: { [ruleSetId: number]: RuleSet };
@@ -571,7 +580,11 @@ export default class OncoprintModel {
571
580
  const precomputedComparator = model.precomputed_comparator.get();
572
581
  const trackIdsWithGaps = model
573
582
  .getTracks()
574
- .filter(trackId => model.getTrackShowGaps(trackId));
583
+ .filter(
584
+ trackId =>
585
+ model.getTrackShowGaps(trackId) !==
586
+ GAP_MODE_ENUM.HIDE_GAPS
587
+ );
575
588
  const ids = model.visible_id_order.get();
576
589
 
577
590
  for (let i = 1; i < ids.length; i++) {
@@ -736,7 +749,7 @@ export default class OncoprintModel {
736
749
  this.column_left.addBoundProperty(this.column_left_no_padding);
737
750
  }
738
751
 
739
- public setTrackShowGaps(trackId: TrackId, show: boolean) {
752
+ public setTrackShowGaps(trackId: TrackId, show: GAP_MODE_ENUM) {
740
753
  this.track_show_gaps[trackId] = show;
741
754
  this.track_gap_change_callback[trackId](trackId, show);
742
755
  this.ids_after_a_gap.update(this);
@@ -1143,7 +1156,14 @@ export default class OncoprintModel {
1143
1156
 
1144
1157
  public getGapSize() {
1145
1158
  if (this.showGaps()) {
1146
- return 50; // this creates enough space for 3 digit percentage
1159
+ switch (this.gapMode()) {
1160
+ case GAP_MODE_ENUM.SHOW_GAPS:
1161
+ return this.getCellWidth(true);
1162
+ case GAP_MODE_ENUM.SHOW_GAPS_PERCENT:
1163
+ return 50;
1164
+ default:
1165
+ return 50;
1166
+ }
1147
1167
  } else {
1148
1168
  return this.getCellWidth(true);
1149
1169
  }
@@ -1425,7 +1445,9 @@ export default class OncoprintModel {
1425
1445
  );
1426
1446
 
1427
1447
  const trackShowGaps = ifndef(params.show_gaps_on_init, false);
1428
- this.track_show_gaps[track_id] = trackShowGaps;
1448
+ this.track_show_gaps[track_id] = trackShowGaps
1449
+ ? GAP_MODE_ENUM.SHOW_GAPS_PERCENT
1450
+ : GAP_MODE_ENUM.HIDE_GAPS;
1429
1451
  const trackNotSorted = this.track_sort_direction[track_id] === 0;
1430
1452
  if (trackShowGaps && trackNotSorted) {
1431
1453
  this.track_sort_direction[track_id] = 1;
@@ -1889,7 +1911,16 @@ export default class OncoprintModel {
1889
1911
  }
1890
1912
 
1891
1913
  public showGaps() {
1892
- return _.some(this.track_show_gaps);
1914
+ return _(this.track_show_gaps)
1915
+ .values()
1916
+ .some(t => t !== GAP_MODE_ENUM.HIDE_GAPS);
1917
+ }
1918
+
1919
+ public gapMode() {
1920
+ const mode = _(this.track_show_gaps)
1921
+ .values()
1922
+ .find(g => g !== GAP_MODE_ENUM.HIDE_GAPS);
1923
+ return mode || GAP_MODE_ENUM.HIDE_GAPS;
1893
1924
  }
1894
1925
 
1895
1926
  public getOncoprintWidthNoColumnPaddingNoGaps() {
@@ -77,21 +77,25 @@ export default class OncoprintTrackInfoView {
77
77
  return;
78
78
  }
79
79
 
80
- const float = parseFloat(text);
80
+ const num = text.match(/^[\d\.]*/)?.[0];
81
+ let suffix = text.match(/[^\d]*$/)?.[0];
82
+
83
+ const float = parseFloat(num);
81
84
  let formattedPercent = '';
82
85
 
83
86
  if (isNaN(float)) {
84
87
  formattedPercent = 'N/P';
88
+ suffix = ''; // we don't want any suffix in this case
85
89
  } else if (isNumber(float)) {
86
90
  formattedPercent =
87
91
  float < 1 && float > 0
88
- ? '<1%'
89
- : Math.round(float) + '%';
92
+ ? '<1'
93
+ : Math.round(float).toString();
90
94
  } else {
91
95
  // do nothing
92
96
  }
93
97
 
94
- $new_label.text(formattedPercent);
98
+ $new_label.text(formattedPercent + suffix);
95
99
  $new_label.appendTo(self.$text_ctr);
96
100
  self.$label_elts.push($new_label);
97
101
  setTimeout(function() {
@@ -1,13 +1,13 @@
1
1
  import $ from 'jquery';
2
2
  import menuDotsIcon from '../img/menudots.svg';
3
3
  import OncoprintModel, {
4
- TrackGroupProp,
4
+ GAP_MODE_ENUM,
5
5
  TrackId,
6
6
  TrackProp,
7
7
  TrackSortDirection,
8
8
  } from './oncoprintmodel';
9
- import ClickEvent = JQuery.ClickEvent;
10
9
  import { CLOSE_MENUS_EVENT as HEADER_VIEW_CLOSE_MENUS_EVENT } from './oncoprintheaderview';
10
+ import ClickEvent = JQuery.ClickEvent;
11
11
 
12
12
  const TOGGLE_BTN_CLASS = 'oncoprintjs__track_options__toggle_btn_img';
13
13
  const TOGGLE_BTN_OPEN_CLASS = 'oncoprintjs__track_options__open';
@@ -44,7 +44,10 @@ export default class OncoprintTrackOptionsView {
44
44
  sortDirection: TrackSortDirection
45
45
  ) => void,
46
46
  private unexpandCallback: TrackCallback,
47
- private showGapsCallback: (trackId: TrackId, showGaps: boolean) => void
47
+ private showGapsCallback: (
48
+ trackId: TrackId,
49
+ showGaps: GAP_MODE_ENUM
50
+ ) => void
48
51
  ) {
49
52
  const position = $div.css('position');
50
53
  if (position !== 'absolute' && position !== 'relative') {
@@ -448,31 +451,51 @@ export default class OncoprintTrackOptionsView {
448
451
  $dropdown.append(
449
452
  OncoprintTrackOptionsView.$makeDropdownSeparator()
450
453
  );
451
- const $show_gaps_opt = OncoprintTrackOptionsView.$makeDropdownOption(
452
- 'Show gaps',
453
- model.getTrackShowGaps(track_id) ? 'bold' : 'normal',
454
+
455
+ const $show_gaps_percent_opt = OncoprintTrackOptionsView.$makeDropdownOption(
456
+ model.getTrackShowGaps(track_id) ===
457
+ GAP_MODE_ENUM.SHOW_GAPS_PERCENT
458
+ ? 'Hide gaps (w/%)'
459
+ : 'Show Gaps (w/%)',
460
+ model.getTrackShowGaps(track_id) ===
461
+ GAP_MODE_ENUM.SHOW_GAPS_PERCENT
462
+ ? 'bold'
463
+ : 'normal',
454
464
  false,
455
465
  function(evt) {
456
466
  evt.stopPropagation();
457
467
  $show_gaps_opt.css('font-weight', 'bold');
458
- $dont_show_gaps_opt.css('font-weight', 'normal');
459
- self.showGapsCallback(track_id, true);
468
+ const mode: GAP_MODE_ENUM = [
469
+ GAP_MODE_ENUM.SHOW_GAPS_PERCENT,
470
+ ].includes(model.getTrackShowGaps(track_id))
471
+ ? GAP_MODE_ENUM.HIDE_GAPS
472
+ : GAP_MODE_ENUM.SHOW_GAPS_PERCENT;
473
+ self.showGapsCallback(track_id, mode);
460
474
  }
461
475
  );
462
- const $dont_show_gaps_opt = OncoprintTrackOptionsView.$makeDropdownOption(
463
- "Don't show gaps",
464
- model.getTrackShowGaps(track_id) ? 'normal' : 'bold',
476
+
477
+ const $show_gaps_opt = OncoprintTrackOptionsView.$makeDropdownOption(
478
+ model.getTrackShowGaps(track_id) === GAP_MODE_ENUM.SHOW_GAPS
479
+ ? 'Hide gaps'
480
+ : 'Show Gaps',
481
+ model.getTrackShowGaps(track_id) === GAP_MODE_ENUM.SHOW_GAPS
482
+ ? 'bold'
483
+ : 'normal',
465
484
  false,
466
485
  function(evt) {
467
486
  evt.stopPropagation();
468
-
469
- $show_gaps_opt.css('font-weight', 'normal');
470
- $dont_show_gaps_opt.css('font-weight', 'bold');
471
- self.showGapsCallback(track_id, false);
487
+ $show_gaps_opt.css('font-weight', 'bold');
488
+ const mode: GAP_MODE_ENUM = [
489
+ GAP_MODE_ENUM.SHOW_GAPS,
490
+ ].includes(model.getTrackShowGaps(track_id))
491
+ ? GAP_MODE_ENUM.HIDE_GAPS
492
+ : GAP_MODE_ENUM.SHOW_GAPS;
493
+ self.showGapsCallback(track_id, mode);
472
494
  }
473
495
  );
496
+
474
497
  $dropdown.append($show_gaps_opt);
475
- $dropdown.append($dont_show_gaps_opt);
498
+ $dropdown.append($show_gaps_percent_opt);
476
499
  }
477
500
  // Add custom options
478
501
  const custom_options = model.getTrackCustomOptions(track_id);
@@ -11,18 +11,19 @@ import OncoprintModel, {
11
11
  ColumnId,
12
12
  ColumnLabel,
13
13
  ColumnProp,
14
+ GAP_MODE_ENUM,
14
15
  IdentifiedShapeList,
15
16
  TrackId,
16
17
  TrackOverlappingCells,
17
18
  TrackProp,
18
19
  } from './oncoprintmodel';
19
20
  import OncoprintToolTip from './oncoprinttooltip';
20
- import { arrayFindIndex, ifndef, sgndiff } from './utils';
21
- import MouseUpEvent = JQuery.MouseUpEvent;
22
- import MouseMoveEvent = JQuery.MouseMoveEvent;
21
+ import { ifndef, sgndiff } from './utils';
23
22
  import { CellClickCallback, CellMouseOverCallback } from './oncoprint';
24
23
  import { getFragmentShaderSource, getVertexShaderSource } from './shaders';
25
24
  import _ from 'lodash';
25
+ import MouseUpEvent = JQuery.MouseUpEvent;
26
+ import MouseMoveEvent = JQuery.MouseMoveEvent;
26
27
 
27
28
  type ColorBankIndex = number; // index into vertex bank (e.g. 0, 4, 8, ...)
28
29
  type ColorBank = number[]; // flat list of color: [c0,c0,c0,c0,v1,v1,v1,c1,c1,c1,c1,...]
@@ -846,7 +847,10 @@ export default class OncoprintWebGLCellView {
846
847
  const cell_top = model.getCellTops(track_id);
847
848
  const cell_height = model.getCellHeight(track_id);
848
849
 
849
- if (model.showGaps()) {
850
+ if (
851
+ model.showGaps() &&
852
+ model.gapMode() === GAP_MODE_ENUM.SHOW_GAPS_PERCENT
853
+ ) {
850
854
  const gaps = this.getGaps(model, track_id);
851
855
  if (gaps) {
852
856
  gaps.forEach((gap: OncoprintGapConfig, i: number) => {
@@ -854,7 +858,8 @@ export default class OncoprintWebGLCellView {
854
858
  const y =
855
859
  model.getZoomedTrackTops()[track_id] +
856
860
  cell_height -
857
- scroll_y;
861
+ scroll_y -
862
+ 4;
858
863
 
859
864
  this.drawGapLabel(gap.labelFormatter(), x, y);
860
865