Skip to content

Commit

Permalink
coercion to matrix to fit BiocNeighbor changes ( #109 )
Browse files Browse the repository at this point in the history
  • Loading branch information
plger committed Sep 9, 2024
1 parent 6f82238 commit 39eafb1
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: scDblFinder
Type: Package
Title: scDblFinder
Version: 1.19.2
Version: 1.19.3
Authors@R: c(
person("Pierre-Luc", "Germain", email="pierre-luc.germain@hest.ethz.ch", role=c("cre","aut"), comment=c(ORCID="0000-0003-3418-4218")),
person("Aaron", "Lun", email="infinite.monkeys.with.keyboards@gmail.com", role="ctb"))
Expand Down
2 changes: 1 addition & 1 deletion R/clustering.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fastcluster <- function( x, k=NULL, rdname="PCA", nstart=3, iter.max=50,
k <- seq_len(nrow(x))
}
if(verbose) message("Building KNN graph and clustering")
x <- makeKNNGraph(x, k=min(max(2,floor(sqrt(length(unique(k))))-1),10))
x <- makeKNNGraph(as.matrix(x), k=min(max(2,floor(sqrt(length(unique(k))))-1),10))
if(returnType=="graph") return(list(k=k, graph=x))
cl <- membership(cluster_louvain(x))
cl[k]
Expand Down
2 changes: 1 addition & 1 deletion R/computeDoubletDensity.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ NULL
sim.pcs <- .spawn_doublet_pcs(x, size.factors.norm, V=pc.out$rotation, centers=rowMeans(y), niters=niters, block=block)

# Computing densities, using a distance computed from the kth nearest neighbor.
pre.pcs <- buildIndex(pcs, BNPARAM=BNPARAM)
pre.pcs <- buildIndex(as.matrix(pcs), BNPARAM=BNPARAM)
self.dist <- findKNN(BNINDEX=pre.pcs, k=k, BPPARAM=BPPARAM, last=1, get.index=FALSE, warn.ties=FALSE)$distance
if(any(self.dist == 0))
stop("Duplicate cells detected. These are probably low-quality cells ",
Expand Down
2 changes: 1 addition & 1 deletion R/recoverDoublets.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ NULL
is.doublet <- logical(nrow(x))
is.doublet[.subset2index(doublets, x, byrow=TRUE)] <- TRUE

fout <- findKNN(x, k=k, BNPARAM=BNPARAM, BPPARAM=BPPARAM)
fout <- findKNN(as.matrix(x), k=k, BNPARAM=BNPARAM, BPPARAM=BPPARAM)
neighbors <- fout$index
neighbors[] <- is.doublet[neighbors]
P <- rowMeans(neighbors)
Expand Down
2 changes: 1 addition & 1 deletion R/scDblFinder.R
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ scDblFinder <- function(

#' @importFrom BiocNeighbors AnnoyParam
.evaluateKNN <- function(pca, ctype, origins, expected=NULL, k){
knn <- suppressWarnings(findKNN(pca, max(k), BNPARAM=AnnoyParam()))
knn <- suppressWarnings(findKNN(as.matrix(pca), max(k), BNPARAM=AnnoyParam()))
hasOrigins <- length(unique(origins))>1
knn$type <- matrix(as.integer(ctype)[knn$index]-1L, nrow=nrow(knn$index))
if(hasOrigins) knn$orig <- matrix(origins[knn$index], nrow=nrow(knn[[1]]))
Expand Down

0 comments on commit 39eafb1

Please sign in to comment.