【发布时间】:2022-01-04 01:02:40
【问题描述】:
我正在做蛇制作并在 python 中使用 seaborn。 我已经到了管道中的一个点,其中 snakemake 缺少输出。
snakemake 的伪代码看起来有点像这样:
WC1 = Wildcard1
WC2 = Wildcard2
rule all:
expand("/path/to/outputs{wc1}_{wc2}.png", wc1=WC1, wc2=WC2)
checkpoint seaborn:
input:
"/OtherPath/to/file1.csv"
"/AnotherPath/to/file2.tsv"
output:
"/path/to/outputs{wc1}_{wc2}.png"
shell:
"python SeabornPlot.py"
python 脚本,有点伪代码,应该是这样的:
import matplotlib.pyplot as plt
import seaborn as sns
CSV1 = pd.read_csv(snakemake.input[O], delimiter=",")
CSV2 = pd.read_csv(snakemake.input[1], delimiter=",")
for column in CSV1:
g = sns.barplot(x=column, data=CSV2)
fig = g.get_figure()
fig.savefig(snakemake.output[0])
plt.clf()
这不起作用。 python 脚本在snakemake 之外工作(使用正确的文件路径和名称)。我怀疑它与使用“snakemake.output[0]”有关,但我可以用什么代替?
我很确定这里的检查点是正确的,而不是规则。但如果我错了,请纠正我。
最后,我知道 rule all 中缺少一些东西。我可能应该为每个图添加一个带有新通配符的函数。
但我的主要问题是让 python 将绘图输出到正确的路径。
提前致谢!
【问题讨论】:
-
我看不出有什么理由让你在这里想要检查点而不是规则。当规则生成未指定数量的输出并且您有依赖于这些未知输出的下游规则时,将使用检查点。这些你都没有。
-
请在您的问题中包含您的命令和错误消息!它使人们更容易帮助您,并且更有可能他们会尝试。如果您没有提供足够的详细信息,许多贡献者只会对您的问题投反对票并继续前进。
标签: python matplotlib path seaborn snakemake