@microbiome-informatics/genome-properties-viewer 1.0.0-beta.1 → 1.0.0-beta.3
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 +25 -12
- package/package.json +5 -4
- package/src/gp-controller.js +62 -13
- package/src/gp-filters.js +19 -11
- package/src/gp-hierarchy.js +9 -7
- 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 +177 -72
- package/src/gp-viewer.js +260 -247
- package/src/modal.js +10 -8
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
|
|
|
@@ -59,14 +61,16 @@ export default class GenomePropertiesViewer {
|
|
|
59
61
|
tax_label_selector = "#tax_label",
|
|
60
62
|
tax_search_selector = "#tax-search",
|
|
61
63
|
template_link_to_GP_page = "https://wwwdev.ebi.ac.uk/interpro/genomeproperties/#{}",
|
|
62
|
-
gp_server = "http://
|
|
64
|
+
gp_server = "http://127.0.0.1:8000/api/v1/assign",
|
|
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,101 @@ 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
|
+
if (this.modal && this.modal.destroy) {
|
|
313
|
+
this.modal.destroy();
|
|
314
|
+
}
|
|
315
|
+
d3.select(this.options.element_selector).selectAll("*").remove();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
get labelWidth() {
|
|
319
|
+
return this.options.dimensions.labels.width;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
get treeHeight() {
|
|
323
|
+
if (this.gp_taxonomy && !this.gp_taxonomy.show_tree) {
|
|
324
|
+
return Math.max(70, this.options.cell_side * 3);
|
|
325
|
+
}
|
|
326
|
+
return this.options.dimensions.tree.width;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
get heatmapLeft() {
|
|
330
|
+
return this.labelWidth;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
get dataWidth() {
|
|
334
|
+
return (this.organisms?.length || 0) * this.options.cell_side;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
get dataOffsetX() {
|
|
338
|
+
return Math.max(0, this.heatmapWidth() - this.dataWidth);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
get heatmapAnchor() {
|
|
342
|
+
return this.heatmapLeft + this.dataOffsetX;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
get heatmapTop() {
|
|
346
|
+
return this.treeHeight;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
heatmapWidth() {
|
|
350
|
+
return Math.max(
|
|
351
|
+
this.options.cell_side,
|
|
352
|
+
this.options.width -
|
|
353
|
+
this.labelWidth -
|
|
354
|
+
this.options.dimensions.total.short_side -
|
|
355
|
+
this.options.dimensions.scroller.short_side
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
heatmapHeight() {
|
|
360
|
+
return Math.max(
|
|
361
|
+
this.options.cell_side,
|
|
362
|
+
this.options.height -
|
|
363
|
+
this.treeHeight -
|
|
364
|
+
this.options.dimensions.total.short_side -
|
|
365
|
+
this.options.dimensions.scroller.short_side
|
|
366
|
+
);
|
|
298
367
|
}
|
|
299
368
|
|
|
300
369
|
refresh_size() {
|
|
@@ -303,11 +372,11 @@ export default class GenomePropertiesViewer {
|
|
|
303
372
|
.node()
|
|
304
373
|
.getBoundingClientRect();
|
|
305
374
|
this.options.width = rect.width;
|
|
375
|
+
if (!this.fixedHeight) this.options.height = rect.height;
|
|
306
376
|
d3.select(this.options.element_selector)
|
|
307
377
|
.select("svg")
|
|
308
|
-
.attr("width", rect.width)
|
|
309
|
-
|
|
310
|
-
|
|
378
|
+
.attr("width", rect.width)
|
|
379
|
+
.attr("height", this.options.height);
|
|
311
380
|
this.update_viewer();
|
|
312
381
|
}
|
|
313
382
|
|
|
@@ -315,69 +384,74 @@ export default class GenomePropertiesViewer {
|
|
|
315
384
|
const p = this.options.cell_side;
|
|
316
385
|
this.options.cell_side = Math.max(20, Math.min(200, value));
|
|
317
386
|
if (p !== this.options.cell_side) {
|
|
318
|
-
this.
|
|
319
|
-
|
|
387
|
+
const ratio = this.options.cell_side / p;
|
|
388
|
+
this.current_scroll.x *= ratio;
|
|
389
|
+
this.current_scroll.y *= ratio;
|
|
320
390
|
this.zoomer.zoomBar.attr("y", this.zoomer.slider(this.options.cell_side));
|
|
321
|
-
this.x.range([0, this.options.cell_side]);
|
|
322
391
|
this.refresh(this);
|
|
323
392
|
}
|
|
324
393
|
}
|
|
325
394
|
|
|
326
395
|
moveScroll({ dx = 0, dy = 0 }) {
|
|
327
|
-
const
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
Math.min(limY, this.current_scroll.y + dy)
|
|
332
|
-
);
|
|
396
|
+
const speciesWidth = (this.organisms?.length || 0) * this.options.cell_side;
|
|
397
|
+
const propsHeight = this.y ? this.y(this.props?.length || 0) : 0;
|
|
398
|
+
const maxX = Math.max(0, speciesWidth - this.heatmapWidth());
|
|
399
|
+
const maxY = Math.max(0, propsHeight - this.heatmapHeight());
|
|
333
400
|
this.current_scroll.x = Math.max(
|
|
334
|
-
-
|
|
335
|
-
this.options.width -
|
|
336
|
-
this.options.dimensions.tree.width -
|
|
337
|
-
this.options.cell_side,
|
|
401
|
+
-maxX,
|
|
338
402
|
Math.min(0, this.current_scroll.x + dx)
|
|
339
403
|
);
|
|
404
|
+
this.current_scroll.y = Math.max(
|
|
405
|
+
-maxY,
|
|
406
|
+
Math.min(0, this.current_scroll.y + dy)
|
|
407
|
+
);
|
|
340
408
|
this.refresh(this);
|
|
341
409
|
}
|
|
342
410
|
|
|
343
|
-
|
|
344
|
-
if (!this.props) return this.
|
|
411
|
+
_adjustYScaleBasedOnSteps() {
|
|
412
|
+
if (!this.props) return this.y;
|
|
345
413
|
const side = this.options.cell_side;
|
|
346
414
|
const marks = {
|
|
347
415
|
0: 0,
|
|
348
416
|
1: side,
|
|
349
417
|
};
|
|
350
418
|
|
|
351
|
-
const
|
|
419
|
+
const newY = d3.scaleLinear().domain([0, 1]).range([0, side]);
|
|
352
420
|
this.props.forEach((prop, i) => {
|
|
353
421
|
if (prop.isShowingSteps) {
|
|
354
|
-
const
|
|
422
|
+
const prevY = newY(i);
|
|
355
423
|
|
|
356
|
-
if (!marks[i]) marks[i] =
|
|
357
|
-
marks[i + 1] = marks[i] + Math.max(2, prop.steps.length) * side;
|
|
424
|
+
if (!marks[i]) marks[i] = prevY;
|
|
425
|
+
marks[i + 1] = marks[i] + Math.max(2, prop.steps.length + 1) * side;
|
|
358
426
|
marks[i + 2] = marks[i + 1] + side;
|
|
359
427
|
const domain = Object.keys(marks)
|
|
360
428
|
.map(Number)
|
|
361
429
|
.sort((a, b) => a - b);
|
|
362
430
|
const range = domain.map((x) => marks[x]).map(Number);
|
|
363
|
-
|
|
431
|
+
newY.range(range).domain(domain);
|
|
364
432
|
}
|
|
365
433
|
});
|
|
366
|
-
this.
|
|
367
|
-
return this.
|
|
434
|
+
this.y = newY;
|
|
435
|
+
return this.y;
|
|
368
436
|
}
|
|
369
437
|
|
|
370
|
-
|
|
371
|
-
this.
|
|
438
|
+
draw_heatmap_panel() {
|
|
439
|
+
this.heatmapLayer = this.mainGroup
|
|
440
|
+
.append("g")
|
|
441
|
+
.attr("class", "heatmap-layer")
|
|
442
|
+
.attr("clip-path", `url(#${this.heatmapClipId})`);
|
|
443
|
+
this.newCols = this.heatmapLayer
|
|
444
|
+
.append("g")
|
|
445
|
+
.attr("class", "gpv-new-cols-group");
|
|
446
|
+
this.newRows = this.heatmapLayer
|
|
372
447
|
.append("g")
|
|
373
|
-
.attr("class", "gpv-new-rows-group")
|
|
374
|
-
.attr("transform", "translate(0,0)");
|
|
448
|
+
.attr("class", "gpv-new-rows-group");
|
|
375
449
|
}
|
|
376
450
|
|
|
377
|
-
|
|
378
|
-
this.
|
|
451
|
+
draw_labels_panel() {
|
|
452
|
+
this.labelGroup = this.mainGroup
|
|
379
453
|
.append("g")
|
|
380
|
-
.attr("class", "gpv-
|
|
454
|
+
.attr("class", "gpv-label-group");
|
|
381
455
|
}
|
|
382
456
|
|
|
383
457
|
move_row(prop, delta) {
|
|
@@ -403,6 +477,12 @@ export default class GenomePropertiesViewer {
|
|
|
403
477
|
}
|
|
404
478
|
}
|
|
405
479
|
|
|
480
|
+
propertyLabel(d) {
|
|
481
|
+
if (this.gp_label_type === "name") return d.name;
|
|
482
|
+
if (this.gp_label_type === "id") return d.property;
|
|
483
|
+
return `${d.property}:${d.name}`;
|
|
484
|
+
}
|
|
485
|
+
|
|
406
486
|
update_viewer(time = 0) {
|
|
407
487
|
this.props = this.organisms.length ? Object.values(this.data) : [];
|
|
408
488
|
refreshGPTotals(this);
|
|
@@ -410,132 +490,136 @@ export default class GenomePropertiesViewer {
|
|
|
410
490
|
filterByText(this);
|
|
411
491
|
filterByLegend(this);
|
|
412
492
|
this.sort_props();
|
|
413
|
-
this.
|
|
493
|
+
this._adjustYScaleBasedOnSteps();
|
|
414
494
|
|
|
415
495
|
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;
|
|
496
|
+
this.gp_taxonomy.width = this.heatmapWidth();
|
|
497
|
+
this.gp_taxonomy.height = this.treeHeight;
|
|
498
|
+
this.gp_taxonomy.x = this.heatmapLeft + this.current_scroll.x;
|
|
499
|
+
this.gp_taxonomy.y = 16;
|
|
429
500
|
this.gp_taxonomy.update_tree(time, this.options.cell_side);
|
|
430
501
|
this.current_order = this.gp_taxonomy.current_order;
|
|
431
502
|
this.organisms = this.gp_taxonomy.get_tax_list();
|
|
432
|
-
this.
|
|
503
|
+
this.x
|
|
504
|
+
.domain(this.current_order)
|
|
505
|
+
.range([0, this.organisms.length * this.options.cell_side]);
|
|
506
|
+
|
|
507
|
+
const heatmapH = this.heatmapHeight();
|
|
508
|
+
this.current_props = this.props.filter((gp, i) => {
|
|
509
|
+
const y0 = this.y(i) + this.current_scroll.y;
|
|
510
|
+
const y1 = this.y(i + 1) + this.current_scroll.y;
|
|
511
|
+
return y1 >= 0 && y0 < heatmapH;
|
|
512
|
+
});
|
|
513
|
+
const dy = Math.max(0, this.props.indexOf(this.current_props[0]));
|
|
514
|
+
const visible_rows = this.current_props.length;
|
|
515
|
+
|
|
516
|
+
const rowY = (d, i) => this.heatmapTop + this.y(i + dy);
|
|
517
|
+
const heatmapX = this.heatmapAnchor;
|
|
433
518
|
|
|
434
|
-
const
|
|
519
|
+
const rows = this.newRows
|
|
435
520
|
.selectAll(".column")
|
|
436
521
|
.data(this.current_props, (d) => d.property);
|
|
437
522
|
|
|
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
|
-
)
|
|
523
|
+
rows
|
|
524
|
+
.attr("transform", (d, i) => `translate(${heatmapX}, ${rowY(d, i)})`)
|
|
447
525
|
.each((d, i, c) => this.update_col(d, i, c));
|
|
448
526
|
|
|
449
|
-
|
|
527
|
+
rows.exit().remove();
|
|
450
528
|
|
|
451
|
-
const
|
|
529
|
+
const newRow = rows
|
|
452
530
|
.enter()
|
|
453
531
|
.append("g")
|
|
454
532
|
.attr("id", (d) => `col_${d.property}`)
|
|
455
533
|
.attr("class", "column")
|
|
534
|
+
.attr("transform", (d, i) => `translate(${heatmapX}, ${rowY(d, i)})`)
|
|
456
535
|
.each((d, i, c) => this.update_col(d, i, c));
|
|
457
536
|
|
|
458
|
-
|
|
537
|
+
newRow.append("line").attr("class", "puff").attr("x2", 0);
|
|
459
538
|
|
|
460
|
-
|
|
461
|
-
"
|
|
462
|
-
|
|
463
|
-
`translate(${this.x(i + dx) + this.options.dimensions.tree.width}, ${
|
|
464
|
-
this.options.dimensions.total.short_side
|
|
465
|
-
})`
|
|
539
|
+
d3.selectAll("g.column line.puff").attr(
|
|
540
|
+
"x1",
|
|
541
|
+
this.organisms.length * this.options.cell_side
|
|
466
542
|
);
|
|
467
543
|
|
|
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
|
-
|
|
544
|
+
const side = this.options.cell_side;
|
|
488
545
|
const template = this.options.template_link_to_GP_page;
|
|
489
|
-
|
|
546
|
+
const labels = this.labelGroup
|
|
547
|
+
.selectAll(".row-label")
|
|
548
|
+
.data(this.current_props, (d) => d.property);
|
|
549
|
+
|
|
550
|
+
labels.exit().remove();
|
|
551
|
+
labels.attr("transform", (d, i) => `translate(${heatmapX}, ${rowY(d, i)})`);
|
|
552
|
+
|
|
553
|
+
const newLabel = labels
|
|
554
|
+
.enter()
|
|
555
|
+
.append("g")
|
|
556
|
+
.attr("class", "row-label")
|
|
557
|
+
.attr("transform", (d, i) => `translate(${heatmapX}, ${rowY(d, i)})`);
|
|
558
|
+
|
|
559
|
+
newLabel
|
|
490
560
|
.append("a")
|
|
491
561
|
.attr("xlink:href", (d) => template.replace("{}", d.property))
|
|
492
562
|
.attr("target", "_blank")
|
|
493
563
|
.style("cursor", "pointer")
|
|
494
564
|
.append("text")
|
|
495
|
-
.attr("class", "
|
|
496
|
-
.attr("
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
.
|
|
500
|
-
.
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
const
|
|
508
|
-
|
|
565
|
+
.attr("class", "row_title")
|
|
566
|
+
.attr("text-anchor", "end");
|
|
567
|
+
|
|
568
|
+
this.labelGroup
|
|
569
|
+
.selectAll(".row-label text.row_title")
|
|
570
|
+
.attr("x", -side - 6)
|
|
571
|
+
.attr("y", side * 0.7)
|
|
572
|
+
.text((d) => this.propertyLabel(d));
|
|
573
|
+
|
|
574
|
+
this.labelGroup.selectAll(".row-label").each((d, i, nodes) => {
|
|
575
|
+
const g = d3.select(nodes[i]);
|
|
576
|
+
const sampleText = d3.select("text").node();
|
|
577
|
+
const textHeight = sampleText ? sampleText.getBBox().height : 12;
|
|
578
|
+
let radius = (side - textHeight) / 2 - 4;
|
|
579
|
+
if (radius < 2) radius = 2;
|
|
580
|
+
if (radius > 6) radius = 6;
|
|
581
|
+
const dots = g
|
|
582
|
+
.selectAll(".top_level_gp")
|
|
583
|
+
.data(d.parent_top_properties || [], (p) => p);
|
|
584
|
+
dots
|
|
585
|
+
.attr("cy", side * 0.5)
|
|
586
|
+
.attr("cx", -side * 0.35)
|
|
587
|
+
.attr("r", radius);
|
|
588
|
+
dots
|
|
589
|
+
.enter()
|
|
590
|
+
.append("circle")
|
|
591
|
+
.attr("class", "top_level_gp")
|
|
592
|
+
.attr("cy", side * 0.5)
|
|
593
|
+
.attr("cx", -side * 0.35)
|
|
594
|
+
.attr("r", radius)
|
|
595
|
+
.style("fill", (p) => this.gp_hierarchy.color(p));
|
|
596
|
+
dots.exit().remove();
|
|
597
|
+
updateStepToggler(this, d, nodes[i], side);
|
|
509
598
|
});
|
|
510
|
-
this.refreshSVGHeight(maxHeight + this.options.cell_side);
|
|
511
599
|
|
|
512
|
-
|
|
600
|
+
updateRowTotalPanel(this);
|
|
601
|
+
|
|
602
|
+
const orgLines = this.newCols
|
|
513
603
|
.selectAll(".row")
|
|
514
604
|
.data(this.organisms, (p) => p);
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
.
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
);
|
|
522
|
-
|
|
523
|
-
const newRow = new_row_p
|
|
605
|
+
orgLines.attr(
|
|
606
|
+
"transform",
|
|
607
|
+
(d, i) => `translate(${heatmapX + this.x(i)}, ${this.heatmapTop})`
|
|
608
|
+
);
|
|
609
|
+
orgLines.exit().remove();
|
|
610
|
+
orgLines
|
|
524
611
|
.enter()
|
|
525
612
|
.append("g")
|
|
526
613
|
.attr("class", "row")
|
|
527
614
|
.attr(
|
|
528
615
|
"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
|
|
616
|
+
(d, i) => `translate(${heatmapX + this.x(i)}, ${this.heatmapTop})`
|
|
617
|
+
)
|
|
537
618
|
.append("line")
|
|
538
|
-
.attr("
|
|
619
|
+
.attr("y2", 0);
|
|
620
|
+
this.newCols
|
|
621
|
+
.selectAll(".row line")
|
|
622
|
+
.attr("y2", this.y(this.props.length) || 0);
|
|
539
623
|
|
|
540
624
|
updateTotalPerOrganismPanel(this);
|
|
541
625
|
updateMasks(this);
|
|
@@ -543,45 +627,20 @@ export default class GenomePropertiesViewer {
|
|
|
543
627
|
this.zoomer.y = this.buttonHeight;
|
|
544
628
|
this.sorter.refresh();
|
|
545
629
|
this.zoomer.refresh();
|
|
546
|
-
if (!this.skip_scroll_refreshing) updateScrollBars(this,
|
|
630
|
+
if (!this.skip_scroll_refreshing) updateScrollBars(this, visible_rows, dy);
|
|
547
631
|
}
|
|
548
632
|
|
|
549
633
|
update_col(gp, i, c) {
|
|
550
|
-
const
|
|
634
|
+
const cell_height =
|
|
551
635
|
this.options.cell_side *
|
|
552
|
-
(gp.isShowingSteps ? Math.max(2, gp.steps.length) : 1);
|
|
636
|
+
(gp.isShowingSteps ? Math.max(2, gp.steps.length + 1) : 1);
|
|
553
637
|
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
638
|
|
|
560
|
-
const
|
|
639
|
+
const newX = d3
|
|
561
640
|
.scaleBand()
|
|
562
641
|
.range([0, this.organisms.length * this.options.cell_side])
|
|
563
642
|
.domain(this.current_order);
|
|
564
643
|
|
|
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
644
|
const cells = d3
|
|
586
645
|
.select(c[i])
|
|
587
646
|
.selectAll(".cell")
|
|
@@ -589,9 +648,9 @@ export default class GenomePropertiesViewer {
|
|
|
589
648
|
|
|
590
649
|
cells
|
|
591
650
|
.transition()
|
|
592
|
-
.attr("
|
|
593
|
-
.attr("width",
|
|
594
|
-
.attr("height",
|
|
651
|
+
.attr("x", (d, j) => newX(j))
|
|
652
|
+
.attr("width", newX.bandwidth())
|
|
653
|
+
.attr("height", cell_height);
|
|
595
654
|
|
|
596
655
|
cells.exit().remove();
|
|
597
656
|
|
|
@@ -609,72 +668,26 @@ export default class GenomePropertiesViewer {
|
|
|
609
668
|
Organism: `${this.getOrganismNameFromTaxId(p)} (${p})`,
|
|
610
669
|
Value: data[0].values[p],
|
|
611
670
|
};
|
|
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
671
|
this.controller.draw_tooltip(event, info);
|
|
618
672
|
};
|
|
619
|
-
const mouseout = (
|
|
673
|
+
const mouseout = () => {
|
|
620
674
|
d3.selectAll("text").classed("active", false);
|
|
621
675
|
d3.selectAll(".gpv-name").remove();
|
|
622
676
|
this.controller.draw_tooltip();
|
|
623
|
-
if (p === "TOTAL") this.controller.draw_legends();
|
|
624
677
|
};
|
|
625
678
|
|
|
626
679
|
cells
|
|
627
680
|
.enter()
|
|
628
681
|
.insert("rect", ":first-child")
|
|
629
682
|
.attr("class", "cell")
|
|
630
|
-
.attr("
|
|
631
|
-
.attr("width",
|
|
632
|
-
.attr("height",
|
|
683
|
+
.attr("x", (d, j) => newX(j))
|
|
684
|
+
.attr("width", newX.bandwidth())
|
|
685
|
+
.attr("height", cell_height)
|
|
633
686
|
.on("mouseover", mouseover)
|
|
634
687
|
.on("mouseout", mouseout)
|
|
635
688
|
.style("fill", (d) => (d in gp.values ? this.c[gp.values[d]] : null));
|
|
636
689
|
|
|
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);
|
|
690
|
+
updateSteps(this, gp, c[i], side, newX);
|
|
678
691
|
}
|
|
679
692
|
|
|
680
693
|
order_organisms(value) {
|
|
@@ -683,7 +696,7 @@ export default class GenomePropertiesViewer {
|
|
|
683
696
|
}
|
|
684
697
|
|
|
685
698
|
order_organisms_current_order() {
|
|
686
|
-
this.
|
|
699
|
+
this.x.domain(this.current_order);
|
|
687
700
|
updateTotalPerOrganismPanel(this);
|
|
688
701
|
this.refresh();
|
|
689
702
|
}
|