Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: voc probability #541

Merged
merged 4 commits into from
Jun 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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