diff --git a/DESCRIPTION b/DESCRIPTION index 5141924..f224f8c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: atena Type: Package Title: Analysis of Transposable Elements -Version: 1.9.6 +Version: 1.9.7 Authors@R: c( person("Beatriz", "Calvo-Serra", email="beatriz.calvo@upf.edu", role=c("aut", "cre")), @@ -24,6 +24,7 @@ Imports: stats, Matrix, BiocGenerics, + MatrixGenerics, BiocParallel, S4Vectors, IRanges, diff --git a/NAMESPACE b/NAMESPACE index ba44daf..ba9e847 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -83,6 +83,7 @@ importFrom(Matrix,sparseMatrix) importFrom(Matrix,summary) importFrom(Matrix,t) importFrom(Matrix,which) +importFrom(MatrixGenerics,rowRanges) importFrom(Rsamtools,"asMates<-") importFrom(Rsamtools,"yieldSize<-") importFrom(Rsamtools,BamFileList) diff --git a/R/annotations.R b/R/annotations.R index c015a5c..d709453 100644 --- a/R/annotations.R +++ b/R/annotations.R @@ -298,10 +298,13 @@ OneCodeToFindThemAll <- function(gr, dictionary=NULL, fuzzy = FALSE, #' Getter functions of TE classes from parsed RepeatMasker annotations. #' -#' @param annot A \link[GenomicRanges:GRangesList-class]{GRangesList} object -#' obtained from parsing RepeatMasker annotations with -#' \code{OneCodeToFindThemAll()} or \code{rmskatenaparser()} -#' function. +#' @param annot A [`GRanges`] or [`GRangesList`] object obtained with the +#' function `annotaTES()`, using either [`OneCodeToFindThemAll`] +#' or [`rmskatenaparser`] as RepeatMasker parser functions. +#' Alternatively, if `annot` is a [`QuantifyParam`] or a +#' [`SummarizedExperiment`] object produced by the `qtex()` +#' function, this function will attempt to extract the +#' corresponding annotations from inside those objects. #' #' @param relLength (Default 0.9) Numeric value that can take values between 0 #' to 1. Sets the minimum relative length required for @@ -365,6 +368,8 @@ OneCodeToFindThemAll <- function(gr, dictionary=NULL, fuzzy = FALSE, getLTRs <- function(annot, relLength=0.9, fullLength=TRUE, partial=FALSE, soloLTR=FALSE, otherLTR=FALSE, returnMask=FALSE) { + annot <- .fetchAnnotationsFromObject(annot) + cnames <- c("Status", "RelLength", "Class") mask <- cnames %in% colnames(mcols(annot)) if (any(!mask)) @@ -409,6 +414,9 @@ getLTRs <- function(annot, relLength=0.9, fullLength=TRUE, partial=FALSE, #' @importFrom GenomicRanges mcols #' @export getLINEs <- function(annot, relLength=0.9, returnMask=FALSE) { + + annot <- .fetchAnnotationsFromObject(annot) + cnames <- c("RelLength", "Class") mask <- cnames %in% colnames(mcols(annot)) if (any(!mask)) @@ -446,6 +454,9 @@ getLINEs <- function(annot, relLength=0.9, returnMask=FALSE) { #' @importFrom GenomicRanges mcols #' @export getSINEs <- function(annot, relLength=0.9, returnMask=FALSE) { + + annot <- .fetchAnnotationsFromObject(annot) + cnames <- c("RelLength", "Class") mask <- cnames %in% colnames(mcols(annot)) if (any(!mask)) @@ -483,6 +494,9 @@ getSINEs <- function(annot, relLength=0.9, returnMask=FALSE) { #' @importFrom GenomicRanges mcols #' @export getDNAtransposons <- function(annot, relLength=0.9, returnMask=FALSE) { + + annot <- .fetchAnnotationsFromObject(annot) + cnames <- c("RelLength", "Class") mask <- cnames %in% colnames(mcols(annot)) if (any(!mask)) @@ -511,6 +525,20 @@ getDNAtransposons <- function(annot, relLength=0.9, returnMask=FALSE) { res } +#' @importFrom MatrixGenerics rowRanges +.fetchAnnotationsFromObject <- function(object) { + annot <- object + + if (is(object, "QuantifyParam")) + annot <- features(object) + else if (is(object, "SummarizedExperiment")) + annot <- rowRanges(object) + else if (!is(object, "GRangesList") && !is(object, "GRanges")) + stop(paste("input annotations should be either a 'GenomicRanges',", + "'QuantifyParam' or a 'SummarizedExperiment' object.")) + annot +} + #' @importFrom stats setNames .builDictionary <- function(gr, fuzzy=FALSE) { annltr <- gr[gr$repClass=="LTR"] diff --git a/man/annotaTEsGetters.Rd b/man/annotaTEsGetters.Rd index ec397c7..edd36a8 100644 --- a/man/annotaTEsGetters.Rd +++ b/man/annotaTEsGetters.Rd @@ -25,10 +25,13 @@ getSINEs(annot, relLength = 0.9, returnMask = FALSE) getDNAtransposons(annot, relLength = 0.9, returnMask = FALSE) } \arguments{ -\item{annot}{A \link[GenomicRanges:GRangesList-class]{GRangesList} object -obtained from parsing RepeatMasker annotations with -\code{OneCodeToFindThemAll()} or \code{rmskatenaparser()} -function.} +\item{annot}{A [`GRanges`] or [`GRangesList`] object obtained with the +function `annotaTES()`, using either [`OneCodeToFindThemAll`] +or [`rmskatenaparser`] as RepeatMasker parser functions. +Alternatively, if `annot` is a [`QuantifyParam`] or a +[`SummarizedExperiment`] object produced by the `qtex()` +function, this function will attempt to extract the +corresponding annotations from inside those objects.} \item{relLength}{(Default 0.9) Numeric value that can take values between 0 to 1. Sets the minimum relative length required for