Skip to content

Commit 5bfdc5e

Browse files
committed
Add rule to compile extracted VCF fields
1 parent 970836d commit 5bfdc5e

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

workflow/rules/vaf.smk

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,19 @@ rule format_vcf_fields_longer:
181181
"../scripts/format_vcf_fields_longer.R"
182182

183183

184+
rule compile_vcf_fields_longer:
185+
threads: 1
186+
conda: "../envs/renv.yaml"
187+
input:
188+
tsv = OUTDIR/"vaf"/"{sample}.vcf_fields.longer.tsv"
189+
output:
190+
tsv = OUTDIR/f"{OUTPUT_NAME}.vcf_fields.longer.tsv"
191+
log:
192+
LOGDIR / "compile_vcf_fields_longer" / "log.txt"
193+
script:
194+
"../scripts/compile_vcf_fields_longer.R"
195+
196+
184197
rule vcf_to_tsv:
185198
threads: 1
186199
conda: "../envs/renv.yaml"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env Rscript
2+
3+
# Write stdout and stderr to log file
4+
log <- file(snakemake@log[[1]], open = "wt")
5+
sink(log, type = "message")
6+
sink(log, type = "output")
7+
8+
library(tidyverse)
9+
library(logger)
10+
log_threshold(INFO)
11+
12+
log_info("Reading input partial tables with VCF extracted fields and adding sample column")
13+
tables <- lapply(
14+
snakemake@input,
15+
function(path) {
16+
read_tsv(path) %>%
17+
mutate(SAMPLE = sub('\\.vcf_fields.longer.tsv$', '', basename(path)))
18+
}
19+
)
20+
21+
log_info("Binding and writing table")
22+
bind_rows(tables) %>%
23+
write_tsv(snakemake@output$tsv)

0 commit comments

Comments
 (0)