Skip to content

Commit

Permalink
Fix gene lookup; #759
Browse files Browse the repository at this point in the history
  • Loading branch information
timoast committed Sep 20, 2021
1 parent 6c9b1b8 commit 1f1bb22
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -1244,15 +1244,22 @@ FindRegion <- function(
extend.downstream = 0
) {
if (!is(object = region, class2 = "GRanges")) {
# if separators are present in the string and we can convert the
# start to a number, assume we're using genomic coordinates
if (all(sapply(X = sep, FUN = grepl, x = region))) {
region <- StringToGRanges(regions = region, sep = sep)
} else {
region <- LookupGeneCoords(object = object, assay = assay, gene = region)
if (is.null(x = region)) {
stop("Gene not found")
# first try to convert to coordinates, if not lookup gene
region <- tryCatch(
expr = suppressWarnings(
expr = StringToGRanges(regions = region, sep = sep)
),
error = function(x) {
region <- LookupGeneCoords(
object = object,
assay = assay,
gene = region
)
return(region)
}
)
if (is.null(x = region)) {
stop("Gene not found")
}
}
region <- suppressWarnings(expr = Extend(
Expand Down

0 comments on commit 1f1bb22

Please sign in to comment.