From 731fcdd469e71436247f80845659e33fc3e0e9cd Mon Sep 17 00:00:00 2001 From: AtaJadidAhari Date: Wed, 24 Apr 2024 11:24:35 +0200 Subject: [PATCH] move strand specific error to validObject --- R/FraserDataSet-class.R | 6 ++++++ R/countRNAseqData.R | 16 +--------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/R/FraserDataSet-class.R b/R/FraserDataSet-class.R index 2d5eb46b..2e4fc535 100644 --- a/R/FraserDataSet-class.R +++ b/R/FraserDataSet-class.R @@ -79,6 +79,12 @@ validateStrandSpecific <- function(object) { "'colData(fds)' must be empty or contain only integers:", "0L == 'no', 1L == 'yes', 2L == 'reverse'.")) } + # Check mixed strand type + ss <- strandSpecific(object) + if ((any(ss == 0) && any(ss == 1)) || (any(ss == 0) && any(ss == 2))){ + stop(paste("Error: Data contains a mix of stranded and unstranded samples.\n ", + "Please consider analyzing them separately.")) + } NULL } diff --git a/R/countRNAseqData.R b/R/countRNAseqData.R index 41888177..d228e49d 100644 --- a/R/countRNAseqData.R +++ b/R/countRNAseqData.R @@ -146,13 +146,6 @@ countRNAData <- function(fds, NcpuPerSample=1, minAnchor=5, recount=FALSE, stopifnot(is.numeric(minAnchor) & minAnchor >= 1) minAnchor <- as.integer(minAnchor) - # Check mixed strand type - ss <- strandSpecific(fds) - if ((any(ss == 0) && any(ss == 1)) || (any(ss == 0) && any(ss == 2))){ - stop(paste("Data contains a mix of stranded and unstranded samples.\n ", - "Please consider analyzing them separately.")) - } - # load needed genomes if provided if(!(is.null(genome) | any(is.na(unique(genome))))){ for(i in unique(genome)){ @@ -407,13 +400,6 @@ addCountsToFraserDataSet <- function(fds, splitCounts, nonSplitCounts){ # check for valid fds validObject(fds) - - # Check mixed strand type - ss <- strandSpecific(fds) - if ((any(ss == 0) && any(ss == 1)) || (any(ss == 0) && any(ss == 2))){ - stop(paste("Data contains a mix of stranded and unstranded samples.\n ", - "Please consider analyzing them separately.")) - } # create final FRASER dataset fds <- new("FraserDataSet", @@ -481,7 +467,7 @@ countSplitReads <- function(sampleID, fds, NcpuPerSample=1, genome=NULL, # check for valid fds validObject(fds) - + # check cache if available if(isFALSE(recount) && !is.null(cacheFile) && file.exists(cacheFile)){ cache <- readRDS(cacheFile)