@microbiome-informatics/genome-properties-viewer 1.0.0-beta.1 → 1.0.0-beta.2
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/README.md +1 -1
- package/gp-style.css +7 -2
- package/package.json +3 -3
- package/src/gp-controller.js +10 -1
- package/src/gp-scroller.js +107 -37
- package/src/gp-steps.js +5 -14
- package/src/gp-tax-node.js +12 -8
- package/src/gp-taxonomy.js +38 -32
- package/src/gp-totals.js +107 -15
- package/src/gp-ui-utils.js +139 -28
- package/src/gp-uploader.js +20 -11
- package/src/gp-viewer.js +256 -246
package/src/gp-viewer.js
CHANGED
|
@@ -33,6 +33,8 @@ import { filterByLegend, filterByHierarchy, filterByText } from "./gp-filters";
|
|
|
33
33
|
import {
|
|
34
34
|
drawTotalPerOrganismPanel,
|
|
35
35
|
updateTotalPerOrganismPanel,
|
|
36
|
+
drawRowTotalPanel,
|
|
37
|
+
updateRowTotalPanel,
|
|
36
38
|
refreshGPTotals,
|
|
37
39
|
} from "./gp-totals";
|
|
38
40
|
|
|
@@ -61,12 +63,14 @@ export default class GenomePropertiesViewer {
|
|
|
61
63
|
template_link_to_GP_page = "https://wwwdev.ebi.ac.uk/interpro/genomeproperties/#{}",
|
|
62
64
|
gp_server = "http://wwwdev.ebi.ac.uk/interpro/genomeproperties/cgi-bin/test.pl",
|
|
63
65
|
dimensions = {
|
|
64
|
-
tree: { width:
|
|
66
|
+
tree: { width: 160 },
|
|
67
|
+
labels: { width: 220 },
|
|
65
68
|
total: { short_side: cell_side },
|
|
66
69
|
step_expander: { short_side: cell_side },
|
|
67
70
|
scroller: { short_side: 12 },
|
|
68
71
|
},
|
|
69
72
|
}) {
|
|
73
|
+
this.destroyed = false;
|
|
70
74
|
this.data = {};
|
|
71
75
|
this.preloaded = {};
|
|
72
76
|
this.organisms = [];
|
|
@@ -111,10 +115,8 @@ export default class GenomePropertiesViewer {
|
|
|
111
115
|
dimensions,
|
|
112
116
|
};
|
|
113
117
|
this.column_total_width = cell_side;
|
|
114
|
-
this.x = d3.
|
|
115
|
-
this.y = d3.
|
|
116
|
-
// this.x = d3.scaleBand().range([0, width - this.column_total_width]);
|
|
117
|
-
// this.y = d3.scaleLinear().range([0, cell_side]);
|
|
118
|
+
this.x = d3.scaleBand().range([0, cell_side]);
|
|
119
|
+
this.y = d3.scaleLinear().range([0, cell_side]);
|
|
118
120
|
this.gp_values = ["YES", "PARTIAL", "NO"];
|
|
119
121
|
this.c = {
|
|
120
122
|
YES: "rgb(49, 130, 189)",
|
|
@@ -145,7 +147,7 @@ export default class GenomePropertiesViewer {
|
|
|
145
147
|
.on("wheel", (event) => {
|
|
146
148
|
if (this?.props?.length) {
|
|
147
149
|
event.stopPropagation();
|
|
148
|
-
this.moveScroll({ dx: -event.deltaX });
|
|
150
|
+
this.moveScroll({ dx: -event.deltaX, dy: -event.deltaY });
|
|
149
151
|
}
|
|
150
152
|
});
|
|
151
153
|
|
|
@@ -181,13 +183,15 @@ export default class GenomePropertiesViewer {
|
|
|
181
183
|
|
|
182
184
|
this.gp_taxonomy = new GenomePropertiesTaxonomy({
|
|
183
185
|
path: server_tax,
|
|
184
|
-
x:
|
|
185
|
-
y:
|
|
186
|
-
height:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
186
|
+
x: 0,
|
|
187
|
+
y: 20,
|
|
188
|
+
height: this.options.dimensions.tree.width,
|
|
189
|
+
width: Math.max(
|
|
190
|
+
cell_side,
|
|
191
|
+
width -
|
|
192
|
+
this.options.dimensions.labels.width -
|
|
193
|
+
this.options.dimensions.total.short_side
|
|
194
|
+
),
|
|
191
195
|
})
|
|
192
196
|
.on("changeOrder", (order) => {
|
|
193
197
|
this.current_order = order;
|
|
@@ -207,38 +211,19 @@ export default class GenomePropertiesViewer {
|
|
|
207
211
|
event.stopPropagation();
|
|
208
212
|
removeGenomePropertiesFile(this, taxId);
|
|
209
213
|
})
|
|
210
|
-
.on("changeWidth", (
|
|
211
|
-
this.options.dimensions.tree.width =
|
|
212
|
-
this.
|
|
214
|
+
.on("changeWidth", (h) => {
|
|
215
|
+
this.options.dimensions.tree.width = Math.max(80, h);
|
|
216
|
+
this.gp_taxonomy.height = this.options.dimensions.tree.width;
|
|
213
217
|
this.update_viewer();
|
|
214
218
|
});
|
|
215
|
-
this.fileGetter.getJSON(server_tax).then((data) => {
|
|
216
|
-
this.gp_taxonomy.load_taxonomy_obj(data);
|
|
217
|
-
});
|
|
218
219
|
|
|
219
220
|
this.gp_hierarchy = new GenomePropertiesHierarchy()
|
|
220
221
|
// .load_hierarchy_from_path(this.options.hierarchy_path)
|
|
221
222
|
.on("siwtchChanged", () => {
|
|
222
223
|
this.mainGroup.y = 0;
|
|
223
|
-
d3.select(".gpv-rows-group").attr(
|
|
224
|
-
"transform",
|
|
225
|
-
`translate(${this.mainGroup.x},${this.mainGroup.y})`
|
|
226
|
-
);
|
|
227
224
|
this.update_viewer(500);
|
|
228
225
|
updateTotalPerOrganismPanel(this);
|
|
229
226
|
});
|
|
230
|
-
this.fileGetter.getJSON(hierarchy_path).then((data) => {
|
|
231
|
-
this.gp_hierarchy.load_hierarchy_from_data(data);
|
|
232
|
-
this.fileGetter.getJSON(model_species_path).then((dataSpecies) => {
|
|
233
|
-
preloadSpecies(this, dataSpecies);
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
// if (hierarchy_path) {
|
|
237
|
-
// this.gp_hierarchy.load_hierarchy_from_data(hierarchy_path);
|
|
238
|
-
// this.fileGetter.getJSON(model_species_path).get(data => {
|
|
239
|
-
// preloadSpecies(this, data);
|
|
240
|
-
// });
|
|
241
|
-
// }
|
|
242
227
|
this.sorter = new TaxonomySortButton({
|
|
243
228
|
container: this.mainGroup,
|
|
244
229
|
x: 0,
|
|
@@ -284,17 +269,98 @@ export default class GenomePropertiesViewer {
|
|
|
284
269
|
);
|
|
285
270
|
|
|
286
271
|
this.current_scroll = { x: 0, y: 0 };
|
|
287
|
-
this.
|
|
288
|
-
this.draw_rows_panel();
|
|
272
|
+
this.draw_heatmap_panel();
|
|
289
273
|
drawMasks(this);
|
|
290
|
-
this.
|
|
291
|
-
this
|
|
274
|
+
this.draw_labels_panel();
|
|
275
|
+
drawRowTotalPanel(this);
|
|
276
|
+
this.gp_taxonomy.draw_tree_panel(this.mainGroup, this.treeClipId);
|
|
277
|
+
this.zoomer.draw_panel();
|
|
292
278
|
this.sorter.draw();
|
|
293
279
|
drawTotalPerOrganismPanel(this);
|
|
294
280
|
drawScrollXBar(this);
|
|
295
|
-
// drawScrollYBar(this);
|
|
296
281
|
drawDragArea(this);
|
|
297
|
-
|
|
282
|
+
updateMasks(this);
|
|
283
|
+
this._onResize = () => this.refresh_size();
|
|
284
|
+
window.addEventListener("resize", this._onResize);
|
|
285
|
+
|
|
286
|
+
this.fileGetter.getJSON(server_tax).then((data) => {
|
|
287
|
+
if (this.destroyed) return;
|
|
288
|
+
this.gp_taxonomy.load_taxonomy_obj(data);
|
|
289
|
+
this.update_viewer();
|
|
290
|
+
});
|
|
291
|
+
this.fileGetter.getJSON(hierarchy_path).then((data) => {
|
|
292
|
+
if (this.destroyed) return;
|
|
293
|
+
this.gp_hierarchy.load_hierarchy_from_data(data);
|
|
294
|
+
this.fileGetter.getJSON(model_species_path).then((dataSpecies) => {
|
|
295
|
+
if (this.destroyed) return;
|
|
296
|
+
preloadSpecies(this, dataSpecies);
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
destroy() {
|
|
302
|
+
this.destroyed = true;
|
|
303
|
+
if (this._onResize) {
|
|
304
|
+
window.removeEventListener("resize", this._onResize);
|
|
305
|
+
}
|
|
306
|
+
if (this.fileGetter && this.fileGetter.destroy) {
|
|
307
|
+
this.fileGetter.destroy();
|
|
308
|
+
}
|
|
309
|
+
if (this.controller && this.controller.destroy) {
|
|
310
|
+
this.controller.destroy();
|
|
311
|
+
}
|
|
312
|
+
d3.select(this.options.element_selector).selectAll("*").remove();
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
get labelWidth() {
|
|
316
|
+
return this.options.dimensions.labels.width;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
get treeHeight() {
|
|
320
|
+
if (this.gp_taxonomy && !this.gp_taxonomy.show_tree) {
|
|
321
|
+
return Math.max(70, this.options.cell_side * 3);
|
|
322
|
+
}
|
|
323
|
+
return this.options.dimensions.tree.width;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
get heatmapLeft() {
|
|
327
|
+
return this.labelWidth;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
get dataWidth() {
|
|
331
|
+
return (this.organisms?.length || 0) * this.options.cell_side;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
get dataOffsetX() {
|
|
335
|
+
return Math.max(0, this.heatmapWidth() - this.dataWidth);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
get heatmapAnchor() {
|
|
339
|
+
return this.heatmapLeft + this.dataOffsetX;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
get heatmapTop() {
|
|
343
|
+
return this.treeHeight;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
heatmapWidth() {
|
|
347
|
+
return Math.max(
|
|
348
|
+
this.options.cell_side,
|
|
349
|
+
this.options.width -
|
|
350
|
+
this.labelWidth -
|
|
351
|
+
this.options.dimensions.total.short_side -
|
|
352
|
+
this.options.dimensions.scroller.short_side
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
heatmapHeight() {
|
|
357
|
+
return Math.max(
|
|
358
|
+
this.options.cell_side,
|
|
359
|
+
this.options.height -
|
|
360
|
+
this.treeHeight -
|
|
361
|
+
this.options.dimensions.total.short_side -
|
|
362
|
+
this.options.dimensions.scroller.short_side
|
|
363
|
+
);
|
|
298
364
|
}
|
|
299
365
|
|
|
300
366
|
refresh_size() {
|
|
@@ -303,11 +369,11 @@ export default class GenomePropertiesViewer {
|
|
|
303
369
|
.node()
|
|
304
370
|
.getBoundingClientRect();
|
|
305
371
|
this.options.width = rect.width;
|
|
372
|
+
if (!this.fixedHeight) this.options.height = rect.height;
|
|
306
373
|
d3.select(this.options.element_selector)
|
|
307
374
|
.select("svg")
|
|
308
|
-
.attr("width", rect.width)
|
|
309
|
-
|
|
310
|
-
|
|
375
|
+
.attr("width", rect.width)
|
|
376
|
+
.attr("height", this.options.height);
|
|
311
377
|
this.update_viewer();
|
|
312
378
|
}
|
|
313
379
|
|
|
@@ -315,69 +381,74 @@ export default class GenomePropertiesViewer {
|
|
|
315
381
|
const p = this.options.cell_side;
|
|
316
382
|
this.options.cell_side = Math.max(20, Math.min(200, value));
|
|
317
383
|
if (p !== this.options.cell_side) {
|
|
318
|
-
this.
|
|
319
|
-
|
|
384
|
+
const ratio = this.options.cell_side / p;
|
|
385
|
+
this.current_scroll.x *= ratio;
|
|
386
|
+
this.current_scroll.y *= ratio;
|
|
320
387
|
this.zoomer.zoomBar.attr("y", this.zoomer.slider(this.options.cell_side));
|
|
321
|
-
this.x.range([0, this.options.cell_side]);
|
|
322
388
|
this.refresh(this);
|
|
323
389
|
}
|
|
324
390
|
}
|
|
325
391
|
|
|
326
392
|
moveScroll({ dx = 0, dy = 0 }) {
|
|
327
|
-
const
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
Math.min(limY, this.current_scroll.y + dy)
|
|
332
|
-
);
|
|
393
|
+
const speciesWidth = (this.organisms?.length || 0) * this.options.cell_side;
|
|
394
|
+
const propsHeight = this.y ? this.y(this.props?.length || 0) : 0;
|
|
395
|
+
const maxX = Math.max(0, speciesWidth - this.heatmapWidth());
|
|
396
|
+
const maxY = Math.max(0, propsHeight - this.heatmapHeight());
|
|
333
397
|
this.current_scroll.x = Math.max(
|
|
334
|
-
-
|
|
335
|
-
this.options.width -
|
|
336
|
-
this.options.dimensions.tree.width -
|
|
337
|
-
this.options.cell_side,
|
|
398
|
+
-maxX,
|
|
338
399
|
Math.min(0, this.current_scroll.x + dx)
|
|
339
400
|
);
|
|
401
|
+
this.current_scroll.y = Math.max(
|
|
402
|
+
-maxY,
|
|
403
|
+
Math.min(0, this.current_scroll.y + dy)
|
|
404
|
+
);
|
|
340
405
|
this.refresh(this);
|
|
341
406
|
}
|
|
342
407
|
|
|
343
|
-
|
|
344
|
-
if (!this.props) return this.
|
|
408
|
+
_adjustYScaleBasedOnSteps() {
|
|
409
|
+
if (!this.props) return this.y;
|
|
345
410
|
const side = this.options.cell_side;
|
|
346
411
|
const marks = {
|
|
347
412
|
0: 0,
|
|
348
413
|
1: side,
|
|
349
414
|
};
|
|
350
415
|
|
|
351
|
-
const
|
|
416
|
+
const newY = d3.scaleLinear().domain([0, 1]).range([0, side]);
|
|
352
417
|
this.props.forEach((prop, i) => {
|
|
353
418
|
if (prop.isShowingSteps) {
|
|
354
|
-
const
|
|
419
|
+
const prevY = newY(i);
|
|
355
420
|
|
|
356
|
-
if (!marks[i]) marks[i] =
|
|
357
|
-
marks[i + 1] = marks[i] + Math.max(2, prop.steps.length) * side;
|
|
421
|
+
if (!marks[i]) marks[i] = prevY;
|
|
422
|
+
marks[i + 1] = marks[i] + Math.max(2, prop.steps.length + 1) * side;
|
|
358
423
|
marks[i + 2] = marks[i + 1] + side;
|
|
359
424
|
const domain = Object.keys(marks)
|
|
360
425
|
.map(Number)
|
|
361
426
|
.sort((a, b) => a - b);
|
|
362
427
|
const range = domain.map((x) => marks[x]).map(Number);
|
|
363
|
-
|
|
428
|
+
newY.range(range).domain(domain);
|
|
364
429
|
}
|
|
365
430
|
});
|
|
366
|
-
this.
|
|
367
|
-
return this.
|
|
431
|
+
this.y = newY;
|
|
432
|
+
return this.y;
|
|
368
433
|
}
|
|
369
434
|
|
|
370
|
-
|
|
371
|
-
this.
|
|
435
|
+
draw_heatmap_panel() {
|
|
436
|
+
this.heatmapLayer = this.mainGroup
|
|
437
|
+
.append("g")
|
|
438
|
+
.attr("class", "heatmap-layer")
|
|
439
|
+
.attr("clip-path", `url(#${this.heatmapClipId})`);
|
|
440
|
+
this.newCols = this.heatmapLayer
|
|
441
|
+
.append("g")
|
|
442
|
+
.attr("class", "gpv-new-cols-group");
|
|
443
|
+
this.newRows = this.heatmapLayer
|
|
372
444
|
.append("g")
|
|
373
|
-
.attr("class", "gpv-new-rows-group")
|
|
374
|
-
.attr("transform", "translate(0,0)");
|
|
445
|
+
.attr("class", "gpv-new-rows-group");
|
|
375
446
|
}
|
|
376
447
|
|
|
377
|
-
|
|
378
|
-
this.
|
|
448
|
+
draw_labels_panel() {
|
|
449
|
+
this.labelGroup = this.mainGroup
|
|
379
450
|
.append("g")
|
|
380
|
-
.attr("class", "gpv-
|
|
451
|
+
.attr("class", "gpv-label-group");
|
|
381
452
|
}
|
|
382
453
|
|
|
383
454
|
move_row(prop, delta) {
|
|
@@ -403,6 +474,12 @@ export default class GenomePropertiesViewer {
|
|
|
403
474
|
}
|
|
404
475
|
}
|
|
405
476
|
|
|
477
|
+
propertyLabel(d) {
|
|
478
|
+
if (this.gp_label_type === "name") return d.name;
|
|
479
|
+
if (this.gp_label_type === "id") return d.property;
|
|
480
|
+
return `${d.property}:${d.name}`;
|
|
481
|
+
}
|
|
482
|
+
|
|
406
483
|
update_viewer(time = 0) {
|
|
407
484
|
this.props = this.organisms.length ? Object.values(this.data) : [];
|
|
408
485
|
refreshGPTotals(this);
|
|
@@ -410,132 +487,136 @@ export default class GenomePropertiesViewer {
|
|
|
410
487
|
filterByText(this);
|
|
411
488
|
filterByLegend(this);
|
|
412
489
|
this.sort_props();
|
|
413
|
-
this.
|
|
490
|
+
this._adjustYScaleBasedOnSteps();
|
|
414
491
|
|
|
415
492
|
this.column_total_width = this.options.cell_side;
|
|
416
|
-
this.
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
this.current_props = this.props.filter(
|
|
422
|
-
(gp, i) =>
|
|
423
|
-
this.x(i + 1) + this.current_scroll.x >= 0 &&
|
|
424
|
-
this.x(i) + this.current_scroll.x <
|
|
425
|
-
this.options.width - this.options.dimensions.tree.width
|
|
426
|
-
);
|
|
427
|
-
const dx = this.props.indexOf(this.current_props[0]);
|
|
428
|
-
const visible_cols = this.current_props.length;
|
|
493
|
+
this.gp_taxonomy.width = this.heatmapWidth();
|
|
494
|
+
this.gp_taxonomy.height = this.treeHeight;
|
|
495
|
+
this.gp_taxonomy.x = this.heatmapLeft + this.current_scroll.x;
|
|
496
|
+
this.gp_taxonomy.y = 16;
|
|
429
497
|
this.gp_taxonomy.update_tree(time, this.options.cell_side);
|
|
430
498
|
this.current_order = this.gp_taxonomy.current_order;
|
|
431
499
|
this.organisms = this.gp_taxonomy.get_tax_list();
|
|
432
|
-
this.
|
|
500
|
+
this.x
|
|
501
|
+
.domain(this.current_order)
|
|
502
|
+
.range([0, this.organisms.length * this.options.cell_side]);
|
|
503
|
+
|
|
504
|
+
const heatmapH = this.heatmapHeight();
|
|
505
|
+
this.current_props = this.props.filter((gp, i) => {
|
|
506
|
+
const y0 = this.y(i) + this.current_scroll.y;
|
|
507
|
+
const y1 = this.y(i + 1) + this.current_scroll.y;
|
|
508
|
+
return y1 >= 0 && y0 < heatmapH;
|
|
509
|
+
});
|
|
510
|
+
const dy = Math.max(0, this.props.indexOf(this.current_props[0]));
|
|
511
|
+
const visible_rows = this.current_props.length;
|
|
433
512
|
|
|
434
|
-
const
|
|
513
|
+
const rowY = (d, i) => this.heatmapTop + this.y(i + dy);
|
|
514
|
+
const heatmapX = this.heatmapAnchor;
|
|
515
|
+
|
|
516
|
+
const rows = this.newRows
|
|
435
517
|
.selectAll(".column")
|
|
436
518
|
.data(this.current_props, (d) => d.property);
|
|
437
519
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
.attr(
|
|
441
|
-
"transform",
|
|
442
|
-
(d, i) =>
|
|
443
|
-
`translate(${this.x(i + dx) + this.options.dimensions.tree.width}, ${
|
|
444
|
-
this.options.dimensions.total.short_side
|
|
445
|
-
})`
|
|
446
|
-
)
|
|
520
|
+
rows
|
|
521
|
+
.attr("transform", (d, i) => `translate(${heatmapX}, ${rowY(d, i)})`)
|
|
447
522
|
.each((d, i, c) => this.update_col(d, i, c));
|
|
448
523
|
|
|
449
|
-
|
|
524
|
+
rows.exit().remove();
|
|
450
525
|
|
|
451
|
-
const
|
|
526
|
+
const newRow = rows
|
|
452
527
|
.enter()
|
|
453
528
|
.append("g")
|
|
454
529
|
.attr("id", (d) => `col_${d.property}`)
|
|
455
530
|
.attr("class", "column")
|
|
531
|
+
.attr("transform", (d, i) => `translate(${heatmapX}, ${rowY(d, i)})`)
|
|
456
532
|
.each((d, i, c) => this.update_col(d, i, c));
|
|
457
533
|
|
|
458
|
-
|
|
534
|
+
newRow.append("line").attr("class", "puff").attr("x2", 0);
|
|
459
535
|
|
|
460
|
-
|
|
461
|
-
"
|
|
462
|
-
|
|
463
|
-
`translate(${this.x(i + dx) + this.options.dimensions.tree.width}, ${
|
|
464
|
-
this.options.dimensions.total.short_side
|
|
465
|
-
})`
|
|
536
|
+
d3.selectAll("g.column line.puff").attr(
|
|
537
|
+
"x1",
|
|
538
|
+
this.organisms.length * this.options.cell_side
|
|
466
539
|
);
|
|
467
540
|
|
|
468
|
-
|
|
469
|
-
// .transition()
|
|
470
|
-
.attr("y1", this.organisms.length * this.options.cell_side);
|
|
471
|
-
|
|
472
|
-
const localX = this.options.cell_side / 4;
|
|
473
|
-
const localY =
|
|
474
|
-
this.options.dimensions.total.short_side +
|
|
475
|
-
this.organisms.length * this.options.cell_side +
|
|
476
|
-
this.options.dimensions.scroller.short_side;
|
|
477
|
-
new_column_p
|
|
478
|
-
.selectAll(".col_title")
|
|
479
|
-
.attr("x", localX)
|
|
480
|
-
.attr("y", localY)
|
|
481
|
-
.attr("transform", `rotate(90,${localX},${localY})`)
|
|
482
|
-
.text((d) => {
|
|
483
|
-
if (this.gp_label_type === "name") return d.name;
|
|
484
|
-
if (this.gp_label_type === "id") return d.property;
|
|
485
|
-
return `${d.property}:${d.name}`;
|
|
486
|
-
});
|
|
487
|
-
|
|
541
|
+
const side = this.options.cell_side;
|
|
488
542
|
const template = this.options.template_link_to_GP_page;
|
|
489
|
-
|
|
543
|
+
const labels = this.labelGroup
|
|
544
|
+
.selectAll(".row-label")
|
|
545
|
+
.data(this.current_props, (d) => d.property);
|
|
546
|
+
|
|
547
|
+
labels.exit().remove();
|
|
548
|
+
labels.attr("transform", (d, i) => `translate(${heatmapX}, ${rowY(d, i)})`);
|
|
549
|
+
|
|
550
|
+
const newLabel = labels
|
|
551
|
+
.enter()
|
|
552
|
+
.append("g")
|
|
553
|
+
.attr("class", "row-label")
|
|
554
|
+
.attr("transform", (d, i) => `translate(${heatmapX}, ${rowY(d, i)})`);
|
|
555
|
+
|
|
556
|
+
newLabel
|
|
490
557
|
.append("a")
|
|
491
558
|
.attr("xlink:href", (d) => template.replace("{}", d.property))
|
|
492
559
|
.attr("target", "_blank")
|
|
493
560
|
.style("cursor", "pointer")
|
|
494
561
|
.append("text")
|
|
495
|
-
.attr("class", "
|
|
496
|
-
.attr("
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
.
|
|
500
|
-
.
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
const
|
|
508
|
-
|
|
562
|
+
.attr("class", "row_title")
|
|
563
|
+
.attr("text-anchor", "end");
|
|
564
|
+
|
|
565
|
+
this.labelGroup
|
|
566
|
+
.selectAll(".row-label text.row_title")
|
|
567
|
+
.attr("x", -side - 6)
|
|
568
|
+
.attr("y", side * 0.7)
|
|
569
|
+
.text((d) => this.propertyLabel(d));
|
|
570
|
+
|
|
571
|
+
this.labelGroup.selectAll(".row-label").each((d, i, nodes) => {
|
|
572
|
+
const g = d3.select(nodes[i]);
|
|
573
|
+
const sampleText = d3.select("text").node();
|
|
574
|
+
const textHeight = sampleText ? sampleText.getBBox().height : 12;
|
|
575
|
+
let radius = (side - textHeight) / 2 - 4;
|
|
576
|
+
if (radius < 2) radius = 2;
|
|
577
|
+
if (radius > 6) radius = 6;
|
|
578
|
+
const dots = g
|
|
579
|
+
.selectAll(".top_level_gp")
|
|
580
|
+
.data(d.parent_top_properties || [], (p) => p);
|
|
581
|
+
dots
|
|
582
|
+
.attr("cy", side * 0.5)
|
|
583
|
+
.attr("cx", -side * 0.35)
|
|
584
|
+
.attr("r", radius);
|
|
585
|
+
dots
|
|
586
|
+
.enter()
|
|
587
|
+
.append("circle")
|
|
588
|
+
.attr("class", "top_level_gp")
|
|
589
|
+
.attr("cy", side * 0.5)
|
|
590
|
+
.attr("cx", -side * 0.35)
|
|
591
|
+
.attr("r", radius)
|
|
592
|
+
.style("fill", (p) => this.gp_hierarchy.color(p));
|
|
593
|
+
dots.exit().remove();
|
|
594
|
+
updateStepToggler(this, d, nodes[i], side);
|
|
509
595
|
});
|
|
510
|
-
this.refreshSVGHeight(maxHeight + this.options.cell_side);
|
|
511
596
|
|
|
512
|
-
|
|
597
|
+
updateRowTotalPanel(this);
|
|
598
|
+
|
|
599
|
+
const orgLines = this.newCols
|
|
513
600
|
.selectAll(".row")
|
|
514
601
|
.data(this.organisms, (p) => p);
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
.
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
);
|
|
522
|
-
|
|
523
|
-
const newRow = new_row_p
|
|
602
|
+
orgLines.attr(
|
|
603
|
+
"transform",
|
|
604
|
+
(d, i) => `translate(${heatmapX + this.x(i)}, ${this.heatmapTop})`
|
|
605
|
+
);
|
|
606
|
+
orgLines.exit().remove();
|
|
607
|
+
orgLines
|
|
524
608
|
.enter()
|
|
525
609
|
.append("g")
|
|
526
610
|
.attr("class", "row")
|
|
527
611
|
.attr(
|
|
528
612
|
"transform",
|
|
529
|
-
(d, i) =>
|
|
530
|
-
|
|
531
|
-
);
|
|
532
|
-
|
|
533
|
-
new_row_p
|
|
534
|
-
.selectAll("line")
|
|
535
|
-
.attr("x2", this.props.length * this.options.cell_side);
|
|
536
|
-
newRow
|
|
613
|
+
(d, i) => `translate(${heatmapX + this.x(i)}, ${this.heatmapTop})`
|
|
614
|
+
)
|
|
537
615
|
.append("line")
|
|
538
|
-
.attr("
|
|
616
|
+
.attr("y2", 0);
|
|
617
|
+
this.newCols
|
|
618
|
+
.selectAll(".row line")
|
|
619
|
+
.attr("y2", this.y(this.props.length) || 0);
|
|
539
620
|
|
|
540
621
|
updateTotalPerOrganismPanel(this);
|
|
541
622
|
updateMasks(this);
|
|
@@ -543,45 +624,20 @@ export default class GenomePropertiesViewer {
|
|
|
543
624
|
this.zoomer.y = this.buttonHeight;
|
|
544
625
|
this.sorter.refresh();
|
|
545
626
|
this.zoomer.refresh();
|
|
546
|
-
if (!this.skip_scroll_refreshing) updateScrollBars(this,
|
|
627
|
+
if (!this.skip_scroll_refreshing) updateScrollBars(this, visible_rows, dy);
|
|
547
628
|
}
|
|
548
629
|
|
|
549
630
|
update_col(gp, i, c) {
|
|
550
|
-
const
|
|
631
|
+
const cell_height =
|
|
551
632
|
this.options.cell_side *
|
|
552
|
-
(gp.isShowingSteps ? Math.max(2, gp.steps.length) : 1);
|
|
633
|
+
(gp.isShowingSteps ? Math.max(2, gp.steps.length + 1) : 1);
|
|
553
634
|
const side = this.options.cell_side;
|
|
554
|
-
const localX = this.options.cell_side * 0.75;
|
|
555
|
-
const localY =
|
|
556
|
-
this.options.dimensions.total.short_side +
|
|
557
|
-
this.organisms.length * this.options.cell_side +
|
|
558
|
-
this.options.dimensions.scroller.short_side;
|
|
559
635
|
|
|
560
|
-
const
|
|
636
|
+
const newX = d3
|
|
561
637
|
.scaleBand()
|
|
562
638
|
.range([0, this.organisms.length * this.options.cell_side])
|
|
563
639
|
.domain(this.current_order);
|
|
564
640
|
|
|
565
|
-
const gps = d3
|
|
566
|
-
.select(c[i])
|
|
567
|
-
.selectAll(".top_level_gp")
|
|
568
|
-
.data(gp.parent_top_properties, (d) => d);
|
|
569
|
-
const text_heigth = d3.select("text").node().getBBox().height;
|
|
570
|
-
let radius = (side - text_heigth) / 2 - 4;
|
|
571
|
-
if (radius < 2) radius = 2;
|
|
572
|
-
if (radius > 6) radius = 6;
|
|
573
|
-
|
|
574
|
-
gps.attr("cy", localY).attr("cx", localX).attr("r", radius);
|
|
575
|
-
|
|
576
|
-
gps
|
|
577
|
-
.enter()
|
|
578
|
-
.append("circle")
|
|
579
|
-
.attr("class", "top_level_gp")
|
|
580
|
-
.attr("cy", localY)
|
|
581
|
-
.attr("cx", localX)
|
|
582
|
-
.attr("r", radius)
|
|
583
|
-
.style("fill", (d) => this.gp_hierarchy.color(d));
|
|
584
|
-
|
|
585
641
|
const cells = d3
|
|
586
642
|
.select(c[i])
|
|
587
643
|
.selectAll(".cell")
|
|
@@ -589,9 +645,9 @@ export default class GenomePropertiesViewer {
|
|
|
589
645
|
|
|
590
646
|
cells
|
|
591
647
|
.transition()
|
|
592
|
-
.attr("
|
|
593
|
-
.attr("width",
|
|
594
|
-
.attr("height",
|
|
648
|
+
.attr("x", (d, j) => newX(j))
|
|
649
|
+
.attr("width", newX.bandwidth())
|
|
650
|
+
.attr("height", cell_height);
|
|
595
651
|
|
|
596
652
|
cells.exit().remove();
|
|
597
653
|
|
|
@@ -609,72 +665,26 @@ export default class GenomePropertiesViewer {
|
|
|
609
665
|
Organism: `${this.getOrganismNameFromTaxId(p)} (${p})`,
|
|
610
666
|
Value: data[0].values[p],
|
|
611
667
|
};
|
|
612
|
-
if (p === "TOTAL") {
|
|
613
|
-
this.controller.draw_legends(data[0].values[p]);
|
|
614
|
-
info.Value = `TOTAL: {YES: ${data[0].values[p].YES}, PARTIAL: ${data[0].values[p].PARTIAL}, NO: ${data[0].values[p].NO}}`;
|
|
615
|
-
info.Organism = "All";
|
|
616
|
-
}
|
|
617
668
|
this.controller.draw_tooltip(event, info);
|
|
618
669
|
};
|
|
619
|
-
const mouseout = (
|
|
670
|
+
const mouseout = () => {
|
|
620
671
|
d3.selectAll("text").classed("active", false);
|
|
621
672
|
d3.selectAll(".gpv-name").remove();
|
|
622
673
|
this.controller.draw_tooltip();
|
|
623
|
-
if (p === "TOTAL") this.controller.draw_legends();
|
|
624
674
|
};
|
|
625
675
|
|
|
626
676
|
cells
|
|
627
677
|
.enter()
|
|
628
678
|
.insert("rect", ":first-child")
|
|
629
679
|
.attr("class", "cell")
|
|
630
|
-
.attr("
|
|
631
|
-
.attr("width",
|
|
632
|
-
.attr("height",
|
|
680
|
+
.attr("x", (d, j) => newX(j))
|
|
681
|
+
.attr("width", newX.bandwidth())
|
|
682
|
+
.attr("height", cell_height)
|
|
633
683
|
.on("mouseover", mouseover)
|
|
634
684
|
.on("mouseout", mouseout)
|
|
635
685
|
.style("fill", (d) => (d in gp.values ? this.c[gp.values[d]] : null));
|
|
636
686
|
|
|
637
|
-
|
|
638
|
-
.arc()
|
|
639
|
-
.outerRadius(side * 0.4)
|
|
640
|
-
.innerRadius(0);
|
|
641
|
-
const pie_f = d3.pie().value((d) => d.value);
|
|
642
|
-
|
|
643
|
-
const cells_t = d3
|
|
644
|
-
.select(c[i])
|
|
645
|
-
.selectAll(".total_cell")
|
|
646
|
-
.data(["TOTAL"], (d) => d);
|
|
647
|
-
|
|
648
|
-
cells_t.attr(
|
|
649
|
-
"transform",
|
|
650
|
-
() => `translate(${cell_width * 0.5}, ${side * -0.5})`
|
|
651
|
-
);
|
|
652
|
-
|
|
653
|
-
cells_t
|
|
654
|
-
.enter()
|
|
655
|
-
.append("g")
|
|
656
|
-
.attr("class", "total_cell")
|
|
657
|
-
.attr("transform", () => `translate(${cell_width * 0.5}, ${side * -0.5})`)
|
|
658
|
-
.on("mouseover", mouseover)
|
|
659
|
-
.on("mouseout", mouseout);
|
|
660
|
-
|
|
661
|
-
const arcs = d3
|
|
662
|
-
.select(c[i])
|
|
663
|
-
.selectAll(".total_cell")
|
|
664
|
-
.selectAll(".arc")
|
|
665
|
-
.data(pie_f(d3.entries(gp.values.TOTAL)), (d) => d.data.key);
|
|
666
|
-
|
|
667
|
-
arcs.attr("d", arc_f);
|
|
668
|
-
|
|
669
|
-
arcs
|
|
670
|
-
.enter()
|
|
671
|
-
.append("path")
|
|
672
|
-
.attr("class", "arc")
|
|
673
|
-
.attr("d", arc_f)
|
|
674
|
-
.style("fill", (d) => this.c[d.data.key]);
|
|
675
|
-
|
|
676
|
-
updateStepToggler(this, gp, c[i], side);
|
|
677
|
-
updateSteps(this, gp, c[i], side, newY);
|
|
687
|
+
updateSteps(this, gp, c[i], side, newX);
|
|
678
688
|
}
|
|
679
689
|
|
|
680
690
|
order_organisms(value) {
|
|
@@ -683,7 +693,7 @@ export default class GenomePropertiesViewer {
|
|
|
683
693
|
}
|
|
684
694
|
|
|
685
695
|
order_organisms_current_order() {
|
|
686
|
-
this.
|
|
696
|
+
this.x.domain(this.current_order);
|
|
687
697
|
updateTotalPerOrganismPanel(this);
|
|
688
698
|
this.refresh();
|
|
689
699
|
}
|