Skip to content

Commit

Permalink
feat: render single sample (#140)
Browse files Browse the repository at this point in the history
* feat: render single sample

* update varlociraptor

* fix template

* move to rule

* Update workflow/rules/common.smk

Co-authored-by: Johannes Köster <[email protected]>

* adjust function call

* snakefmt

* typo

* fix function call

Co-authored-by: Johannes Köster <[email protected]>
  • Loading branch information
FelixMoelder and johanneskoester authored May 10, 2022
1 parent a6cceec commit 2858ca8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 24 deletions.
33 changes: 17 additions & 16 deletions workflow/resources/datavzrd/variant-calls-template.datavzrd.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ?f"Variant calls {wildcards.event}"

default-view: overview
default-view: ?"overview" if input.variant_oncoprints else f"{params.groups[0]}-coding"

__definitions__:
- |
Expand Down Expand Up @@ -55,23 +55,24 @@ __definitions__:
"""
datasets:
gene-oncoprint:
path: ?params.gene_oncoprint
separator: "\t"
links:
gene details:
column: symbol
view: "overview-{value}"
?for gene, path in params.variant_oncoprints:
?f"variant-oncoprint-{gene}":
path: ?path
?if input.variant_oncoprints:
gene-oncoprint:
path: ?params.gene_oncoprint
separator: "\t"
links:
?for group in params.groups:
?group:
column: hgvsp
table-row: ?f"{group}-coding/hgvsp"
optional: true
gene details:
column: symbol
view: "overview-{value}"
?for gene, path in params.variant_oncoprints:
?f"variant-oncoprint-{gene}":
path: ?path
separator: "\t"
links:
?for group in params.groups:
?group:
column: hgvsp
table-row: ?f"{group}-coding/hgvsp"
optional: true

?for group, path in zip(params.groups, params.coding_calls):
?f"{group}-coding":
Expand Down
42 changes: 36 additions & 6 deletions workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -836,12 +836,17 @@ def get_oncoprint_input(wildcards):


def get_variant_oncoprint_tables(wildcards, input):
oncoprint_dir = input.variant_oncoprints
valid = re.compile(r"^[^/]+\.tsv$")
tables = [f for f in os.listdir(oncoprint_dir) if valid.match(f)]
assert all(table.endswith(".tsv") for table in tables)
genes = [gene_table[:-4] for gene_table in tables]
return list(zip(genes, expand(f"{oncoprint_dir}/{{oncoprint}}", oncoprint=tables)))
if input.variant_oncoprints:
oncoprint_dir = input.variant_oncoprints
valid = re.compile(r"^[^/]+\.tsv$")
tables = [f for f in os.listdir(oncoprint_dir) if valid.match(f)]
assert all(table.endswith(".tsv") for table in tables)
genes = [gene_table[:-4] for gene_table in tables]
return list(
zip(genes, expand(f"{oncoprint_dir}/{{oncoprint}}", oncoprint=tables))
)
else:
return []


def get_datavzrd_report_labels(wildcards):
Expand Down Expand Up @@ -886,3 +891,28 @@ def get_fastqc_results(wildcards):

# samtools stats
yield from expand("results/qc/{sample}.bam.stats", sample=group_samples)


def get_variant_oncoprints(wildcards):
if len(get_report_batch(wildcards)) > 1:
return "results/tables/oncoprints/{wildcards.batch}.{wildcards.event}/variant-oncoprints"
else:
return []


def get_oncoprint(oncoprint_type):
def inner(wildcards):
if len(get_report_batch(wildcards)) > 1:
oncoprint_path = (
f"results/tables/oncoprints/{wildcards.batch}.{wildcards.event}"
)
if oncoprint_type == "gene":
return f"{oncoprint_path}/gene-oncoprint.tsv"
elif oncoprint_type == "variant":
return f"{oncoprint_path}/variant-oncoprints"
else:
raise ValueError(f"bug: unsupported oncoprint type {oncoprint_type}")
else:
return []

return inner
4 changes: 2 additions & 2 deletions workflow/rules/datavzrd.smk
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ rule render_datavzrd_config:
template=workflow.source_path(
"../resources/datavzrd/variant-calls-template.datavzrd.yaml"
),
variant_oncoprints="results/tables/oncoprints/{batch}.{event}/variant-oncoprints",
variant_oncoprints=get_oncoprint("variant"),
output:
"resources/datavzrd/{batch}.{event}.datavzrd.yaml",
params:
gene_oncoprint="results/tables/oncoprints/{batch}.{event}/gene-oncoprint.tsv",
gene_oncoprint=get_oncoprint("gene"),
variant_oncoprints=get_variant_oncoprint_tables,
groups=get_report_batch,
coding_calls=get_datavzrd_data(impact="coding"),
Expand Down

0 comments on commit 2858ca8

Please sign in to comment.