-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuildConverter.R
More file actions
42 lines (27 loc) · 908 Bytes
/
Copy pathBuildConverter.R
File metadata and controls
42 lines (27 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
if(!require("dplyr")){
install.packages("dplyr")
library("dplyr")
}
if(!require("rtracklayer")){
BiocManager::install("rtracklayer")
library("rtracklayer")
}
chainObject_tohg19 = import.chain("hg38ToHg19.over.chain")
chainObject_tohg38 = import.chain("hg19ToHg38.over.chain")
build_convert = function(
chromosome = 15,
pos = 48481729,
action = c("HG38TOHG19", "HG19TOHG38")){
grObject = GRanges(seqnames = paste0("chr", chromosome),
ranges = IRanges(start=pos, end=pos))
if(action == "HG38TOHG19"){
results = as.data.frame(liftOver(grObject, chainObject_tohg19))
results = paste0(results$seqnames, ":", results$start)
}else if(action == "HG19TOHG38"){
results = as.data.frame(liftOver(grObject, chainObject_tohg38))
results = paste0(results$seqnames, ":", results$start)
}else{
results = NA
}
return(results)
}