Skip to content

Commit

Permalink
Bugfix to handling of nimble append when there are zero rows (#39)
Browse files Browse the repository at this point in the history
* Bugfix to handling of nimble append when there are zero rows
  • Loading branch information
bbimber authored Jan 10, 2024
1 parent 590c1aa commit 3c6f4ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/NimbleAppend.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ AppendNimbleCounts <- function(seuratObject, nimbleFile, targetAssayName, dropAm
}
})

# Indicates no data in TSV
if (all(is.null(df))){
return(seuratObject)
}

if (sum(df$V1 == "") > 0) {
stop("The nimble data contains blank feature names. This should not occur.")
}
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-nimbleappend.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ test_that("Nimble Append deletes blank feature names when appending", {
expect_equal(unique(seuratObj@assays$Nimble@meta.features$FeatureSource), c('Nimble'))
})

test_that("Nimble Append works with empty input", {
seuratObj <- Seurat::UpdateSeuratObject(readRDS("../testdata/nimbleTest.rds"))
fn <- tempfile(fileext = '.txt')
file.create(fn)
seuratObj <- AppendNimbleCounts(seuratObj, fn, targetAssayName = 'Nimble')
unlink(fn)
expect_false('Nimble' %in% names(seuratObj@assays))
})

test_that("Nimble Append deletes all barcodes not in Seurat when appending", {
seuratObj <- Seurat::UpdateSeuratObject(readRDS("../testdata/nimbleTest.rds"))
nimbleExclusiveBarcodes <- c("12345_CCAGCGAAGTCCGTAT", "12345_CCAGCGAAGTCCGTAC")
Expand Down

0 comments on commit 3c6f4ff

Please sign in to comment.