Skip to content

Commit 7417a58

Browse files
authored
Merge pull request #492 from Hugolyu/master
[snp_modifyBuild] add local_chain + fix ftp error close #491
2 parents 94b1058 + bac8eed commit 7417a58

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Encoding: UTF-8
22
Package: bigsnpr
33
Type: Package
44
Title: Analysis of Massive SNP Arrays
5-
Version: 1.12.6
6-
Date: 2023-10-18
5+
Version: 1.12.7
6+
Date: 2024-04-17
77
Authors@R: c(
88
person("Florian", "Privé", email = "[email protected]", role = c("aut", "cre")),
99
person("Michael", "Blum", role = "ths"),

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## bigsnpr 1.12.7
2+
3+
- In function `snp_modifyBuild()`, fix a ftp broken link, and add the possibility to use a local chain file specified by the new parameter `local_file`.
4+
15
## bigsnpr 1.12.6
26

37
- Fix issue with `snp_subset()` when either `$fam` or `$map` are missing.

R/modify-positions.R

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#' @param to Genome build to convert to. Default is `hg19`.
1515
#' @param check_reverse Whether to discard positions for which we cannot go back
1616
#' to initial values by doing 'from -> to -> from'. Default is `TRUE`.
17+
#' @param local_chain Local chain file (e.g. `hg18ToHg19.over.chain.gz`) to use
18+
#' instead of downloading one from parameters `from` and `to` (the default).
19+
#' You can download one such file from e.g.
20+
#' \url{https://hgdownload.soe.ucsc.edu/goldenPath/hg18/liftOver/}.
1721
#'
1822
#' @references
1923
#' Hinrichs, Angela S., et al. "The UCSC genome browser database: update 2006."
@@ -24,7 +28,8 @@
2428
#'
2529
snp_modifyBuild <- function(info_snp, liftOver,
2630
from = "hg18", to = "hg19",
27-
check_reverse = TRUE) {
31+
check_reverse = TRUE,
32+
local_chain = NULL) {
2833

2934
if (!all(c("chr", "pos") %in% names(info_snp)))
3035
stop2("Expecting variables 'chr' and 'pos' in input 'info_snp'.")
@@ -44,10 +49,15 @@ snp_modifyBuild <- function(info_snp, liftOver,
4449
BED, col.names = FALSE, sep = " ", scipen = 50)
4550

4651
# Need chain file
47-
url <- paste0("ftp://hgdownload.cse.ucsc.edu/goldenPath/", from, "/liftOver/",
48-
from, "To", tools::toTitleCase(to), ".over.chain.gz")
49-
chain <- tempfile(fileext = ".over.chain.gz")
50-
utils::download.file(url, destfile = chain, quiet = TRUE)
52+
if (is.null(local_chain)) {
53+
url <- paste0("https://hgdownload.soe.ucsc.edu/goldenPath/", from, "/liftOver/",
54+
from, "To", tools::toTitleCase(to), ".over.chain.gz")
55+
chain <- tempfile(fileext = ".over.chain.gz")
56+
utils::download.file(url, destfile = chain, quiet = TRUE)
57+
} else {
58+
assert_exist(local_chain)
59+
chain <- local_chain
60+
}
5161

5262
# Run liftOver (usage: liftOver oldFile map.chain newFile unMapped)
5363
lifted <- tempfile(fileext = ".BED")

docs/news/index.html

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/snp_modifyBuild.Rd

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)