Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: SeuratObject
Title: Data Structures for Single Cell Data
Version: 5.2.0
Version: 5.2.0.9000
Authors@R: c(
person(given = 'Paul', family = 'Hoffman', email = '[email protected]', role = 'aut', comment = c(ORCID = '0000-0002-7693-8957')),
person(given = 'Rahul', family = 'Satija', email = '[email protected]', role = c('aut', 'cre'), comment = c(ORCID = '0000-0001-9448-8833')),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased

## Changes
- Update `subset.Seurat` to no longer call `droplevels` on the input's cell-level `meta.data` slot; update `subset.Assay` to no longer call `droplevels` on the input's feature-level `meta.features` slot; update `subset.StdAssay` to no longer call `droplevels` on the input's feature-level `meta.data` slot (reverting #251, see discussion in #247)

# SeuratObject 5.2.0

Expand Down
8 changes: 1 addition & 7 deletions R/assay.R
Original file line number Diff line number Diff line change
Expand Up @@ -1488,13 +1488,7 @@ subset.Assay <- function(x, cells = NULL, features = NULL, ...) {
new(Class = 'matrix')
}
VariableFeatures(object = x) <- VariableFeatures(object = x)[VariableFeatures(object = x) %in% features]

# Subset feature-level metadata.
meta.features <- x[[]]
meta.features <- meta.features[features, , drop = FALSE]
meta.features <- droplevels(meta.features)
slot(object = x, name = 'meta.features') <- meta.features

slot(object = x, name = 'meta.features') <- x[[]][features, , drop = FALSE]
validObject(object = x)
return(x)
}
Expand Down
8 changes: 2 additions & 6 deletions R/assay5.R
Original file line number Diff line number Diff line change
Expand Up @@ -2484,12 +2484,8 @@ subset.StdAssay <- function(
orig = features,
ordered = TRUE
)

# Subset feature-level metadata.
meta.data <- slot(x, name = "meta.data")
meta.data <- meta.data[mfeatures, , drop = FALSE]
meta.data <- droplevels(meta.data)
slot(x, name = "meta.data") <- meta.data
# subset the meta.data slot accordingly
slot(x, name = "meta.data") <- slot(x, name = "meta.data")[mfeatures, , drop = FALSE]

# ensure the object is valid
validObject(x)
Expand Down
8 changes: 1 addition & 7 deletions R/seurat.R
Original file line number Diff line number Diff line change
Expand Up @@ -3727,13 +3727,7 @@ subset.Seurat <- function(
# Remove metadata for cells not present
orig.cells <- colnames(x = x)
cells <- intersect(x = orig.cells, y = cells)

# Subset cell-level metadata.
meta.data <- x[[]]
meta.data <- meta.data[cells, , drop = FALSE]
meta.data <- droplevels(meta.data)
slot(object = x, name = 'meta.data') <- meta.data

slot(object = x, name = 'meta.data') <- x[[]][cells, , drop = FALSE]
if (!all(orig.cells %in% cells)) {
# Remove neighbors
slot(object = x, name = 'neighbors') <- list()
Expand Down