From ef48e84d5070a950ac885fd73ba5dcc259a3294d Mon Sep 17 00:00:00 2001 From: mikelove Date: Fri, 11 Aug 2023 18:51:18 -0400 Subject: [PATCH] fixing up some things --- R/easylift.R | 16 ++++++++-------- man/easylift.Rd | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/R/easylift.R b/R/easylift.R index b5cef28..62e9ba8 100644 --- a/R/easylift.R +++ b/R/easylift.R @@ -3,7 +3,7 @@ #' This function takes a GRanges object with genomic coordinates in one genome #' assembly and lifts them to another genome assembly using a chain file. #' -#' @param gr A GRanges object with genomic coordinates in the original assembly. +#' @param x A GRanges object with genomic coordinates in the original assembly. #' @param to The target genome assembly (e.g., "hg38"). #' @param chain The path to the chain file containing the liftover mapping. #' Can be provided in gzipped or non-gzipped format. @@ -14,21 +14,21 @@ #' @import tools #' @import BiocFileCache #' @export -easylift <- function(gr, to, chain) { - if (is.na(GenomeInfoDb::genome(gr))) { +easylift <- function(x, to, chain) { + if (any(is.na(GenomeInfoDb::genome(x)))) { stop( - "The genome information for the 'gr' object is missing (NA). Please set the genome before using easylift." + "The genome information is missing. Please set genome(x) before using easylift." ) } # Convert the input GRanges to the "UCSC" seqlevels style if not already - if (GenomeInfoDb::seqlevelsStyle(gr) != "UCSC") { - GenomeInfoDb::seqlevelsStyle(gr) <- "UCSC" + if (GenomeInfoDb::seqlevelsStyle(x) != "UCSC") { + GenomeInfoDb::seqlevelsStyle(x) <- "UCSC" } if (missing(chain)) { bfc <- BiocFileCache() capTo <- paste0(toupper(substr(to,1,1)),substr(to,2,nchar(to))) # capitalize first letter - trychainfile <- paste0(genome(gr),"To",capTo,".over.chain") + trychainfile <- paste0(genome(x),"To",capTo,".over.chain") q <- bfcquery(bfc, trychainfile) if (nrow(q) >= 1) { chain <- bfc[[q$rid[1]]] @@ -57,7 +57,7 @@ easylift <- function(gr, to, chain) { } # LiftOver the genomic coordinates - cur <- unlist(rtracklayer::liftOver(gr, ch)) + cur <- unlist(rtracklayer::liftOver(x, ch)) GenomeInfoDb::seqlevels(cur) <- GenomeInfoDb::seqlevels(to_seqinfo) GenomeInfoDb::seqinfo(cur) <- to_seqinfo diff --git a/man/easylift.Rd b/man/easylift.Rd index e8413ca..9d7ad77 100644 --- a/man/easylift.Rd +++ b/man/easylift.Rd @@ -4,10 +4,10 @@ \alias{easylift} \title{Lift genomic coordinates from one genome assembly to another.} \usage{ -easylift(gr, to, chain) +easylift(x, to, chain) } \arguments{ -\item{gr}{A GRanges object with genomic coordinates in the original assembly.} +\item{x}{A GRanges object with genomic coordinates in the original assembly.} \item{to}{The target genome assembly (e.g., "hg38").}