在参数中使用通配符
Using wildcards in params
在snakemake中使用config.yaml文件定义参数时是否可以使用通配符?我使用通用 R 脚本制作相同的基本热图,但输入矩阵不同。我想使用通配符为我的 config.yaml 文件中的每个热图指定热图的配置(例如 K 均值聚类的 K 数)。
例如:
rule heatmap:
input: {condition}.mat
output: {condition}.png
params: clusters=config["heatmap-{condition}"][k]
log: "logs/results/heatmap-{condition}.log"
这样我就可以在我的 config.yaml 文件中将 k 的数量定义为 20,当 {condition} = "development"
:
heatmap-development:
k:
- 20
现在我得到 KeyError
'{condition}'
。任何帮助将不胜感激,非常感谢
您需要在 params 指令中使用一个函数,让它知道通配符。
rule heatmap:
input: {condition}.mat
output: {condition}.png
params: clusters = lambda w: config["heatmap-{}".format(w.condition)][k]
log: "logs/results/heatmap-{condition}.log"
在此处阅读更多内容:http://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#non-file-parameters-for-rules
在snakemake中使用config.yaml文件定义参数时是否可以使用通配符?我使用通用 R 脚本制作相同的基本热图,但输入矩阵不同。我想使用通配符为我的 config.yaml 文件中的每个热图指定热图的配置(例如 K 均值聚类的 K 数)。
例如:
rule heatmap:
input: {condition}.mat
output: {condition}.png
params: clusters=config["heatmap-{condition}"][k]
log: "logs/results/heatmap-{condition}.log"
这样我就可以在我的 config.yaml 文件中将 k 的数量定义为 20,当 {condition} = "development"
:
heatmap-development:
k:
- 20
现在我得到 KeyError
'{condition}'
。任何帮助将不胜感激,非常感谢
您需要在 params 指令中使用一个函数,让它知道通配符。
rule heatmap:
input: {condition}.mat
output: {condition}.png
params: clusters = lambda w: config["heatmap-{}".format(w.condition)][k]
log: "logs/results/heatmap-{condition}.log"
在此处阅读更多内容:http://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#non-file-parameters-for-rules