Skip to content

Commit 9c5660e

Browse files
committed
Split SnpEff error column
Many error/warning/info messages can appear on the same variant
1 parent 2df2dc4 commit 9c5660e

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

config/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ANNOTATION:
3636
FEATUREID: "ANN[*].FEATUREID"
3737
HGVS_P: "ANN[*].HGVS_P"
3838
HGVS_C: "ANN[*].HGVS_C"
39-
ERRORS: "ANN[*].ERRORS"
39+
ERRORS: "ANN[*].ERRORS" # hard-coded column
4040
FILTER_INCLUDE:
4141
# IMPACT: [HIGH, MODERATE, LOW]
4242
FILTER_EXCLUDE:

workflow/scripts/format_vcf_fields_longer.R

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,34 @@ sink(log, type = "output")
77

88
library(tidyverse)
99

10-
# Replace "" values with NA in R filter list
11-
# Snakemake passes filters like: list(ERRORS = c(""))
1210
empty.to.na <- function(x) {
1311
x[x == ""] <- NA
1412
x
1513
}
14+
15+
separate_rows_if_exist <- function(df, col, sep) {
16+
if (col %in% colnames(df)) {
17+
separate_longer_delim(df, all_of(cols), delim = sep)
18+
} else {
19+
df
20+
}
21+
}
22+
23+
# Replace "" values with NA in R filter list
24+
# Snakemake passes filters like: list(ERRORS = c(""))
1625
filter.include <- lapply(snakemake@params$filter_include, empty.to.na)
1726
filter.exclude <- lapply(snakemake@params$filter_exclude, empty.to.na)
1827

1928
# Process input table
2029
read_tsv(snakemake@input$tsv) %>%
2130
# Separate <sep>-delimited "...[*]..." columns (e.g. ANN[*].EFFECT)
22-
separate_rows(contains("[*]"), sep = snakemake@params$sep, convert = TRUE) %>%
31+
separate_rows(
32+
contains("[*]"),
33+
sep = snakemake@params$sep,
34+
convert = TRUE
35+
) %>%
36+
# Separate &-delimited error column (more than one error/warning/info message per row is possible)
37+
separate_rows_if_exist("ERRORS", sep = snakemake@params$sep) %>%
2338
# Rename "...[*]..." columns using the provided lookup via Snakemake config
2439
rename(all_of(unlist(snakemake@params$colnames_mapping))) %>%
2540
# Apply dynamic filters from the Snakemake config:

0 commit comments

Comments
 (0)