Skip to content

Commit 58bf437

Browse files
authored
Merge pull request #205 from satijalab/release/5.0.2
Release/5.0.2
2 parents 4d3739b + 6be58e1 commit 58bf437

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+353
-158
lines changed

DESCRIPTION

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Package: SeuratObject
22
Type: Package
33
Title: Data Structures for Single Cell Data
4-
Version: 5.0.1
4+
Version: 5.0.2
55
Authors@R: c(
6-
person(given = 'Rahul', family = 'Satija', email = 'rsatija@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0001-9448-8833')),
7-
person(given = 'Paul', family = 'Hoffman', email = 'seurat@nygenome.org', role = c('aut', 'cre'), comment = c(ORCID = '0000-0002-7693-8957')),
6+
person(given = 'Paul', family = 'Hoffman', email = 'hoff0792@alumni.umn.edu', role = 'aut', comment = c(ORCID = '0000-0002-7693-8957')),
7+
person(given = 'Rahul', family = 'Satija', email = 'seurat@nygenome.org', role = c('aut', 'cre'), comment = c(ORCID = '0000-0001-9448-8833')),
8+
person(given = 'David', family = 'Collins', email = 'dcollins@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0001-9243-7821')),
89
person(given = "Yuhan", family = "Hao", email = 'yhao@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0002-1810-0822')),
910
person(given = "Austin", family = "Hartman", email = 'ahartman@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0001-7278-1852')),
1011
person(given = "Gesmira", family = "Molla", email = 'gmolla@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0002-8628-5056')),
@@ -29,24 +30,24 @@ Description: Defines S4 classes for single-cell genomic data and associated
2930
Hao Y, Hao S, et al (2021) <doi:10.1016/j.cell.2021.04.048> and
3031
Hao Y, et al (2023) <doi:10.1101/2022.02.24.481684> for
3132
more details.
32-
URL: https://mojaveazure.github.io/seurat-object/,
33-
https://github.com/mojaveazure/seurat-object
34-
BugReports: https://github.com/mojaveazure/seurat-object/issues
33+
URL: https://satijalab.github.io/seurat-object/,
34+
https://github.com/satijalab/seurat-object
35+
BugReports: https://github.com/satijalab/seurat-object/issues
3536
License: MIT + file LICENSE
3637
Encoding: UTF-8
3738
LazyData: true
38-
RoxygenNote: 7.2.3
39+
RoxygenNote: 7.3.1
3940
Additional_repositories:
4041
https://bnprks.r-universe.dev
4142
Depends:
42-
R (>= 4.0.0),
43+
R (>= 4.1.0),
4344
sp (>= 1.5.0)
4445
Imports:
4546
future,
4647
future.apply,
4748
grDevices,
4849
grid,
49-
Matrix (>= 1.6.3),
50+
Matrix (>= 1.6.4),
5051
methods,
5152
progressr,
5253
Rcpp (>= 1.0.5),

NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ export(Degrees)
432432
export(Distances)
433433
export(Embeddings)
434434
export(EmptyDF)
435+
export(EmptyMatrix)
435436
export(ExtractField)
436437
export(Features)
437438
export(FetchData)
@@ -506,6 +507,7 @@ export(as.sparse)
506507
export(handlers)
507508
export(intersect)
508509
export(plan)
510+
export(t)
509511
export(with_progress)
510512
exportClasses(Assay)
511513
exportClasses(Assay5)
@@ -622,7 +624,6 @@ importFrom(sp,SpatialPolygons)
622624
importFrom(sp,bbox)
623625
importFrom(sp,coordinates)
624626
importFrom(sp,over)
625-
importFrom(spam,t)
626627
importFrom(stats,aggregate)
627628
importFrom(stats,median)
628629
importFrom(stats,na.omit)

