Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import('vcfR');
importFrom(
'data.table',
'tstrsplit',
'setDT'
'setDT',
':='
);
import('reshape2');
import('BoutrosLab.plotting.general');
Expand Down
5 changes: 3 additions & 2 deletions R/combine-vcf-with-pgs.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
utils::globalVariables(c('ID', 'new.ID', '.')); # data table syntax work-around for CRAN legitimacy
#' @title Combine VCF with PGS
#' @description Match PGS SNPs to corresponding VCF information by genomic coordinates or rsID using a merge operation.
#' @param vcf.data A data.frame containing VCF data. Required columns: \code{CHROM, POS}.
Expand Down Expand Up @@ -111,8 +112,8 @@ combine.vcf.with.pgs <- function(vcf.data, pgs.weight.data) {
split.rsid.vcf.data <- merge(
x = vcf.data,
# split only entries with multiple rsIDs, save in new column, and merge back with the original data
y = vcf.data[grepl(';', ID), unique(unlist(strsplit(as.character(ID), ';', fixed = TRUE))), by = .(Indiv, CHROM, POS)
][,.(new.ID = V1, Indiv, CHROM, POS)],
y = vcf.data[grepl(';', get('ID')), unique(unlist(strsplit(as.character(get('ID')), ';', fixed = TRUE))), by = .(get('Indiv'), get('CHROM'), get('POS'))
][,.(new.ID = get('V1'), get('Indiv'), get('CHROM'), get('POS'))],
by = c('CHROM', 'POS', 'Indiv'),
all = TRUE
);
Expand Down