Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug for no indels #166

Merged
merged 1 commit into from
Aug 23, 2023
Merged
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
46 changes: 24 additions & 22 deletions R/check_on_ref_genome.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,26 @@ check_on_ref_genome <-function(sumstats_dt,
#if indels in dataset, don't check they are present on the ref
# genome as they won't be there
if(indels){
data.table::setkey(sumstats_dt, SNP)
#make copy, check if not pres in ref first
indel_dt <-
data.table::copy(sumstats_dt[!unique(rsids$SNP),])
#also check >1 character in A1 A2, use this to define indel
indel_dt <- indel_dt[(nchar(A1)>1 | nchar(A2)>1),]
if(nrow(indel_dt)>0){
#remove indels from sumstats for now
sumstats_dt <- sumstats_dt[!indel_dt$SNP, ]
msg <- paste0("Found ",
formatC(nrow(indel_dt),big.mark = ","),
" Indels. These won't",
" be checked against the reference ",
"genome as it does not contain ",
"Indels.\nWARNING If your sumstat ",
"doesn't contain Indels, set the ",
"indel param to FALSE & rerun ",
"MungeSumstats::format_sumstats()")
message(msg)
}
data.table::setkey(sumstats_dt, SNP)
#make copy, check if not pres in ref first
indel_dt <-
data.table::copy(sumstats_dt[!unique(rsids$SNP),])
#also check >1 character in A1 A2, use this to define indel
indel_dt <- indel_dt[(nchar(A1)>1 | nchar(A2)>1),]
if(nrow(indel_dt)>0){
#remove indels from sumstats for now
sumstats_dt <- sumstats_dt[!indel_dt$SNP, ]
msg <- paste0("Found ",
formatC(nrow(indel_dt),big.mark = ","),
" Indels. These won't",
" be checked against the reference ",
"genome as it does not contain ",
"Indels.\nWARNING If your sumstat ",
"doesn't contain Indels, set the ",
"indel param to FALSE & rerun ",
"MungeSumstats::format_sumstats()")
message(msg)
}
}else{
# join using SNP
data.table::setkey(sumstats_dt, SNP)
Expand Down Expand Up @@ -115,8 +115,10 @@ check_on_ref_genome <-function(sumstats_dt,
if (imputation_ind &&
!"IMPUTATION_SNP" %in% names(sumstats_dt)) {
sumstats_dt[, IMPUTATION_SNP := NA]
#update for indels so can rbind later
indel_dt[, IMPUTATION_SNP := NA]
# update for indels so can rbind later
if(indels){
indel_dt[, IMPUTATION_SNP := NA]
}
}
sumstats_dt <-
data.table::rbindlist(
Expand Down
Loading