Skip to content

Commit

Permalink
retain Graph and Neighbor objects when only subsetting features
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewwbutler committed Sep 11, 2020
1 parent 361e60a commit 5bd99f6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -7349,6 +7349,10 @@ subset.Seurat <- function(x, subset, cells = NULL, features = NULL, idents = NUL
if (all(cells %in% Cells(x = x)) && length(x = cells) == length(x = Cells(x = x)) && is.null(x = features)) {
return(x)
}
if (!all(all.cells %in% cells)) {
slot(object = x, name = 'graphs') <- list()
slot(object = x, name = 'neighbors') <- list()
}
assays <- FilterObjects(object = x, classes.keep = 'Assay')
# Filter Assay objects
for (assay in assays) {
Expand Down Expand Up @@ -7394,8 +7398,6 @@ subset.Seurat <- function(x, subset, cells = NULL, features = NULL, idents = NUL
x[[names(x = n.calc)]] <- n.calc
}
}
slot(object = x, name = 'graphs') <- list()
slot(object = x, name = 'neighbors') <- list()
Idents(object = x, drop = TRUE) <- Idents(object = x)[cells]
# subset images
for (image in Images(object = x)) {
Expand Down

0 comments on commit 5bd99f6

Please sign in to comment.