I have the following Snakemake
rules (I have only shown the relevant parts):
SAMPLE_IP = ['control_1_hif1a_hyp', 'control_2_hif1a_hyp']
SAMPLE_INPUT = ['control_1_input_hyp', 'control_2_input_hyp']
rule all:
input:
expand("bigwig/compare/{sample_ip}_vs_{sample_input}.bw", sample_ip=SAMPLE_IP, sample_input=SAMPLE_INPUT),]
rule bigwig_sample_vs_input:
input:
ip="mapped/{sample_ip}_dedup.bam",
inpt="mapped/{sample_input}_dedup.bam",
output:
"bigwig/compare/{sample_ip}_vs_{sample_input}.bw",
params:
bs=config["general"]["bigwig"]["binSize"],
threads: config["resources"]["deeptools"]["cpu"]
resources:
runtime=config["resources"]["deeptools"]["time"]
conda:
"envs/chipseq.yaml"
shell:
"bamCompare -p {threads} -bs {params.bs} -b1 {input.ip} -b2 {input.inpt} "
The rule works but Snakemake
creates four .bw
files with these values:
sample_input: control_1_input_hyp
sample_ip: control_1_hif1a_hyp
sample_input: control_2_input_hyp
sample_ip: control_1_hif1a_hyp
sample_input: control_1_input_hyp
sample_ip: control_2_hif1a_hyp
sample_input: control_2_input_hyp
sample_ip: control_2_hif1a_hyp
But I only want to use:
sample_input: control_1_input_hyp
sample_ip: control_1_hif1a_hyp
sample_input: control_2_input_hyp
sample_ip: control_2_hif1a_hyp
How can I tell Snakemake
to only combine the elements from SAMPLE_IP
and SAMPLE_INPUT
that have the same position in these lists?
Use the zip
option in expand
, your directive for input
in rule all
would look like this:
expand("bigwig/compare/{sample_ip}_vs_{sample_input}.bw", zip, sample_ip=SAMPLE_IP, sample_input=SAMPLE_INPUT),]