Skip to content

Commit

Permalink
fix: voc probability (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
alethomas authored Jun 18, 2022
1 parent 2ac229c commit db6eb17
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
14 changes: 12 additions & 2 deletions resources/lineage-variant-table-formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<span class="badge p-0 m-1"><span class="p-1 rounded" style="background:hsl(138, 72%, ${lighting}%);">${prob}</span></span>`;
return `<span class="badge p-0 m-1"><span class="p-1 rounded" style="background:hsl(${color});">${prob}</span></span>`;
} else {
return "&nbsp;"
}
Expand Down
14 changes: 11 additions & 3 deletions workflow/scripts/generate-lineage-variant-table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit db6eb17

Please sign in to comment.