From b4c3146f00d855f2f935944c4bfce5cc1b0ba2f3 Mon Sep 17 00:00:00 2001 From: Josh Campbell Date: Thu, 20 Feb 2025 17:11:04 -0500 Subject: [PATCH] Updated runBarcodeRanks() to match output from new DropletUtils update --- R/dropletUtils_barcodeRank.R | 15 +++++++-------- tests/testthat/test-dropletUtils.R | 8 +++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/R/dropletUtils_barcodeRank.R b/R/dropletUtils_barcodeRank.R index 7f10ab27e..62c93e54a 100644 --- a/R/dropletUtils_barcodeRank.R +++ b/R/dropletUtils_barcodeRank.R @@ -9,20 +9,20 @@ fit.bounds = fit.bounds, df = df) - knee.ix <- as.integer(output@listData$total >= + knee.ix <- as.integer(output$total >= S4Vectors::metadata(output)$knee) - inflection.ix <- as.integer(output@listData$total >= + inflection.ix <- as.integer(output$total >= S4Vectors::metadata(output)$inflection) + rank.ix <- as.integer(output$rank) total.ix <- as.integer(output$total) - fitted.ix <- as.integer(output$fitted) - result <- cbind(knee.ix, inflection.ix, rank.ix, total.ix, fitted.ix) + result <- cbind(knee.ix, inflection.ix, rank.ix, total.ix) colnames(result) <- c("dropletUtils_barcodeRank_knee", "dropletUtils_barcodeRank_inflection", "dropletUtils_barcodeRank_rank", - "dropletUtils_barcodeRank_total", - "dropletUtils_barcodeRank_fitted") + "dropletUtils_barcodeRank_total") + result.list <- list(result, S4Vectors::metadata(output)$knee, S4Vectors::metadata(output)$inflection) @@ -117,8 +117,7 @@ runBarcodeRankDrops <- function(inSCE, "dropletUtils_barcodeRank_inflection")] metaCols <- c("dropletUtils_barcodeRank_rank", - "dropletUtils_barcodeRank_total", - "dropletUtils_barcodeRank_fitted") + "dropletUtils_barcodeRank_total") metaOutput[, metaCols] <- result.matrix[, metaCols] metaOutput[,"dropletUtils_barcodeRank_knee"] <- rep(result$knee, sum(sceSampleInd)) diff --git a/tests/testthat/test-dropletUtils.R b/tests/testthat/test-dropletUtils.R index dbec1ee32..39306e1fb 100644 --- a/tests/testthat/test-dropletUtils.R +++ b/tests/testthat/test-dropletUtils.R @@ -5,8 +5,10 @@ context("Testing dropletUtils algorithms") data(scExample, package = "singleCellTK") test_that(desc = "Testing runBarcodeRankDrops", { - sceres <- runBarcodeRankDrops(inSCE = sce) - expect_equal(length(colData(sceres)$dropletUtils_BarcodeRank_Inflection),ncol(sce)) - expect_equal(class(colData(sceres)$dropletUtils_BarcodeRank_Inflection), "integer") + sce <- runBarcodeRankDrops(inSCE = sce) + expect_equal(length(colData(sce)$dropletUtils_BarcodeRank_Inflection),ncol(sce)) + expect_equal(class(colData(sce)$dropletUtils_BarcodeRank_Inflection), "integer") + gg <- plotBarcodeRankDropsResults(sce) + expect_is(gg$scatterBarcodeRank, "ggplot") })