From 0618da197b740ee3b92a7f260555109171e8706c Mon Sep 17 00:00:00 2001 From: Sergei Date: Sat, 2 Nov 2024 09:40:12 -0400 Subject: [PATCH] Adjusting some of the network statistics to be aware of MSPP --- html/priority-sets-args.html | 2 +- src/clusternetwork.js | 15 +++++++++++++++ src/hivtraceClusterGraphSummary.js | 6 +++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/html/priority-sets-args.html b/html/priority-sets-args.html index 6df0019..52be824 100644 --- a/html/priority-sets-args.html +++ b/html/priority-sets-args.html @@ -975,7 +975,7 @@ } else { d3.select("#app-error").style("display", "none"); hivtrace.histogramDistances(graph, histogram_tag, histogram_label); - hivtrace.graphSummary(graph, graph_summary_tag); + hivtrace.graphSummary(user_graph.json, graph_summary_tag); [ "#main-tab", diff --git a/src/clusternetwork.js b/src/clusternetwork.js index 117c837..fb074df 100755 --- a/src/clusternetwork.js +++ b/src/clusternetwork.js @@ -1711,12 +1711,15 @@ var hivtrace_cluster_network_graph = function ( self.cluster_sizes = []; self.cluster_sizes_in_entities = {}; + let cluster_set = new Set(); + graph_data.Nodes.forEach((d) => { if (typeof self.cluster_sizes[d.cluster - 1] === "undefined") { self.cluster_sizes[d.cluster - 1] = 1; } else { self.cluster_sizes[d.cluster - 1]++; } + cluster_set.add(d.cluster); if ("is_lanl" in d) { d.is_lanl = d.is_lanl === "true"; } @@ -1732,13 +1735,25 @@ var hivtrace_cluster_network_graph = function ( }); if (self.has_multiple_sequences) { + let entity_count = 0; self.apply_to_entities((entity_id, nodes) => { if (self.cluster_sizes_in_entities[nodes[0].cluster]) { self.cluster_sizes_in_entities[nodes[0].cluster]++; } else { self.cluster_sizes_in_entities[nodes[0].cluster] = 1; } + entity_count++; + }); + self.json["Network Summary"]["Nodes"] = entity_count; + self.json["Network Summary"]["Clusters"] = _.size( + self.cluster_sizes_in_entities + ); + self.json["Cluster sizes"] = []; + _.each(self.cluster_sizes_in_entities, (d, c) => { + self.json["Cluster sizes"].push(d); }); + } else { + self.json["Network Summary"]["Clusters"] = cluster_set.size; } /* add buttons and handlers */ diff --git a/src/hivtraceClusterGraphSummary.js b/src/hivtraceClusterGraphSummary.js index 8859afa..99d8fc8 100644 --- a/src/hivtraceClusterGraphSummary.js +++ b/src/hivtraceClusterGraphSummary.js @@ -37,7 +37,7 @@ function hivtraceClusterGraphSummary(graph, tag, not_CDC) { if (!summary_table.empty()) { _.each(graph["Network Summary"], (value, key) => { // Handle special case for cluster count - if (key === "Clusters") { + if (not_CDC && key === "Clusters") { value = _.size(graph["Cluster description"]); } @@ -97,7 +97,7 @@ function hivtraceClusterGraphSummary(graph, tag, not_CDC) { degrees["min"] + " - " + degrees["max"], ]); table_data.push([ - "  " + __("statistics")["interquartile_range"] + "range", + "  " + __("statistics")["interquartile_range"] + "", degrees["Q1"] + " - " + degrees["Q3"], ]); @@ -123,7 +123,7 @@ function hivtraceClusterGraphSummary(graph, tag, not_CDC) { _defaultPercentFormat(degrees["max"]), ]); table_data.push([ - "  " + __("statistics")["interquartile_range"] + "range", + "  " + __("statistics")["interquartile_range"] + "", _defaultPercentFormat(degrees["Q1"]) + " - " + _defaultPercentFormat(degrees["Q3"]),