Skip to content

Commit

Permalink
Fix warnings related to strandSpecific on load and examples (#76)
Browse files Browse the repository at this point in the history
* ensure old fds' load without warning about `strandSpecific`
* remove warning about missing strandSpecific field for empty and example fds
* fix loading again for new fds and remove warning for test data
* adjust example for merging with external counts to new strandSpecific vector

---------

Co-authored-by: Christian Mertes <mertes@in.tum.de>
  • Loading branch information
ischeller and c-mertes committed May 10, 2024
1 parent 8899967 commit f10c215
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions R/example_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ 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)

Expand Down
2 changes: 1 addition & 1 deletion R/mergeExternalData.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

#
Expand Down
7 changes: 4 additions & 3 deletions R/saveHDF5Objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ 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
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 ",
Expand Down
Binary file modified inst/extdata/externalCounts/annotation.tsv.gz
Binary file not shown.

0 comments on commit f10c215

Please sign in to comment.