Is it possible to use wildcards when defining parameters using config.yaml files in snakemake? I use a general R script to make the same basic heatmap but with different input matrices. I'd like to specify the configuration for the heatmap (such as number of K for K-means clustering) for each heatmap from my config.yaml file using wildcards.
For example:
rule heatmap:
input: {condition}.mat
output: {condition}.png
params: clusters=config["heatmap-{condition}"][k]
log: "logs/results/heatmap-{condition}.log"
So that way I can define the number of k as 20 in my config.yaml file like this when {condition} = "development"
:
heatmap-development:
k:
- 20
Right now I get a KeyError
for '{condition}'
. Any help would be appreciated, thanks so much
You need to use a function in the params directive for it to know the wildcards.
rule heatmap:
input: {condition}.mat
output: {condition}.png
params: clusters = lambda w: config["heatmap-{}".format(w.condition)][k]
log: "logs/results/heatmap-{condition}.log"
Read more here: http://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#non-file-parameters-for-rules
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With