From 6984d2c991ed777478a5278e6cc640f4df0e635f Mon Sep 17 00:00:00 2001 From: Ines Scheller Date: Thu, 2 May 2024 15:59:04 +0200 Subject: [PATCH 1/7] ensure old fds load without warning about strandSpecific --- R/saveHDF5Objects.R | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/R/saveHDF5Objects.R b/R/saveHDF5Objects.R index 37948de4..9a199d4a 100644 --- a/R/saveHDF5Objects.R +++ b/R/saveHDF5Objects.R @@ -70,10 +70,8 @@ loadFraserDataSet <- function(dir, name=NULL, file=NULL, upgrade=FALSE){ # can be removed later if the full pipeline is rerun attributes(fds)$class <- structure("FraserDataSet", package="FRASER") - # adapt type of strandSpecific if needed (changed from logical to integer) - if(is.logical(strandSpecific(fds))){ - strandSpecific(fds) <- as.integer(strandSpecific(fds)) - } + # ensure strandSpecific slot is up-to-date with new vector format + strandSpecific(fds) <- slot(fds, "strandSpecific") e <- try(assays(fds), silent=TRUE) if(is.error(e)){ From 1397a9e01787bca640533fdcab390899bd6eaf14 Mon Sep 17 00:00:00 2001 From: Ines Scheller Date: Thu, 2 May 2024 15:59:41 +0200 Subject: [PATCH 2/7] remove warning about missing strandSpecific field for empty and example fds --- R/AllGenerics.R | 4 +++- R/example_functions.R | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/R/AllGenerics.R b/R/AllGenerics.R index 65cda1fb..1e327edc 100644 --- a/R/AllGenerics.R +++ b/R/AllGenerics.R @@ -152,9 +152,11 @@ setReplaceMethod("workingDir", "FraserDataSet", function(object, value) { #' @rdname fds-methods setMethod("strandSpecific", "FraserDataSet", function(object) { if(!"strand" %in% colnames(colData(object))){ - warning("Strand is not specified. Please set the used RNA-seq", + if(ncol(object) > 0){ + warning("Strand is not specified. Please set the used RNA-seq", " protocol by using 'strandSpecific(object) <- c(...)'.", "\n\nWe assume as default a non stranded protocol.") + } return(rep(0, ncol(object))) } return(colData(object)$strand) diff --git a/R/example_functions.R b/R/example_functions.R index 1ec450d1..78e0be22 100644 --- a/R/example_functions.R +++ b/R/example_functions.R @@ -45,6 +45,7 @@ createTestFraserSettings <- function(workingDir="FRASER_output"){ # create FRASER object fds <- FraserDataSet(colData=sampleTable, workingDir=workingDir) + strandSpecific(fds) <- 'no' # dont use hdf5 for example data set dontWriteHDF5(fds) <- TRUE From 291cfcc6b9097cfcb8854380a29054181718f616 Mon Sep 17 00:00:00 2001 From: Ines Scheller Date: Thu, 2 May 2024 16:24:18 +0200 Subject: [PATCH 3/7] fix loading again for new fds and remove warning for test data --- R/example_functions.R | 4 +++- R/saveHDF5Objects.R | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/R/example_functions.R b/R/example_functions.R index 78e0be22..99b90f6d 100644 --- a/R/example_functions.R +++ b/R/example_functions.R @@ -43,9 +43,11 @@ createTestFraserSettings <- function(workingDir="FRASER_output"){ # check that NHDF is NA group sampleTable[gene=='NHDF', condition:=NA] + # set strand specificity column in colData + sampleTable[, strand := 0L] + # create FRASER object fds <- FraserDataSet(colData=sampleTable, workingDir=workingDir) - strandSpecific(fds) <- 'no' # dont use hdf5 for example data set dontWriteHDF5(fds) <- TRUE diff --git a/R/saveHDF5Objects.R b/R/saveHDF5Objects.R index 9a199d4a..fde002e3 100644 --- a/R/saveHDF5Objects.R +++ b/R/saveHDF5Objects.R @@ -71,7 +71,15 @@ loadFraserDataSet <- function(dir, name=NULL, file=NULL, upgrade=FALSE){ attributes(fds)$class <- structure("FraserDataSet", package="FRASER") # ensure strandSpecific slot is up-to-date with new vector format - strandSpecific(fds) <- slot(fds, "strandSpecific") + if("strandSpecific" %in% slotNames(fds)){ + strandSpecific(fds) <- slot(fds, "strandSpecific") + } else{ + # adapt type of strandSpecific if needed (changed logical -> integer) + if(is.logical(strandSpecific(fds))){ + strandSpecific(fds) <- as.integer(strandSpecific(fds)) + } + } + e <- try(assays(fds), silent=TRUE) if(is.error(e)){ From be6713720722d5066bbec6825ace120dd284fd93 Mon Sep 17 00:00:00 2001 From: Ines Scheller Date: Thu, 2 May 2024 17:18:56 +0200 Subject: [PATCH 4/7] adjust example for merging with external counts to new strandSpecific vector --- R/mergeExternalData.R | 2 +- inst/extdata/externalCounts/annotation.tsv.gz | Bin 164 -> 165 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/R/mergeExternalData.R b/R/mergeExternalData.R index c5f5dc4c..44ba7123 100644 --- a/R/mergeExternalData.R +++ b/R/mergeExternalData.R @@ -93,7 +93,7 @@ mergeExternalData <- function(fds, countFiles, sampleIDs, annotation=NULL){ rownames(annotation) <- annotation[,"sampleID"] newColData <- DataFrame(rbind(fill=TRUE, as.data.table(colData(fds)), - as.data.table(annotation[sampleIDs,]))) + as.data.table(annotation[sampleIDs,,drop=FALSE]))) rownames(newColData) <- newColData[,"sampleID"] # diff --git a/inst/extdata/externalCounts/annotation.tsv.gz b/inst/extdata/externalCounts/annotation.tsv.gz index 780e0359e1eeddfac7ebc0a169511ce2711ede2f..8e4edb842b248d76a513d7eeecce17a34e0b1fc5 100644 GIT binary patch literal 165 zcmV;W09yYaiwFodsxxK)17U7%Z**aFX>V>WbaQq9b+AuQgPQ}s3-Hx%s&R;X%q_ykEReX8JKC_>MRnH)f%AC^d71i4 J|E~gC1OPw-K+FID From 42d0a084b68a588d68e92a9f2b3f9c8dc8970be2 Mon Sep 17 00:00:00 2001 From: Christian Mertes Date: Wed, 8 May 2024 14:59:19 +0200 Subject: [PATCH 5/7] remove else clause in loadFraserObject --- R/saveHDF5Objects.R | 5 ----- 1 file changed, 5 deletions(-) diff --git a/R/saveHDF5Objects.R b/R/saveHDF5Objects.R index fde002e3..a7e89bb7 100644 --- a/R/saveHDF5Objects.R +++ b/R/saveHDF5Objects.R @@ -73,11 +73,6 @@ loadFraserDataSet <- function(dir, name=NULL, file=NULL, upgrade=FALSE){ # ensure strandSpecific slot is up-to-date with new vector format if("strandSpecific" %in% slotNames(fds)){ strandSpecific(fds) <- slot(fds, "strandSpecific") - } else{ - # adapt type of strandSpecific if needed (changed logical -> integer) - if(is.logical(strandSpecific(fds))){ - strandSpecific(fds) <- as.integer(strandSpecific(fds)) - } } From 4b69ccbe0b7d6de64061aa1ca399917a2ddb365c Mon Sep 17 00:00:00 2001 From: Ines Scheller <56256384+ischeller@users.noreply.github.com> Date: Fri, 10 May 2024 11:28:11 +0200 Subject: [PATCH 6/7] remove else clause Co-authored-by: Christian Mertes --- R/saveHDF5Objects.R | 5 ----- 1 file changed, 5 deletions(-) diff --git a/R/saveHDF5Objects.R b/R/saveHDF5Objects.R index a7e89bb7..c18e6e91 100644 --- a/R/saveHDF5Objects.R +++ b/R/saveHDF5Objects.R @@ -73,11 +73,6 @@ loadFraserDataSet <- function(dir, name=NULL, file=NULL, upgrade=FALSE){ # ensure strandSpecific slot is up-to-date with new vector format if("strandSpecific" %in% slotNames(fds)){ strandSpecific(fds) <- slot(fds, "strandSpecific") - } - - - e <- try(assays(fds), silent=TRUE) - if(is.error(e)){ if(grepl("DelayedMatrix .* representation .* Please update it ", as.character(e))){ if(isTRUE(upgrade)){ From 4d8f91e9e6cf1e51b1bd7acc0aa1bb593f79acf8 Mon Sep 17 00:00:00 2001 From: Ines Scheller Date: Fri, 10 May 2024 11:37:45 +0200 Subject: [PATCH 7/7] Revert "remove else clause" This reverts commit 4b69ccbe0b7d6de64061aa1ca399917a2ddb365c. --- R/saveHDF5Objects.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/R/saveHDF5Objects.R b/R/saveHDF5Objects.R index c18e6e91..a7e89bb7 100644 --- a/R/saveHDF5Objects.R +++ b/R/saveHDF5Objects.R @@ -73,6 +73,11 @@ loadFraserDataSet <- function(dir, name=NULL, file=NULL, upgrade=FALSE){ # ensure strandSpecific slot is up-to-date with new vector format if("strandSpecific" %in% slotNames(fds)){ strandSpecific(fds) <- slot(fds, "strandSpecific") + } + + + e <- try(assays(fds), silent=TRUE) + if(is.error(e)){ if(grepl("DelayedMatrix .* representation .* Please update it ", as.character(e))){ if(isTRUE(upgrade)){