Skip to content

Commit

Permalink
move strand specific error to validObject
Browse files Browse the repository at this point in the history
  • Loading branch information
AtaJadidAhari committed Apr 25, 2024
1 parent b421e44 commit 731fcdd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
6 changes: 6 additions & 0 deletions R/FraserDataSet-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
16 changes: 1 addition & 15 deletions R/countRNAseqData.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 731fcdd

Please sign in to comment.