Skip to content

Commit

Permalink
v27
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksunderland committed Sep 11, 2024
1 parent 729e508 commit 0fe332b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: genepi.utils
Title: GenEpi Utility Functions
Version: 0.0.26
Version: 0.0.27
Authors@R: c(person("Nicholas", "Sunderland", , "nicholas.sunderland@bristol.ac.uk", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-3625-630X")))
Description: The genepi.utils package is a collection of utility functions for working with genetic epidemiology data.
License: MIT + file LICENSE
Expand Down
6 changes: 0 additions & 6 deletions R/class_gwas.R
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,6 @@ method(get_proxies, GWAS) <- function(x,
} else {
message(paste0("[i] ", length(missing), "/", length(snps), " (", sprintf("%.2f", 100*(length(missing)/length(snps))), "%) missing variants"))

tryCatch({

# search for proxies for the missing SNPs
proxies <- get_proxies(missing,
Expand Down Expand Up @@ -954,11 +953,6 @@ method(get_proxies, GWAS) <- function(x,

return(object)
})
},
error = function(e) {
warning("Getting proxies failed, returning original GWAS object")
return(x)
})

}

Expand Down
14 changes: 8 additions & 6 deletions R/plink.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ method(get_proxies, class_character) <- function(x,
# read the found SNPs
snps_exist <- data.table::fread(paste0(exists_file,".pvar"), skip="#CHROM POS ID REF ALT", select=c("ID"))

# clean up
unlink(paste0(exists_file,".pvar"))

# report
message(paste0("[i] ", nrow(snps_exist), "/", length(x), " (", sprintf("%.1f", 100*(nrow(snps_exist)/length(x))), "%) input SNPs found in plink reference file"))

Expand All @@ -203,8 +206,7 @@ method(get_proxies, class_character) <- function(x,
system(cmd)

if (!file.exists(paste0(proxy_file,".vcor"))) {
warning("No variants found, or plink failed")
return(NULL)
stop(paste0("Plink `", paste0("--", stat), "` failed"))
}

# read in the extracted variants file
Expand All @@ -224,6 +226,10 @@ method(get_proxies, class_character) <- function(x,
proxy_freq_alt = as.numeric(NONMAJ_FREQ_B),
rstat = as.numeric(get(names(which(stats == stat)))))]

# clean up
unlink(paste0(proxy_file,".vcor"))
unlink(snps_found)

# filter on eaf
if (!is.null(proxy_eaf)) {
nproxies <- nrow(proxies)
Expand All @@ -233,10 +239,6 @@ method(get_proxies, class_character) <- function(x,
}
}

# clean up
unlink(paste0(exists_file,".pvar"))
unlink(paste0(proxy_file,".vcor"))

return(proxies)
}

Expand Down

0 comments on commit 0fe332b

Please sign in to comment.