From 47cdb22f7ce80142a1e47e6ef08b01d52a0642f3 Mon Sep 17 00:00:00 2001 From: yuhanH Date: Fri, 30 Apr 2021 17:02:36 -0400 Subject: [PATCH 01/37] check reference.reduction in FindTransferAnchors --- R/integration.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/R/integration.R b/R/integration.R index 18ff8bd8b..715fa1d6d 100644 --- a/R/integration.R +++ b/R/integration.R @@ -762,6 +762,7 @@ FindTransferAnchors <- function( projected <- ifelse(test = reduction == "pcaproject", yes = TRUE, no = FALSE) reduction.2 <- character() feature.mean <- NULL + reference.reduction.init <- reference.reduction if (normalization.method == "SCT") { # ensure all residuals required are computed query <- suppressWarnings(expr = GetResidual(object = query, assay = query.assay, features = features, verbose = FALSE)) @@ -1131,6 +1132,7 @@ FindTransferAnchors <- function( } slot(object = combined.ob, name = "reductions") <- reductions command <- LogSeuratCommand(object = combined.ob, return.command = TRUE) + slot(command, name = 'params')$reference.reduction <- reference.reduction.init anchor.set <- new( Class = "TransferAnchorSet", object.list = list(combined.ob), @@ -1894,9 +1896,15 @@ MapQuery <- function( projectumap.args = list(), verbose = TRUE ) { + # determine anchor type if (grepl(pattern = "pca", x = slot(object = anchorset, name = "command")$reduction)) { anchor.reduction <- "pcaproject" + # check if the anchorset can be used for mapping + if (is.null(slot(object = anchorset, name = "command")$reference.reduction)) { + stop('reference.reduction is not set in FindTransferAnchors, ', + 'so this anchor object cannot be used in MapQuery function') + } } else if (grepl(pattern = "cca", x = slot(object = anchorset, name = "command")$reduction)) { anchor.reduction <- "cca" ref.cca.embedding <- Embeddings( @@ -1933,6 +1941,7 @@ MapQuery <- function( stop("unkown type of anchors") } + reference.reduction <- reference.reduction %||% slot(object = anchorset, name = "command")$reference.reduction %||% anchor.reduction From 0091105c287d4d1a7001f5ce9241fc6ce9e86c2e Mon Sep 17 00:00:00 2001 From: bbimber Date: Mon, 24 May 2021 21:15:32 -0700 Subject: [PATCH 02/37] Bugfix to as.SingleCellExperiment --- R/objects.R | 10 ++++++---- tests/testthat/test_objects.R | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/R/objects.R b/R/objects.R index cd5d8fe40..9a9a90c8f 100644 --- a/R/objects.R +++ b/R/objects.R @@ -1190,9 +1190,11 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) { metadata$ident <- Idents(object = x) SummarizedExperiment::colData(x = sce) <- S4Vectors::DataFrame(metadata) for (assayn in assay){ - sce <- SingleCellExperiment::swapAltExp(x = sce, name = assayn, saved = orig.exp.name) - SummarizedExperiment::rowData(x = sce) <- S4Vectors::DataFrame(x[[assayn]][[]]) - sce <- SingleCellExperiment::swapAltExp(x = sce, name = orig.exp.name, saved = assayn) + if (assayn != orig.exp.name) { + sce <- SingleCellExperiment::swapAltExp(x = sce, name = assayn, saved = orig.exp.name) + SummarizedExperiment::rowData(x = sce) <- S4Vectors::DataFrame(x[[assayn]][[]]) + sce <- SingleCellExperiment::swapAltExp(x = sce, name = orig.exp.name, saved = assayn) + } } for (dr in FilterObjects(object = x, classes.keep = "DimReduc")) { assay.used <- DefaultAssay(object = x[[dr]]) @@ -1202,7 +1204,7 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) { sce <- SingleCellExperiment::swapAltExp(x = sce, name = orig.exp.name, saved = assay.used) } } - sce <- SingleCellExperiment::swapAltExp(x = sce, name = orig.exp.name, saved = NULL) + return(sce) } diff --git a/tests/testthat/test_objects.R b/tests/testthat/test_objects.R index dde05e7f2..4b75702ec 100644 --- a/tests/testthat/test_objects.R +++ b/tests/testthat/test_objects.R @@ -341,3 +341,25 @@ test_that("Top works", { expect_equal(length(tpc1.sub[[1]]), 40) expect_equal(length(tpc1.sub[[2]]), 39) }) + +test_that("as.SingleCellExperiment works", { + mat <- matrix(1:100, ncol = 10) + colnames(mat) <- LETTERS[1:10] + rownames(mat) <- LETTERS[1:10] + seuratObj <- Seurat::CreateSeuratObject(mat) + sce <- as.SingleCellExperiment(seuratObj) + + expect_equal(ncol(sce), 10) + expect_equal(nrow(sce), 10) + expect_equal(length(SingleCellExperiment::altExps(sce)), 0) + expect_equal(SingleCellExperiment::mainExpName(sce), 'RNA') + + seuratObj <- Seurat::CreateSeuratObject(mat) + seuratObj[['ADT']] <- CreateAssayObject(mat) + sce <- as.SingleCellExperiment(seuratObj) + expect_equal(ncol(sce), 10) + expect_equal(nrow(sce), 10) + expect_equal(names(SingleCellExperiment::altExps(sce)), 'ADT') + expect_equal(SingleCellExperiment::mainExpName(sce), 'RNA') + +}) \ No newline at end of file From 85d5ea0de4e570859c087529000a8d04e8e05a10 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 26 May 2021 13:45:47 -0400 Subject: [PATCH 03/37] add CIPR to wrappers table --- vignettes/vignettes.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vignettes/vignettes.yaml b/vignettes/vignettes.yaml index 10d96e8bc..c85f04e8a 100644 --- a/vignettes/vignettes.yaml +++ b/vignettes/vignettes.yaml @@ -210,3 +210,9 @@ citation: La Manno et al, Nature 2018 source: https://velocyto.org + - name: CIPR + title: Using CIPR with human PBMC data + link: http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/cipr.html + reference: https://doi.org/10.1186/s12859-020-3538-2 + citation: Ekiz et. al., BMC Bioinformatics 2020 + source: https://github.com/atakanekiz/CIPR-Package From 78c2c94dbd9fdb7e3facbacee7f34900d8f20ff1 Mon Sep 17 00:00:00 2001 From: Andrew Butler Date: Thu, 27 May 2021 15:34:29 -0400 Subject: [PATCH 04/37] explicitly specify reference.reduction --- vignettes/integration_mapping.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/integration_mapping.Rmd b/vignettes/integration_mapping.Rmd index f28e3cdee..71f5769cd 100644 --- a/vignettes/integration_mapping.Rmd +++ b/vignettes/integration_mapping.Rmd @@ -126,7 +126,7 @@ After finding anchors, we use the `TransferData()` function to classify the quer ```{r label.transfer, warning = FALSE, message = FALSE} pancreas.query <- pancreas.list[["fluidigmc1"]] -pancreas.anchors <- FindTransferAnchors(reference = pancreas.integrated, query = pancreas.query, dims = 1:30) +pancreas.anchors <- FindTransferAnchors(reference = pancreas.integrated, query = pancreas.query, dims = 1:30, reference.reduction = "pca") predictions <- TransferData(anchorset = pancreas.anchors, refdata = pancreas.integrated$celltype, dims = 1:30) pancreas.query <- AddMetaData(pancreas.query, metadata = predictions) ``` From c93899ae544122f3e7a6692020e20d5b80d5cd6b Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 27 May 2021 17:59:00 -0400 Subject: [PATCH 05/37] minor style changes, update NEWS, bump version --- DESCRIPTION | 4 ++-- NEWS.md | 4 ++++ R/integration.R | 9 +++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3ae038404..8fa8f9914 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Seurat -Version: 4.0.2 -Date: 2021-05-20 +Version: 4.0.2.9001 +Date: 2021-05-27 Title: Tools for Single Cell Genomics Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) , Macosko E, Basu A, Satija R, et al (2015) , Stuart T, Butler A, et al (2019) , and Hao, Hao, et al (2020) for more details. Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 40d3c3910..792955446 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# Seurat develop +## Changes +- Ensure proper reference.reduction is used in `MapQuery()` + # Seurat 4.0.2 (2020-03-20) ## Added - New `AddAzimuthScores()` and `AddAzimuthResults()` functions diff --git a/R/integration.R b/R/integration.R index 85f00b808..a59da0f2d 100644 --- a/R/integration.R +++ b/R/integration.R @@ -1909,9 +1909,10 @@ MapQuery <- function( if (grepl(pattern = "pca", x = slot(object = anchorset, name = "command")$reduction)) { anchor.reduction <- "pcaproject" # check if the anchorset can be used for mapping - if (is.null(slot(object = anchorset, name = "command")$reference.reduction)) { - stop('reference.reduction is not set in FindTransferAnchors, ', - 'so this anchor object cannot be used in MapQuery function') + if (is.null(x = slot(object = anchorset, name = "command")$reference.reduction)) { + stop('The reference.reduction parameter was not set when running ', + 'FindTransferAnchors, so the resulting AnchorSet object cannot be used ', + 'in the MapQuery function.') } } else if (grepl(pattern = "cca", x = slot(object = anchorset, name = "command")$reduction)) { anchor.reduction <- "cca" @@ -1949,7 +1950,7 @@ MapQuery <- function( stop("unkown type of anchors") } - + reference.reduction <- reference.reduction %||% slot(object = anchorset, name = "command")$reference.reduction %||% anchor.reduction From 3a80651d6568ea124cabd4ce2bbbb1074b5a6d70 Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Fri, 28 May 2021 12:51:45 -0400 Subject: [PATCH 06/37] Minor style fixes --- R/objects.R | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/R/objects.R b/R/objects.R index 9a9a90c8f..ae8aae081 100644 --- a/R/objects.R +++ b/R/objects.R @@ -1173,7 +1173,7 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) { stop("One or more of the assays you are trying to convert is not in the Seurat object") } experiments <- list() - for (assayn in assay){ + for (assayn in assay) { assays = list( counts = GetAssayData(object = x, assay = assayn, slot = "counts"), logcounts = GetAssayData(object = x, assay = assayn, slot = "data")) @@ -1185,26 +1185,45 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) { sce <- as(object = experiments[[1]], Class = "SingleCellExperiment") sce <- SingleCellExperiment::SingleCellExperiment(sce, altExps = experiments) orig.exp.name <- names(x = experiments[1]) - sce <- SingleCellExperiment::swapAltExp(x = sce, name = orig.exp.name, saved = NULL) + sce <- SingleCellExperiment::swapAltExp( + x = sce, + name = orig.exp.name, + saved = NULL + ) metadata <- x[[]] metadata$ident <- Idents(object = x) SummarizedExperiment::colData(x = sce) <- S4Vectors::DataFrame(metadata) - for (assayn in assay){ + for (assayn in assay) { if (assayn != orig.exp.name) { - sce <- SingleCellExperiment::swapAltExp(x = sce, name = assayn, saved = orig.exp.name) + sce <- SingleCellExperiment::swapAltExp( + x = sce, + name = assayn, + saved = orig.exp.name + ) SummarizedExperiment::rowData(x = sce) <- S4Vectors::DataFrame(x[[assayn]][[]]) - sce <- SingleCellExperiment::swapAltExp(x = sce, name = orig.exp.name, saved = assayn) + sce <- SingleCellExperiment::swapAltExp( + x = sce, + name = orig.exp.name, + saved = assayn + ) } } for (dr in FilterObjects(object = x, classes.keep = "DimReduc")) { assay.used <- DefaultAssay(object = x[[dr]]) if (assay.used %in% SingleCellExperiment::altExpNames(x = sce)) { - sce <- SingleCellExperiment::swapAltExp(x = sce, name = assay.used, saved = orig.exp.name) - SingleCellExperiment::reducedDim(x = sce, toupper(x = dr)) <- Embeddings(object = x[[dr]]) - sce <- SingleCellExperiment::swapAltExp(x = sce, name = orig.exp.name, saved = assay.used) + sce <- SingleCellExperiment::swapAltExp( + x = sce, + name = assay.used, + saved = orig.exp.name + ) + SingleCellExperiment::reducedDim(x = sce, type = toupper(x = dr)) <- Embeddings(object = x[[dr]]) + sce <- SingleCellExperiment::swapAltExp( + x = sce, + name = orig.exp.name, + saved = assay.used + ) } } - return(sce) } From b152aed6071a51a00f6b32792db6a1e9c394252e Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Fri, 28 May 2021 12:56:34 -0400 Subject: [PATCH 07/37] Skip SCE tests on CRAN Check if SingleCellExperiment is installed before checking Kill tests that require Bioc 3.13/R 4.1 --- tests/testthat/test_objects.R | 45 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/tests/testthat/test_objects.R b/tests/testthat/test_objects.R index 4b75702ec..ed6961b14 100644 --- a/tests/testthat/test_objects.R +++ b/tests/testthat/test_objects.R @@ -342,24 +342,29 @@ test_that("Top works", { expect_equal(length(tpc1.sub[[2]]), 39) }) + +# Tests for SCE conversion +# ------------------------------------------------------------------------------ test_that("as.SingleCellExperiment works", { - mat <- matrix(1:100, ncol = 10) - colnames(mat) <- LETTERS[1:10] - rownames(mat) <- LETTERS[1:10] - seuratObj <- Seurat::CreateSeuratObject(mat) - sce <- as.SingleCellExperiment(seuratObj) - - expect_equal(ncol(sce), 10) - expect_equal(nrow(sce), 10) - expect_equal(length(SingleCellExperiment::altExps(sce)), 0) - expect_equal(SingleCellExperiment::mainExpName(sce), 'RNA') - - seuratObj <- Seurat::CreateSeuratObject(mat) - seuratObj[['ADT']] <- CreateAssayObject(mat) - sce <- as.SingleCellExperiment(seuratObj) - expect_equal(ncol(sce), 10) - expect_equal(nrow(sce), 10) - expect_equal(names(SingleCellExperiment::altExps(sce)), 'ADT') - expect_equal(SingleCellExperiment::mainExpName(sce), 'RNA') - -}) \ No newline at end of file + skip_on_cran() + if (requireNamespace('SingleCellExperiment', quietly = TRUE)) { + mat <- matrix(1:100, ncol = 10) + colnames(mat) <- LETTERS[1:10] + rownames(mat) <- LETTERS[1:10] + seuratObj <- Seurat::CreateSeuratObject(mat) + sce <- as.SingleCellExperiment(seuratObj) + + expect_equal(ncol(sce), 10) + expect_equal(nrow(sce), 10) + # expect_equal(length(SingleCellExperiment::altExps(sce)), 0) + # expect_equal(SingleCellExperiment::mainExpName(sce), 'RNA') + + seuratObj <- Seurat::CreateSeuratObject(mat) + seuratObj[['ADT']] <- CreateAssayObject(mat) + sce <- as.SingleCellExperiment(seuratObj) + expect_equal(ncol(sce), 10) + expect_equal(nrow(sce), 10) + # expect_equal(names(SingleCellExperiment::altExps(sce)), 'ADT') + # expect_equal(SingleCellExperiment::mainExpName(sce), 'RNA') + } +}) From 410f9688958e5517e9bef9f266ab7c76c6621767 Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Fri, 28 May 2021 13:14:38 -0400 Subject: [PATCH 08/37] Bump develop version Update changelog --- DESCRIPTION | 4 ++-- NEWS.md | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3ae038404..3ee39d044 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Seurat -Version: 4.0.2 -Date: 2021-05-20 +Version: 4.0.2.9001 +Date: 2021-05-28 Title: Tools for Single Cell Genomics Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) , Macosko E, Basu A, Satija R, et al (2015) , Stuart T, Butler A, et al (2019) , and Hao, Hao, et al (2020) for more details. Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 40d3c3910..1c53787f4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +## Seurat develop + +## Added + +## Changes +- Fix issues with `as.SingleCellExperiment.Seurat` for the latest verion of SingleCellExperiment ([#4532](https://github.com/satijalab/seurat/pull/4532)) + # Seurat 4.0.2 (2020-03-20) ## Added - New `AddAzimuthScores()` and `AddAzimuthResults()` functions From 2d7beb56feeb6c002d74124429c77e14331a9711 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 28 May 2021 14:59:06 -0400 Subject: [PATCH 09/37] fix assay metadata setting error --- R/objects.R | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/R/objects.R b/R/objects.R index cd5d8fe40..7fb4f47bf 100644 --- a/R/objects.R +++ b/R/objects.R @@ -1106,15 +1106,17 @@ as.Seurat.SingleCellExperiment <- function( DefaultAssay(object = object) <- assay # add feature level meta data md <- SingleCellExperiment::rowData(x = x) - # replace underscores - rownames(x = md) <- gsub(pattern = "_", replacement = "-", x = rownames(x = md)) - md <- as.data.frame(x = md) - # ensure order same as data - md <- md[rownames(x = object[[assay]]), ] - object[[assay]] <- AddMetaData( - object = object[[assay]], - metadata = md - ) + if (ncol(x = md) > 0) { + # replace underscores + rownames(x = md) <- gsub(pattern = "_", replacement = "-", x = rownames(x = md)) + md <- as.data.frame(x = md) + # ensure order same as data + md <- md[rownames(x = object[[assay]]), ] + object[[assay]] <- AddMetaData( + object = object[[assay]], + metadata = md + ) + } Idents(object = object) <- project # Get DimReduc information, add underscores if needed and pull from different alt EXP if (length(x = SingleCellExperiment::reducedDimNames(x = x)) > 0) { From 892096ffae1ce83ab3caa68d1e1445339937f3e8 Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Fri, 28 May 2021 15:25:34 -0400 Subject: [PATCH 10/37] UpdateSymbolList no longer searches aliases Currently, UpdateSymbolList will sometimes provide alternate names rather than simply updating old names This patch exposes the search types in GeneSymbolThesarus to the user and forces the search perfomed by UpdateSymbolList to only be updates --- R/utilities.R | 28 +++++++++++++++++++++------- man/Seurat-package.Rd | 2 +- man/UpdateSymbolList.Rd | 25 +++++++++++++++++++------ 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/R/utilities.R b/R/utilities.R index 85509c821..cde0e94b7 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -796,14 +796,25 @@ FastRowScale <- function( #' @note This function requires internet access #' #' @param symbols A vector of gene symbols -#' @param timeout Time to wait before cancelling query in seconds -#' @param several.ok Allow several current gene sybmols for each provided symbol +#' @param timeout Time to wait before canceling query in seconds +#' @param several.ok Allow several current gene symbols for each +#' provided symbol +#' @param search.types Type of query to perform: +#' \describe{ +#' \itemize{\dQuote{\code{alias_symbol}}}{Find alternate symbols for the genes +#' described by \code{symbols}} +#' \itemize{\dQuote{\code{prev_symbol}}}{Find new new symbols for the genes +#' described by \code{symbols}} +#' } +#' This parameter accepts multiple options and short-hand options +#' (eg. \dQuote{\code{prev}} for \dQuote{\code{prev_symbol}}) #' @param verbose Show a progress bar depicting search progress #' @param ... Extra parameters passed to \code{\link[httr]{GET}} #' -#' @return For \code{GeneSymbolThesarus}, if \code{several.ok}, a named list -#' where each entry is the current symbol found for each symbol provided and the -#' names are the provided symbols. Otherwise, a named vector with the same information. +#' @return \code{GeneSymbolThesarus}:, if \code{several.ok}, a named list +#' where each entry is the current symbol found for each symbol provided and +#' the names are the provided symbols. Otherwise, a named vector with the +#' same information. #' #' @source \url{https://www.genenames.org/} \url{https://www.genenames.org/help/rest/} #' @@ -827,11 +838,13 @@ GeneSymbolThesarus <- function( symbols, timeout = 10, several.ok = FALSE, + search.types = c('alias_symbol', 'prev_symbol'), verbose = TRUE, ... ) { db.url <- 'http://rest.genenames.org/fetch' - search.types <- c('alias_symbol', 'prev_symbol') + # search.types <- c('alias_symbol', 'prev_symbol') + search.types <- match.arg(arg = search.types, several.ok = TRUE) synonyms <- vector(mode = 'list', length = length(x = symbols)) not.found <- vector(mode = 'logical', length = length(x = symbols)) multiple.found <- vector(mode = 'logical', length = length(x = symbols)) @@ -1472,7 +1485,7 @@ RegroupIdents <- function(object, metadata) { #' @rdname UpdateSymbolList #' -#' @return For \code{UpdateSymbolList}, \code{symbols} with updated symbols from +#' @return \code{UpdateSymbolList}: \code{symbols} with updated symbols from #' HGNC's gene names database #' #' @export @@ -1494,6 +1507,7 @@ UpdateSymbolList <- function( symbols = symbols, timeout = timeout, several.ok = several.ok, + search.types = 'prev_symbol', verbose = verbose, ... )) diff --git a/man/Seurat-package.Rd b/man/Seurat-package.Rd index 952b03798..9b3fc3749 100644 --- a/man/Seurat-package.Rd +++ b/man/Seurat-package.Rd @@ -43,7 +43,7 @@ Useful links: } \author{ -\strong{Maintainer}: Paul Hoffman \email{nygcSatijalab@nygenome.org} (\href{https://orcid.org/0000-0002-7693-8957}{ORCID}) +\strong{Maintainer}: Paul Hoffman \email{seurat@nygenome.org} (\href{https://orcid.org/0000-0002-7693-8957}{ORCID}) Other contributors: \itemize{ diff --git a/man/UpdateSymbolList.Rd b/man/UpdateSymbolList.Rd index 9bf5e6ab8..ca5f3cdae 100644 --- a/man/UpdateSymbolList.Rd +++ b/man/UpdateSymbolList.Rd @@ -12,6 +12,7 @@ GeneSymbolThesarus( symbols, timeout = 10, several.ok = FALSE, + search.types = c("alias_symbol", "prev_symbol"), verbose = TRUE, ... ) @@ -27,20 +28,32 @@ UpdateSymbolList( \arguments{ \item{symbols}{A vector of gene symbols} -\item{timeout}{Time to wait before cancelling query in seconds} +\item{timeout}{Time to wait before canceling query in seconds} -\item{several.ok}{Allow several current gene sybmols for each provided symbol} +\item{several.ok}{Allow several current gene symbols for each +provided symbol} + +\item{search.types}{Type of query to perform: +\describe{ + \itemize{\dQuote{\code{alias_symbol}}}{Find alternate symbols for the genes + described by \code{symbols}} + \itemize{\dQuote{\code{prev_symbol}}}{Find new new symbols for the genes + described by \code{symbols}} +} +This parameter accepts multiple options and short-hand options +(eg. \dQuote{\code{prev}} for \dQuote{\code{prev_symbol}})} \item{verbose}{Show a progress bar depicting search progress} \item{...}{Extra parameters passed to \code{\link[httr]{GET}}} } \value{ -For \code{GeneSymbolThesarus}, if \code{several.ok}, a named list -where each entry is the current symbol found for each symbol provided and the -names are the provided symbols. Otherwise, a named vector with the same information. +\code{GeneSymbolThesarus}:, if \code{several.ok}, a named list +where each entry is the current symbol found for each symbol provided and +the names are the provided symbols. Otherwise, a named vector with the +same information. -For \code{UpdateSymbolList}, \code{symbols} with updated symbols from +\code{UpdateSymbolList}: \code{symbols} with updated symbols from HGNC's gene names database } \description{ From 799001908780db2980f7fff1d028e7ad90fea888 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 28 May 2021 15:46:58 -0400 Subject: [PATCH 11/37] transfer scale.data slot to assay in SCE conversion --- R/objects.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/objects.R b/R/objects.R index ae8aae081..d4e59f8da 100644 --- a/R/objects.R +++ b/R/objects.R @@ -1176,7 +1176,8 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) { for (assayn in assay) { assays = list( counts = GetAssayData(object = x, assay = assayn, slot = "counts"), - logcounts = GetAssayData(object = x, assay = assayn, slot = "data")) + logcounts = GetAssayData(object = x, assay = assayn, slot = "data"), + scaledata = GetAssayData(object = x, assay = assayn, slot = "scale.data")) assays <- assays[sapply(X = assays, FUN = nrow) != 0] sume <- SummarizedExperiment::SummarizedExperiment(assays = assays) experiments[[assayn]] <- sume From 7b817c0e32cca1739f8dad5066a884e4db78aeb2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 28 May 2021 17:21:16 -0400 Subject: [PATCH 12/37] enable alpha parameter for SpatialDimPlot --- R/visualization.R | 38 +++++++++++++++++++++++++++++--------- man/ISpatialDimPlot.Rd | 3 ++- man/ISpatialFeaturePlot.Rd | 3 ++- man/LinkedPlots.Rd | 3 ++- man/Seurat-package.Rd | 2 +- man/SpatialPlot.Rd | 3 ++- 6 files changed, 38 insertions(+), 14 deletions(-) diff --git a/R/visualization.R b/R/visualization.R index 7e363c0b6..a0be66a9e 100644 --- a/R/visualization.R +++ b/R/visualization.R @@ -2937,7 +2937,8 @@ ISpatialFeaturePlot <- function( #' themeing will not work when plotting multiple features/groupings #' @param pt.size.factor Scale the size of the spots. #' @param alpha Controls opacity of spots. Provide as a vector specifying the -#' min and max +#' min and max for SpatialFeaturePlot. For SpatialDimPlot, provide a single +#' alpha value for each plot. #' @param stroke Control the width of the border around the spots #' @param interactive Launch an interactive SpatialDimPlot or SpatialFeaturePlot #' session, see \code{\link{ISpatialDimPlot}} or @@ -3177,6 +3178,11 @@ SpatialPlot <- function( } else { NULL }, + pt.alpha = if (!is.null(x = group.by)) { + alpha[j] + } else { + NULL + }, geom = if (inherits(x = image.use, what = "STARmap")) { 'poly' } else { @@ -7510,6 +7516,7 @@ SingleSpatialPlot <- function( image, cols = NULL, image.alpha = 1, + pt.alpha = NULL, crop = TRUE, pt.size.factor = NULL, stroke = 0.25, @@ -7550,14 +7557,27 @@ SingleSpatialPlot <- function( plot <- switch( EXPR = geom, 'spatial' = { - plot + geom_spatial( - point.size.factor = pt.size.factor, - data = data, - image = image, - image.alpha = image.alpha, - crop = crop, - stroke = stroke - ) + coord_fixed() + theme(aspect.ratio = 1) + if (is.null(x = pt.alpha)) { + plot <- plot + geom_spatial( + point.size.factor = pt.size.factor, + data = data, + image = image, + image.alpha = image.alpha, + crop = crop, + stroke = stroke, + ) + } else { + plot <- plot + geom_spatial( + point.size.factor = pt.size.factor, + data = data, + image = image, + image.alpha = image.alpha, + crop = crop, + stroke = stroke, + alpha = pt.alpha + ) + } + plot + coord_fixed() + theme(aspect.ratio = 1) }, 'interactive' = { plot + geom_spatial_interactive( diff --git a/man/ISpatialDimPlot.Rd b/man/ISpatialDimPlot.Rd index 9f4f65b90..a19d06119 100644 --- a/man/ISpatialDimPlot.Rd +++ b/man/ISpatialDimPlot.Rd @@ -15,7 +15,8 @@ ISpatialDimPlot(object, image = NULL, group.by = NULL, alpha = c(0.3, 1)) (for example, orig.ident); pass 'ident' to group by identity class} \item{alpha}{Controls opacity of spots. Provide as a vector specifying the -min and max} +min and max for SpatialFeaturePlot. For SpatialDimPlot, provide a single +alpha value for each plot.} } \value{ Returns final plot as a ggplot object diff --git a/man/ISpatialFeaturePlot.Rd b/man/ISpatialFeaturePlot.Rd index 3e4c022c1..48528668a 100644 --- a/man/ISpatialFeaturePlot.Rd +++ b/man/ISpatialFeaturePlot.Rd @@ -22,7 +22,8 @@ ISpatialFeaturePlot( \item{slot}{Which slot to pull expression data from?} \item{alpha}{Controls opacity of spots. Provide as a vector specifying the -min and max} +min and max for SpatialFeaturePlot. For SpatialDimPlot, provide a single +alpha value for each plot.} } \value{ Returns final plot as a ggplot object diff --git a/man/LinkedPlots.Rd b/man/LinkedPlots.Rd index ff3bd2aa0..103241f9f 100644 --- a/man/LinkedPlots.Rd +++ b/man/LinkedPlots.Rd @@ -42,7 +42,8 @@ LinkedFeaturePlot( (for example, orig.ident); pass 'ident' to group by identity class} \item{alpha}{Controls opacity of spots. Provide as a vector specifying the -min and max} +min and max for SpatialFeaturePlot. For SpatialDimPlot, provide a single +alpha value for each plot.} \item{combine}{Combine plots into a single \code{\link[patchwork]{patchwork}ed} ggplot object. If \code{FALSE}, return a list of ggplot objects} diff --git a/man/Seurat-package.Rd b/man/Seurat-package.Rd index 952b03798..9b3fc3749 100644 --- a/man/Seurat-package.Rd +++ b/man/Seurat-package.Rd @@ -43,7 +43,7 @@ Useful links: } \author{ -\strong{Maintainer}: Paul Hoffman \email{nygcSatijalab@nygenome.org} (\href{https://orcid.org/0000-0002-7693-8957}{ORCID}) +\strong{Maintainer}: Paul Hoffman \email{seurat@nygenome.org} (\href{https://orcid.org/0000-0002-7693-8957}{ORCID}) Other contributors: \itemize{ diff --git a/man/SpatialPlot.Rd b/man/SpatialPlot.Rd index d131cd820..b54822859 100644 --- a/man/SpatialPlot.Rd +++ b/man/SpatialPlot.Rd @@ -136,7 +136,8 @@ themeing will not work when plotting multiple features/groupings} \item{pt.size.factor}{Scale the size of the spots.} \item{alpha}{Controls opacity of spots. Provide as a vector specifying the -min and max} +min and max for SpatialFeaturePlot. For SpatialDimPlot, provide a single +alpha value for each plot.} \item{stroke}{Control the width of the border around the spots} From b7ad561683a60251df83f2ecfecd65c8338a62bf Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 28 May 2021 17:24:13 -0400 Subject: [PATCH 13/37] add doc entry --- R/visualization.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/visualization.R b/R/visualization.R index a0be66a9e..45140e70f 100644 --- a/R/visualization.R +++ b/R/visualization.R @@ -7490,6 +7490,7 @@ SingleRasterMap <- function( # By default, ggplot2 assigns colors # @param image.alpha Adjust the opacity of the background images. Set to 0 to # remove. +# @param pt.alpha Adjust the opacity of the points if plotting a SpatialDimPlot # @param crop Crop the plot in to focus on points plotted. Set to FALSE to show # entire background image. # @param pt.size.factor Sets the size of the points relative to spot.radius From 2287748d6422da9111266d9fc3c1af63f2773ca6 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 30 May 2021 21:20:53 -0400 Subject: [PATCH 14/37] fix DimReduc conversion --- R/objects.R | 4 +++- vignettes/conversion_vignette.Rmd | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/R/objects.R b/R/objects.R index 6185d3b29..58fb0ecc1 100644 --- a/R/objects.R +++ b/R/objects.R @@ -1218,7 +1218,9 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) { name = assay.used, saved = orig.exp.name ) - SingleCellExperiment::reducedDim(x = sce, type = toupper(x = dr)) <- Embeddings(object = x[[dr]]) + } + SingleCellExperiment::reducedDim(x = sce, type = toupper(x = dr)) <- Embeddings(object = x[[dr]]) + if (assay.used %in% SingleCellExperiment::altExpNames(x = sce)) { sce <- SingleCellExperiment::swapAltExp( x = sce, name = orig.exp.name, diff --git a/vignettes/conversion_vignette.Rmd b/vignettes/conversion_vignette.Rmd index 399a13d99..c8a54cd65 100644 --- a/vignettes/conversion_vignette.Rmd +++ b/vignettes/conversion_vignette.Rmd @@ -41,6 +41,7 @@ library(Seurat) # install SeuratDisk from GitHub using the remotes package # remotes::install_github(repo = 'mojaveazure/seurat-disk', ref = 'develop') library(SeuratDisk) +library(SeuratData) library(patchwork) ``` @@ -49,9 +50,9 @@ library(patchwork) [`SingleCellExperiment`](https://bioconductor.org/packages/release/bioc/html/SingleCellExperiment.html) is a class for storing single-cell experiment data, created by Davide Risso, Aaron Lun, and Keegan Korthauer, and is used by many Bioconductor analysis packages. Here we demonstrate converting the Seurat object produced in our 3k PBMC tutorial to SingleCellExperiment for use with Davis McCarthy's [scater](https://bioconductor.org/packages/release/bioc/html/scater.html) package. ```{r seurat_singlecell} -# download from satija lab -# https://www.dropbox.com/s/kwd3kcxkmpzqg6w/pbmc3k_final.rds?dl=0 -pbmc <- readRDS(file = '../data/pbmc3k_final.rds') +# Use PBMC3K from SeuratData +InstallData(pbmc3k) +pbmc <- LoadData(ds = "pbmc3k", type = "pbmc3k.final") pbmc.sce <- as.SingleCellExperiment(pbmc) p1 <- plotExpression(pbmc.sce, features = 'MS4A1', x = 'ident') + theme(axis.text.x = element_text(angle = 45, hjust = 1)) p2 <- plotPCA(pbmc.sce, colour_by = 'ident') From 129920b007af800d2309704d9c64806159e574c5 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 31 May 2021 00:39:10 -0400 Subject: [PATCH 15/37] fix seuratdata --- vignettes/conversion_vignette.Rmd | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vignettes/conversion_vignette.Rmd b/vignettes/conversion_vignette.Rmd index c8a54cd65..820f34d7a 100644 --- a/vignettes/conversion_vignette.Rmd +++ b/vignettes/conversion_vignette.Rmd @@ -41,7 +41,6 @@ library(Seurat) # install SeuratDisk from GitHub using the remotes package # remotes::install_github(repo = 'mojaveazure/seurat-disk', ref = 'develop') library(SeuratDisk) -library(SeuratData) library(patchwork) ``` @@ -49,9 +48,13 @@ library(patchwork) [`SingleCellExperiment`](https://bioconductor.org/packages/release/bioc/html/SingleCellExperiment.html) is a class for storing single-cell experiment data, created by Davide Risso, Aaron Lun, and Keegan Korthauer, and is used by many Bioconductor analysis packages. Here we demonstrate converting the Seurat object produced in our 3k PBMC tutorial to SingleCellExperiment for use with Davis McCarthy's [scater](https://bioconductor.org/packages/release/bioc/html/scater.html) package. -```{r seurat_singlecell} +```{r data} # Use PBMC3K from SeuratData +library(SeuratData) InstallData(pbmc3k) +``` + +```{r seurat_singlecell} pbmc <- LoadData(ds = "pbmc3k", type = "pbmc3k.final") pbmc.sce <- as.SingleCellExperiment(pbmc) p1 <- plotExpression(pbmc.sce, features = 'MS4A1', x = 'ident') + theme(axis.text.x = element_text(angle = 45, hjust = 1)) From e1abe0817f59c1862be3af616e6a19acc848e873 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 31 May 2021 09:07:16 -0400 Subject: [PATCH 16/37] another seuratdata fix --- vignettes/conversion_vignette.Rmd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vignettes/conversion_vignette.Rmd b/vignettes/conversion_vignette.Rmd index 820f34d7a..8810cdb32 100644 --- a/vignettes/conversion_vignette.Rmd +++ b/vignettes/conversion_vignette.Rmd @@ -31,6 +31,9 @@ knitr::opts_chunk$set( ) ``` +```{r, include = FALSE, cache=FALSE} +options(SeuratData.repo.use = "http://satijalab04.nygenome.org") +``` In this vignette, we demonstrate the ability to convert between Seurat objects, SingleCellExperiment objects, and anndata objects. ```{r packages} @@ -41,6 +44,7 @@ library(Seurat) # install SeuratDisk from GitHub using the remotes package # remotes::install_github(repo = 'mojaveazure/seurat-disk', ref = 'develop') library(SeuratDisk) +library(SeuratData) library(patchwork) ``` @@ -48,13 +52,9 @@ library(patchwork) [`SingleCellExperiment`](https://bioconductor.org/packages/release/bioc/html/SingleCellExperiment.html) is a class for storing single-cell experiment data, created by Davide Risso, Aaron Lun, and Keegan Korthauer, and is used by many Bioconductor analysis packages. Here we demonstrate converting the Seurat object produced in our 3k PBMC tutorial to SingleCellExperiment for use with Davis McCarthy's [scater](https://bioconductor.org/packages/release/bioc/html/scater.html) package. -```{r data} +```{r seurat_singlecell} # Use PBMC3K from SeuratData -library(SeuratData) InstallData(pbmc3k) -``` - -```{r seurat_singlecell} pbmc <- LoadData(ds = "pbmc3k", type = "pbmc3k.final") pbmc.sce <- as.SingleCellExperiment(pbmc) p1 <- plotExpression(pbmc.sce, features = 'MS4A1', x = 'ident') + theme(axis.text.x = element_text(angle = 45, hjust = 1)) From 75417fe322dfcc92e192ff1e939719e2d544ade2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 31 May 2021 11:20:26 -0400 Subject: [PATCH 17/37] forgot quotes --- vignettes/conversion_vignette.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/conversion_vignette.Rmd b/vignettes/conversion_vignette.Rmd index 8810cdb32..ac4917b27 100644 --- a/vignettes/conversion_vignette.Rmd +++ b/vignettes/conversion_vignette.Rmd @@ -54,7 +54,7 @@ library(patchwork) ```{r seurat_singlecell} # Use PBMC3K from SeuratData -InstallData(pbmc3k) +InstallData("pbmc3k") pbmc <- LoadData(ds = "pbmc3k", type = "pbmc3k.final") pbmc.sce <- as.SingleCellExperiment(pbmc) p1 <- plotExpression(pbmc.sce, features = 'MS4A1', x = 'ident') + theme(axis.text.x = element_text(angle = 45, hjust = 1)) From 8d45e29bf8f0c3f372df52e7116db00847967c5f Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 31 May 2021 23:48:55 -0400 Subject: [PATCH 18/37] altExp fix --- R/objects.R | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/R/objects.R b/R/objects.R index 58fb0ecc1..87d907c39 100644 --- a/R/objects.R +++ b/R/objects.R @@ -1176,22 +1176,24 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) { } experiments <- list() for (assayn in assay) { - assays = list( - counts = GetAssayData(object = x, assay = assayn, slot = "counts"), - logcounts = GetAssayData(object = x, assay = assayn, slot = "data")) + assays = list( + counts = GetAssayData(object = x, assay = assayn, slot = "counts"), + logcounts = GetAssayData(object = x, assay = assayn, slot = "data")) assays <- assays[sapply(X = assays, FUN = nrow) != 0] sume <- SummarizedExperiment::SummarizedExperiment(assays = assays) experiments[[assayn]] <- sume } # create one single cell experiment sce <- as(object = experiments[[1]], Class = "SingleCellExperiment") - sce <- SingleCellExperiment::SingleCellExperiment(sce, altExps = experiments) orig.exp.name <- names(x = experiments[1]) - sce <- SingleCellExperiment::swapAltExp( - x = sce, - name = orig.exp.name, - saved = NULL - ) + if (length(x = experiments) > 1) { + sce <- SingleCellExperiment::SingleCellExperiment(sce, altExps = experiments[2:length(x = experiments)]) + sce <- SingleCellExperiment::swapAltExp( + x = sce, + name = orig.exp.name, + saved = NULL + ) + } metadata <- x[[]] metadata$ident <- Idents(object = x) SummarizedExperiment::colData(x = sce) <- S4Vectors::DataFrame(metadata) From 66cbaee094af937d431ee712538b5dba097b57a9 Mon Sep 17 00:00:00 2001 From: Andrew Butler Date: Tue, 1 Jun 2021 09:22:31 -0400 Subject: [PATCH 19/37] fix multiassay in both versions --- R/objects.R | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/R/objects.R b/R/objects.R index 87d907c39..032296991 100644 --- a/R/objects.R +++ b/R/objects.R @@ -1186,14 +1186,12 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) { # create one single cell experiment sce <- as(object = experiments[[1]], Class = "SingleCellExperiment") orig.exp.name <- names(x = experiments[1]) - if (length(x = experiments) > 1) { - sce <- SingleCellExperiment::SingleCellExperiment(sce, altExps = experiments[2:length(x = experiments)]) - sce <- SingleCellExperiment::swapAltExp( - x = sce, - name = orig.exp.name, - saved = NULL - ) - } + sce <- SingleCellExperiment::SingleCellExperiment(sce, altExps = experiments) + sce <- SingleCellExperiment::swapAltExp( + x = sce, + name = orig.exp.name, + saved = NULL + ) metadata <- x[[]] metadata$ident <- Idents(object = x) SummarizedExperiment::colData(x = sce) <- S4Vectors::DataFrame(metadata) @@ -1214,7 +1212,7 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) { } for (dr in FilterObjects(object = x, classes.keep = "DimReduc")) { assay.used <- DefaultAssay(object = x[[dr]]) - if (assay.used %in% SingleCellExperiment::altExpNames(x = sce)) { + if (assay.used %in% SingleCellExperiment::altExpNames(x = sce) & assay.used != orig.exp.name) { sce <- SingleCellExperiment::swapAltExp( x = sce, name = assay.used, @@ -1222,7 +1220,7 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) { ) } SingleCellExperiment::reducedDim(x = sce, type = toupper(x = dr)) <- Embeddings(object = x[[dr]]) - if (assay.used %in% SingleCellExperiment::altExpNames(x = sce)) { + if (assay.used %in% SingleCellExperiment::altExpNames(x = sce) & assay.used != orig.exp.name) { sce <- SingleCellExperiment::swapAltExp( x = sce, name = orig.exp.name, From a5cb5ed526440428ed58f53e5e7d1f780f8be122 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 1 Jun 2021 17:33:46 -0400 Subject: [PATCH 20/37] bump version --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index beb4bc973..c8868a348 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Seurat -Version: 4.0.2.9002 -Date: 2021-05-28 +Version: 4.0.2.9003 +Date: 2021-06-01 Title: Tools for Single Cell Genomics Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) , Macosko E, Basu A, Satija R, et al (2015) , Stuart T, Butler A, et al (2019) , and Hao, Hao, et al (2020) for more details. Authors@R: c( From 5991ca000f9dacc8315d4ec72f9000b7d21eb1ab Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 2 Jun 2021 12:52:23 -0400 Subject: [PATCH 21/37] bump version, update NEWS --- DESCRIPTION | 4 ++-- NEWS.md | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c8868a348..44c98a0b6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Seurat -Version: 4.0.2.9003 -Date: 2021-06-01 +Version: 4.0.2.9004 +Date: 2021-06-02 Title: Tools for Single Cell Genomics Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) , Macosko E, Basu A, Satija R, et al (2015) , Stuart T, Butler A, et al (2019) , and Hao, Hao, et al (2020) for more details. Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 38738b54b..1b10eea8e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ ## Changes - Fix issues with `as.SingleCellExperiment.Seurat` for the latest verion of SingleCellExperiment ([#4532](https://github.com/satijalab/seurat/pull/4532)) - Ensure proper reference.reduction is used in `MapQuery()` +- Fix to `UpdateSymbolList()`, no longer searches aliases and exposes the `search.types` parameter in `GeneSymbolThesarus()` ([#4545](https://github.com/satijalab/seurat/issues/4545)) # Seurat 4.0.2 (2020-03-20) ## Added From 7a996cfde5ae7383503142f4f10ebf0167a0a79d Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 2 Jun 2021 16:01:25 -0400 Subject: [PATCH 22/37] bump version, update NEWS --- DESCRIPTION | 2 +- NEWS.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 44c98a0b6..83fb11ee1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: Seurat -Version: 4.0.2.9004 +Version: 4.0.2.9005 Date: 2021-06-02 Title: Tools for Single Cell Genomics Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) , Macosko E, Basu A, Satija R, et al (2015) , Stuart T, Butler A, et al (2019) , and Hao, Hao, et al (2020) for more details. diff --git a/NEWS.md b/NEWS.md index 1b10eea8e..d35edeb73 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,7 @@ - Fix issues with `as.SingleCellExperiment.Seurat` for the latest verion of SingleCellExperiment ([#4532](https://github.com/satijalab/seurat/pull/4532)) - Ensure proper reference.reduction is used in `MapQuery()` - Fix to `UpdateSymbolList()`, no longer searches aliases and exposes the `search.types` parameter in `GeneSymbolThesarus()` ([#4545](https://github.com/satijalab/seurat/issues/4545)) +- Transfer `scale.data` slot as well when converting with `as.SingleCellExperiment.Seurat()` # Seurat 4.0.2 (2020-03-20) ## Added From 29a6331f90676b380d41a5bff15c256af5826c11 Mon Sep 17 00:00:00 2001 From: Jaison Jain Date: Fri, 4 Jun 2021 11:49:06 -0400 Subject: [PATCH 23/37] add jitter option to FeatureScatter + related fxns --- R/visualization.R | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/R/visualization.R b/R/visualization.R index 7e363c0b6..fdcc49e05 100644 --- a/R/visualization.R +++ b/R/visualization.R @@ -1871,6 +1871,7 @@ CellScatter <- function( #' @param raster Convert points to raster format, default is \code{NULL} #' which will automatically use raster if the number of points plotted is greater than #' 100,000 +#' @param jitter Jitter for easier visualization of crowded points #' #' @return A ggplot object #' @@ -1902,7 +1903,8 @@ FeatureScatter <- function( combine = TRUE, slot = 'data', plot.cor = TRUE, - raster = NULL + raster = NULL, + jitter = TRUE ) { cells <- cells %||% colnames(x = object) if (isTRUE(x = shuffle)) { @@ -1943,7 +1945,8 @@ FeatureScatter <- function( legend.title = 'Identity', span = span, plot.cor = plot.cor, - raster = raster + raster = raster, + jitter = jitter ) } ) @@ -6844,6 +6847,7 @@ globalVariables(names = '..density..', package = 'Seurat') # @param raster Convert points to raster format, default is \code{NULL} # which will automatically use raster if the number of points plotted is greater than # 100,000 +# @param jitter Jitter for easier visualization of crowded points # # @param ... Extra parameters to MASS::kde2d # @@ -6866,7 +6870,8 @@ SingleCorPlot <- function( na.value = 'grey50', span = NULL, raster = NULL, - plot.cor = TRUE + plot.cor = TRUE, + jitter = TRUE ) { pt.size <- pt.size %||% AutoPointSize(data = data, raster = raster) if ((nrow(x = data) > 1e5) & !isFALSE(raster)){ @@ -6958,25 +6963,31 @@ SingleCorPlot <- function( scale_fill_continuous(low = 'white', high = 'dodgerblue4') + guides(fill = FALSE) } + position <- NULL + if (jitter) { + position <- 'jitter' + } else { + position <- 'identity' + } if (!is.null(x = col.by)) { if (raster) { plot <- plot + geom_scattermore( mapping = aes_string(color = 'colors'), - position = 'jitter', + position = position, pointsize = pt.size ) } else { plot <- plot + geom_point( mapping = aes_string(color = 'colors'), - position = 'jitter', + position = position, size = pt.size ) } } else { if (raster) { - plot <- plot + geom_scattermore(position = 'jitter', pointsize = pt.size) + plot <- plot + geom_scattermore(position = position, pointsize = pt.size) } else { - plot <- plot + geom_point(position = 'jitter', size = pt.size) + plot <- plot + geom_point(position = position, size = pt.size) } } if (!is.null(x = cols)) { From aa189123b4cb2af6d6a068423cd648324eae317d Mon Sep 17 00:00:00 2001 From: Jaison Jain Date: Fri, 4 Jun 2021 11:49:27 -0400 Subject: [PATCH 24/37] docs --- man/FeatureScatter.Rd | 5 ++++- man/as.sparse.Rd | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/man/FeatureScatter.Rd b/man/FeatureScatter.Rd index ef6ac6eb9..c3181f38e 100644 --- a/man/FeatureScatter.Rd +++ b/man/FeatureScatter.Rd @@ -21,7 +21,8 @@ FeatureScatter( combine = TRUE, slot = "data", plot.cor = TRUE, - raster = NULL + raster = NULL, + jitter = TRUE ) } \arguments{ @@ -61,6 +62,8 @@ useful for crowded plots if points of interest are being buried. (default is FAL \item{raster}{Convert points to raster format, default is \code{NULL} which will automatically use raster if the number of points plotted is greater than 100,000} + +\item{jitter}{Jitter for easier visualization of crowded points} } \value{ A ggplot object diff --git a/man/as.sparse.Rd b/man/as.sparse.Rd index 1872e4fe8..b0cdaae48 100644 --- a/man/as.sparse.Rd +++ b/man/as.sparse.Rd @@ -20,8 +20,8 @@ \item{...}{Arguments passed to other methods} -\item{row.names}{\code{NULL} or a character vector giving the row names for -the data; missing values are not allowed} +\item{row.names}{\code{NULL} or a character vector giving the row + names for the data frame. Missing values are not allowed.} \item{optional}{logical. If \code{TRUE}, setting row names and converting column names (to syntactic names: see From 250675782d09acae12e0ecd282a1f7eb4f91f69a Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 4 Jun 2021 17:53:35 -0400 Subject: [PATCH 25/37] fix sce conversion when reducedDim is missing names --- R/objects.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/objects.R b/R/objects.R index 901e1e428..73e9434ac 100644 --- a/R/objects.R +++ b/R/objects.R @@ -1068,7 +1068,7 @@ as.Seurat.SingleCellExperiment <- function( # if cell names are NULL, fill with cell_X if (is.null(x = colnames(x = mats[[m]]))) { warning( - "The column names of the", + "The column names of the ", names(x = mats)[m], " matrix is NULL. Setting cell names to cell_columnidx (e.g 'cell_1').", call. = FALSE, @@ -1121,15 +1121,15 @@ as.Seurat.SingleCellExperiment <- function( # Get DimReduc information, add underscores if needed and pull from different alt EXP if (length(x = SingleCellExperiment::reducedDimNames(x = x)) > 0) { for (dr in SingleCellExperiment::reducedDimNames(x = x)) { - embeddings <- SingleCellExperiment::reducedDim(x = x, type = dr) + embeddings <- as.matrix(x = SingleCellExperiment::reducedDim(x = x, type = dr)) if (is.null(x = rownames(x = embeddings))) { rownames(x = embeddings) <- cell.names } - if(!grepl('_$', + if (isTRUE(x = !grepl('_$', gsub(pattern = "[[:digit:]]", replacement = "_", x = colnames(x = SingleCellExperiment::reducedDim(x = x, type = dr))[1] - ))){ + )))) { key <- gsub( pattern = "[[:digit:]]", replacement = "_", From 53cc0560b5f7feeabc9a7d30852ac063fe26d3bc Mon Sep 17 00:00:00 2001 From: Andrew Butler Date: Mon, 7 Jun 2021 09:38:09 -0400 Subject: [PATCH 26/37] bump verion, update NEWS --- DESCRIPTION | 4 ++-- NEWS.md | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 83fb11ee1..5b3601d66 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Seurat -Version: 4.0.2.9005 -Date: 2021-06-02 +Version: 4.0.2.9006 +Date: 2021-06-07 Title: Tools for Single Cell Genomics Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) , Macosko E, Basu A, Satija R, et al (2015) , Stuart T, Butler A, et al (2019) , and Hao, Hao, et al (2020) for more details. Authors@R: c( diff --git a/NEWS.md b/NEWS.md index d35edeb73..60946dd45 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,7 @@ - Ensure proper reference.reduction is used in `MapQuery()` - Fix to `UpdateSymbolList()`, no longer searches aliases and exposes the `search.types` parameter in `GeneSymbolThesarus()` ([#4545](https://github.com/satijalab/seurat/issues/4545)) - Transfer `scale.data` slot as well when converting with `as.SingleCellExperiment.Seurat()` +- Enable `alpha` parameter for `SpatialDimPlot()` # Seurat 4.0.2 (2020-03-20) ## Added From 8debeb19e3e8eebe80df99d76e808d57a3c4470c Mon Sep 17 00:00:00 2001 From: Andrew Butler Date: Mon, 7 Jun 2021 11:07:16 -0400 Subject: [PATCH 27/37] fix colname dropping issue in feature metadata --- R/objects.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/objects.R b/R/objects.R index 73e9434ac..6538ca1b6 100644 --- a/R/objects.R +++ b/R/objects.R @@ -1111,7 +1111,7 @@ as.Seurat.SingleCellExperiment <- function( rownames(x = md) <- gsub(pattern = "_", replacement = "-", x = rownames(x = md)) md <- as.data.frame(x = md) # ensure order same as data - md <- md[rownames(x = object[[assay]]), ] + md <- md[rownames(x = object[[assay]]), , drop = FALSE] object[[assay]] <- AddMetaData( object = object[[assay]], metadata = md From 8482f75ee42eb8e73347890eb20f349a0288e5f1 Mon Sep 17 00:00:00 2001 From: Andrew Butler Date: Mon, 7 Jun 2021 14:51:00 -0400 Subject: [PATCH 28/37] fix altExp convert --- R/objects.R | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/R/objects.R b/R/objects.R index 6538ca1b6..4658060b1 100644 --- a/R/objects.R +++ b/R/objects.R @@ -1187,12 +1187,14 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) { # create one single cell experiment sce <- as(object = experiments[[1]], Class = "SingleCellExperiment") orig.exp.name <- names(x = experiments[1]) - sce <- SingleCellExperiment::SingleCellExperiment(sce, altExps = experiments) - sce <- SingleCellExperiment::swapAltExp( - x = sce, - name = orig.exp.name, - saved = NULL - ) + if (length(x = experiments) > 1) { + sce <- SingleCellExperiment::SingleCellExperiment(sce, altExps = experiments) + sce <- SingleCellExperiment::swapAltExp( + x = sce, + name = orig.exp.name, + saved = NULL + ) + } metadata <- x[[]] metadata$ident <- Idents(object = x) SummarizedExperiment::colData(x = sce) <- S4Vectors::DataFrame(metadata) From ec94c098fab627b92c321ebb5208f522a277f78f Mon Sep 17 00:00:00 2001 From: Andrew Butler Date: Mon, 7 Jun 2021 17:05:08 -0400 Subject: [PATCH 29/37] make roundtrip names consistent when possible --- R/objects.R | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/R/objects.R b/R/objects.R index 4658060b1..8ecf4f8a2 100644 --- a/R/objects.R +++ b/R/objects.R @@ -1039,17 +1039,22 @@ as.Seurat.SingleCellExperiment <- function( ) } meta.data <- as.data.frame(x = SummarizedExperiment::colData(x = x)) + if (packageVersion(pkg = "SingleCellExperiment") >= "1.14.0") { + orig.exp <- SingleCellExperiment::mainExpName(x = x) %||% "originalexp" + } else { + orig.exp <- "originalexp" + } if (!is.null(SingleCellExperiment::altExpNames(x = x))) { assayn <- assay %||% SingleCellExperiment::altExpNames(x = x) if (!all(assay %in% SingleCellExperiment::altExpNames(x = x))) { stop("One or more of the assays you are trying to convert is not in the SingleCellExperiment object") } - assayn <- c("originalexp", assayn) + assayn <- c(orig.exp, assayn) } else { - assayn <- "originalexp" + assayn <- orig.exp } for (assay in assayn) { - if (assay != "originalexp") { + if (assay != orig.exp) { x <- SingleCellExperiment::swapAltExp(x = x, name = assay, saved = NULL) } # Pull matrices @@ -1187,6 +1192,9 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) { # create one single cell experiment sce <- as(object = experiments[[1]], Class = "SingleCellExperiment") orig.exp.name <- names(x = experiments[1]) + if (packageVersion(pkg = "SingleCellExperiment") >= "1.14.0") { + SingleCellExperiment::mainExpName(sce) <- names(x = experiments[1]) + } if (length(x = experiments) > 1) { sce <- SingleCellExperiment::SingleCellExperiment(sce, altExps = experiments) sce <- SingleCellExperiment::swapAltExp( From 0ca51307e3a7fafe7483abcaf56c607ee0ebe65f Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 7 Jun 2021 19:39:19 -0400 Subject: [PATCH 30/37] update NEWS, bump version --- DESCRIPTION | 2 +- NEWS.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5b3601d66..e5de8805a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: Seurat -Version: 4.0.2.9006 +Version: 4.0.2.9007 Date: 2021-06-07 Title: Tools for Single Cell Genomics Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) , Macosko E, Basu A, Satija R, et al (2015) , Stuart T, Butler A, et al (2019) , and Hao, Hao, et al (2020) for more details. diff --git a/NEWS.md b/NEWS.md index 60946dd45..32bb79dc0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,11 +3,12 @@ ## Added ## Changes -- Fix issues with `as.SingleCellExperiment.Seurat` for the latest verion of SingleCellExperiment ([#4532](https://github.com/satijalab/seurat/pull/4532)) +- Fix issues with `as.SingleCellExperiment.Seurat()` for the latest verion of SingleCellExperiment ([#4532](https://github.com/satijalab/seurat/pull/4532)) - Ensure proper reference.reduction is used in `MapQuery()` - Fix to `UpdateSymbolList()`, no longer searches aliases and exposes the `search.types` parameter in `GeneSymbolThesarus()` ([#4545](https://github.com/satijalab/seurat/issues/4545)) - Transfer `scale.data` slot as well when converting with `as.SingleCellExperiment.Seurat()` - Enable `alpha` parameter for `SpatialDimPlot()` +- Fix `as.SingleCellExperiment.Seurat()` conversion for atypical `reducedDim` components # Seurat 4.0.2 (2020-03-20) ## Added From 04ba209c3be9005a08a7d7b332c6704775227f8f Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 8 Jun 2021 09:41:31 -0400 Subject: [PATCH 31/37] bump version, update NEWS --- DESCRIPTION | 4 ++-- NEWS.md | 1 + man/as.sparse.Rd | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e5de8805a..af3deb1d6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Seurat -Version: 4.0.2.9007 -Date: 2021-06-07 +Version: 4.0.2.9008 +Date: 2021-06-08 Title: Tools for Single Cell Genomics Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) , Macosko E, Basu A, Satija R, et al (2015) , Stuart T, Butler A, et al (2019) , and Hao, Hao, et al (2020) for more details. Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 32bb79dc0..fb1b44a4f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ ## Seurat develop ## Added +- Add `jitter` parameter to `FeatureScatter()` ## Changes - Fix issues with `as.SingleCellExperiment.Seurat()` for the latest verion of SingleCellExperiment ([#4532](https://github.com/satijalab/seurat/pull/4532)) diff --git a/man/as.sparse.Rd b/man/as.sparse.Rd index b0cdaae48..1872e4fe8 100644 --- a/man/as.sparse.Rd +++ b/man/as.sparse.Rd @@ -20,8 +20,8 @@ \item{...}{Arguments passed to other methods} -\item{row.names}{\code{NULL} or a character vector giving the row - names for the data frame. Missing values are not allowed.} +\item{row.names}{\code{NULL} or a character vector giving the row names for +the data; missing values are not allowed} \item{optional}{logical. If \code{TRUE}, setting row names and converting column names (to syntactic names: see From 57217d8bf1506583b78f71834499d61140d6abff Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 8 Jun 2021 09:55:50 -0400 Subject: [PATCH 32/37] release prep --- DESCRIPTION | 2 +- NEWS.md | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index af3deb1d6..8b730070c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: Seurat -Version: 4.0.2.9008 +Version: 4.0.3 Date: 2021-06-08 Title: Tools for Single Cell Genomics Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) , Macosko E, Basu A, Satija R, et al (2015) , Stuart T, Butler A, et al (2019) , and Hao, Hao, et al (2020) for more details. diff --git a/NEWS.md b/NEWS.md index fb1b44a4f..edad1dde2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,4 @@ -## Seurat develop - +## Seurat 4.0.3 (2020-06-08) ## Added - Add `jitter` parameter to `FeatureScatter()` @@ -11,7 +10,7 @@ - Enable `alpha` parameter for `SpatialDimPlot()` - Fix `as.SingleCellExperiment.Seurat()` conversion for atypical `reducedDim` components -# Seurat 4.0.2 (2020-03-20) +# Seurat 4.0.2 (2020-05-20) ## Added - New `AddAzimuthScores()` and `AddAzimuthResults()` functions - Add `shuffle` parameter to `FeatureScatter()` ([#4280](https://github.com/satijalab/seurat/pull/4280)) From c3a258313c34d7c102c8da6255d796a89818b5ca Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 8 Jun 2021 16:27:26 -0400 Subject: [PATCH 33/37] replace v4preprint with paper --- index.md | 6 +++--- inst/CITATION | 10 +++++----- vignettes/get_started.Rmd | 4 ++-- vignettes/multimodal_reference_mapping.Rmd | 10 +++++----- vignettes/multimodal_vignette.Rmd | 4 ++-- vignettes/weighted_nearest_neighbor_analysis.Rmd | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/index.md b/index.md index 82fc4d196..18c8ba515 100644 --- a/index.md +++ b/index.md @@ -5,9 +5,9 @@ We are excited to release Seurat v4.0! This update brings the following new features and functionality: * **Integrative multimodal analysis.** The ability to make simultaneous measurements of multiple data types from the same cell, known as multimodal analysis, represents a new and exciting frontier for single-cell genomics. In Seurat v4, we introduce weighted nearest neighbor (WNN) analysis, an unsupervised strategy to learn the information content of each modality in each cell, and to define cellular state based on a weighted combination of both modalities. - In our new preprint, we generate a CITE-seq dataset featuring paired measurements of the transcriptome and 228 surface proteins, and leverage WNN to define a multimodal reference of human PBMC. You can use WNN to analyze multimodal data from a variety of technologies, including CITE-seq, ASAP-seq, 10X Genomics ATAC + RNA, and SHARE-seq. + In our new paper, we generate a CITE-seq dataset featuring paired measurements of the transcriptome and 228 surface proteins, and leverage WNN to define a multimodal reference of human PBMC. You can use WNN to analyze multimodal data from a variety of technologies, including CITE-seq, ASAP-seq, 10X Genomics ATAC + RNA, and SHARE-seq. - - Preprint: [Integrated analysis of multimodal single-cell data](https://satijalab.org/v4preprint) + - Paper: [Integrated analysis of multimodal single-cell data](https://doi.org/10.1016/j.cell.2021.04.048) - Vignette: [Multimodal clustering of a human bone marrow CITE-seq dataset](articles/weighted_nearest_neighbor_analysis.html) - Portal: [Click here](https://atlas.fredhutch.org/nygc/multimodal-pbmc/) - Dataset: [Download here](https://atlas.fredhutch.org/data/nygc/multimodal/pbmc_multimodal.h5seurat) @@ -27,7 +27,7 @@ Seurat is an R package designed for QC, analysis, and exploration of single-cell If you use Seurat in your research, please considering citing: -* [Hao\*, Hao\*, et al., bioRxiv 2020](https://www.biorxiv.org/content/10.1101/2020.10.12.335331v1) [Seurat V4] +* [Hao\*, Hao\*, et al., Cell 2021](https://doi.org/10.1016/j.cell.2021.04.048) [Seurat V4] * [Stuart\*, Butler\*, et al., Cell 2019](https://www.cell.com/cell/fulltext/S0092-8674(19)30559-8) [Seurat V3] * [Butler\* et al., Nat Biotechnol 2018](https://doi.org/10.1038/nbt.4096) [Seurat V2] * [Satija\*, Farrell\*, et al., Nat Biotechnol 2015](https://doi.org/10.1038/nbt.3192) [Seurat V1] diff --git a/inst/CITATION b/inst/CITATION index 708a88e01..4aaa4d01f 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -27,11 +27,11 @@ citEntry(entry = "article", as.person("Peter Smibert"), as.person("Rahul Satija")), title = "Integrated analysis of multimodal single-cell data", - journal = "bioRxiv", - year = "2020", - doi = "10.1101/2020.10.12.335331", - url = "https://doi.org/10.1101/2020.10.12.335331", - textVersion = "Hao and Hao et al. Integrated analysis of multimodal single-cell data. bioRxiv (2020) [Seurat V4]" + journal = "Cell", + year = "2021", + doi = "10.1016/j.cell.2021.04.048", + url = "https://doi.org/10.1016/j.cell.2021.04.048", + textVersion = "Hao and Hao et al. Integrated analysis of multimodal single-cell data. Cell (2021) [Seurat V4]" ) citEntry(entry = "article", diff --git a/vignettes/get_started.Rmd b/vignettes/get_started.Rmd index 3ab8f6d03..b1fcf518f 100644 --- a/vignettes/get_started.Rmd +++ b/vignettes/get_started.Rmd @@ -123,8 +123,8 @@ make_vignette_card_section(vdat = vdat, cat = 2) Seurat also offers additional novel statistical methods for analyzing single-cell data. These include: -* Weighted-nearest neighbor (WNN) analysis: to define cell state based on multiple modalities [[paper](https://satijalab.org/v4preprint)] -* Mixscape: to analyze data from pooled single-cell CRISPR screens [[paper](https://www.biorxiv.org/content/10.1101/2020.06.28.175596v1)] +* Weighted-nearest neighbor (WNN) analysis: to define cell state based on multiple modalities [[paper](https://doi.org/10.1016/j.cell.2021.04.048)] +* Mixscape: to analyze data from pooled single-cell CRISPR screens [[paper](https://doi.org/10.1038/s41588-021-00778-2)] * SCTransform: Improved normalization for single-cell RNA-seq data [paper](https://genomebiology.biomedcentral.com/articles/10.1186/s13059-019-1874-1)] ```{r results='asis', echo=FALSE, warning=FALSE, message = FALSE} diff --git a/vignettes/multimodal_reference_mapping.Rmd b/vignettes/multimodal_reference_mapping.Rmd index 2ed285423..2d0be4f07 100644 --- a/vignettes/multimodal_reference_mapping.Rmd +++ b/vignettes/multimodal_reference_mapping.Rmd @@ -29,7 +29,7 @@ knitr::opts_chunk$set( # Intro: Seurat v4 Reference Mapping -This vignette introduces the process of mapping query datasets to annotated references in Seurat. In this example, we map one of the first scRNA-seq datasets released by 10X Genomics of 2,700 PBMC to our [recently described CITE-seq reference of 162,000 PBMC measured with 228 antibodies](http://www.satijalab.org/v4preprint). We chose this example to demonstrate how supervised analysis guided by a reference dataset can help to enumerate cell states that would be challenging to find with [unsupervised analysis](pbmc3k_tutorial.html). In a second example, we demonstrate how to serially map Human Cell Atlas datasets of human BMNC profiled from different individuals onto a consistent reference. +This vignette introduces the process of mapping query datasets to annotated references in Seurat. In this example, we map one of the first scRNA-seq datasets released by 10X Genomics of 2,700 PBMC to our [recently described CITE-seq reference of 162,000 PBMC measured with 228 antibodies](https://doi.org/10.1016/j.cell.2021.04.048). We chose this example to demonstrate how supervised analysis guided by a reference dataset can help to enumerate cell states that would be challenging to find with [unsupervised analysis](pbmc3k_tutorial.html). In a second example, we demonstrate how to serially map Human Cell Atlas datasets of human BMNC profiled from different individuals onto a consistent reference. We have [previously demonstrated](integration_mapping.html) how to use reference-mapping approach to annotate cell labels in a query dataset . In Seurat v4, we have substantially improved the speed and memory requirements for integrative tasks including reference mapping, and also include new functionality to project query cells onto a previously computed UMAP visualization. @@ -61,7 +61,7 @@ options(SeuratData.repo.use = "http://satijalab04.nygenome.org") ## A Multimodal PBMC Reference Dataset -We load the reference (download [here](https://atlas.fredhutch.org/data/nygc/multimodal/pbmc_multimodal.h5seurat)) from our recent [preprint](http://www.satijalab.org/v4preprint), and visualize the pre-computed UMAP. This reference is stored as an h5Seurat file, a format that enables on-disk storage of multimodal Seurat objects (more details on h5Seurat and `SeuratDisk` can be found [here](https://mojaveazure.github.io/seurat-disk/index.html)). +We load the reference (download [here](https://atlas.fredhutch.org/data/nygc/multimodal/pbmc_multimodal.h5seurat)) from our recent [paper](https://doi.org/10.1016/j.cell.2021.04.048), and visualize the pre-computed UMAP. This reference is stored as an h5Seurat file, a format that enables on-disk storage of multimodal Seurat objects (more details on h5Seurat and `SeuratDisk` can be found [here](https://mojaveazure.github.io/seurat-disk/index.html)). ```{r pbmc.ref} reference <- LoadH5Seurat("../data/pbmc_multimodal.h5seurat") @@ -86,7 +86,7 @@ The reference was normalized using `SCTransform()`, so we use the same approach pbmc3k <- SCTransform(pbmc3k, verbose = FALSE) ``` -We then find anchors between reference and query. As described in the [manuscript](http://www.satijalab.org/v4preprint), we used a precomputed supervised PCA (spca) transformation for this example. We recommend the use of supervised PCA for CITE-seq datasets, and demonstrate how to compute this transformation on the next tab of this vignette. However, you can also use a standard PCA transformation. +We then find anchors between reference and query. As described in the [manuscript](https://doi.org/10.1016/j.cell.2021.04.048), we used a precomputed supervised PCA (spca) transformation for this example. We recommend the use of supervised PCA for CITE-seq datasets, and demonstrate how to compute this transformation on the next tab of this vignette. However, you can also use a standard PCA transformation. ```{r transfer.anchors} anchors <- FindTransferAnchors( @@ -194,7 +194,7 @@ FeaturePlot(pbmc3k, features = c("CD3-1", "CD45RA", "IgD"), reduction = "ref.uma In the previous examples, we visualize the query cells after mapping to the reference-derived UMAP. Keeping a consistent visualization can assist with the interpretation of new datasets. However, if there are cell states that are present in the query dataset that are not represented in the reference, they will project to the most similar cell in the reference. This is the expected behavior and functionality as established by the UMAP package, but can potentially mask the presence of new cell types in the query which may be of interest. -In our [manuscript](http://www.satijalab.org/v4preprint), we map a query dataset containing developing and differentiated neutrophils, which are not included in our reference. We find that computing a new UMAP ('de novo visualization') after merging the reference and query can help to identify these populations, as demonstrated in Supplementary Figure 8. In the 'de novo' visualization, unique cell states in the query remain separated. In this example, the 2,700 PBMC does not contain unique cell states, but we demonstrate how to compute this visualization below. +In our [manuscript](https://doi.org/10.1016/j.cell.2021.04.048), we map a query dataset containing developing and differentiated neutrophils, which are not included in our reference. We find that computing a new UMAP ('de novo visualization') after merging the reference and query can help to identify these populations, as demonstrated in Supplementary Figure 8. In the 'de novo' visualization, unique cell states in the query remain separated. In this example, the 2,700 PBMC does not contain unique cell states, but we demonstrate how to compute this visualization below. We emphasize that if users are attempting to map datasets where the underlying samples are not PBMC, or contain cell types that are not present in the reference, computing a 'de novo' visualization is an important step in interpreting their dataset. @@ -248,7 +248,7 @@ DimPlot(bm, group.by = "celltype.l2", reduction = "wnn.umap") ## Computing an sPCA transformation -As described in our [manuscript](www.satijalab.org/v4preprint), we first compute a 'supervised' PCA. This identifies the transformation of the transcriptome data that best encapsulates the structure of the WNN graph. This allows a weighted combination of the protein and RNA measurements to 'supervise' the PCA, and highlight the most relevant sources of variation. After computing this transformation, we can project it onto a query dataset. We can also compute and project a PCA projection, but recommend the use of sPCA when working with multimodal references that have been constructed with WNN analysis. +As described in our [manuscript](https://doi.org/10.1016/j.cell.2021.04.048), we first compute a 'supervised' PCA. This identifies the transformation of the transcriptome data that best encapsulates the structure of the WNN graph. This allows a weighted combination of the protein and RNA measurements to 'supervise' the PCA, and highlight the most relevant sources of variation. After computing this transformation, we can project it onto a query dataset. We can also compute and project a PCA projection, but recommend the use of sPCA when working with multimodal references that have been constructed with WNN analysis. The sPCA calculation is performed once, and then can be rapidly projected onto each query dataset. diff --git a/vignettes/multimodal_vignette.Rmd b/vignettes/multimodal_vignette.Rmd index ce002e7a3..7a7789961 100644 --- a/vignettes/multimodal_vignette.Rmd +++ b/vignettes/multimodal_vignette.Rmd @@ -36,7 +36,7 @@ knitr::opts_chunk$set( The ability to make simultaneous measurements of multiple data types from the same cell, known as multimodal analysis, represents a new and exciting frontier for single-cell genomics. For example, [CITE-seq](http://www.nature.com/nmeth/journal/v14/n9/full/nmeth.4380.html) enables the simultaneous measurements of transcriptomes and cell-surface proteins from the same cell. Other exciting multimodal technologies, such as the [10x multiome kit](https://www.10xgenomics.com/products/single-cell-multiome-atac-plus-gene-expression) allow for the paired measurements of cellular transcriptome and chromatin accessibility (i.e scRNA-seq+scATAC-seq). Other modalities that can be measured alongside cellular transcriptomes include genetic perturbations, cellular methylomes, and hashtag oligos from [Cell Hashing](https://genomebiology.biomedcentral.com/articles/10.1186/s13059-018-1603-1). We have designed Seurat4 to enable for the seamless storage, analysis, and exploration of diverse multimodal single-cell datasets. -In this vignette, we present an introductory workflow for creating a multimodal Seurat object and performing an initial analysis. For example, we demonstrate how to cluster a CITE-seq dataset on the basis of the measured cellular transcriptomes, and subsequently discover cell surface proteins that are enriched in each cluster. We note that Seurat4 also enables more advanced techniques for the analysis of multimodal data, in particular the application of our [Weighted Nearest Neighbors (WNN) approach](https://www.biorxiv.org/content/10.1101/2020.10.12.335331v1) that enables simultaneous clustering of cells based on a weighted combination of both modalities, and you can explore this functionality [here](weighted_nearest_neighbor_analysis.html). +In this vignette, we present an introductory workflow for creating a multimodal Seurat object and performing an initial analysis. For example, we demonstrate how to cluster a CITE-seq dataset on the basis of the measured cellular transcriptomes, and subsequently discover cell surface proteins that are enriched in each cluster. We note that Seurat4 also enables more advanced techniques for the analysis of multimodal data, in particular the application of our [Weighted Nearest Neighbors (WNN) approach](https://doi.org/10.1016/j.cell.2021.04.048) that enables simultaneous clustering of cells based on a weighted combination of both modalities, and you can explore this functionality [here](weighted_nearest_neighbor_analysis.html). Here, we analyze a dataset of 8,617 cord blood mononuclear cells (CBMCs), where transcriptomic measurements are paired with abundance estimates for 11 surface proteins, whose levels are quantified with DNA-barcoded antibodies. First, we load in two count matrices : one for the RNA measurements, and one for the antibody-derived tags (ADT). You can download the ADT file [here](ftp://ftp.ncbi.nlm.nih.gov/geo/series/GSE100nnn/GSE100866/suppl/GSE100866_CBMC_8K_13AB_10X-ADT_umi.csv.gz) and the RNA file [here](ftp://ftp.ncbi.nlm.nih.gov/geo/series/GSE100nnn/GSE100866/suppl/GSE100866_CBMC_8K_13AB_10X-RNA_umi.csv.gz) @@ -218,7 +218,7 @@ write.csv(x = t(as.data.frame(all_times)), file = "../output/timings/multimodal_ Seurat v4 also includes additional functionality for the analysis, visualization, and integration of multimodal datasets. For more information, please explore the resources below: -* Defining cellular identity from multimodal data using WNN analysis in Seurat v4 [vignette link](weighted_nearest_neighbor_analysis.html) +* Defining cellular identity from multimodal data using WNN analysis in Seurat v4 [vignette](weighted_nearest_neighbor_analysis.html) * Mapping scRNA-seq data onto CITE-seq references [[vignette](reference_mapping.html)] * Introduction to the analysis of spatial transcriptomics analysis [[vignette](spatial_vignette.html)] * Analysis of 10x multiome (paired scRNA-seq + ATAC) using WNN analysis [[vignette](weighted_nearest_neighbor_analysis.html)] diff --git a/vignettes/weighted_nearest_neighbor_analysis.Rmd b/vignettes/weighted_nearest_neighbor_analysis.Rmd index cd0d1b091..1116e3e95 100644 --- a/vignettes/weighted_nearest_neighbor_analysis.Rmd +++ b/vignettes/weighted_nearest_neighbor_analysis.Rmd @@ -26,7 +26,7 @@ knitr::opts_chunk$set( time_it = TRUE ) ``` -The simultaneous measurement of multiple modalities, known as multimodal analysis, represents an exciting frontier for single-cell genomics and necessitates new computational methods that can define cellular states based on multiple data types. The varying information content of each modality, even across cells in the same dataset, represents a pressing challenge for the analysis and integration of multimodal datasets. In ([Hao\*, Hao\* et al, bioRxiv 2020](https://www.biorxiv.org/content/10.1101/2020.10.12.335331v1)), we introduce 'weighted-nearest neighbor' (WNN) analysis, an unsupervised framework to learn the relative utility of each data type in each cell, enabling an integrative analysis of multiple modalities. +The simultaneous measurement of multiple modalities, known as multimodal analysis, represents an exciting frontier for single-cell genomics and necessitates new computational methods that can define cellular states based on multiple data types. The varying information content of each modality, even across cells in the same dataset, represents a pressing challenge for the analysis and integration of multimodal datasets. In ([Hao\*, Hao\* et al, Cell 2021](https://doi.org/10.1016/j.cell.2021.04.048)), we introduce 'weighted-nearest neighbor' (WNN) analysis, an unsupervised framework to learn the relative utility of each data type in each cell, enabling an integrative analysis of multiple modalities. This vignette introduces the WNN workflow for the analysis of multimodal single-cell datasets. The workflow consists of three steps @@ -162,7 +162,7 @@ You can download the dataset from the 10x Genomics website [here](https://suppor Finally, in order to run the vignette, make sure the following packages are installed: -* [Seurat v4](install.html). +* [Seurat v4](install.html) * [Signac](https://satijalab.org/signac/) for the analysis of single-cell chromatin datasets * [EnsDb.Hsapiens.v86](https://bioconductor.org/packages/release/data/annotation/html/EnsDb.Hsapiens.v86.html) for a set of annotations for hg38 * [dplyr](https://cran.r-project.org/web/packages/dplyr/index.html) to help manipulate data tables From fa10ca2de395e4d86fc3e0608924dfe61268c079 Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Wed, 9 Jun 2021 09:30:49 -0400 Subject: [PATCH 34/37] Pin latest version of SeuratObject --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8b730070c..437ce5e8c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Seurat Version: 4.0.3 -Date: 2021-06-08 +Date: 2021-06-09 Title: Tools for Single Cell Genomics Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) , Macosko E, Basu A, Satija R, et al (2015) , Stuart T, Butler A, et al (2019) , and Hao, Hao, et al (2020) for more details. Authors@R: c( @@ -66,7 +66,7 @@ Imports: scales, scattermore (>= 0.7), sctransform (>= 0.3.2), - SeuratObject, + SeuratObject (>= 4.0.2), shiny, spatstat.core, spatstat.geom, From 0714eb01d088387082c8719c0c4f4fe74359cc04 Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Wed, 9 Jun 2021 09:30:57 -0400 Subject: [PATCH 35/37] Update CRAN comments --- cran-comments.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index 955ac6563..2bff06026 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,12 +1,10 @@ -# Seurat v4.0.2 +# Seurat v4.0.3 ## Test environments -* local Ubuntu 18.04.4 install, R 4.0.3 -* local Ubuntu 20.04 install, R 4.0.3 -* local Windows 10 install, R 4.0.3 +* local Ubuntu 20.04 install, R 4.0.5 * Ubuntu 16.04.6 (on travis-ci), R 4.0.0, R devel * macOS 10.13.6 (on travis-ci), R 4.0.2 -* Windows Server 2012 R2 (on AppVeyor), R 4.0.2 Patched +* Windows Server 2012 R2 (on AppVeyor), R 4.1.0 Patched * win-builder (release, devel) ## R CMD check results @@ -18,4 +16,4 @@ There is one package that depends on Seurat: tidyseurat; this update does not im There are seven packages that imports Seurat: CDSeq, DUBStepR, rPanglaoDB, scMappR, Signac, SignacX, and SoupX; this update does not impact their functionality -There are nine packages that suggest Seurat: BisqueRNA, ClustAssess, clustree, conos, DIscBIO, dyngen, rliger, Rmagic, VAM; this update does not impact their functionality. +There are ten packages that suggest Seurat: BisqueRNA, ClustAssess, clustree, conos, DIscBIO, dyngen, harmony, rliger, Rmagic, VAM; this update does not impact their functionality. From 599d8ba597ea4a6f8e2bc90c83fbf49871e585bd Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Wed, 9 Jun 2021 09:56:51 -0400 Subject: [PATCH 36/37] Fix broken documentation --- R/utilities.R | 4 ++-- man/UpdateSymbolList.Rd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/utilities.R b/R/utilities.R index cde0e94b7..6ae270517 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -801,9 +801,9 @@ FastRowScale <- function( #' provided symbol #' @param search.types Type of query to perform: #' \describe{ -#' \itemize{\dQuote{\code{alias_symbol}}}{Find alternate symbols for the genes +#' \item{\dQuote{\code{alias_symbol}}}{Find alternate symbols for the genes #' described by \code{symbols}} -#' \itemize{\dQuote{\code{prev_symbol}}}{Find new new symbols for the genes +#' \item{\dQuote{\code{prev_symbol}}}{Find new new symbols for the genes #' described by \code{symbols}} #' } #' This parameter accepts multiple options and short-hand options diff --git a/man/UpdateSymbolList.Rd b/man/UpdateSymbolList.Rd index ca5f3cdae..b97438f16 100644 --- a/man/UpdateSymbolList.Rd +++ b/man/UpdateSymbolList.Rd @@ -35,9 +35,9 @@ provided symbol} \item{search.types}{Type of query to perform: \describe{ - \itemize{\dQuote{\code{alias_symbol}}}{Find alternate symbols for the genes + \item{\dQuote{\code{alias_symbol}}}{Find alternate symbols for the genes described by \code{symbols}} - \itemize{\dQuote{\code{prev_symbol}}}{Find new new symbols for the genes + \item{\dQuote{\code{prev_symbol}}}{Find new new symbols for the genes described by \code{symbols}} } This parameter accepts multiple options and short-hand options From 7ffd3554668a7a065aff35d834aa8f320947105c Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Thu, 10 Jun 2021 13:25:37 -0400 Subject: [PATCH 37/37] Update dates --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 437ce5e8c..209768e97 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Seurat Version: 4.0.3 -Date: 2021-06-09 +Date: 2021-06-10 Title: Tools for Single Cell Genomics Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) , Macosko E, Basu A, Satija R, et al (2015) , Stuart T, Butler A, et al (2019) , and Hao, Hao, et al (2020) for more details. Authors@R: c( diff --git a/NEWS.md b/NEWS.md index edad1dde2..7f933542c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -## Seurat 4.0.3 (2020-06-08) +## Seurat 4.0.3 (2020-06-10) ## Added - Add `jitter` parameter to `FeatureScatter()`