From 9263c5a89eefd5f8a9a007fd970ecac29c05d8dd Mon Sep 17 00:00:00 2001 From: Drew Behrens Date: Sat, 10 Feb 2024 08:18:09 +0000 Subject: [PATCH] change generic subset.FRASER drop, and formal argument matching in setMethod --- DESCRIPTION | 2 +- R/AllGenerics.R | 14 +++++++------- R/countRNAseqData.R | 8 ++++---- man/countRNA.Rd | 4 ++-- man/subset.Rd | 14 +++++++------- tests/testthat/helper_test_data.R | 8 ++++---- vignettes/FRASER.Rnw | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index bd4c21f1..09516c1a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -28,7 +28,7 @@ biocViews: License: MIT + file LICENSE URL: https://github.com/gagneurlab/FRASER BugRepots: https://github.com/gagneurlab/FRASER/issues -RoxygenNote: 7.3.0 +RoxygenNote: 7.3.1 Encoding: UTF-8 VignetteBuilder: knitr Depends: diff --git a/R/AllGenerics.R b/R/AllGenerics.R index c0202151..fb4148a6 100644 --- a/R/AllGenerics.R +++ b/R/AllGenerics.R @@ -236,12 +236,12 @@ setReplaceMethod("nonSplicedReads", "FraserDataSet", function(object, value){ #' @return A subsetted \code{FraserDataSet} object #' @examples #' fds <- createTestFraserDataSet() -#' fds[1:10,2:3,,drop=FALSE] -#' fds[,samples(fds) %in% c("sample1", "sample2"),,drop=FALSE] -#' fds[1:10,by="ss",,drop=FALSE] +#' fds[1:10,2:3] +#' fds[,samples(fds) %in% c("sample1", "sample2")] +#' fds[1:10,by="ss"] #' #' @rdname subset -subset.FRASER <- function(x, i, j, by=c("j", "ss"), drop = FALSE){ +subset.FRASER <- function(x, i, j, by=c("j", "ss"), ..., drop=FALSE){ if(length(by) == 1){ by <- whichReadType(x, by) } @@ -312,7 +312,7 @@ subset.FRASER <- function(x, i, j, by=c("j", "ss"), drop = FALSE){ } #' @rdname subset #' @export -setMethod("[", c("FraserDataSet", "ANY", "ANY"), subset.FRASER) +setMethod("[", c("FraserDataSet", "ANY", "ANY", drop="ANY"), subset.FRASER) #' @@ -673,7 +673,7 @@ FRASER.results <- function(object, sampleIDs, fdrCutoff, zscoreCutoff, ans <- lapply(seq_along(sampleChunks), function(idx){ message(date(), ": Process chunk: ", idx, " for: ", type) sc <- sampleChunks[[idx]] - tmp_x <- object[,sc,,drop=FALSE] + tmp_x <- object[,sc] # extract values rawCts <- as.matrix(K(tmp_x)) @@ -865,7 +865,7 @@ mapSeqlevels <- function(fds, style="UCSC", ...){ nonSplicedReads(fds) <- keepStandardChromosomes(nonSplicedReads(fds)) validObject(fds) } - fds <- fds[as.vector(seqnames(fds)) %in% names(mappings),,,drop=FALSE] + fds <- fds[as.vector(seqnames(fds)) %in% names(mappings)] seqlevels(fds) <- as.vector(mappings) seqlevels(nonSplicedReads(fds)) <- as.vector(mappings) diff --git a/R/countRNAseqData.R b/R/countRNAseqData.R index b5909087..f68c4bdc 100644 --- a/R/countRNAseqData.R +++ b/R/countRNAseqData.R @@ -459,8 +459,8 @@ getSplitCountCacheFile <- function(sampleID, settings){ #' @export countSplitReads <- function(sampleID, fds, NcpuPerSample=1, genome=NULL, recount=FALSE, keepNonStandardChromosomes=TRUE, - bamfile=bamFile(fds[,sampleID,,drop=FALSE]), - pairedend=pairedEnd(fds[,sampleID,,drop=FALSE]), + bamfile=bamFile(fds[,sampleID]), + pairedend=pairedEnd(fds[,sampleID]), strandmode=strandSpecific(fds), cacheFile=getSplitCountCacheFile(sampleID, fds), scanbamparam=scanBamParam(fds), @@ -856,11 +856,11 @@ countNonSplicedReads <- function(sampleID, splitCountRanges, fds, } - bamFile <- bamFile(fds[,samples(fds) == sampleID,,drop=FALSE])[[1]] + bamFile <- bamFile(fds[,samples(fds) == sampleID])[[1]] # unstranded case: for counting only non spliced reads we # skip this information - isPairedEnd <- pairedEnd(fds[,samples(fds) == sampleID,,drop=FALSE])[[1]] + isPairedEnd <- pairedEnd(fds[,samples(fds) == sampleID])[[1]] doAutosort <- isPairedEnd # check cache if available diff --git a/man/countRNA.Rd b/man/countRNA.Rd index b4bbcdb9..440231fe 100644 --- a/man/countRNA.Rd +++ b/man/countRNA.Rd @@ -60,8 +60,8 @@ countSplitReads( genome = NULL, recount = FALSE, keepNonStandardChromosomes = TRUE, - bamfile = bamFile(fds[, sampleID,,drop=FALSE]), - pairedend = pairedEnd(fds[, sampleID,,drop=FALSE]), + bamfile = bamFile(fds[, sampleID]), + pairedend = pairedEnd(fds[, sampleID]), strandmode = strandSpecific(fds), cacheFile = getSplitCountCacheFile(sampleID, fds), scanbamparam = scanBamParam(fds), diff --git a/man/subset.Rd b/man/subset.Rd index 7253f973..19ed6857 100644 --- a/man/subset.Rd +++ b/man/subset.Rd @@ -5,9 +5,9 @@ \alias{[,FraserDataSet,ANY,ANY,ANY-method} \title{Subsetting by indices for junctions} \usage{ -\method{subset}{FRASER}(x, i, j, by = c("j", "ss"), drop = FALSE) +\method{subset}{FRASER}(x, i, j, by = c("j", "ss"), ..., drop = FALSE) -\S4method{[}{FraserDataSet,ANY,ANY,ANY}(x, i, j, by = c("j", "ss"), drop = FALSE) +\S4method{[}{FraserDataSet,ANY,ANY,ANY}(x, i, j, by = c("j", "ss"), ..., drop = FALSE) } \arguments{ \item{x}{A \code{FraserDataSet} object} @@ -16,10 +16,10 @@ \item{j}{A integer vector to subset the columns/samples} -\item{by}{a character (j or ss) definig if we subset by +\item{by}{a character (j or ss) defining if we subset by junctions or splice sites} -\item{drop}{currently not used} +\item{drop}{Currently not used} } \value{ A subsetted \code{FraserDataSet} object @@ -29,8 +29,8 @@ Providing subsetting by indices through the single-bracket operator } \examples{ fds <- createTestFraserDataSet() - fds[1:10,2:3,,drop=FALSE] - fds[,samples(fds) \%in\% c("sample1", "sample2"),,drop=FALSE] - fds[1:10,by="ss",,drop=FALSE] + fds[1:10,2:3] + fds[,samples(fds) \%in\% c("sample1", "sample2")] + fds[1:10,by="ss"] } diff --git a/tests/testthat/helper_test_data.R b/tests/testthat/helper_test_data.R index 8bfce622..58fd0f6a 100644 --- a/tests/testthat/helper_test_data.R +++ b/tests/testthat/helper_test_data.R @@ -5,7 +5,7 @@ test_generate_count_example <- function(recount=FALSE){ # get a new object for only one sample if(recount || !"test_fdsSample3" %in% ls()){ - test_fdsSample3 <- getFraser()[,"sample3",,drop=FALSE] + test_fdsSample3 <- getFraser()[,"sample3"] name(test_fdsSample3) <- "onlySample3" # count the sample @@ -22,7 +22,7 @@ test_generate_count_example <- function(recount=FALSE){ end =c(7592749, 7595171, 7595320) )) test_rangeOV <- findOverlaps(test_range, test_fdsSample3, type = "equal") - test_rangeFDS <- test_fdsSample3[to(test_rangeOV),,,drop=FALSE] + test_rangeFDS <- test_fdsSample3[to(test_rangeOV)] # # This is manually counted from the IGV browser @@ -51,7 +51,7 @@ test_generate_strand_specific_count_example <- function(recount=FALSE){ if(recount || !"test_fdsSample3_stranded" %in% ls()){ test_fdsSample3_stranded <- createTestFraserSettings( - workingDir=file.path(tempdir(), "strandSpecific"))[,"sample3",,drop=FALSE] + workingDir=file.path(tempdir(), "strandSpecific"))[,"sample3"] name(test_fdsSample3_stranded) <- "onlySample3_stranded" strandSpecific(test_fdsSample3_stranded) <- TRUE pairedEnd(test_fdsSample3_stranded) <- TRUE @@ -72,7 +72,7 @@ test_generate_strand_specific_count_example <- function(recount=FALSE){ test_rangeOV_stranded <- findOverlaps(test_range_stranded, test_fdsSample3_stranded, type = "equal") test_rangeFDS_stranded <- - test_fdsSample3_stranded[to(test_rangeOV_stranded),,,drop=FALSE] + test_fdsSample3_stranded[to(test_rangeOV_stranded)] # # This is manually counted from the IGV browser diff --git a/vignettes/FRASER.Rnw b/vignettes/FRASER.Rnw index aecfe4e3..82e9b56c 100644 --- a/vignettes/FRASER.Rnw +++ b/vignettes/FRASER.Rnw @@ -420,7 +420,7 @@ After looking at the expression distribution between filtered and unfiltered junctions, we can now subset the dataset: <>= -fds_filtered <- fds[mcols(fds, type="j")[,"passed"],,,drop=FALSE] +fds_filtered <- fds[mcols(fds, type="j")[,"passed"]] fds_filtered # filtered_fds not further used for this tutorial because the example dataset # is otherwise too small