NEWS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# SeuratObject 5.0.2
2+
3+
## Changes:
4+
- Properly re-export `%||%` from rlang (#178)
5+
- Class key-based warnings (#180)
6+
- Require R 4.1 (#180)
7+
- Fix errors in `UpdateSeuratObject` (@ddiez, #182)
8+
- Add `...` to call signature for `Radius` generic (#190)
9+
- Fix bug in `PolyVtx` (#194)
10+
- Fix bug in feature-level subsetting (#200)
11+
- Update `UpdateSeuratObject` to run without `Seurat` installed (#199)
12+
- Add warning in `Layers.Assay()` when the search returns no results (@maxim-h, #189)
13+
- Fix bug in `subset` to allow empty images to be dropped (#204)
14+
115
# SeuratObject 5.0.1
216

317
## Changes:

R/assay.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,15 @@ Layers.Assay <- function(object, search = NA, ...) {
697697
if (!is_na(x = search)) {
698698
layers <- intersect(x = search, y = layers)
699699
if (length(x = layers) == 0) {
700+
warning(
701+
"Layer ",
702+
search,
703+
" isn't present in the assay ",
704+
deparse(expr = substitute(expr = object)),
705+
"; returning NULL",
706+
call. = FALSE,
707+
immediate. = TRUE
708+
)
700709
return(NULL)
701710
}
702711
}

R/assay5.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,6 +2411,12 @@ subset.StdAssay <- function(
24112411
for (lyr in setdiff(x = layers.all, y = layers)) {
24122412
LayerData(object = x, layer = lyr) <- NULL
24132413
}
2414+
# Subset feature-level metadata
2415+
mfeatures <- MatchCells(
2416+
new = Features(x = x, layer = NA),
2417+
orig = features,
2418+
ordered = TRUE
2419+
)
24142420
# Perform the subsets
24152421
for (l in layers) {
24162422
lcells <- MatchCells(
@@ -2442,12 +2448,6 @@ subset.StdAssay <- function(
24422448
for (i in c('cells', 'features')) {
24432449
slot(object = x, name = i) <- droplevels(x = slot(object = x, name = i))
24442450
}
2445-
# Subset feature-level metadata
2446-
mfeatures <- MatchCells(
2447-
new = Features(x = x, layer = NA),
2448-
orig = features,
2449-
ordered = TRUE
2450-
)
24512451
slot(object = x, name = 'meta.data') <- slot(
24522452
object = x,
24532453
name = 'meta.data'

R/centroids.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ GetTissueCoordinates.Centroids <- function(object, full = TRUE, ...) {
192192
#' @method Radius Centroids
193193
#' @export
194194
#'
195-
Radius.Centroids <- function(object) {
195+
Radius.Centroids <- function(object, ...) {
196196
return(slot(object = object, name = 'radius'))
197197
}
198198

R/fov.R

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -904,13 +904,8 @@ setMethod(
904904
setMethod(
905905
f = 'initialize',
906906
signature = 'FOV',
907-
definition = function(.Object, molecules, boundaries, assay, key, ...) {
907+
definition = function(.Object, ...) {
908908
.Object <- callNextMethod(.Object, ...)
909-
slot(object = .Object, name = 'molecules') <- molecules
910-
slot(object = .Object, name = 'boundaries') <- boundaries
911-
slot(object = .Object, name = 'assay') <- assay
912-
slot(object = .Object, name = 'key') <- key
913-
# Reorder cells in boundaries
914909
.Object <- .OrderCells(object = .Object)
915910
validObject(object = .Object)
916911
return(.Object)

R/generics.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,8 @@ IsGlobal <- function(object, ...) {
997997
#'
998998
#' @concept utils
999999
#'
1000+
#' @seealso \code{\link{EmptyMatrix}()}
1001+
#'
10001002
#' @examples
10011003
#' IsMatrixEmpty(new("matrix"))
10021004
#' IsMatrixEmpty(matrix())
@@ -1273,6 +1275,7 @@ Project <- function(object, ...) {
12731275
#' Get the spot radius from an image
12741276
#'
12751277
#' @param object An image object
1278+
#' @param ... Arguments passed to other methods
12761279
#'
12771280
#' @return The radius size
12781281
#'
@@ -1281,7 +1284,7 @@ Project <- function(object, ...) {
12811284
#'
12821285
#' @concept spatialimage
12831286
#'
1284-
Radius <- function(object) {
1287+
Radius <- function(object, ...) {
12851288
UseMethod(generic = 'Radius', object = object)
12861289
}
12871290

R/keymixin.R

Lines changed: 83 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ setClass(
4343
#'
4444
#' @family key
4545
#'
46-
.KeyPattern <- function() {
47-
return('^[a-zA-Z][a-zA-Z0-9]*_$')
48-
}
46+
.KeyPattern <- \() '^[a-zA-Z][a-zA-Z0-9]*_$'
4947

5048
#' Generate a Random Key
5149
#'
@@ -63,24 +61,22 @@ setClass(
6361
#' set.seed(42L)
6462
#' .RandomKey()
6563
#'
66-
.RandomKey <- function(length = 7L, ...) {
67-
return(Key(
68-
object = RandomName(
69-
length = length,
70-
chars = c(letters, LETTERS, seq.int(from = 0L, to = 9L)),
71-
...
72-
),
73-
quiet = TRUE
74-
))
75-
}
64+
.RandomKey <- \(length = 7L, ...) Key(
65+
object = RandomName(
66+
length = length,
67+
chars = c(letters, LETTERS, seq.int(from = 0L, to = 9L)),
68+
...
69+
),
70+
quiet = TRUE
71+
)
7672

7773
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7874
# Methods for Seurat-defined generics
7975
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8076

8177
#' @param object An object
82-
#' @param quiet Suppress warnings when updating characters to keys
8378
#' @param ... Ignored
79+
#' @param quiet Suppress warnings when updating characters to keys
8480
#' @param value A key to set
8581
#'
8682
#' @details \code{Key.character}: Update a character to a key
@@ -91,10 +87,14 @@ setClass(
9187
#' @method Key character
9288
#' @export
9389
#'
94-
Key.character <- function(object, quiet = FALSE, ...) {
95-
f <- ifelse(test = isTRUE(x = quiet), yes = suppressWarnings, no = identity)
96-
return(f(UpdateKey(key = object)))
97-
}
90+
Key.character <- \(object, ..., quiet = FALSE) withCallingHandlers(
91+
expr = UpdateKey(key = object),
92+
updatedKeyWarning = \(cnd) tryInvokeRestart(r = ifelse(
93+
test = isTRUE(x = quiet),
94+
yes = 'muffleWarning',
95+
no = RandomName()
96+
))
97+
)
9898

9999
#' @details \code{Key.KeyMixin}: Get the key of a keyed object
100100
#'
@@ -130,9 +130,7 @@ Key.KeyMixin <- function(object, ...) {
130130
#' @method Key NULL
131131
#' @export
132132
#'
133-
Key.NULL <- function(object, ...) {
134-
return(NULL)
135-
}
133+
Key.NULL <- \(object, ...) NULL
136134

137135
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138136
# Methods for R-defined generics
@@ -142,6 +140,57 @@ Key.NULL <- function(object, ...) {
142140
# Internal
143141
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
144142

143+
#' Check Usage of Existing Keys
144+
#'
145+
#' Check key usage against existing keys to ensure key uniqueness
146+
#'
147+
#' @param key Existing key to check usage of; if missing, creates a
148+
#' key from \code{name}
149+
#' @param existing A vector of existing keys to match against \code{key}
150+
#' @param name Name of object that \code{key} is used for; if provided and
151+
#' \code{existing} is named, the entry of \code{existing} for \code{name} is
152+
#' removed from the check
153+
#'
154+
#' @return A key guaranteed to be unique in the context of \code{existing}
155+
#'
156+
#' @keywords internal
157+
#'
158+
#' @noRd
159+
#'
160+
.CheckKey <- function(key, existing = NULL, name = NULL) {
161+
if (rlang::is_missing(x = key) || !length(x = key) || !nzchar(x = key)) {
162+
key <- Key(object = tolower(name) %||% RandomName(), quiet = TRUE)
163+
}
164+
key <- Key(object = key, quiet = TRUE)
165+
if (!is.null(x = names(x = existing)) && !is.null(x = name)) {
166+
existing <- existing[setdiff(x = names(x = existing), y = name)]
167+
}
168+
if (key %in% existing) {
169+
old <- key
170+
key <- Key(object = tolower(x = name %||% RandomName()), quiet = TRUE)
171+
i <- 1L
172+
n <- 5L
173+
while (key %in% existing) {
174+
key <- Key(object = RandomName(length = n), quiet = TRUE)
175+
i <- i + 1L
176+
if (!i %% 7L) {
177+
n <- n + 2L
178+
}
179+
}
180+
warn(
181+
message = paste(
182+
"Key",
183+
sQuote(x = old),
184+
"taken, using",
185+
sQuote(x = key),
186+
"instead"
187+
),
188+
class = 'existingKeyWarning'
189+
)
190+
}
191+
return(key)
192+
}
193+
145194
#' Internal Key Methods
146195
#'
147196
#' Internal key methods for classes that inherit from \code{\link{KeyMixin}};
@@ -199,18 +248,21 @@ UpdateKey <- function(key) {
199248
if (new.key == '_') {
200249
new.key <- paste0(RandomName(length = 3), '_')
201250
}
202-
warning(
203-
key.msg,
204-
", setting key from ",
205-
key,
206-
" to ",
207-
new.key,
208-
call. = FALSE,
209-
immediate. = TRUE
251+
warn(
252+
message = paste0(
253+
key.msg,
254+
", setting key from ",
255+
key,
256+
" to ",
257+
new.key
258+
),
259+
class = 'updatedKeyWarning'
210260
)
211261
return(new.key)
212262
}
213263

264+
.MetaKey <- Key(object = 'md', quiet = TRUE)
265+
214266
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
215267
# S4 methods
216268
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -224,7 +276,7 @@ UpdateKey <- function(key) {
224276
#' Keys must be a one-length character vector; a key must be composed of one
225277
#' of the following:
226278
#' \itemize{
227-
#' \item An empty string (eg. \dQuote{\code{''}}) where \code{nzchar() == 0}
279+
#' \item An empty string (eg. \dQuote{\code{''}}) where \code{nchar() == 0}
228280
#' \item An string composed of one or more alphanumeric values
229281
#' (both lower- and upper-case) that ends with an underscore
230282
#' (\dQuote{\code{_}}); the first character must be a letter
@@ -262,42 +314,10 @@ setValidity(
262314
# Ensure proper key composition
263315
valid <- c(
264316
valid,
265-
paste0("Keys must match the pattern '", .KeyPattern(), "'")
317+
paste("Keys must match the pattern", sQuote(x = .KeyPattern()))
266318
)
267319
}
268320
}
269321
return(valid %||% TRUE)
270322
}
271323
)
272-
273-
.CheckKey <- function(key, existing = NULL, name = NULL) {
274-
if (rlang::is_missing(x = key) || !length(x = key) || !nzchar(x = key)) {
275-
key <- Key(object = tolower(name) %||% RandomName(), quiet = TRUE)
276-
}
277-
if (!is.null(x = names(x = existing)) && !is.null(x = name)) {
278-
existing <- existing[setdiff(x = names(x = existing), y = name)]
279-
}
280-
if (key %in% existing) {
281-
old <- key
282-
key <- Key(object = tolower(x = name %||% RandomName()), quiet = TRUE)
283-
i <- 1L
284-
n <- 5L
285-
while (key %in% existing) {
286-
key <- Key(object = RandomName(length = n), quiet = TRUE)
287-
i <- i + 1L
288-
if (!i %% 7L) {
289-
n <- n + 2L
290-
}
291-
}
292-
warn(
293-
message = paste(
294-
"Key",
295-
sQuote(x = old),
296-
"taken, using",
297-
sQuote(x = key),
298-
"instead"
299-
)
300-
)
301-
}
302-
return(key)
303-
}

0 commit comments

Comments
 (0)