From a4104201c88e3a0bedb3a6800c6da009e34629f7 Mon Sep 17 00:00:00 2001 From: AustinHartman Date: Tue, 27 Sep 2022 13:26:26 -0400 Subject: [PATCH 01/15] fix error for Crops() with 0 cells --- DESCRIPTION | 2 +- R/centroids.R | 3 +++ R/fov.R | 10 +++++++++- R/segmentation.R | 4 ++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4f6ae81d..c1a52015 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: SeuratObject Type: Package Title: Data Structures for Single Cell Data -Version: 4.1.2 +Version: 4.1.2.9000 Date: 2022-09-20 Authors@R: c( person(given = 'Rahul', family = 'Satija', email = 'rsatija@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0001-9448-8833')), diff --git a/R/centroids.R b/R/centroids.R index 2a9c6f20..e1938fc6 100644 --- a/R/centroids.R +++ b/R/centroids.R @@ -373,6 +373,9 @@ setMethod( definition = function(x, y, invert = FALSE, ...) { idx <- over(x = x, y = y) idx <- idx[!is.na(x = idx)] + if (length(idx) == 0) { + warning("The selected region does not contain any cell centroids") + } idx <- sort(x = as.integer(x = names(x = idx))) if (isTRUE(x = invert)) { idx <- -idx diff --git a/R/fov.R b/R/fov.R index e07b24a1..6b1ffa42 100644 --- a/R/fov.R +++ b/R/fov.R @@ -1016,9 +1016,17 @@ setValidity( ) break } else { + cells <- Cells(x = object[[s]]) + if (is.null(cells)) { + valid <- c( + valid, + paste(s, "boundary does not contain any cells") + ) + break + } matched.cells <- MatchCells( new = all.cells, - orig = Cells(x = object[[s]]), + orig = cells, ordered = TRUE ) if (length(x = matched.cells) != length(x = Cells(x = object[[s]]))) { diff --git a/R/segmentation.R b/R/segmentation.R index b802ff6a..8768116f 100644 --- a/R/segmentation.R +++ b/R/segmentation.R @@ -304,6 +304,10 @@ setMethod( definition = function(x, y, invert = FALSE, ...) { idx <- over(x = x, y = y) idx <- idx[!is.na(x = idx)] + if (length(idx) == 0) { + warning("The selected region does not contain any cell segmentations") + return(x[NULL]) + } names(x = idx) <- vapply( X = strsplit(x = names(x = idx), split = '\\.'), FUN = '[[', From f0643330c27226d806b2e7879cedff4e794017c5 Mon Sep 17 00:00:00 2001 From: AustinHartman Date: Tue, 27 Sep 2022 14:23:29 -0400 Subject: [PATCH 02/15] faster length() check. update setValidity. return NULL for 0 cell boundaries --- R/centroids.R | 3 ++- R/fov.R | 41 +++++++++++++++++++++-------------------- R/segmentation.R | 4 ++-- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/R/centroids.R b/R/centroids.R index e1938fc6..67ebdd19 100644 --- a/R/centroids.R +++ b/R/centroids.R @@ -373,8 +373,9 @@ setMethod( definition = function(x, y, invert = FALSE, ...) { idx <- over(x = x, y = y) idx <- idx[!is.na(x = idx)] - if (length(idx) == 0) { + if (!length(idx)) { warning("The selected region does not contain any cell centroids") + return(NULL) } idx <- sort(x = as.integer(x = names(x = idx))) if (isTRUE(x = invert)) { diff --git a/R/fov.R b/R/fov.R index 6b1ffa42..b1b0ec0f 100644 --- a/R/fov.R +++ b/R/fov.R @@ -862,7 +862,7 @@ setMethod( if (inherits(x = x[[i]], what = 'Molecules')) { slot(object = x, name = 'molecules')[[i]] <- NULL } else if (i == DefaultBoundary(object = x)) { - stop("Cannot remove default segmentation", call. = FALSE) + stop("Cannot remove default boundary", call. = FALSE) } else { slot(object = x, name = 'boundaries')[[i]] <- NULL } @@ -1017,28 +1017,29 @@ setValidity( break } else { cells <- Cells(x = object[[s]]) - if (is.null(cells)) { - valid <- c( - valid, - paste(s, "boundary does not contain any cells") + if (!is.null(cells)) { + matched.cells <- MatchCells( + new = all.cells, + orig = cells, + ordered = TRUE ) - break - } - matched.cells <- MatchCells( - new = all.cells, - orig = cells, - ordered = TRUE - ) - if (length(x = matched.cells) != length(x = Cells(x = object[[s]]))) { - valid <- c( - valid, - "All segmentation boundaries must have cells" - ) - break - } else if (is.unsorted(x = matched.cells)) { + if (length(x = matched.cells) != length(x = Cells(x = object[[s]]))) { + valid <- c( + valid, + "All segmentation boundaries must have cells" + ) + break + } else if (is.unsorted(x = matched.cells)) { + valid <- c( + valid, + "All segmentation boundaries must be ordered" + ) + break + } + } else { valid <- c( valid, - "All segmentation boundaries must be ordered" + paste(s, "contains 0 cells") ) break } diff --git a/R/segmentation.R b/R/segmentation.R index 8768116f..e2b23f41 100644 --- a/R/segmentation.R +++ b/R/segmentation.R @@ -304,9 +304,9 @@ setMethod( definition = function(x, y, invert = FALSE, ...) { idx <- over(x = x, y = y) idx <- idx[!is.na(x = idx)] - if (length(idx) == 0) { + if (!length(idx)) { warning("The selected region does not contain any cell segmentations") - return(x[NULL]) + return(NULL) } names(x = idx) <- vapply( X = strsplit(x = names(x = idx), split = '\\.'), From e0bd2cd28f1dd89eba27f57353aba2697b45c81c Mon Sep 17 00:00:00 2001 From: AustinHartman Date: Wed, 28 Sep 2022 09:28:13 -0400 Subject: [PATCH 03/15] add missing keys --- DESCRIPTION | 2 +- NEWS.md | 6 ++++++ R/seurat.R | 17 ++++++++++++----- tests/testthat/test_objects.R | 15 +++++++++++++++ 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c1a52015..d2e37ca2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: SeuratObject Type: Package Title: Data Structures for Single Cell Data -Version: 4.1.2.9000 +Version: 4.1.2.9001 Date: 2022-09-20 Authors@R: c( person(given = 'Rahul', family = 'Satija', email = 'rsatija@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0001-9448-8833')), diff --git a/NEWS.md b/NEWS.md index 2638413b..ecab95ac 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# Unreleased +## Change + +## Added +- Add keys to `Assays` and `DimReducs` in `UpdateSeuratObject` when missing + # SeuratObject 4.1.2 ## Changed - Bump required Matrix version to >= 1.5.0 diff --git a/R/seurat.R b/R/seurat.R index a99207b5..a60b309e 100644 --- a/R/seurat.R +++ b/R/seurat.R @@ -562,6 +562,18 @@ UpdateSeuratObject <- function(object) { # Update object slots message("Updating object slots") object <- UpdateSlots(object = object) + # Validate object keys + message("Ensuring keys are in the proper structure") + for (ko in FilterObjects(object = object)) { + key <- Key(object = object[[ko]]) + if (!length(x = key) || !nzchar(x = key)) { + key <- Key(object = ko, quiet = TRUE) + } + slot( + object = slot(object = object, name = FindObject(object, ko))[[ko]], + name = 'key' + ) <- UpdateKey(key) + } # Rename assays assays <- make.names(names = Assays(object = object)) names(x = assays) <- Assays(object = object) @@ -574,11 +586,6 @@ UpdateSeuratObject <- function(object) { object = Command(object = object, command = cmd) ) } - # Validate object keys - message("Ensuring keys are in the proper strucutre") - for (ko in FilterObjects(object = object)) { - Key(object = object[[ko]]) <- UpdateKey(key = Key(object = object[[ko]])) - } # Check feature names message("Ensuring feature names don't have underscores or pipes") for (assay.name in FilterObjects(object = object, classes.keep = 'Assay')) { diff --git a/tests/testthat/test_objects.R b/tests/testthat/test_objects.R index 150f3dbe..f27ef645 100644 --- a/tests/testthat/test_objects.R +++ b/tests/testthat/test_objects.R @@ -341,3 +341,18 @@ test_that("Top works", { expect_equal(length(tpc1.sub[[1]]), 40) expect_equal(length(tpc1.sub[[2]]), 39) }) + +# Tests for UpdateSeuratObject +# ---------------------------------------------------------------------------- +context("UpdateSeuratObject") +pbmc_small_no_key <- pbmc_small +slot(slot(pbmc_small_no_key, "assays")$RNA, "key") <- character(0) +slot(slot(pbmc_small_no_key, "assays")$RNA2, "key") <- character(0) +slot(slot(pbmc_small_no_key, "reductions")$pca, "key") <- character(0) +test_that("Update keys works", { + pbmc_small_no_key <- UpdateSeuratObject(pbmc_small_no_key) + expect_equal(Key(pbmc_small_no_key[["RNA"]]), "RNA_") + expect_equal(Key(pbmc_small_no_key[["RNA2"]]), "RNA2_") + expect_equal(Key(pbmc_small_no_key[["pca"]]), "pca_") + expect_equal(Key(pbmc_small_no_key[["tsne"]]), "tSNE_") +}) From e873a27bedc8b9ab92e1ac0694d2afd28d0c008f Mon Sep 17 00:00:00 2001 From: AustinHartman Date: Thu, 29 Sep 2022 11:40:57 -0400 Subject: [PATCH 04/15] fix segmentation subset method --- DESCRIPTION | 2 +- R/segmentation.R | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index d2e37ca2..cd6e73a2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: SeuratObject Type: Package Title: Data Structures for Single Cell Data -Version: 4.1.2.9001 +Version: 4.1.2.9002 Date: 2022-09-20 Authors@R: c( person(given = 'Rahul', family = 'Satija', email = 'rsatija@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0001-9448-8833')), diff --git a/R/segmentation.R b/R/segmentation.R index e2b23f41..536c6027 100644 --- a/R/segmentation.R +++ b/R/segmentation.R @@ -223,6 +223,8 @@ subset.Segmentation <- function(x, cells = NULL, ...) { if (is.numeric(x = cells)) { cells <- Cells(x = x)[cells] cells <- MatchCells(new = Cells(x = x), orig = cells, ordered = TRUE) + } else { + cells <- intersect(Cells(x), cells) } if (!length(x = cells)) { stop("None of the requested cells found") From cb6960b767211a32e6cc50507c32e44a58cabce3 Mon Sep 17 00:00:00 2001 From: AustinHartman Date: Fri, 30 Sep 2022 15:33:15 -0400 Subject: [PATCH 05/15] pass union of Cells to RenameCells FOV method --- R/centroids.R | 2 +- R/segmentation.R | 2 +- R/seurat.R | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/R/centroids.R b/R/centroids.R index 67ebdd19..39967a8c 100644 --- a/R/centroids.R +++ b/R/centroids.R @@ -211,7 +211,7 @@ RenameCells.Centroids <- function(object, new.names = NULL, ...) { } new.names <- make.unique(names = new.names) if (length(x = new.names) != length(x = Cells(x = object))) { - stop("Cannot partially rename cells", call. = FALSE) + stop("Cannot partially rename centroid cells", call. = FALSE) } slot(object = object, name = 'cells') <- new.names return(object) diff --git a/R/segmentation.R b/R/segmentation.R index 536c6027..ec54b32e 100644 --- a/R/segmentation.R +++ b/R/segmentation.R @@ -174,7 +174,7 @@ RenameCells.Segmentation <- function(object, new.names = NULL, ...) { } new.names <- make.unique(names = new.names) if (length(x = new.names) != length(x = Cells(x = object))) { - stop("Cannot partially rename cells", call. = FALSE) + stop("Cannot partially rename segmentation cells", call. = FALSE) } names(x = slot(object = object, name = 'polygons')) <- new.names p <- progressor(along = slot(object = object, name = 'polygons')) diff --git a/R/seurat.R b/R/seurat.R index a60b309e..eda47fa9 100644 --- a/R/seurat.R +++ b/R/seurat.R @@ -1675,7 +1675,9 @@ RenameCells.Seurat <- function( for (i in Images(object = object)) { object[[i]] <- RenameCells( object = object[[i]], - new.names = unname(obj = new.cell.names[Cells(x = object[[i]])]) + new.names = unname( + obj = new.cell.names[Cells(x = object[[i]], boundary = NA)] + ) ) } # Rename the Neighbor From e4dd5afd5600008cea3bbc8e075464bbbb0a27f5 Mon Sep 17 00:00:00 2001 From: AustinHartman Date: Fri, 30 Sep 2022 15:33:59 -0400 Subject: [PATCH 06/15] bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index cd6e73a2..e3476499 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: SeuratObject Type: Package Title: Data Structures for Single Cell Data -Version: 4.1.2.9002 +Version: 4.1.2.9003 Date: 2022-09-20 Authors@R: c( person(given = 'Rahul', family = 'Satija', email = 'rsatija@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0001-9448-8833')), From 1cc4ef278c976284e8b8b1392512244d6e5e4f08 Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Tue, 25 Oct 2022 11:42:14 -0400 Subject: [PATCH 07/15] Move rgeos to Suggests --- DESCRIPTION | 4 ++-- NAMESPACE | 1 - R/utils.R | 7 ++++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e3476499..8e412add 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,7 +29,7 @@ BugReports: License: MIT + file LICENSE Encoding: UTF-8 LazyData: true -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.1 Depends: R (>= 4.0.0) Imports: @@ -42,13 +42,13 @@ Imports: progressr, Rcpp (>= 1.0.5), sp (>= 1.5.0), - rgeos, rlang (>= 0.4.7), stats, tools, utils Suggests: ggplot2, + rgeos, testthat Collate: 'RcppExports.R' diff --git a/NAMESPACE b/NAMESPACE index 6bd50be8..6cc01e68 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -384,7 +384,6 @@ importFrom(methods,validObject) importFrom(progressr,handlers) importFrom(progressr,progressor) importFrom(progressr,with_progress) -importFrom(rgeos,gSimplify) importFrom(rlang,"%||%") importFrom(rlang,enquo) importFrom(rlang,eval_tidy) diff --git a/R/utils.R b/R/utils.R index 26f69767..4680cde4 100644 --- a/R/utils.R +++ b/R/utils.R @@ -702,13 +702,14 @@ S4ToList.list <- function(object) { return(object) } -#' @importFrom rgeos gSimplify -#' #' @rdname Simplify #' @method Simplify Spatial #' @export #' Simplify.Spatial <- function(coords, tol, topologyPreserve = TRUE) { + if (!PackageCheck('rgeos', error = FALSE)) { + stop("'Simplify' requires rgeos to be installed", call. = FALSE) + } class.orig <- class(x = coords) dest <- ifelse( test = grepl(pattern = '^Spatial', x = class.orig), @@ -719,7 +720,7 @@ Simplify.Spatial <- function(coords, tol, topologyPreserve = TRUE) { value = TRUE )[1L] ) - coords <- gSimplify( + coords <- rgeos::gSimplify( spgeom = as(object = coords, Class = dest), tol = as.numeric(x = tol), topologyPreserve = isTRUE(x = topologyPreserve) From c9ce82e9ea6ab499152ac0f9a8b4485b6471cf6d Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Tue, 25 Oct 2022 11:42:35 -0400 Subject: [PATCH 08/15] devtools::document() updated these --- man/Assay-methods.Rd | 30 ++++++++++++++-------------- man/DimReduc-methods.Rd | 22 ++++++++++----------- man/JackStrawData-methods.Rd | 10 +++++----- man/Neighbor-methods.Rd | 6 +++--- man/Seurat-methods.Rd | 38 ++++++++++++++++++------------------ man/SeuratCommand-methods.Rd | 12 ++++++------ man/SpatialImage-methods.Rd | 30 ++++++++++++++-------------- 7 files changed, 74 insertions(+), 74 deletions(-) diff --git a/man/Assay-methods.Rd b/man/Assay-methods.Rd index 36e712ca..01be0f63 100644 --- a/man/Assay-methods.Rd +++ b/man/Assay-methods.Rd @@ -125,37 +125,37 @@ other packages } \section{Functions}{ \itemize{ -\item \code{[.Assay}: Get expression data from an \code{Assay} +\item \code{[}: Get expression data from an \code{Assay} -\item \code{[[.Assay}: Get feature-level metadata +\item \code{[[}: Get feature-level metadata -\item \code{dim.Assay}: Number of cells and features for an \code{Assay} +\item \code{dim(Assay)}: Number of cells and features for an \code{Assay} -\item \code{dimnames.Assay}: Cell- and feature-names for an \code{Assay} +\item \code{dimnames(Assay)}: Cell- and feature-names for an \code{Assay} -\item \code{head.Assay}: Get the first rows of feature-level metadata +\item \code{head(Assay)}: Get the first rows of feature-level metadata -\item \code{merge.Assay}: Merge \code{Assay} objects +\item \code{merge(Assay)}: Merge \code{Assay} objects -\item \code{subset.Assay}: Subset an \code{Assay} +\item \code{subset(Assay)}: Subset an \code{Assay} -\item \code{tail.Assay}: Get the last rows of feature-level metadata +\item \code{tail(Assay)}: Get the last rows of feature-level metadata -\item \code{[[<-,Assay,ANY,ANY,ANY-method}: Add feature-level metadata +\item \code{`[[`(x = Assay, i = ANY, j = ANY) <- value}: Add feature-level metadata -\item \code{colMeans,Assay-method}: Calculate \code{\link[base]{colMeans}} on an +\item \code{colMeans(Assay)}: Calculate \code{\link[base]{colMeans}} on an \code{Assay} -\item \code{colSums,Assay-method}: Calculate \code{\link[base]{colSums}} on an +\item \code{colSums(Assay)}: Calculate \code{\link[base]{colSums}} on an \code{Assay} -\item \code{rowMeans,Assay-method}: Calculate \code{\link[base]{rowMeans}} on an +\item \code{rowMeans(Assay)}: Calculate \code{\link[base]{rowMeans}} on an \code{Assay} -\item \code{rowSums,Assay-method}: Calculate \code{\link[base]{rowSums}} on an +\item \code{rowSums(Assay)}: Calculate \code{\link[base]{rowSums}} on an \code{Assay} -\item \code{show,Assay-method}: Overview of an \code{Assay} object -}} +\item \code{show(Assay)}: Overview of an \code{Assay} object +}} \concept{assay} diff --git a/man/DimReduc-methods.Rd b/man/DimReduc-methods.Rd index ba5eafb0..2436f50a 100644 --- a/man/DimReduc-methods.Rd +++ b/man/DimReduc-methods.Rd @@ -90,33 +90,33 @@ other packages } \section{Functions}{ \itemize{ -\item \code{[.DimReduc}: Pull feature loadings +\item \code{[}: Pull feature loadings -\item \code{[[.DimReduc}: Pull cell embeddings +\item \code{[[}: Pull cell embeddings -\item \code{dim.DimReduc}: The number of cells and dimensions for a +\item \code{dim(DimReduc)}: The number of cells and dimensions for a \code{DimReduc} -\item \code{dimnames.DimReduc}: The cell and dimension names for a +\item \code{dimnames(DimReduc)}: The cell and dimension names for a \code{DimReduc} object -\item \code{length.DimReduc}: The number of dimensions for a \code{DimReduc} +\item \code{length(DimReduc)}: The number of dimensions for a \code{DimReduc} object -\item \code{merge.DimReduc}: Merge two or more \code{DimReduc} objects +\item \code{merge(DimReduc)}: Merge two or more \code{DimReduc} objects together -\item \code{names.DimReduc}: The dimension names for a \code{DimReduc} object +\item \code{names(DimReduc)}: The dimension names for a \code{DimReduc} object -\item \code{print.DimReduc}: Prints a set of features that most strongly +\item \code{print(DimReduc)}: Prints a set of features that most strongly define a set of components; \strong{note}: requires feature loadings to be present in order to work -\item \code{subset.DimReduc}: Subset a \code{DimReduc} object +\item \code{subset(DimReduc)}: Subset a \code{DimReduc} object -\item \code{show,DimReduc-method}: Show basic summary of a \code{DimReduc} object -}} +\item \code{show(DimReduc)}: Show basic summary of a \code{DimReduc} object +}} \seealso{ \code{\link[base]{cat}} } diff --git a/man/JackStrawData-methods.Rd b/man/JackStrawData-methods.Rd index 03dbf52e..f26c3624 100644 --- a/man/JackStrawData-methods.Rd +++ b/man/JackStrawData-methods.Rd @@ -42,16 +42,16 @@ other packages } \section{Functions}{ \itemize{ -\item \code{.DollarNames.JackStrawData}: Autocompletion for \code{$} access on a +\item \code{.DollarNames(JackStrawData)}: Autocompletion for \code{$} access on a \code{JackStrawData} object -\item \code{$.JackStrawData}: Access data from a \code{JackStrawData} +\item \code{$}: Access data from a \code{JackStrawData} object -\item \code{as.logical.JackStrawData}: Have empirical p-values for a +\item \code{as.logical(JackStrawData)}: Have empirical p-values for a \code{JackStrawData} object been calculated -\item \code{show,JackStrawData-method}: Overview of a \code{JackStrawData} object -}} +\item \code{show(JackStrawData)}: Overview of a \code{JackStrawData} object +}} \concept{jackstraw} diff --git a/man/Neighbor-methods.Rd b/man/Neighbor-methods.Rd index 2659b047..72029ff1 100644 --- a/man/Neighbor-methods.Rd +++ b/man/Neighbor-methods.Rd @@ -25,9 +25,9 @@ other packages } \section{Functions}{ \itemize{ -\item \code{dim.Neighbor}: Dimensions of the neighbor indices +\item \code{dim(Neighbor)}: Dimensions of the neighbor indices -\item \code{show,Neighbor-method}: Overview of a \code{Neighbor} object -}} +\item \code{show(Neighbor)}: Overview of a \code{Neighbor} object +}} \concept{neighbor} diff --git a/man/Seurat-methods.Rd b/man/Seurat-methods.Rd index f65cd632..e18402b8 100644 --- a/man/Seurat-methods.Rd +++ b/man/Seurat-methods.Rd @@ -186,48 +186,48 @@ packages } \section{Functions}{ \itemize{ -\item \code{.DollarNames.Seurat}: Autocompletion for \code{$} access on a +\item \code{.DollarNames(Seurat)}: Autocompletion for \code{$} access on a \code{Seurat} object -\item \code{$.Seurat}: Metadata access for \code{Seurat} objects +\item \code{$}: Metadata access for \code{Seurat} objects -\item \code{$<-.Seurat}: Metadata setter for \code{Seurat} objects +\item \code{`$`(Seurat) <- value}: Metadata setter for \code{Seurat} objects -\item \code{[.Seurat}: Simple subsetter for \code{Seurat} objects +\item \code{[}: Simple subsetter for \code{Seurat} objects -\item \code{[[.Seurat}: Metadata and associated object accessor +\item \code{[[}: Metadata and associated object accessor -\item \code{dim.Seurat}: Number of cells and features for the active assay +\item \code{dim(Seurat)}: Number of cells and features for the active assay -\item \code{dimnames.Seurat}: The cell and feature names for the active assay +\item \code{dimnames(Seurat)}: The cell and feature names for the active assay -\item \code{head.Seurat}: Get the first rows of cell-level metadata +\item \code{head(Seurat)}: Get the first rows of cell-level metadata -\item \code{merge.Seurat}: Merge two or more \code{Seurat} objects together +\item \code{merge(Seurat)}: Merge two or more \code{Seurat} objects together -\item \code{names.Seurat}: Common associated objects +\item \code{names(Seurat)}: Common associated objects -\item \code{subset.Seurat}: Subset a \code{\link{Seurat}} object +\item \code{subset(Seurat)}: Subset a \code{\link{Seurat}} object -\item \code{tail.Seurat}: Get the last rows of cell-level metadata +\item \code{tail(Seurat)}: Get the last rows of cell-level metadata -\item \code{[[<-,Seurat,ANY,ANY,ANY-method}: Add cell-level metadata or associated objects +\item \code{`[[`(x = Seurat, i = ANY, j = ANY) <- value}: Add cell-level metadata or associated objects -\item \code{colMeans,Seurat-method}: Calculate \code{\link[base]{colMeans}} on a +\item \code{colMeans(Seurat)}: Calculate \code{\link[base]{colMeans}} on a \code{Seurat} object -\item \code{colSums,Seurat-method}: Calculate \code{\link[base]{colSums}} on a +\item \code{colSums(Seurat)}: Calculate \code{\link[base]{colSums}} on a \code{Seurat} object -\item \code{rowMeans,Seurat-method}: Calculate \code{\link[base]{rowMeans}} on a +\item \code{rowMeans(Seurat)}: Calculate \code{\link[base]{rowMeans}} on a \code{rowMeans} object -\item \code{rowSums,Seurat-method}: Calculate \code{\link[base]{rowSums}} on a +\item \code{rowSums(Seurat)}: Calculate \code{\link[base]{rowSums}} on a \code{Seurat} object -\item \code{show,Seurat-method}: Overview of a \code{Seurat} object -}} +\item \code{show(Seurat)}: Overview of a \code{Seurat} object +}} \section{Merge Details}{ When merging Seurat objects, the merge procedure will merge the Assay level diff --git a/man/SeuratCommand-methods.Rd b/man/SeuratCommand-methods.Rd index b9f1656d..c5263c38 100644 --- a/man/SeuratCommand-methods.Rd +++ b/man/SeuratCommand-methods.Rd @@ -51,18 +51,18 @@ other packages } \section{Functions}{ \itemize{ -\item \code{.DollarNames.SeuratCommand}: Autocompletion for \code{$} access on a +\item \code{.DollarNames(SeuratCommand)}: Autocompletion for \code{$} access on a \code{SeuratCommand} object -\item \code{$.SeuratCommand}: Access a parameter from a +\item \code{$}: Access a parameter from a \code{SeuratCommand} object -\item \code{[.SeuratCommand}: Access data from a \code{SeuratCommand} +\item \code{[}: Access data from a \code{SeuratCommand} object -\item \code{as.list.SeuratCommand}: Coerce a \code{SeuratCommand} to a list +\item \code{as.list(SeuratCommand)}: Coerce a \code{SeuratCommand} to a list -\item \code{show,SeuratCommand-method}: Overview of a \code{SeuratCommand} object -}} +\item \code{show(SeuratCommand)}: Overview of a \code{SeuratCommand} object +}} \concept{command} diff --git a/man/SpatialImage-methods.Rd b/man/SpatialImage-methods.Rd index c4c0e6c1..58328cc9 100644 --- a/man/SpatialImage-methods.Rd +++ b/man/SpatialImage-methods.Rd @@ -109,47 +109,47 @@ should only be overridden if necessary } \section{Functions}{ \itemize{ -\item \code{Cells.SpatialImage}: Get the cell names from an image +\item \code{Cells(SpatialImage)}: Get the cell names from an image (\strong{[Override]}) -\item \code{DefaultAssay.SpatialImage}: Get the associated assay of a +\item \code{DefaultAssay(SpatialImage)}: Get the associated assay of a \code{SpatialImage}-derived object -\item \code{DefaultAssay<-.SpatialImage}: Set the associated assay of a +\item \code{DefaultAssay(SpatialImage) <- value}: Set the associated assay of a \code{SpatialImage}-derived object -\item \code{GetImage.SpatialImage}: Get the image data from a +\item \code{GetImage(SpatialImage)}: Get the image data from a \code{SpatialImage}-derived object -\item \code{GetTissueCoordinates.SpatialImage}: Get tissue coordinates for a +\item \code{GetTissueCoordinates(SpatialImage)}: Get tissue coordinates for a \code{SpatialImage}-derived object (\strong{[Override]}) -\item \code{IsGlobal.SpatialImage}: Globality test for +\item \code{IsGlobal(SpatialImage)}: Globality test for \code{SpatialImage}-derived object -\item \code{Key.SpatialImage}: Get the key for a +\item \code{Key(SpatialImage)}: Get the key for a \code{SpatialImage}-derived object -\item \code{Key<-.SpatialImage}: Set the key for a +\item \code{Key(SpatialImage) <- value}: Set the key for a \code{SpatialImage}-derived object -\item \code{Radius.SpatialImage}: Get the spot radius size +\item \code{Radius(SpatialImage)}: Get the spot radius size -\item \code{RenameCells.SpatialImage}: Rename cells in a +\item \code{RenameCells(SpatialImage)}: Rename cells in a \code{SpatialImage}-derived object (\strong{[Override]}) -\item \code{[.SpatialImage}: Subset a \code{SpatialImage}-derived object +\item \code{[}: Subset a \code{SpatialImage}-derived object -\item \code{dim.SpatialImage}: Get the plotting dimensions of an image +\item \code{dim(SpatialImage)}: Get the plotting dimensions of an image (\strong{[Override]}) -\item \code{subset.SpatialImage}: Subset a \code{SpatialImage}-derived object +\item \code{subset(SpatialImage)}: Subset a \code{SpatialImage}-derived object (\strong{[Override]}) -\item \code{show,SpatialImage-method}: Overview of a \code{SpatialImage}-derived +\item \code{show(SpatialImage)}: Overview of a \code{SpatialImage}-derived object -}} +}} \section{Provided methods}{ These methods are defined on the \code{SpatialImage} object and should not From b9f3c4b022a8fae882998b1d03f6cf392b5134f9 Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Tue, 25 Oct 2022 11:43:47 -0400 Subject: [PATCH 09/15] Bump develop version Update changelog --- DESCRIPTION | 4 ++-- NEWS.md | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8e412add..edf1a11c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: SeuratObject Type: Package Title: Data Structures for Single Cell Data -Version: 4.1.2.9003 -Date: 2022-09-20 +Version: 4.1.2.9004 +Date: 2022-10-25 Authors@R: c( person(given = 'Rahul', family = 'Satija', email = 'rsatija@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0001-9448-8833')), person(given = 'Andrew', family = 'Butler', email = 'abutler@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0003-3608-0463')), diff --git a/NEWS.md b/NEWS.md index ecab95ac..f9176417 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # Unreleased -## Change +## Changes +- Move {rgeos} to Suggests; segmentation simplification now requires {regos} to be installed manually ## Added - Add keys to `Assays` and `DimReducs` in `UpdateSeuratObject` when missing From 03c9df03ab00dfd9f4be6fccc7a226e803cfa81c Mon Sep 17 00:00:00 2001 From: timoast <4591688+timoast@users.noreply.github.com> Date: Fri, 4 Nov 2022 14:13:30 -0400 Subject: [PATCH 10/15] Coerce to numeric if character matrix --- DESCRIPTION | 4 ++-- R/utils.R | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index edf1a11c..26802d52 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: SeuratObject Type: Package Title: Data Structures for Single Cell Data -Version: 4.1.2.9004 -Date: 2022-10-25 +Version: 4.1.2.9005 +Date: 2022-11-04 Authors@R: c( person(given = 'Rahul', family = 'Satija', email = 'rsatija@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0001-9448-8833')), person(given = 'Andrew', family = 'Butler', email = 'abutler@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0003-3608-0463')), diff --git a/R/utils.R b/R/utils.R index 4680cde4..8f31ecb5 100644 --- a/R/utils.R +++ b/R/utils.R @@ -598,6 +598,11 @@ as.sparse.Matrix <- function(x, ...) { #' @method as.sparse matrix #' as.sparse.matrix <- function(x, ...) { + if (is.character(x = x)) { + dnames <- dimnames(x = x) + x <- matrix(data = as.numeric(x = x), ncol = length(x = dnames[[2]])) + dimnames(x = x) <- dnames + } x <- as(object = x, Class = "Matrix") return(as.sparse.Matrix(x, ...)) } From cd2a8511112e67492b62b33eb07383dfe79341e8 Mon Sep 17 00:00:00 2001 From: timoast <4591688+timoast@users.noreply.github.com> Date: Fri, 4 Nov 2022 14:16:34 -0400 Subject: [PATCH 11/15] Use ncol in case dimnames is null --- R/utils.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index 8f31ecb5..4b960bca 100644 --- a/R/utils.R +++ b/R/utils.R @@ -600,7 +600,8 @@ as.sparse.Matrix <- function(x, ...) { as.sparse.matrix <- function(x, ...) { if (is.character(x = x)) { dnames <- dimnames(x = x) - x <- matrix(data = as.numeric(x = x), ncol = length(x = dnames[[2]])) + nc <- ncol(x = x) + x <- matrix(data = as.numeric(x = x), ncol = nc) dimnames(x = x) <- dnames } x <- as(object = x, Class = "Matrix") From d1bfd31b2f804314af71fd7f931d3c1ad367a115 Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Mon, 7 Nov 2022 10:51:10 -0500 Subject: [PATCH 12/15] Update version --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 26802d52..2b80b546 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: SeuratObject Type: Package Title: Data Structures for Single Cell Data -Version: 4.1.2.9005 -Date: 2022-11-04 +Version: 4.1.3 +Date: 2022-11-07 Authors@R: c( person(given = 'Rahul', family = 'Satija', email = 'rsatija@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0001-9448-8833')), person(given = 'Andrew', family = 'Butler', email = 'abutler@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0003-3608-0463')), From dcd1e5fabc790d47b994662a61feaff596216506 Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Mon, 7 Nov 2022 13:13:19 -0500 Subject: [PATCH 13/15] Move sp to Depends --- DESCRIPTION | 4 ++-- R/zzz.R | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2b80b546..17ca464a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,7 +31,8 @@ Encoding: UTF-8 LazyData: true RoxygenNote: 7.2.1 Depends: - R (>= 4.0.0) + R (>= 4.0.0), + sp (>= 1.5.0) Imports: future, future.apply, @@ -41,7 +42,6 @@ Imports: methods, progressr, Rcpp (>= 1.0.5), - sp (>= 1.5.0), rlang (>= 0.4.7), stats, tools, diff --git a/R/zzz.R b/R/zzz.R index 62fdd710..35b9cefc 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -460,11 +460,6 @@ NameIndex <- function(x, names, MARGIN) { # Hooks #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -.onAttach <- function(libname, pkgname) { - AttachDeps(deps = 'sp') - return(invisible(x = NULL)) -} - .onLoad <- function(libname, pkgname) { toset <- setdiff(x = names(x = Seurat.options), y = names(x = options())) if (length(x = toset)) { From 7c264bbf67739bd0ccb04d5518215f5129ab1ec0 Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Mon, 7 Nov 2022 13:13:31 -0500 Subject: [PATCH 14/15] Update changelog --- NEWS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index f9176417..5213ac12 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ -# Unreleased +# SeuratObject 4.1.3 ## Changes - Move {rgeos} to Suggests; segmentation simplification now requires {regos} to be installed manually +- Move {sp} to Depends ## Added - Add keys to `Assays` and `DimReducs` in `UpdateSeuratObject` when missing From a11e140fad17abfa63a2be65d319be083c0111ed Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Mon, 7 Nov 2022 13:15:20 -0500 Subject: [PATCH 15/15] Update CRAN comments --- cran-comments.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index bff93c50..b594028b 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,8 +1,8 @@ -# SeuratObject v4.1.2 +# SeuratObject v4.1.3 ## Test environments -* local ubuntu 20.04 install, R 4.1.3 -* win-builder (release, devel) +* local ubuntu 20.04 install, R 4.2.0 +* win-builder (oldrelease, release, devel) ## R CMD check results @@ -12,6 +12,6 @@ There were no ERRORs, WARNINGs, or NOTEs There is one package that depends on SeuratObject: tidyseurat; this update does not impact its functionality -There are four packages that import SeuratObject: CAMML, Platypus, Seurat, and Signac; this update does not impact their functionality +There are six packages that import SeuratObject: bbknnR, CAMML, Platypus, scpoisson, Seurat, and Signac; this update does not impact their functionality -There are two packages that suggest SeuratObject: singleCellHaystack and VAM; this update does not impact their functionality +There are five packages that suggest SeuratObject: cellpypes, scOntoMatch, singleCellHaystack, SPECK, and VAM; this update does not impact their functionality