Skip to content

Commit b099f82

Browse files
committed
CoI merging indirect revisions and stats updates
1 parent 63372f3 commit b099f82

5 files changed

+116
-29
lines changed

html/priority-sets-args.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ <h5 class="modal-desc">Select CoI from the list</h5>
979979
} else {
980980
d3.select("#app-error").style("display", "none");
981981
hivtrace.histogramDistances(graph, histogram_tag, histogram_label);
982-
hivtrace.graphSummary(user_graph.json, graph_summary_tag);
982+
hivtrace.graphSummary(user_graph, graph_summary_tag);
983983

984984
[
985985
"#main-tab",

src/clusternetwork.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -4482,7 +4482,13 @@ var hivtrace_cluster_network_graph = function (
44824482
container
44834483
.selectAll("path")
44844484
.attr("d", misc.symbol(symbol_type).size(node_size(node)))
4485-
.style("fill", (d) => node_color(d));
4485+
.style("fill", (d) => node_color(d))
4486+
.classed(
4487+
"multi_sequence",
4488+
(d) =>
4489+
_.isArray(d[kGlobals.network.AliasedSequencesID]) &&
4490+
d[kGlobals.network.AliasedSequencesID].length > 1
4491+
);
44864492

44874493
if (node.show_label) {
44884494
if (container.selectAll("text").empty()) {
@@ -4514,12 +4520,6 @@ var hivtrace_cluster_network_graph = function (
45144520
"selected_object",
45154521
(d) => d.match_filter && !self.hide_unselected
45164522
)
4517-
.classed(
4518-
"multi_sequence",
4519-
(d) =>
4520-
_.isArray(d[kGlobals.network.AliasedSequencesID]) &&
4521-
d[kGlobals.network.AliasedSequencesID].length > 1
4522-
)
45234523
.classed("injected_object", (d) => d.node_class === "injected")
45244524
.attr("transform", (d) => "translate(" + d.x + "," + d.y + ")")
45254525
.style("opacity", (d) => node_opacity(d))
@@ -5715,7 +5715,7 @@ var hivtrace_cluster_network_graph = function (
57155715
anything_changed = true;
57165716
}
57175717

5718-
if (n.match_filter) {
5718+
if (n.match_filter && n.parent) {
57195719
n.parent.match_filter += 1;
57205720
}
57215721
});
@@ -6318,6 +6318,10 @@ var hivtrace_cluster_network_graph = function (
63186318
null,
63196319
{ "no-filter": true }
63206320
);
6321+
} else {
6322+
self.draw_extended_node_table([], null, null, {
6323+
"no-filter": true,
6324+
});
63216325
}
63226326
});
63236327
}

src/hiv_tx_network.js

