Skip to content

Commit e0360b6

Browse files
committed
Fix zero-filling of alternate allele frequencies
Resolved an issue where alternate allele frequencies could not be zero-filled when multiple rows for the same sample shared the same frequency
1 parent a9eaa3b commit e0360b6

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

workflow/scripts/report/snp_plots.R

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,10 @@ vcf <- vcf %>%
4343
REGION,
4444
ALT_FREQ,
4545
POS
46-
)
47-
48-
# Get a list with studied samples ID
49-
IDs <- pull(
50-
vcf,
51-
REGION
52-
) %>%
53-
unique()
46+
)
5447

55-
vcf <- vcf %>%
56-
pivot_wider( # Obtain 0 in positions without freq
57-
names_from = REGION,
58-
values_from = ALT_FREQ,
59-
values_fill = 0
60-
) %>%
61-
pivot_longer(
62-
IDs,
63-
names_to = "REGION",
64-
values_to = "ALT_FREQ"
65-
) %>%
66-
ungroup()
48+
# Fill positions without alt frequency with 0
49+
vcf <- vcf %>% complete(nesting(variant, POS), REGION, fill = list(ALT_FREQ = 0))
6750

6851
# Join variants file and metadata file
6952
vcf <- left_join(vcf, data, by = c("REGION" = "ID"))

0 commit comments

Comments
 (0)