Skip to content

Commit 9f88769

Browse files
authored
Merge pull request #68 from mojaveazure/release/4.1.3
SeuratObject v4.1.3
2 parents 6cbe481 + a11e140 commit 9f88769

18 files changed

+167
-115
lines changed

DESCRIPTION

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: SeuratObject
22
Type: Package
33
Title: Data Structures for Single Cell Data
4-
Version: 4.1.2
5-
Date: 2022-09-20
4+
Version: 4.1.3
5+
Date: 2022-11-07
66
Authors@R: c(
77
person(given = 'Rahul', family = 'Satija', email = '[email protected]', role = 'aut', comment = c(ORCID = '0000-0001-9448-8833')),
88
person(given = 'Andrew', family = 'Butler', email = '[email protected]', role = 'aut', comment = c(ORCID = '0000-0003-3608-0463')),
@@ -29,9 +29,10 @@ BugReports:
2929
License: MIT + file LICENSE
3030
Encoding: UTF-8
3131
LazyData: true
32-
RoxygenNote: 7.2.0
32+
RoxygenNote: 7.2.1
3333
Depends:
34-
R (>= 4.0.0)
34+
R (>= 4.0.0),
35+
sp (>= 1.5.0)
3536
Imports:
3637
future,
3738
future.apply,
@@ -41,14 +42,13 @@ Imports:
4142
methods,
4243
progressr,
4344
Rcpp (>= 1.0.5),
44-
sp (>= 1.5.0),
45-
rgeos,
4645
rlang (>= 0.4.7),
4746
stats,
4847
tools,
4948
utils
5049
Suggests:
5150
ggplot2,
51+
rgeos,
5252
testthat
5353
Collate:
5454
'RcppExports.R'

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ importFrom(methods,validObject)
384384
importFrom(progressr,handlers)
385385
importFrom(progressr,progressor)
386386
importFrom(progressr,with_progress)
387-
importFrom(rgeos,gSimplify)
388387
importFrom(rlang,"%||%")
389388
importFrom(rlang,enquo)
390389
importFrom(rlang,eval_tidy)

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# SeuratObject 4.1.3
2+
## Changes
3+
- Move {rgeos} to Suggests; segmentation simplification now requires {regos} to be installed manually
4+
- Move {sp} to Depends
5+
6+
## Added
7+
- Add keys to `Assays` and `DimReducs` in `UpdateSeuratObject` when missing
8+
19
# SeuratObject 4.1.2
210
## Changed
311
- Bump required Matrix version to >= 1.5.0

R/centroids.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ RenameCells.Centroids <- function(object, new.names = NULL, ...) {
211211
}
212212
new.names <- make.unique(names = new.names)
213213
if (length(x = new.names) != length(x = Cells(x = object))) {
214-
stop("Cannot partially rename cells", call. = FALSE)
214+
stop("Cannot partially rename centroid cells", call. = FALSE)
215215
}
216216
slot(object = object, name = 'cells') <- new.names
217217
return(object)
@@ -373,6 +373,10 @@ setMethod(
373373
definition = function(x, y, invert = FALSE, ...) {
374374
idx <- over(x = x, y = y)
375375
idx <- idx[!is.na(x = idx)]
376+
if (!length(idx)) {
377+
warning("The selected region does not contain any cell centroids")
378+
return(NULL)
379+
}
376380
idx <- sort(x = as.integer(x = names(x = idx)))
377381
if (isTRUE(x = invert)) {
378382
idx <- -idx

R/fov.R

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ setMethod(
862862
if (inherits(x = x[[i]], what = 'Molecules')) {
863863
slot(object = x, name = 'molecules')[[i]] <- NULL
864864
} else if (i == DefaultBoundary(object = x)) {
865-
stop("Cannot remove default segmentation", call. = FALSE)
865+
stop("Cannot remove default boundary", call. = FALSE)
866866
} else {
867867
slot(object = x, name = 'boundaries')[[i]] <- NULL
868868
}
@@ -1016,21 +1016,30 @@ setValidity(
10161016
)
10171017
break
10181018
} else {
1019-
matched.cells <- MatchCells(
1020-
new = all.cells,
1021-
orig = Cells(x = object[[s]]),
1022-
ordered = TRUE
1023-
)
1024-
if (length(x = matched.cells) != length(x = Cells(x = object[[s]]))) {
1025-
valid <- c(
1026-
valid,
1027-
"All segmentation boundaries must have cells"
1019+
cells <- Cells(x = object[[s]])
1020+
if (!is.null(cells)) {
1021+
matched.cells <- MatchCells(
1022+
new = all.cells,
1023+
orig = cells,
1024+
ordered = TRUE
10281025
)
1029-
break
1030-
} else if (is.unsorted(x = matched.cells)) {
1026+
if (length(x = matched.cells) != length(x = Cells(x = object[[s]]))) {
1027+
valid <- c(
1028+
valid,
1029+
"All segmentation boundaries must have cells"
1030+
)
1031+
break
1032+
} else if (is.unsorted(x = matched.cells)) {
1033+
valid <- c(
1034+
valid,
1035+
"All segmentation boundaries must be ordered"
1036+
)
1037+
break
1038+
}
1039+
} else {
10311040
valid <- c(
10321041
valid,
1033-
"All segmentation boundaries must be ordered"
1042+
paste(s, "contains 0 cells")
10341043
)
10351044
break
10361045
}

R/segmentation.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ RenameCells.Segmentation <- function(object, new.names = NULL, ...) {
174174
}
175175
new.names <- make.unique(names = new.names)
176176
if (length(x = new.names) != length(x = Cells(x = object))) {
177-
stop("Cannot partially rename cells", call. = FALSE)
177+
stop("Cannot partially rename segmentation cells", call. = FALSE)
178178
}
179179
names(x = slot(object = object, name = 'polygons')) <- new.names
180180
p <- progressor(along = slot(object = object, name = 'polygons'))
@@ -223,6 +223,8 @@ subset.Segmentation <- function(x, cells = NULL, ...) {
223223
if (is.numeric(x = cells)) {
224224
cells <- Cells(x = x)[cells]
225225
cells <- MatchCells(new = Cells(x = x), orig = cells, ordered = TRUE)
226+
} else {
227+
cells <- intersect(Cells(x), cells)
226228
}
227229
if (!length(x = cells)) {
228230
stop("None of the requested cells found")
@@ -304,6 +306,10 @@ setMethod(
304306
definition = function(x, y, invert = FALSE, ...) {
305307
idx <- over(x = x, y = y)
306308
idx <- idx[!is.na(x = idx)]
309+
if (!length(idx)) {
310+
warning("The selected region does not contain any cell segmentations")
311+
return(NULL)
312+
}
307313
names(x = idx) <- vapply(
308314
X = strsplit(x = names(x = idx), split = '\\.'),
309315
FUN = '[[',

R/seurat.R

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,18 @@ UpdateSeuratObject <- function(object) {
562562
# Update object slots
563563
message("Updating object slots")
564564
object <- UpdateSlots(object = object)
565+
# Validate object keys
566+
message("Ensuring keys are in the proper structure")
567+
for (ko in FilterObjects(object = object)) {
568+
key <- Key(object = object[[ko]])
569+
if (!length(x = key) || !nzchar(x = key)) {
570+
key <- Key(object = ko, quiet = TRUE)
571+
}
572+
slot(
573+
object = slot(object = object, name = FindObject(object, ko))[[ko]],
574+
name = 'key'
575+
) <- UpdateKey(key)
576+
}
565577
# Rename assays
566578
assays <- make.names(names = Assays(object = object))
567579
names(x = assays) <- Assays(object = object)
@@ -574,11 +586,6 @@ UpdateSeuratObject <- function(object) {
574586
object = Command(object = object, command = cmd)
575587
)
576588
}
577-
# Validate object keys
578-
message("Ensuring keys are in the proper strucutre")
579-
for (ko in FilterObjects(object = object)) {
580-
Key(object = object[[ko]]) <- UpdateKey(key = Key(object = object[[ko]]))
581-
}
582589
# Check feature names
583590
message("Ensuring feature names don't have underscores or pipes")
584591
for (assay.name in FilterObjects(object = object, classes.keep = 'Assay')) {
@@ -1668,7 +1675,9 @@ RenameCells.Seurat <- function(
16681675
for (i in Images(object = object)) {
16691676
object[[i]] <- RenameCells(
16701677
object = object[[i]],
1671-
new.names = unname(obj = new.cell.names[Cells(x = object[[i]])])
1678+
new.names = unname(
1679+
obj = new.cell.names[Cells(x = object[[i]], boundary = NA)]
1680+
)
16721681
)
16731682
}
16741683
# Rename the Neighbor

R/utils.R

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,12 @@ as.sparse.Matrix <- function(x, ...) {
598598
#' @method as.sparse matrix
599599
#'
600600
as.sparse.matrix <- function(x, ...) {
601+
if (is.character(x = x)) {
602+
dnames <- dimnames(x = x)
603+
nc <- ncol(x = x)
604+
x <- matrix(data = as.numeric(x = x), ncol = nc)
605+
dimnames(x = x) <- dnames
606+
}
601607
x <- as(object = x, Class = "Matrix")
602608
return(as.sparse.Matrix(x, ...))
603609
}
@@ -702,13 +708,14 @@ S4ToList.list <- function(object) {
702708
return(object)
703709
}
704710

705-
#' @importFrom rgeos gSimplify
706-
#'
707711
#' @rdname Simplify
708712
#' @method Simplify Spatial
709713
#' @export
710714
#'
711715
Simplify.Spatial <- function(coords, tol, topologyPreserve = TRUE) {
716+
if (!PackageCheck('rgeos', error = FALSE)) {
717+
stop("'Simplify' requires rgeos to be installed", call. = FALSE)
718+
}
712719
class.orig <- class(x = coords)
713720
dest <- ifelse(
714721
test = grepl(pattern = '^Spatial', x = class.orig),
@@ -719,7 +726,7 @@ Simplify.Spatial <- function(coords, tol, topologyPreserve = TRUE) {
719726
value = TRUE
720727
)[1L]
721728
)
722-
coords <- gSimplify(
729+
coords <- rgeos::gSimplify(
723730
spgeom = as(object = coords, Class = dest),
724731
tol = as.numeric(x = tol),
725732
topologyPreserve = isTRUE(x = topologyPreserve)

R/zzz.R

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,6 @@ NameIndex <- function(x, names, MARGIN) {
460460
# Hooks
461461
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
462462

463-
.onAttach <- function(libname, pkgname) {
464-
AttachDeps(deps = 'sp')
465-
return(invisible(x = NULL))
466-
}
467-
468463
.onLoad <- function(libname, pkgname) {
469464
toset <- setdiff(x = names(x = Seurat.options), y = names(x = options()))
470465
if (length(x = toset)) {

cran-comments.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# SeuratObject v4.1.2
1+
# SeuratObject v4.1.3
22

33
## Test environments
4-
* local ubuntu 20.04 install, R 4.1.3
5-
* win-builder (release, devel)
4+
* local ubuntu 20.04 install, R 4.2.0
5+
* win-builder (oldrelease, release, devel)
66

77
## R CMD check results
88

@@ -12,6 +12,6 @@ There were no ERRORs, WARNINGs, or NOTEs
1212

1313
There is one package that depends on SeuratObject: tidyseurat; this update does not impact its functionality
1414

15-
There are four packages that import SeuratObject: CAMML, Platypus, Seurat, and Signac; this update does not impact their functionality
15+
There are six packages that import SeuratObject: bbknnR, CAMML, Platypus, scpoisson, Seurat, and Signac; this update does not impact their functionality
1616

17-
There are two packages that suggest SeuratObject: singleCellHaystack and VAM; this update does not impact their functionality
17+
There are five packages that suggest SeuratObject: cellpypes, scOntoMatch, singleCellHaystack, SPECK, and VAM; this update does not impact their functionality

0 commit comments

Comments
 (0)