From db6eb175aa7c25948677a9b64258afd377016d8c Mon Sep 17 00:00:00 2001
From: Alexander Thomas <77535027+alethomas@users.noreply.github.com>
Date: Sat, 18 Jun 2022 17:37:09 +0200
Subject: [PATCH] fix: voc probability (#541)
---
resources/lineage-variant-table-formatter.js | 14 ++++++++++++--
workflow/scripts/generate-lineage-variant-table.py | 14 +++++++++++---
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/resources/lineage-variant-table-formatter.js b/resources/lineage-variant-table-formatter.js
index c980d5682..862fe9d67 100644
--- a/resources/lineage-variant-table-formatter.js
+++ b/resources/lineage-variant-table-formatter.js
@@ -117,13 +117,23 @@
Probability: function (prob) {
prob = parseFloat(prob)
if (!isNaN(prob)) {
- var lighting = (0.9 - prob * 0.4) * 100;
+ if (prob < 0.5) {
+ var lighting = (0.5 + (prob * 0.8)) * 100;
+ var color = "10, 85%, " + lighting + "%"
+
+ } else if (prob < 0.95 && prob >= 0.5){
+ var lighting = ((0.9 * prob) + 0.05) * 100;
+ var color = "47, 100%, " + lighting + "%"
+ } else {
+ var lighting = (8.5 - (prob * 8)) * 100;
+ var color = "138, 72%, " + lighting + "%"
+ }
if (prob < 0.1) {
prob = prob.toExponential(2)
} else {
prob = prob.toFixed(2)
}
- return `${prob}`;
+ return `${prob}`;
} else {
return " "
}
diff --git a/workflow/scripts/generate-lineage-variant-table.py b/workflow/scripts/generate-lineage-variant-table.py
index 6784c48a0..6a7491fed 100644
--- a/workflow/scripts/generate-lineage-variant-table.py
+++ b/workflow/scripts/generate-lineage-variant-table.py
@@ -21,11 +21,19 @@ def phred_to_prob(phred):
# np.prod returns 1's as values for a pd series with NaN's. A list would return NaN's
-def prod_prob_not_present(probs):
+# switched for use of minimum
+# def prod_prob_not_present(probs):
+# if pd.isna(probs).any():
+# return pd.NA
+# else:
+# return np.prod(probs)
+
+
+def min_prob_not_present(probs):
if pd.isna(probs).any():
return pd.NA
else:
- return np.prod(probs)
+ return np.min(probs)
def has_numbers(inputString):
@@ -89,7 +97,7 @@ def rename_enumeration(list_length):
variants_df = variants_df.groupby(["Mutations"]).agg(
func={
"Frequency": lambda x: min(sum(x), 1.0),
- "Prob_not_present": prod_prob_not_present,
+ "Prob_not_present": min_prob_not_present,
"ReadDepth": np.min,
},
axis=1,