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: allow setting of custom alignment properties #346

Merged
merged 7 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions .test/config-chm-eval/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,8 @@ report:
stratify:
activate: false
by-column: condition

custom_alignment_properties:
activate: false
column: "panel"
tsv: ""
5 changes: 5 additions & 0 deletions .test/config-giab/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,8 @@ params:

gene_coverage:
min_avg_coverage: 5

custom_alignment_properties:
activate: false
column: "panel"
tsv: ""
5 changes: 5 additions & 0 deletions .test/config-no-candidate-filtering/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,8 @@ report:
stratify:
activate: false
by-column: condition

custom_alignment_properties:
activate: false
column: "panel"
tsv: ""
5 changes: 5 additions & 0 deletions .test/config-simple/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,8 @@ tables:
coverage: true
event_prob: true
generate_excel: true

custom_alignment_properties:
activate: false
column: "panel"
tsv: ""
7 changes: 6 additions & 1 deletion .test/config-sra/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,9 @@ tables:
genotype: true
coverage: true
event_prob: true
generate_excel: true
generate_excel: true

custom_alignment_properties:
activate: false
column: "panel"
FelixMoelder marked this conversation as resolved.
Show resolved Hide resolved
tsv: ""
5 changes: 5 additions & 0 deletions .test/config-target-regions/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,8 @@ tables:
coverage: true
event_prob: true
generate_excel: true

custom_alignment_properties:
activate: false
column: "panel"
tsv: ""
5 changes: 5 additions & 0 deletions .test/config-target-regions/config_multiple_beds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,8 @@ tables:
coverage: true
event_prob: true
generate_excel: true

custom_alignment_properties:
activate: false
column: "panel"
tsv: ""
7 changes: 6 additions & 1 deletion .test/config_primers/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,9 @@ tables:
genotype: true
coverage: true
event_prob: true
generate_excel: true
generate_excel: true

custom_alignment_properties:
activate: false
column: "panel"
tsv: ""
1 change: 1 addition & 0 deletions config/alignment_properties.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name path
9 changes: 9 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,12 @@ params:
freebayes:
min_alternate_fraction: 0.05 # Reduce for calling variants with lower VAFs
extra: ""

# If activated preprocessed alignment properties can be applied to each sample individually.
# Paths to the alignment properties json-files need to be set in a tsv-file containing a property name and path.
# Alignment properties will be derived from a customizable column in the sample sheet.
# If not property name is set for a sample the alignment properties will be estimated best on the samples mapping.
johanneskoester marked this conversation as resolved.
Show resolved Hide resolved
custom_alignment_properties:
activate: false
column: "panel"
tsv: "config/alignment_properties.tsv"
2 changes: 1 addition & 1 deletion workflow/rules/calling.smk
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ rule varlociraptor_preprocess:
candidates=get_candidate_calls,
bam="results/recal/{sample}.bam",
bai="results/recal/{sample}.bai",
alignment_props="results/alignment-properties/{group}/{sample}.json",
alignment_props=get_alignment_props(),
output:
"results/observations/{group}/{sample}.{caller}.{scatteritem}.bcf",
params:
Expand Down
44 changes: 37 additions & 7 deletions workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,29 @@ primer_panels = (
)


def is_activated(xpath):
c = config
for entry in xpath.split("/"):
c = c.get(entry, {})
return bool(c.get("activate", False))


custom_alignment_props = (
(
pd.read_csv(
config["custom_alignment_properties"]["tsv"],
johanneskoester marked this conversation as resolved.
Show resolved Hide resolved
sep="\t",
dtype={"name": str, "path": str},
comment="#",
)
.set_index(["name"], drop=False)
.sort_index()
)
if is_activated("custom_alignment_properties")
else None
)
johanneskoester marked this conversation as resolved.
Show resolved Hide resolved


def get_calling_events(calling_type):
events = [
event
Expand Down Expand Up @@ -606,13 +629,6 @@ def get_all_group_observations(wildcards):
)


def is_activated(xpath):
c = config
for entry in xpath.split("/"):
c = c.get(entry, {})
return bool(c.get("activate", False))


def get_star_read_group(wildcards):
"""Denote sample name and platform in read group."""
platform = extract_unique_sample_column_value(wildcards.sample, "platform")
Expand Down Expand Up @@ -1591,3 +1607,17 @@ def get_delly_excluded_regions():
)
else:
return []


def get_alignment_props():
def inner(wildcards):
if is_activated("custom_alignment_properties"):
alignment_prop_column = config["custom_alignment_properties"]["column"]
prop_name = extract_unique_sample_column_value(
wildcards.sample, alignment_prop_column
)
if pd.notna(prop_name):
return custom_alignment_props.loc[prop_name, "path"]
return "results/alignment-properties/{group}/{sample}.json"

return inner
FelixMoelder marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 12 additions & 0 deletions workflow/schemas/config.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,17 @@ properties:
- freebayes
- varlociraptor

custom_alignment_properties:
type: object
properties:
activate:
type: boolean
column:
type: string
tsv:
type: string


required:
- samples
- units
Expand All @@ -355,3 +366,4 @@ required:
- calling
- params
- annotations
- custom_alignment_properties
FelixMoelder marked this conversation as resolved.
Show resolved Hide resolved
Loading