Skip to content

Commit

Permalink
Merge pull request satijalab#3825 from satijalab/develop
Browse files Browse the repository at this point in the history
Seurat v3.2.3
  • Loading branch information
satijalab authored Dec 15, 2020
2 parents fe93b05 + fe0f02d commit b56d194
Show file tree
Hide file tree
Showing 27 changed files with 379 additions and 173 deletions.
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Seurat
Version: 3.2.2
Date: 2020-09-25
Version: 3.2.3
Date: 2020-12-14
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) <doi:10.1038/nbt.3192>, Macosko E, Basu A, Satija R, et al (2015) <doi:10.1016/j.cell.2015.05.002>, and Stuart T, Butler A, et al (2019) <doi:10.1016/j.cell.2019.05.031> for more details.
Authors@R: c(
Expand Down Expand Up @@ -58,14 +58,15 @@ Imports:
rsvd,
Rtsne,
scales,
sctransform (>= 0.3.0),
scattermore (>= 0.7),
sctransform (>= 0.3.1),
shiny,
spatstat,
stats,
tibble,
tools,
utils,
uwot (>= 0.1.5)
uwot (>= 0.1.9)
LinkingTo: Rcpp (>= 0.11.0), RcppEigen, RcppProgress
License: GPL-3 | file LICENSE
LazyData: true
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export(CellScatter)
export(CellSelector)
export(Cells)
export(CellsByIdentities)
export(CenterTitle)
export(CollapseEmbeddingOutliers)
export(CollapseSpeciesExpressionMatrix)
export(ColorDimSplit)
Expand Down Expand Up @@ -641,6 +642,7 @@ importFrom(scales,hue_pal)
importFrom(scales,rescale)
importFrom(scales,squish_infinite)
importFrom(scales,zero_range)
importFrom(scattermore,geom_scattermore)
importFrom(sctransform,correct_counts)
importFrom(sctransform,get_residual_var)
importFrom(sctransform,get_residuals)
Expand Down
20 changes: 20 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
All notable changes to Seurat will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [3.2.3] - 2020-12-14
### Added
- Titles added to `DimPlot` when specifying `group.by` parameter
- `keep.scale` parameter added to `FeaturePlot` to control scaling across multiple features and/or splits.

### Changes
- `Same` deprecated in favor of `base::identity`
- Fix in `DietSeurat` to work with specialized `Assay` objects
- Fix p-value return when using the `ape` implementation of Moran's I
- Fix bug in FindMarkers when using MAST with a latent variable
- Updates to `Key<-.DimReduc` that allow handling of empty reduction column names
- Allow setting `ctrl` in `CellCycleScoring`
- Modify subset.Seurat to allow specialized Assay subsetting methods
- Fix image selection in interactive spatial plots
- Update Rcpp functions with `export(rng=FALSE)` to avoid potential future warnings
- Fix RenameCells bug for integrated SCT assays
- Fix highlight order with proper factor levels when using `SetHighlight` in plots
- Small change in CellRanger version detection logic of h5 file to improve robustness to outside tools.
- `do.cpp` deprecated and will default to true

## [3.2.2] - 2020-09-25
### Changes
- Set the seed in `WhichCells` regardless of whether or not `idents` is passed
Expand Down
4 changes: 1 addition & 3 deletions R/differential_expression.R
Original file line number Diff line number Diff line change
Expand Up @@ -1351,9 +1351,6 @@ MASTDETest <- function(
if (!PackageCheck('MAST', error = FALSE)) {
stop("Please install MAST - learn more at https://github.com/RGLab/MAST")
}
if (length(x = latent.vars) > 0) {
latent.vars <- scale(x = latent.vars)
}
group.info <- data.frame(row.names = c(cells.1, cells.2))
latent.vars <- latent.vars %||% group.info
group.info[cells.1, "group"] <- "Group1"
Expand All @@ -1367,6 +1364,7 @@ MASTDETest <- function(
rownames(x = fdat) <- fdat[, 1]
sca <- MAST::FromMatrix(
exprsArray = as.matrix(x = data.use),
check_sanity = FALSE,
cData = latent.vars,
fData = fdat
)
Expand Down
5 changes: 0 additions & 5 deletions R/dimensional_reduction.R
Original file line number Diff line number Diff line change
Expand Up @@ -1301,11 +1301,6 @@ RunUMAP.default <- function(
)
}
if (is.list(x = object)) {
if (packageVersion(pkg = "uwot") <= '0.1.8.9000') {
stop("This uwot functionality requires uwot version >= 0.1.8.9000",
"Installing the latest version from github can be done with",
"remotes::install_github('jlmelville/uwot')")
}
uwot::umap_transform(
X = NULL,
nn_method = object,
Expand Down
55 changes: 50 additions & 5 deletions R/integration.R
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,8 @@ GetTransferPredictions <- function(object, assay = "predictions", slot = "data",
#' automatically.
#' @param preserve.order Do not reorder objects based on size for each pairwise
#' integration.
#' @param do.cpp Run cpp code where applicable
#' @param do.cpp Run cpp code where applicable. This argument is being
#' deprecated and will be set to TRUE by default.
#' @param eps Error bound on the neighbor finding algorithm (from
#' \code{\link{RANN}})
#' @param verbose Print progress bars and output
Expand Down Expand Up @@ -921,6 +922,14 @@ IntegrateData <- function(
eps = 0,
verbose = TRUE
) {
# TODO: deprecate fully in 4.0
if (!isTRUE(x = do.cpp)) {
warning(
"The do.cpp parameter is being deprecated. It will default to TRUE.",
call. = FALSE,
immediate. = TRUE
)
}
normalization.method <- match.arg(arg = normalization.method)
reference.datasets <- slot(object = anchorset, name = 'reference.objects')
object.list <- slot(object = anchorset, name = 'object.list')
Expand Down Expand Up @@ -1584,7 +1593,8 @@ SelectIntegrationFeatures <- function(
#' @param sd.weight Controls the bandwidth of the Gaussian kernel for weighting
#' @param eps Error bound on the neighbor finding algorithm (from
#' \code{\link{RANN}})
#' @param do.cpp Run cpp code where applicable
#' @param do.cpp Run cpp code where applicable. This argument is being
#' deprecated and will be set to TRUE by default.
#' @param verbose Print progress bars and output
#' @param slot Slot to store the imputed data. Must be either "data" (default)
#' or "counts"
Expand Down Expand Up @@ -1641,6 +1651,14 @@ TransferData <- function(
slot = "data",
prediction.assay = FALSE
) {
# TODO: deprecate fully in 4.0
if (!isTRUE(x = do.cpp)) {
warning(
"The do.cpp parameter is being deprecated. It will default to TRUE.",
call. = FALSE,
immediate. = TRUE
)
}
combined.ob <- slot(object = anchorset, name = "object.list")[[1]]
anchors <- slot(object = anchorset, name = "anchors")
reference.cells <- slot(object = anchorset, name = "reference.cells")
Expand Down Expand Up @@ -2477,7 +2495,8 @@ GetCellOffsets <- function(anchors, dataset, cell, cellnames.list, cellnames) {
# @param sd.weight Controls the bandwidth of the Gaussian kernel for weighting
# @param sample.tree Specify the order of integration. If NULL, will compute automatically.
# @param preserve.order Do not reorder objects based on size for each pairwise integration.
# @param do.cpp Run cpp code where applicable
# @param do.cpp Run cpp code where applicable. This argument is being
# deprecated and will be set to TRUE by default.
# @param eps Error bound on the neighbor finding algorithm (from \code{\link{RANN}})
# @param verbose Print progress bars and output
#
Expand All @@ -2500,6 +2519,14 @@ MapQuery <- function(
eps = 0,
verbose = TRUE
) {
# TODO: deprecate fully in 4.0
if (!isTRUE(x = do.cpp)) {
warning(
"The do.cpp parameter is being deprecated. It will default to TRUE.",
call. = FALSE,
immediate. = TRUE
)
}
normalization.method <- match.arg(arg = normalization.method)
reference.datasets <- slot(object = anchorset, name = 'reference.objects')
object.list <- slot(object = anchorset, name = 'object.list')
Expand Down Expand Up @@ -2619,7 +2646,8 @@ NNtoMatrix <- function(idx, distance, k) {
# automatically.
# @param preserve.order Do not reorder objects based on size for each pairwise
# integration.
# @param do.cpp Run cpp code where applicable
# @param do.cpp Run cpp code where applicable. This argument is being
# deprecated and will be set to TRUE by default.
# @param eps Error bound on the neighbor finding algorithm (from
# \code{\link{RANN}})
# @param verbose Print progress bars and output
Expand All @@ -2642,6 +2670,14 @@ PairwiseIntegrateReference <- function(
eps = 0,
verbose = TRUE
) {
# TODO: deprecate fully in 4.0
if (!isTRUE(x = do.cpp)) {
warning(
"The do.cpp parameter is being deprecated. It will default to TRUE.",
call. = FALSE,
immediate. = TRUE
)
}
object.list <- slot(object = anchorset, name = "object.list")
reference.objects <- slot(object = anchorset, name = "reference.objects")
features <- features %||% slot(object = anchorset, name = "anchor.features")
Expand Down Expand Up @@ -2955,7 +2991,8 @@ ReferenceRange <- function(x, lower = 0.025, upper = 0.975) {
# query, and weights will need to be calculated for all cells in the object.
# @param sd.weight Controls the bandwidth of the Gaussian kernel for weighting
# @param sample.tree Specify the order of integration. If NULL, will compute automatically.
# @param do.cpp Run cpp code where applicable
# @param do.cpp Run cpp code where applicable. This argument is being
# deprecated and will be set to TRUE by default.
# @param eps Error bound on the neighbor finding algorithm (from \code{\link{RANN}})
# @param verbose Print progress bars and output
#
Expand All @@ -2976,6 +3013,14 @@ RunIntegration <- function(
eps,
verbose
) {
# TODO: deprecate fully in 4.0
if (!isTRUE(x = do.cpp)) {
warning(
"The do.cpp parameter is being deprecated. It will default to TRUE.",
call. = FALSE,
immediate. = TRUE
)
}
cells1 <- colnames(x = reference)
cells2 <- colnames(x = query)
merged.obj <- merge(x = reference, y = query, merge.data = TRUE)
Expand Down
80 changes: 37 additions & 43 deletions R/objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -1077,40 +1077,28 @@ DietSeurat <- function(
if (!(assay %in% assays)) {
object[[assay]] <- NULL
} else {
features.assay <- features %||% rownames(x = object[[assay]])
features.assay <- intersect(x = features.assay, y = rownames(x = object[[assay]]))
if (length(x = features.assay) == 0) {
if (assay == DefaultAssay(object = object)) {
stop("The default assay is slated to be removed, please change the default assay")
} else {
warning("No features found in assay '", assay, "', removing...")
object[[assay]] <- NULL
}
} else {
if (counts) {
if (!is.null(x = features) && !IsMatrixEmpty(x = GetAssayData(object = object[[assay]], slot = "counts"))) {
slot(object = object[[assay]], name = 'counts') <- slot(object = object[[assay]], name = 'counts')[features.assay, ]
}
} else {
slot(object = object[[assay]], name = 'counts') <- new(Class = 'matrix')
}
if (data) {
if (!is.null(x = features)) {
slot(object = object[[assay]], name = 'data') <- slot(object = object[[assay]], name = 'data')[features.assay, ]
}
} else {
stop('data = FALSE currently not supported')
slot(object = object[[assay]], name = 'data') <- new(Class = 'matrix')
}
features.scaled <- features.assay[features.assay %in% rownames(x = slot(object = object[[assay]], name = 'scale.data'))]
if (scale.data && length(x = features.scaled) > 0) {
if (! all(rownames(x = slot(object = object[[assay]], name = 'scale.data')) %in% features.scaled)) {
slot(object = object[[assay]], name = 'scale.data') <- slot(object = object[[assay]], name = 'scale.data')[features.scaled, ]
if (!is.null(x = features)) {
features.assay <- intersect(x = features, y = rownames(x = object[[assay]]))
if (length(x = features.assay) == 0) {
if (assay == DefaultAssay(object = object)) {
stop("The default assay is slated to be removed, please change the default assay")
} else {
warning("No features found in assay '", assay, "', removing...")
object[[assay]] <- NULL
}
} else {
slot(object = object[[assay]], name = 'scale.data') <- new(Class = 'matrix')
object[[assay]] <- subset(x = object[[assay]], features = features.assay)
}
}
if (!counts) {
slot(object = object[[assay]], name = 'counts') <- new(Class = 'matrix')
}
if (!data) {
stop('data = FALSE currently not supported')
}
if (!scale.data) {
slot(object = object[[assay]], name = 'scale.data') <- new(Class = 'matrix')
}
}
}
# remove unspecified DimReducs and Graphs
Expand Down Expand Up @@ -3844,7 +3832,7 @@ IsGlobal.default <- function(object) {
#'
IsGlobal.DimReduc <- function(object) {
object <- UpdateSlots(object = object)
return(slot(object = object, name = 'global'))
return(isTRUE(x = slot(object = object, name = 'global')))
}

#' @rdname IsGlobal
Expand Down Expand Up @@ -4008,6 +3996,7 @@ Key.SpatialImage <- function(object, ...) {
"Key<-.DimReduc" <- function(object, ..., value) {
CheckDots(...)
object <- UpdateSlots(object = object)
value <- UpdateKey(key = value)
old.key <- Key(object = object)
slots <- Filter(
f = function(x) {
Expand All @@ -4018,11 +4007,15 @@ Key.SpatialImage <- function(object, ...) {
for (s in slots) {
mat <- slot(object = object, name = s)
if (!IsMatrixEmpty(x = mat)) {
colnames(x = mat) <- sub(
pattern = paste0('^', old.key),
replacement = value,
x = colnames(x = mat)
)
colnames(x = mat) <- if (is.null(x = colnames(x = mat))) {
paste0(value, seq.int(from = 1, to = ncol(x = mat)))
} else {
sub(
pattern = paste0('^', old.key),
replacement = value,
x = colnames(x = mat)
)
}
}
slot(object = object, name = s) <- mat
}
Expand Down Expand Up @@ -4921,7 +4914,7 @@ ReorderIdent.Seurat <- function(
yes = function(x) {
return(max(x) + 1 - x)
},
no = Same
no = identity
)
new.levels <- names(x = rfxn(x = sort(x = tapply(
X = data.use,
Expand Down Expand Up @@ -4968,16 +4961,16 @@ RenameCells.Assay <- function(object, new.names = NULL, ...) {
CheckDots(...)
if (IsSCT(assay = object)) {
if (is.null(x = Misc(object = object, slot = 'vst.set'))) {
suppressWarnings(Misc(object = object, slot = "vst.out")$cells_step1 <- new.names)
suppressWarnings(rownames(x = Misc(object = object, slot = "vst.out")$cell_attr) <- new.names)
x <- Misc(object = object, slot = "vst.out")
suppressWarnings(Misc(object = object, slot = "vst.out")$cells_step1 <- new.names[which(x = x$cells_step1 %in% Cells(x = object))])
suppressWarnings(rownames(x = Misc(object = object, slot = "vst.out")$cell_attr) <- new.names[which(x = rownames(x$cell_attr) %in% Cells(x = object))])
} else{
suppressWarnings(
Misc(object, slot = "vst.set") <- lapply(
X = Misc(object = object, slot = "vst.set"),
FUN = function(x) {
new.names.vst <- new.names[which(x = x$cells_step1 %in% Cells(x = object))]
x$cells_step1 <- new.names.vst
rownames(x = x$cell_attr) <- new.names.vst
x$cells_step1 <- new.names[which(x = x$cells_step1 %in% Cells(x = object))]
rownames(x = x$cell_attr) <- new.names[which(x = rownames(x$cell_attr) %in% Cells(x = object))]
return(x)
}
)
Expand Down Expand Up @@ -7358,7 +7351,8 @@ subset.Seurat <- function(x, subset, cells = NULL, features = NULL, idents = NUL
for (assay in assays) {
assay.features <- features %||% rownames(x = x[[assay]])
slot(object = x, name = 'assays')[[assay]] <- tryCatch(
expr = subset.Assay(x = x[[assay]], cells = cells, features = assay.features),
# because subset is also an argument, we need to explictly use the base::subset function
expr = base::subset(x = x[[assay]], cells = cells, features = assay.features),
error = function(e) {
if (e$message == "Cannot find features provided") {
return(NULL)
Expand Down
Loading

0 comments on commit b56d194

Please sign in to comment.