Skip to content

Commit 7aff72b

Browse files
committed
handle duplicate rsIDs
1 parent 0fd71b7 commit 7aff72b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

R/combine-vcf-with-pgs.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ combine.vcf.with.pgs <- function(vcf.data, pgs.weight.data) {
116116
fixed = TRUE
117117
);
118118

119+
# remove duplicate IDs
120+
split.rows <- lapply(split.rows, function(x) unique(x));
121+
119122
row.indices <- rep(
120123
x = seq_len(nrow(vcf.data)),
121124
times = lengths(split.rows)

tests/testthat/test-vcf-pgs-merge.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ test_that(
294294
test.vcf.data.missing.locus.matching.rsid.with.semicolons <- data.frame(
295295
CHROM = c('chr1', 'chr3', 'chr2', 'chr4'),
296296
POS = c(1, 3, 3, 6),
297-
ID = c('rs1;rsA', 'rs3', 'rs2;rsB', 'rs5;rsC'),
297+
ID = c('rs1;rs1', 'rs3', 'rs2;rsB', 'rs5;rsC'),
298298
REF = c('A', 'T', 'C', 'G'),
299299
ALT = c('T', 'A', 'G', 'C'),
300300
Indiv = c('sample1', 'sample2', 'sample3', 'sample4'),
@@ -486,7 +486,7 @@ test_that(
486486
);
487487
expect_equal(
488488
test.combine.vcf.with.pgs.missing.locus.matching.rsid.with.semicolons$merged.vcf.with.pgs.data$ID.vcf,
489-
c('rs1;rsA', 'rs3', 'rs2;rsB', NA)
489+
c('rs1;rs1', 'rs3', 'rs2;rsB', NA)
490490
);
491491

492492
expect_equal(

0 commit comments

Comments
 (0)