Skip to content

Commit

Permalink
removed neighbor argument from localOutliers to fix bug occuring in s…
Browse files Browse the repository at this point in the history
…ome datasets.
  • Loading branch information
MicTott committed Nov 14, 2024
1 parent c8b76bc commit 18123bf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Date: 2024-11-08
Authors@R: c(
person("Michael", "Totty", ,"[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-9292-8556")),
person("Stephanie", "Hicks", ,email = "[email protected]", role = c("aut"),
person("Stephanie", "Hicks", ,email = "[email protected]", role = c("aut"),
comment = c(ORCID = "0000-0002-7858-0231")),
person("Boyi", "Guo", ,email = "[email protected]", role = c("aut"),
comment = c(ORCID = "0000-0003-2950-2349")))
Expand Down
3 changes: 0 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@

- **Parallelization**: Added a `workers` argument for parallel processing using `BiocParallel` in both `localOutlier` and `localVariance` functions. This allows for faster computation, particularly on larger datasets.

- **`neighborhood` Argument**: Introduced a new `neighborhood` parameter to the `localOutlier` function to support neighborhoods beyond spatial coordinates. Users can now specify alternative neighborhood matrices, such as reduced dimensions from PCA or UMAP, enabling local outlier detection in non-spatial datasets such as snRNA-seq.


### Deprecations
- **`plotQC` Function Deprecated**: The `plotQC` function is now deprecated. While it remains available for backward compatibility, users are encouraged to transition to `plotQCmetrics`. Calling `plotQC` will display a warning, reminding users of the deprecation.

Expand Down
9 changes: 3 additions & 6 deletions R/localOutliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#' @param log Logical indicating whether to log1p transform the features
#' (default is TRUE)
#' @param cutoff Cutoff for outlier detection (default is 3)
#' @param neighborhood Matrix of spatial coordinates for neighborhood calculation
#' @param workers Number of workers for parallel processing (default is 1)
#'
#' @return SpatialExperiment or SingleCellExperiment object with updated colData containing outputs
Expand Down Expand Up @@ -51,15 +50,13 @@
#' spe <- localOutliers(spe,
#' metric = "sum",
#' direction = "lower",
#' log = TRUE,
#' neighborhood = spatialCoords(spe)
#' log = TRUE
#' )
#'
localOutliers <- function(
spe, metric = "detected",
direction = "lower", n_neighbors = 36, samples = "sample_id",
log = TRUE, cutoff = 3, neighborhood = spatialCoords(spe_subset),
workers=1) {
log = TRUE, cutoff = 3, workers=1) {

# ===== Validity checks =====
# Check if 'spe' is a valid object with required components
Expand Down Expand Up @@ -109,7 +106,7 @@ localOutliers <- function(
columnData <- colData(spe_subset)

# Find nearest neighbors
dnn <- BiocNeighbors::findKNN(neighborhood,
dnn <- BiocNeighbors::findKNN(spatialCoords(spe_subset),
k = n_neighbors, warn.ties = FALSE,
BPPARAM = BiocParallel::MulticoreParam(workers=workers))$index

Expand Down

0 comments on commit 18123bf

Please sign in to comment.