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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
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 @@ -284,3 +284,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.
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
41 changes: 34 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"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this fail if there is no global tsv?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I would expect the user to define one in case this option has been activated.

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,14 @@ def get_delly_excluded_regions():
)
else:
return []


def get_alignment_props(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 f"results/alignment-properties/{wildcards.group}/{wildcards.sample}.json"
4 changes: 1 addition & 3 deletions workflow/rules/mapping.smk
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ rule map_reads_bwa:
"v3.8.0/bio/bwa/mem"


# Create distance and minimizer index before mapping
# Otherwise it will be performed on the first execution leading to race conditions for multiple samples
rule map_reads_vg:
input:
reads=get_map_reads_input,
Expand All @@ -31,7 +29,7 @@ rule map_reads_vg:
extra="",
sorting="fgbio",
sort_order="queryname",
threads: 8
threads: 64
wrapper:
"v5.3.0/bio/vg/giraffe"

Expand Down
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