The trick is to use a python dictionary to pair samples and a function to define Input files.
I will show an toy example with ChIP-seq processing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aDict = {"B":"inputG1", "A":"inputG1", "C":"inputG2"} | |
rule all: | |
input: ["C.bed", "A.bed", "B.bed"] | |
def get_files(wildcards): | |
case = wildcards.case | |
control = aDict[case] | |
return [case + ".sorted.bam", control + ".sorted.bam"] | |
rule call_peak: | |
input: get_files | |
output: "{case}.bed" | |
run: | |
case = input[0] | |
control = input[1] | |
shell("echo macs14 -t {case} -c {control} -n {wildcards.case}") | |
shell("touch {output}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# read https://groups.google.com/forum/#!searchin/snakemake/dependencies/snakemake/iDnr3PIcsfE/x-qQvzWBBgAJ | |
# https://groups.google.com/forum/#!searchin/snakemake/dependencies/snakemake/1QelazgzilY/oBgZoP19BL4J | |
aDict = {"B":"inputG1", "A":"inputG1", "C":"inputG2"} | |
rule all: | |
input: ["C.bed", "A.bed", "B.bed"] | |
def get_files(wildcards): | |
case = wildcards.case | |
control = aDict[case] | |
return [case + ".sorted.bam", control + ".sorted.bam"] | |
rule call_peak: | |
input: get_files | |
output: "{case}.bed" | |
shell: | |
""" | |
echo macs14 -t {input[0]} -c {input[1]} -n {wildcards.case} | |
touch {output} | |
""" |