Skip to content

Commit

Permalink
Merge pull request satijalab#414 from satijalab/fix/futureAnnoy
Browse files Browse the repository at this point in the history
fix annoy search with non-multicore future plans
  • Loading branch information
andrewwbutler authored Sep 18, 2020
2 parents 02145bc + ad59e2a commit b7e7ffe
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Seurat
Version: 3.2.1.9003
Date: 2020-09-17
Version: 3.2.1.9004
Date: 2020-09-18
Title: Tools for Single Cell Genomics
Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) <doi:10.1038/nbt.3192>, Macosko E, Basu A, Satija R, et al (2015) <doi:10.1016/j.cell.2015.05.002>, and Stuart T, Butler A, et al (2019) <doi:10.1016/j.cell.2019.05.031> for more details.
Authors@R: c(
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ importFrom(cowplot,plot_grid)
importFrom(cowplot,theme_cowplot)
importFrom(fitdistrplus,fitdist)
importFrom(future,nbrOfWorkers)
importFrom(future,plan)
importFrom(future.apply,future_lapply)
importFrom(future.apply,future_sapply)
importFrom(ggplot2,Geom)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Set the seed in `WhichCells` regardless of whether or not `idents` is passed
- Retain Graph and Neighbor objects when subsetting only on features
- Fix data.frame input to `CreateAssayObject()` when data.frame has no rownames.
- Default annoy search to sequential if not using multicore future plans.

## [3.2.1] - 2020-09-04
### Added
Expand Down
6 changes: 6 additions & 0 deletions R/clustering.R
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,18 @@ AnnoyBuildIndex <- function(data, metric = "euclidean", n.trees = 50) {
# @param search.k During the query it will inspect up to search_k nodes which
# gives you a run-time tradeoff between better accuracy and speed.
# @ param include.distance Include the corresponding distances
#' @importFrom future plan
#' @importFrom future.apply future_lapply
#
AnnoySearch <- function(index, query, k, search.k = -1, include.distance = TRUE) {
n <- nrow(x = query)
idx <- matrix(nrow = n, ncol = k)
dist <- matrix(nrow = n, ncol = k)
convert <- methods::is(index, "Rcpp_AnnoyAngular")
if (!inherits(x = plan(), what = "multicore")) {
oplan <- plan(strategy = "sequential")
on.exit(plan(oplan), add = TRUE)
}
res <- future_lapply(X = 1:n, FUN = function(x) {
res <- index$getNNsByVectorList(query[x, ], k, search.k, include.distance)
# Convert from Angular to Cosine distance
Expand Down

0 comments on commit b7e7ffe

Please sign in to comment.