generated from snakemake-workflows/snakemake-workflow-template
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Report FP / FN negative variants in single table #107
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4b1a64b
feat: Change folder structure for fp-fn results, add collection of fp…
BiancaStoecker 6456fb5
fix: fmt and clean up
BiancaStoecker 0f5198e
fix: fix bug with collect-fp-fn when running low and high coverage ca…
BiancaStoecker c09e5fe
feat: yte config and report rendering per benchmark
famosab 1431b3a
fix: snakefmt
famosab 7f620d1
fix: output naming
famosab 31f3add
feat: add new datavzrd reports to Snakefile
famosab 49d2330
fix: snakefmt
famosab 2b5f9d3
fix: fix input files and params.labels for report_fp_fn_benchmark
BiancaStoecker 5e8dbb9
feat: show columns based on germline/somatic
famosab e4c2eaa
fix: report directory
famosab f6bd3ca
fix: snakefmt
famosab af469ef
fix: column names to match gemrline
famosab 10dd05a
feat: add reports per callset
famosab a6b1e7f
fix: snakefmt
famosab a88e4e6
fix: reporting
famosab 2fda48f
fix: remove unused output
famosab 313bad5
feat: add description to reports and fix rule names
famosab 6bb7766
fix: remove repeated code
BiancaStoecker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
workflow/resources/datavzrd/fp-fn-per-benchmark-config.yte.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
__use_yte__: true | ||
|
||
__variables__: | ||
green: "#74c476" | ||
orange: "#fd8d3c" | ||
labels: ?params.labels | ||
|
||
name: ?f"{wildcards.classification} of {wildcards.benchmark}" | ||
|
||
webview-controls: true | ||
default-view: results-table | ||
|
||
datasets: | ||
results: | ||
path: ?input.table | ||
separator: "\t" | ||
offer-excel: true | ||
links: | ||
link to table: | ||
column: callset | ||
table-row: results-table/callset | ||
|
||
views: | ||
?for view in ["main", "coverage"]: | ||
results-table: | ||
dataset: results | ||
# desc: | | ||
# ?f""" | ||
# Benchmark version: {params.genome} {params.version} | ||
# """ | ||
page-size: 12 | ||
render-table: | ||
columns: | ||
coverage: | ||
plot: | ||
heatmap: | ||
scale: ordinal | ||
sort_index: | ||
display-mode: hidden | ||
?if params.somatic: | ||
true_genotype: | ||
display-mode: hidden | ||
predicted_genotype: | ||
display-mode: hidden |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import sys | ||
sys.stderr = open(snakemake.log[0], "w") | ||
|
||
import pandas as pd | ||
|
||
|
||
def load_data(path, callset): | ||
d = pd.read_csv(path, sep="\t") | ||
d.insert(0, "callset", callset) | ||
return d | ||
|
||
|
||
results = pd.concat( | ||
[ | ||
load_data(f, callset) | ||
for f, callset in zip(snakemake.input.tables, snakemake.params.callsets) | ||
], | ||
axis="rows", | ||
) | ||
famosab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def cov_key(cov_label): | ||
# return lower bound as integer for sorting | ||
if ".." in cov_label: | ||
return int(cov_label.split("..")[0]) | ||
else: | ||
return int(cov_label[1:]) | ||
|
||
|
||
|
||
def sort_key(col): | ||
if col.name == "callset": | ||
return col | ||
if col.name == "coverage": | ||
return col.apply(cov_key) | ||
else: | ||
return col | ||
|
||
famosab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
results.sort_values(["callset", "coverage"], inplace=True, key=sort_key) | ||
results["sort_index"] = results["coverage"].apply(cov_key) | ||
|
||
results.to_csv(snakemake.output[0], sep="\t", index=False) | ||
famosab marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import sys | ||
|
||
sys.stderr = open(snakemake.log[0], "w") | ||
|
||
import pandas as pd | ||
|
||
famosab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def get_cov_label(coverage): | ||
lower = snakemake.params.coverage_lower_bounds[coverage] | ||
bounds = [ | ||
bound | ||
for bound in snakemake.params.coverage_lower_bounds.values() | ||
if bound > lower | ||
] | ||
if bounds: | ||
upper = min(bounds) | ||
return f"{lower}..{upper}" | ||
else: | ||
return f"≥{lower}" | ||
|
||
|
||
def load_data(f, coverage): | ||
d = pd.read_csv(f, sep="\t") | ||
d.insert(0, "coverage", get_cov_label(coverage)) | ||
return d | ||
|
||
famosab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if snakemake.input: | ||
report = pd.concat( | ||
load_data(f, cov) for cov, f in zip(snakemake.params.coverages, snakemake.input) | ||
) | ||
|
||
# TODO With separate files for SNVs and indels with e.g. STRELKA no predicted variants for the other type are expected | ||
# If later relevant, add annotation to the report | ||
# if (report["tp_truth"] == 0).all(): | ||
# raise ValueError( | ||
# f"The callset {snakemake.wildcards.callset} does not predict any variant from the truth. " | ||
# "This is likely a technical issue in the callset and should be checked before further evaluation." | ||
# ) | ||
|
||
report.to_csv(snakemake.output[0], sep="\t", index=False) | ||
else: | ||
pd.DataFrame( | ||
{ | ||
col: [] | ||
for col in [ | ||
"coverage", | ||
"class", | ||
"chromosome position", | ||
"ref_allele", | ||
"alt_allele" | ||
"true_genotype", | ||
"predicted_genotype" | ||
] | ||
famosab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
).to_csv(snakemake.output[0], sep="\t") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.