是否有任何标准或推荐的方法将版本号添加到管道(在我的例子中用 Snakemake 编写)?
例如,我有这个管道,刚才我添加了一个CHANGELOG.md文件,其中当前版本位于顶部。是否有更好的方法来识别用户正在部署的版本?
tmp.sh即使发送到命名管道的进程失败,以下玩具脚本()也会以代码0退出.如何从命名管道捕获非零退出代码?或者更一般地说,事情出了问题?
#!/bin/bash
set -eo pipefail
mkfifo mypipe
FOOBAR > mypipe &
cat mypipe
Run Code Online (Sandbox Code Playgroud)
运行并检查退出代码:
bash tmp.sh
tmp.sh: line 6: FOOBAR: command not found
echo $? # <- Exit code is 0 despite the "command not found"!
Run Code Online (Sandbox Code Playgroud) 我发现 Snakemake文档非常简洁。因为我被问过几次,所以我想发布这个问题和我自己的答案。
如何在 Snakemake 规则中执行或集成此 R 脚本?
my-script.R
CUTOFF <- 25
dat <- read.table('input-table.txt')
out <- dat[dat$V1 > CUTOFF, ]
write.table(out, 'output-table.txt')
Run Code Online (Sandbox Code Playgroud)
蛇文件:
rule one:
    input:
        txt= 'input-table.txt',
    output:
        out= 'output-table.txt',
    params:
        cutoff= 25,
    # now what?        
Run Code Online (Sandbox Code Playgroud) 我有一个data.frame(data.table实际上是一个)我需要按多列排序。要排序的列的名称在一个向量中。我该怎么做?例如
DF <- data.frame(A= 5:1, B= 11:15, C= c(3, 3, 2, 2, 1))
DF
  A  B C
  5 11 3
  4 12 3
  3 13 2
  2 14 2
  1 15 1
sortby <- c('C', 'A')
DF[order(sortby),] ## How to do this?
Run Code Online (Sandbox Code Playgroud)
所需的输出如下,但使用sortby向量作为输入。
DF[with(DF, order(C, A)),]
  A  B C
  1 15 1
  2 14 2
  3 13 2
  4 12 3
  5 11 3
Run Code Online (Sandbox Code Playgroud)
( 的解决方案data.table是可取的。)
编辑:如果基本 R 或 data.table 不需要太多编码,我宁愿避免导入其他包。
r ×2
snakemake ×2
bash ×1
data.table ×1
dataframe ×1
exit-code ×1
named-pipes ×1
pipeline ×1
python ×1
python-3.x ×1
sorting ×1
version ×1