Skip to content

Commit 316bbc2

Browse files
committed
Fix merger iVar TSV with SnpEff annotation using the same variant format
Adds columns REF_VCF and ALT_VCF with VCF-like alleles
1 parent d7ed3a0 commit 316bbc2

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

workflow/scripts/merge_annotation.R

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,21 @@ variants <- read_tsv(
1919
ALT = col_character()
2020
)
2121
) %>%
22-
mutate(REGION = snakemake@params$ref_name)
22+
mutate(
23+
REGION = snakemake@params$ref_name,
24+
is_insertion = startsWith(ALT, "+"),
25+
is_deletion = startsWith(ALT, "-"),
26+
REF_VCF = case_when(
27+
is_deletion ~ paste0(REF, substring(ALT, 2)),
28+
TRUE ~ REF
29+
),
30+
ALT_VCF = case_when(
31+
is_insertion ~ paste0(REF, substring(ALT, 2)),
32+
is_deletion ~ REF,
33+
TRUE ~ ALT
34+
)
35+
) %>%
36+
select(-is_insertion, -is_deletion)
2337

2438
log_info("Reading annotation table")
2539
annotation <- read_tsv(
@@ -42,7 +56,12 @@ log_info("Merging tables")
4256
merged <- left_join(
4357
variants,
4458
annotation,
45-
by = c("REGION" = "CHROM", "POS", "REF", "ALT")
59+
by = c(
60+
"REGION" = "CHROM",
61+
"POS" = "POS",
62+
"REF_VCF" = "REF",
63+
"ALT_VCF" = "ALT"
64+
)
4665
)
4766

4867
log_info("Saving results")

0 commit comments

Comments
 (0)