+88-16
Original file line numberDiff line numberDiff line change
@@ -554,10 +554,12 @@ class HIVTxNetwork {
554554

555555
annotate_multiple_clusters_on_nodes() {
556556
if (this.has_multiple_sequences) {
557+
let entities_in_multiple_clusters = {};
557558
_.each(this.primary_key_list, (nodes, key) => {
558559
if (nodes.length >= 2) {
559560
let cl = _.groupBy(nodes, (n) => n.cluster);
560561
if (_.size(cl) > 1) {
562+
entities_in_multiple_clusters[key] = _.keys(cl);
561563
_.each(nodes, (n) => {
562564
n["multiple clusters"] = _.keys(cl);
563565
});
@@ -584,6 +586,17 @@ class HIVTxNetwork {
584586
}
585587
}
586588
});
589+
this.entities_in_multiple_clusters = entities_in_multiple_clusters;
590+
/*let by_cluster = {};
591+
_.each (this.entities_in_multiple_clusters, (c,n)=> {
592+
_.each (c, (ci)=> {
593+
if (ci in by_cluster) {
594+
by_cluster[ci].push (n);
595+
} else {
596+
by_cluster[ci] = [n];
597+
}
598+
});
599+
});*/
587600
}
588601
}
589602

@@ -1030,28 +1043,56 @@ class HIVTxNetwork {
10301043
let d = node_list[i];
10311044
if (d in this.json.Nodes) {
10321045
_.each([...edgesByNode[d]], (e) => {
1046+
let add_nodes = [];
1047+
10331048
if (!node_set.has(e.source)) {
1034-
node_list.push(e.source);
1035-
node_set.add(e.source);
1049+
add_nodes.push(e.source);
10361050
}
10371051
if (!node_set.has(e.target)) {
1038-
node_list.push(e.target);
1039-
node_set.add(e.target);
1052+
add_nodes.push(e.target);
10401053
}
1054+
/*if (this.has_multiple_sequences) {
1055+
let extra_nodes = [];
1056+
_.each (add_nodes, n2a=> {
1057+
let node_object = this.json.Nodes[n2a];
1058+
_.each (this.primary_key_list [this.primary_key(node_object)], (no)=> {
1059+
let nidx = nodeID2idx[no.id];
1060+
if (!node_set.has(nidx)) {
1061+
extra_nodes.push (nidx);
1062+
node_set.add (nidx);
1063+
}
1064+
});
1065+
});
1066+
if (extra_nodes.length) {
1067+
add_nodes.push (...extra_nodes);
1068+
}
1069+
}*/
1070+
1071+
_.each(add_nodes, (n2a) => {
1072+
node_list.push(n2a);
1073+
node_set.add(n2a);
1074+
});
10411075
});
10421076
}
10431077
}
10441078

1045-
const existing_nodes = _.map(
1079+
edge_set = new Set();
1080+
_.each(
10461081
_.filter(node_list, (d) => d in this.json.Nodes),
1047-
(d) => edgesByNode[d]
1082+
(d) => {
1083+
for (const e of edgesByNode[d]) {
1084+
edge_set.add(e);
1085+
}
1086+
}
10481087
);
10491088

1050-
edge_set = [
1089+
edge_set = [...edge_set];
1090+
1091+
/*edge_set = [
10511092
...existing_nodes.reduce((acc, set) => {
10521093
return new Set([...acc, ...set]);
10531094
}, new Set()),
1054-
];
1095+
];*/
10551096
} else {
10561097
edge_set = this.json.Edges;
10571098
}
@@ -1464,15 +1505,44 @@ class HIVTxNetwork {
14641505
const nodeID2idx = {};
14651506
const edgesByNode = {};
14661507

1467-
_.each(this.json.Nodes, (n, i) => {
1468-
nodeID2idx[n.id] = i;
1469-
edgesByNode[i] = new Set();
1470-
});
1508+
if (this.has_multiple_sequences) {
1509+
const blobs = {};
1510+
_.each(this.json.Nodes, (n, i) => {
1511+
nodeID2idx[n.id] = i;
1512+
edgesByNode[i] = new Set();
1513+
blobs[i] = new Set();
1514+
});
14711515

1472-
_.each(this.json.Edges, (e) => {
1473-
edgesByNode[e.source].add(e);
1474-
edgesByNode[e.target].add(e);
1475-
});
1516+
_.each(this.primary_key_list, (list, id) => {
1517+
let ids = _.map(list, (n) => nodeID2idx[n.id]);
1518+
_.each(ids, (id) => {
1519+
_.each(ids, (iid) => blobs[id].add(iid));
1520+
});
1521+
});
1522+
1523+
_.each(this.json.Edges, (e) => {
1524+
_.each([...blobs[e.source]], (id) => {
1525+
let ee = _.clone(e);
1526+
ee.source = id;
1527+
edgesByNode[id].add(ee);
1528+
});
1529+
_.each([...blobs[e.target]], (id) => {
1530+
let ee = _.clone(e);
1531+
ee.target = id;
1532+
edgesByNode[id].add(ee);
1533+
});
1534+
});
1535+
} else {
1536+
_.each(this.json.Nodes, (n, i) => {
1537+
nodeID2idx[n.id] = i;
1538+
edgesByNode[i] = new Set();
1539+
});
1540+
1541+
_.each(this.json.Edges, (e) => {
1542+
edgesByNode[e.source].add(e);
1543+
edgesByNode[e.target].add(e);
1544+
});
1545+
}
14761546

14771547
let traversal_cache = null;
14781548

@@ -1739,6 +1809,8 @@ class HIVTxNetwork {
17391809
edgesByNode
17401810
);
17411811

1812+
//console.log (pg.name, _.map ([...added_nodes], (n)=>this.json.Nodes[n]));
1813+
17421814
if (added_nodes.size) {
17431815
_.each([...added_nodes], (nid) => {
17441816
const n = this.json.Nodes[nid];

src/hivtrace.css

+1-3
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,7 @@ circle.selected_object {
191191
stroke: #000;
192192
}
193193

194-
g.multi_sequence,
195-
path.multi_sequence,
196-
circle.multi_sequence {
194+
.multi_sequence {
197195
stroke-width: 1px;
198196
stroke: #350e6b;
199197
border-radius: 50%;

src/hivtraceClusterGraphSummary.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Creates and populates a summary table for an HIV trace cluster graph.
2121
None
2222
*/
2323

24-
function hivtraceClusterGraphSummary(graph, tag, not_CDC) {
24+
function hivtraceClusterGraphSummary(network, tag, not_CDC) {
2525
// Select the target element for appending the summary table
2626
var summary_table = d3.select(tag).select("tbody");
2727

@@ -30,6 +30,8 @@ function hivtraceClusterGraphSummary(graph, tag, not_CDC) {
3030
summary_table = d3.select(tag).append("tbody");
3131
}
3232

33+
let graph = network.json;
34+
3335
// Initialize an empty array to store table data
3436
var table_data = [];
3537

@@ -101,6 +103,17 @@ function hivtraceClusterGraphSummary(graph, tag, not_CDC) {
101103
degrees["Q1"] + " - " + degrees["Q3"],
102104
]);
103105

106+
if (network.has_multiple_sequences) {
107+
table_data.push([
108+
"Persons with ≥1 sequence",
109+
_.filter(network.primary_key_list, (d, k) => d.length > 1).length,
110+
]);
111+
table_data.push([
112+
"Persons in multiple clusters",
113+
_.size(network.entities_in_multiple_clusters),
114+
]);
115+
}
116+
104117
// If not CDC flag is false, add additional statistics
105118
if (!not_CDC) {
106119
// Extract edge lengths from graph and calculate statistics

0 commit comments

Comments
 (0)