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

feat: add group-by-variant-oncoprint #237

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
22065a2
feat: add group-by-variant-oncoprint
johanneskoester May 15, 2023
5278ea7
ongoing work
johanneskoester May 24, 2023
ba7b6b2
clean up config
johanneskoester May 24, 2023
ba85c33
latest datavzrd
johanneskoester May 24, 2023
245f138
Merge branch 'master' into feat/group-by-variant-oncoprint
johanneskoester Jun 14, 2023
97a7c44
fix corner case of having empty calls
johanneskoester Jun 14, 2023
ecf72cd
Merge branch 'feat/group-by-variant-oncoprint' of github.com:snakemak…
johanneskoester Jun 14, 2023
83b609c
fix label names
johanneskoester Jun 21, 2023
02b979a
formatting
FelixMoelder Jun 23, 2023
acc8102
import json
FelixMoelder Jun 23, 2023
86017c9
Merge branch 'master' into feat/group-by-variant-oncoprint
FelixMoelder Jun 27, 2023
81a317d
fixes
johanneskoester Jun 28, 2023
ef6a6c5
Merge branch 'feat/group-by-variant-oncoprint' of github.com:snakemak…
johanneskoester Jun 28, 2023
7959fcf
use custom vega plot for group by variant oncoprint
johanneskoester Jun 28, 2023
a29c0c5
Merge branch 'master' into feat/group-by-variant-oncoprint
johanneskoester Jul 3, 2023
999de91
fixes
johanneskoester Aug 7, 2023
0fa26ce
fixes
johanneskoester Aug 7, 2023
f0f363b
Merge branch 'feat/group-by-variant-oncoprint' of github.com:snakemak…
johanneskoester Aug 7, 2023
dd38d93
fixes
johanneskoester Aug 7, 2023
d5eb69f
fixes
johanneskoester Aug 7, 2023
3c28d04
improvements
johanneskoester Aug 7, 2023
75e90e2
fix rect height
johanneskoester Aug 20, 2023
94b1ee8
fixes
johanneskoester Aug 21, 2023
db3b797
add somalier
johanneskoester Sep 4, 2023
1e0cd3b
fixed multiqc
johanneskoester Sep 7, 2023
13b16ed
update target
johanneskoester Sep 7, 2023
d75426c
simplify code
johanneskoester Sep 18, 2023
f3ae314
sorting and label config
johanneskoester Oct 4, 2023
91a9490
polishing
johanneskoester Oct 5, 2023
603c8a2
fixes
johanneskoester Oct 6, 2023
7b8ff8b
fix
johanneskoester Mar 19, 2024
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
!workflow/scripts/*
!workflow/rules/*
!workflow/rules/annotation/*
!workflow/resources/*
!workflow/resources/**
!config/*
!LICENSE
!README.md
Expand Down
13 changes: 11 additions & 2 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ report:
activate: false
# select a sample sheet column for stratification
by-column: condition
# Optionally define annotation label types sort direction and domain for
# displaying them as heatmaps.
# By default, the annotated values are considered to be 'nominal',
# leading to categorical color coding without an order.
# Alternatively, you can set them as quantitative or ordinal here.
# The domain can take any values that are considered valid by vega-lite.
# annotation_labels:
# mycolumn:
# type: ordinal
# ascending: true
# domain: [-100, 0]

calling:
# Set to true to infer classical genotypes from Varlociraptor's VAF predictions
Expand Down Expand Up @@ -181,8 +192,6 @@ tables:
# Uncomment and add VEP annotation fields to include (IMPACT, Consequence, Feature, SYMBOL, and HGVSp are always included)
annotation_fields:
- EXON
event_prob: true
observations: true
generate_excel: true

params:
Expand Down
7 changes: 7 additions & 0 deletions workflow/envs/somalier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
channels:
- conda-forge
- bioconda
- nodefaults
dependencies:
- somalier =0.2.18
- bcftools =1.17
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
"symbol",
"hgvsp",
"hgvsg",
"consequence"
]
180 changes: 180 additions & 0 deletions workflow/resources/datavzrd/spec_compact_oncoprint.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"config": {
"concat": {
"spacing": 0
}
},
"resolve": {
"scale": {
"color": "independent",
"x": "shared"
}
},
"vconcat": [
{% for annotation_label in params.annotation_labels %}
{
"transform": [
{
"filter": "datum.annotation == '{{ annotation_label|replace("'", "\'") }}'"
}
],
"mark": "rect",
"encoding": {
"x": {
"field": "group",
"type": "ordinal",
{% if loop.first %}
"axis": {
"orient": "top",
"title": null
},
{% else %}
"axis": null,
{% endif %}
"sort": {{ params.group_sorting|tojson }}
},
"y": {
"field": "annotation",
"axis": {
"title": null
},
"scale": {
"scheme": "category10"
}
},
"color": {
"field": "annotation_value",
"type": {{ params.annotation_label_config[annotation_label].get("type", "nominal")|tojson }},
{% if params.annotation_label_config[annotation_label].get("domain") is not none %}
"scale": {
"domain": {{ params.annotation_label_config[annotation_label].get("domain")|tojson }}
},
{% endif %}
"legend": null
},
"opacity": {
"value": 0.8
},
"tooltip": {"field": "annotation_value"}
}
},
{% endfor %}
{
"layer": [
{
"transform": [
{
"filter": "datum.status"
}
],
"mark": {
"type": "rect",
"color": "lightgrey"
},
"encoding": {
"x": {
"field": "group",
"type": "ordinal",
"axis": null,
"sort": {{ params.group_sorting|tojson }}
},
"y": {
"field": "symbol",
"type": "nominal",
"axis": {
"title": null
},
"sort": {
"op": "count",
"field": "status",
"order": "descending"
}
}
}
},
{
"transform": [
{
"filter": "datum.status"
}
],
"height": {
"step": 3
},
"mark": {
"type": "rect",
"tooltip": true,
},
"encoding": {
"x": {
"field": "group",
"type": "ordinal",
"axis": null,
"sort": {{ params.group_sorting|tojson }}
},
"y": {
"field": "symbol",
"type": "nominal",
"axis": {
"title": null,
"grid": true,
"zindex": 0
},
"sort": {
"op": "count",
"field": "status",
"order": "descending"
}
},
"yOffset": {
"field": "status",
"type": "nominal"
},
"color": {
"field": "status",
"type": "nominal",
"scale": {
"scheme": "category10"
},
"legend": {"labelLimit": 1000}
}
}
}
]
},
{
"transform": [{"filter": "datum.status"}],
"mark": "rect",
"encoding": {
"x": {
"field": "group",
"type": "ordinal",
"axis": null,
"sort": {{ params.group_sorting|tojson }}
},
"color": {
"aggregate": "count",
"field": "status",
"legend": {
"title": "#events"
}
},
"tooltip": {
"field": "status",
"aggregate": "count"
}
}
}
],
"transform": [
{
"calculate": "datum.hgvsp ? (datum.symbol + ':' + split(replace(datum.hgvsp, '%3D', '='), ':')[1]): datum.hgvsg",
"as": "variant"
},
{
"calculate": "datum.hgvsp ? datum.hgvsp : datum.hgvsg",
"as": "alteration"
}
]
}
33 changes: 27 additions & 6 deletions workflow/resources/datavzrd/variant-calls-template.datavzrd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ default-view: ?"overview" if input.variant_oncoprints else f"{params.groups[0]}-

__definitions__:
- import os
- import pandas as pd
- |
def read_file(path):
return open(path, 'r').read()
Expand All @@ -30,6 +31,16 @@ __definitions__:
}}
}}
"""
- |
def get_annotation_scale(annotation):
# TODO remove this function once datavzrd does it internally (next release)
thetype = params.annotation_label_config[annotation].get("type", "ordinal")
if thetype == "quantitative":
return "linear"
elif thetype == "nominal":
return "ordinal"
else:
return thetype

datasets:
?if input.variant_oncoprints:
Expand All @@ -41,9 +52,12 @@ datasets:
gene details:
column: symbol
view: "overview-{value}"
compact-oncoprint:
path: ?params.compact_oncoprint
separator: "\t"
?for label in params.labels.index.values:
?label:
path: ?os.path.join(params.oncoprint_sorted_datasets, f"{label}.tsv")
path: ?os.path.join(input.compact_oncoprint_sortings, f"{label}.tsv")
separator: "\t"
headers: 2
?for gene, path in params.variant_oncoprints:
Expand Down Expand Up @@ -71,7 +85,7 @@ views:
?if params.gene_oncoprint:
?for view in ["gene-oncoprint"] + list(params.labels.index.values):
__variables__:
labels: ?params.group_annotations.columns.values if view == "gene-oncoprint" else [view]
labels: ?list(params.group_annotations.columns.values) if view == "gene-oncoprint" else [view]
?"overview" if view == "gene-oncoprint" else f"by {view}":
?if view == "gene-oncoprint":
desc: |
Expand All @@ -95,7 +109,7 @@ views:
label: ?annotation
plot:
heatmap:
scale: ordinal
scale: ?get_annotation_scale(annotation)
color-scheme: category20
columns:
symbol:
Expand Down Expand Up @@ -124,21 +138,28 @@ views:
ticks:
scale: linear
optional: true


?for sort_label, spec_path in zip(params.labels.index, input.specs_compact_oncoprint):
?f"compact-oncoprint-by-{sort_label}":
desc: ?f"Compact oncoprint sorted by {sort_label}. Hover annotation rows with the mouse pointer to see values associated with colors."
dataset: compact-oncoprint
render-plot:
spec-path: ?spec_path

?for gene, path in params.variant_oncoprints:
?f"overview-{gene}":
desc: ?f"Variants found in gene {gene}."
dataset: ?f"variant-oncoprint-{gene}"
hidden: true
render-table:
?if params.group_annotations.columns.values:
?if list(params.group_annotations.columns.values):
headers:
?for i, annotation in enumerate(params.group_annotations.columns.values):
?i + 1:
label: ?annotation
plot:
heatmap:
scale: ordinal
scale: ?get_annotation_scale(annotation)
color-scheme: category20
columns:
consequence:
Expand Down
Loading
Loading