diff --git a/DESCRIPTION b/DESCRIPTION index 2f53183..d73d797 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: Canek Type: Package Title: Batch Correction of Single Cell Transcriptome Data -Version: 0.2.3 +Version: 0.2.4 Authors@R: c( person("Martin", "Loza", email = "martin.loza.lopez@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3342-2643")), @@ -20,7 +20,8 @@ Imports: fpc, bluster, igraph, - matrixStats + matrixStats, + utils Suggests: testthat (>= 2.1.0), Seurat, diff --git a/NAMESPACE b/NAMESPACE index 17df596..7bd5e5e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -21,3 +21,4 @@ importFrom(stats,dist) importFrom(stats,kmeans) importFrom(stats,quantile) importFrom(stats,sd) +importFrom(utils,packageVersion) diff --git a/NEWS.md b/NEWS.md index aa6bcc6..771bab7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# Canek 0.2.4 + +## Changes + +- Update Canek for compatibility with Seurat v5 ([#20](https://github.com/MartinLoza/Canek/issues/20)) + # Canek 0.2.3 ## Changes diff --git a/R/Canek-package.R b/R/Canek-package.R index 2de5617..3a31261 100644 --- a/R/Canek-package.R +++ b/R/Canek-package.R @@ -5,6 +5,7 @@ # roxygen namespace tags. Modify with care! ## usethis namespace: start #' @import numbers +#' @importFrom utils packageVersion #' @importFrom stats dist kmeans sd quantile #' @importFrom igraph cluster_louvain membership mst graph_from_adjacency_matrix as_edgelist #' @importFrom bluster makeSNNGraph diff --git a/R/RunCanek.R b/R/RunCanek.R index ac6bda0..fb132c8 100644 --- a/R/RunCanek.R +++ b/R/RunCanek.R @@ -41,7 +41,10 @@ RunCanek.Seurat <- function(x, batches = NULL, slot = "data", assay = NULL, feat } counts <- lapply(obj, function(xx) { - Seurat::GetAssayData(xx, slot = slot, assay = assay)[features, ] + if (packageVersion("Seurat") >= "5.0.0") + Seurat::GetAssayData(xx, layer = slot, assay = assay)[features, ] + else + Seurat::GetAssayData(xx, slot = slot, assay = assay)[features, ] }) counts <- Canek::CorrectBatches(counts, debug = debug, ...) diff --git a/tests/testthat/test_RunCanek.R b/tests/testthat/test_RunCanek.R index 78d1cdf..001313d 100644 --- a/tests/testthat/test_RunCanek.R +++ b/tests/testthat/test_RunCanek.R @@ -24,7 +24,7 @@ y <- SingleCellExperiment::SingleCellExperiment(list(counts=m, logcounts=m)) y$batch <- b # RunCanek. -x <- RunCanek(x, "batch") +x <- RunCanek(x, "batch", slot="counts") y <- RunCanek(y, "batch") z <- RunCanek(list(B1=m1, B2=m2), debug = TRUE)