Newer
Older
get_targets('indexcov') if {'all', 'indexcov'}.intersection(MODULES_TO_RUN) else [],
get_targets('covviz') if {'all', 'covviz'}.intersection(MODULES_TO_RUN) else [],
get_targets('mosdepth') if {'all', 'mosdepth'}.intersection(MODULES_TO_RUN) else [],
########################## Mosdepth ##########################
bam = PROJECTS_PATH / PROJECT_NAME / "analysis" / "{sample}" / "bam" / "{sample}.bam",
bam_index = PROJECTS_PATH / PROJECT_NAME / "analysis" / "{sample}" / "bam" / "{sample}.bam.bai",
dist = OUT_DIR / "mosdepth" / "results" / "{sample}.mosdepth.global.dist.txt",
summary = OUT_DIR / "mosdepth" / "results" / "{sample}.mosdepth.summary.txt",
"Running mosdepth for coverage. Sample: {wildcards.sample}"
conda:
str(WORKFLOW_PATH / "configs/env/mosdepth.yaml")
params:
out_prefix = lambda wildcards, output: output['summary'].replace('.mosdepth.summary.txt', ''),
shell:
r"""
mosdepth \
--no-per-base \
--threads {threads} \
--fast-mode \
{params.out_prefix} \
dist = expand(str(OUT_DIR / "mosdepth" / "results" / "{sample}.mosdepth.global.dist.txt"),
script = WORKFLOW_PATH / "src/mosdepth/v0.3.1/plot-dist.py",
output:
OUT_DIR / "mosdepth" / f"mosdepth_{PROJECT_NAME}.html",
"Running mosdepth plotting"
params:
in_dir = lambda wildcards, input: Path(input[0]).parent,
workflow_dir = Path(workflow.basedir).parent
echo "Heads up: Mosdepth-plotting is run on all samples in "{params.in_dir}"; Not just the files mentioned in the rule's input."
cd {params.in_dir} # if not in directory, mosdepth uses filepath as sample name :(
--output {params.workflow_dir}/{output} \
########################## indexcov ##########################
rule indexcov:
input:
bam = expand(str(PROJECTS_PATH / PROJECT_NAME / "analysis" / "{sample}" / "bam" / "{sample}.bam"),
bam_index = expand(str(PROJECTS_PATH / PROJECT_NAME / "analysis" / "{sample}" / "bam" / "{sample}.bam.bai"),
goleft_tool = config['goleft']['tool'],
output:
html = OUT_DIR / "indexcov" / "index.html",
bed = OUT_DIR / "indexcov" / f"{PROJECT_NAME}-indexcov.bed.gz",
log = OUT_DIR / "indexcov" / "stdout.log",
"Running indexcov"
params:
outdir = lambda wildcards, output: Path(output[0]).parent,
project_dir = lambda wildcards, input: str(Path(input['bam'][0]).parents[2]),
shell:
r"""
echo "Heads up: Indexcov is run on all samples in the "project directory"; Not just the files mentioned in the rule's input."
{input.goleft_tool} indexcov \
--directory {params.outdir} \
{params.project_dir}/[LU][WD]*/bam/*.bam \
> {output.log} 2>&1
########################## covviz ##########################
rule covviz:
input:
bed = OUT_DIR / "indexcov" / f"{PROJECT_NAME}-indexcov.bed.gz",
html = OUT_DIR / "covviz" / "covviz_report.html",
log = OUT_DIR / "covviz" / "stdout.log",
"Running covviz"
conda:
str(WORKFLOW_PATH / "configs/env/covviz.yaml")
shell:
r"""
covviz \
--ped {input.ped} \
--output {output} \