ALIGNOTH_REPORT
Export variants via vembrane and create alignment plots with alignoth for a Datavzrd report.
Usage
Via module
This usage is recommended with Snakemake >=7.9.
You can include this meta-wrapper in your workflow via the Snakemake module system:
module alignoth_report:
meta_wrapper: "v8.1.0/meta/bio/alignoth_report"
pathvars:
results="...", # Path to results directory
logs="...", # Path to logs directory
use rule * from alignoth_report as alignoth_report_*
Upon using the rules, you can additionally modify input, output, log, and params as needed (see the definition of each rule below and the modules documentation). For additional parameters in each individual wrapper, please refer to their corresponding documentation (see links below).
Via copy-paste
Alternatively, you can directly copy-paste and modify the full meta-wrapper code below into your workflow.
Execution
When running with
snakemake --sdm conda
the software dependencies will be automatically deployed into an isolated environment before execution.
Used wrappers
The following individual wrappers are used in this meta-wrapper:
Please refer to each wrapper in above list for additional configuration parameters and information about the executed code.
Code
def get_alignoth_tables(wildcards, results_dir):
count = count_variants(wildcards)
return [f"{results_dir}/alignoth/{{sample}}/{i}/" for i in range(count)]
def count_variants(wildcards):
return sum(1 for _ in open(checkpoints.vembrane_table.get(sample=wildcards.sample).output[0], "r")) - 1
checkpoint vembrane_table:
input:
"<results>/{sample}.bcf",
output:
"<results>/tables/{sample}.tsv"
log:
"<logs>/vembrane_table/{sample}.log"
params:
expression="INDEX, CHROM, POS, REF, ALT",
extra=""
wrapper:
"v7.6.1/bio/vembrane/table"
rule alignoth:
input:
bam="<results>/mapped/{sample}.bam",
bam_idx="<results>/mapped/{sample}.bam.bai",
reference="resources/genome.fa",
reference_idx="resources/genome.fa.fai",
vcf="<results>/{sample}.bcf",
vcf_idx="<results>/{sample}.bcf.csi",
overview="<results>/tables/{sample}.tsv"
output:
directory("<results>/alignoth/{sample}/{index}/")
params:
extra=lambda wc, input: f"--around-vcf-record {wc.index} -f tsv"
log:
"<logs>/alignoth/{sample}_{index}.log"
wrapper:
"v8.0.2/bio/alignoth"
rule datavzrd:
input:
config=workflow.source_path("resources/template.datavzrd.yaml"),
overview="<results>/tables/{sample}.tsv",
plot_tables=lambda wc: get_alignoth_tables(wc, "<results>")
output:
report(
directory("<results>/datavzrd-report/{sample}"),
htmlindex="index.html",
),
# config = "resources/datavzrd/{sample}.rendered_config.yaml"
params:
max_index=lambda wc: count_variants(wc)
log:
"<logs>/datavzrd/{sample}.log",
wrapper:
"v7.9.1/utils/datavzrd"