Skip to content

Commit c463873

Browse files
authored
Merge pull request #6467 from satijalab/release/4.2.0
Seurat v4.2.0
2 parents 3bee84a + 3d26669 commit c463873

31 files changed

+289
-212
lines changed

DESCRIPTION

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: Seurat
2-
Version: 4.1.1
3-
Date: 2022-05-01
2+
Version: 4.2.0
3+
Date: 2022-09-21
44
Title: Tools for Single Cell Genomics
55
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>, Stuart T, Butler A, et al (2019) <doi:10.1016/j.cell.2019.05.031>, and Hao, Hao, et al (2020) <doi:10.1101/2020.10.12.335331> for more details.
66
Authors@R: c(
@@ -48,7 +48,7 @@ Imports:
4848
leiden (>= 0.3.1),
4949
lmtest,
5050
MASS,
51-
Matrix (>= 1.2-14),
51+
Matrix (>= 1.5.0),
5252
matrixStats,
5353
miniUI,
5454
patchwork,
@@ -65,16 +65,16 @@ Imports:
6565
Rtsne,
6666
scales,
6767
scattermore (>= 0.7),
68-
sctransform (>= 0.3.3),
69-
SeuratObject (>= 4.1.0),
68+
sctransform (>= 0.3.4),
69+
SeuratObject (>= 4.1.2),
7070
shiny,
7171
spatstat.core,
7272
spatstat.geom,
7373
stats,
7474
tibble,
7575
tools,
7676
utils,
77-
uwot (>= 0.1.9)
77+
uwot (>= 0.1.14)
7878
LinkingTo: Rcpp (>= 0.11.0), RcppEigen, RcppProgress
7979
License: MIT + file LICENSE
8080
LazyData: true
@@ -95,7 +95,7 @@ Collate:
9595
'tree.R'
9696
'utilities.R'
9797
'zzz.R'
98-
RoxygenNote: 7.1.2
98+
RoxygenNote: 7.2.1
9999
Encoding: UTF-8
100100
Suggests:
101101
ape,

NAMESPACE

-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,6 @@ importFrom(ggplot2,position_jitterdodge)
521521
importFrom(ggplot2,scale_alpha)
522522
importFrom(ggplot2,scale_alpha_ordinal)
523523
importFrom(ggplot2,scale_color_brewer)
524-
importFrom(ggplot2,scale_color_discrete)
525524
importFrom(ggplot2,scale_color_distiller)
526525
importFrom(ggplot2,scale_color_gradient)
527526
importFrom(ggplot2,scale_color_gradientn)

NEWS.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Seurat 4.2.0 (2022-09-21)
2+
3+
## Changes
4+
- Fix legend color in `DoHeatmap()` ([#5783](https://github.com/satijalab/seurat/issues/5783))
5+
- Fix bug in `ScaleData()` when regressing out one gene ([#5970](https://github.com/satijalab/seurat/pull/5970))
6+
- Fix name pulling in `PlotPerturbScore()` ([#6081](https://github.com/satijalab/seurat/pull/6081))
7+
- Support spaceranger 2.0 ([#6208](https://github.com/satijalab/seurat/pull/6208))
8+
- Fix bug in `SpatialDimPlot()` when using `group.by` ([#6179](https://github.com/satijalab/seurat/issues/6179))
9+
- Add `add.noise` parameter in `VlnPlot()`
10+
([#5756](https://github.com/satijalab/seurat/issues/5756))
11+
- Fix uwot model backwards compatibility ([#6345](https://github.com/satijalab/seurat/issues/6345))
12+
- Allow `pseudocount.use` in differential expression functions to be set at the `Assay` level
13+
114
# Seurat 4.1.1 (2022-05-01)
215

316
## Changes

R/clustering.R

+2-4
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,7 @@ PredictAssay <- function(
259259
)
260260
colnames(x = predicted) <- Cells(x = object)
261261
if (return.assay) {
262-
# TODO: restore once check.matrix is implemented in SeuratObject
263-
# predicted.assay <- CreateAssayObject(data = predicted, check.matrix = FALSE)
264-
predicted.assay <- CreateAssayObject(data = predicted)
262+
predicted.assay <- CreateAssayObject(data = predicted, check.matrix = FALSE)
265263
return (predicted.assay)
266264
} else {
267265
return (predicted)
@@ -1689,7 +1687,7 @@ RunLeiden <- function(
16891687
graph_from_adj_list(adjlist = object)
16901688
} else if (inherits(x = object, what = c('dgCMatrix', 'matrix', 'Matrix'))) {
16911689
if (inherits(x = object, what = 'Graph')) {
1692-
object <- as(object = object, Class = "dgCMatrix")
1690+
object <- as.sparse(x = object)
16931691
}
16941692
graph_from_adjacency_matrix(adjmatrix = object, weighted = TRUE)
16951693
} else if (inherits(x = object, what = 'igraph')) {

R/differential_expression.R

+35-22
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ FindAllMarkers <- function(
5959
latent.vars = NULL,
6060
min.cells.feature = 3,
6161
min.cells.group = 3,
62-
pseudocount.use = 1,
6362
mean.fxn = NULL,
6463
fc.name = NULL,
6564
base = 2,
@@ -136,7 +135,6 @@ FindAllMarkers <- function(
136135
latent.vars = latent.vars,
137136
min.cells.feature = min.cells.feature,
138137
min.cells.group = min.cells.group,
139-
pseudocount.use = pseudocount.use,
140138
mean.fxn = mean.fxn,
141139
fc.name = fc.name,
142140
base = base,
@@ -512,6 +510,7 @@ FindMarkers.default <- function(
512510
densify = FALSE,
513511
...
514512
) {
513+
pseudocount.use <- pseudocount.use %||% 1
515514
ValidateCellGroups(
516515
object = object,
517516
cells.1 = cells.1,
@@ -603,6 +602,9 @@ FindMarkers.default <- function(
603602
return(de.results)
604603
}
605604

605+
#' @param norm.method Normalization method for fold change calculation when
606+
#' \code{slot} is \dQuote{\code{data}}
607+
#'
606608
#' @rdname FindMarkers
607609
#' @concept differential_expression
608610
#' @export
@@ -630,8 +632,10 @@ FindMarkers.Assay <- function(
630632
fc.name = NULL,
631633
base = 2,
632634
densify = FALSE,
635+
norm.method = NULL,
633636
...
634637
) {
638+
pseudocount.use <- pseudocount.use %||% 1
635639
data.slot <- ifelse(
636640
test = test.use %in% DEmethods_counts(),
637641
yes = 'counts',
@@ -652,7 +656,8 @@ FindMarkers.Assay <- function(
652656
pseudocount.use = pseudocount.use,
653657
mean.fxn = mean.fxn,
654658
fc.name = fc.name,
655-
base = base
659+
base = base,
660+
norm.method = norm.method
656661
)
657662
de.results <- FindMarkers(
658663
object = data.use,
@@ -712,6 +717,7 @@ FindMarkers.SCTAssay <- function(
712717
recorrect_umi = TRUE,
713718
...
714719
) {
720+
pseudocount.use <- pseudocount.use %||% 1
715721
data.slot <- ifelse(
716722
test = test.use %in% DEmethods_counts(),
717723
yes = 'counts',
@@ -813,6 +819,7 @@ FindMarkers.DimReduc <- function(
813819
...
814820

815821
) {
822+
pseudocount.use <- pseudocount.use %||% 1
816823
if (test.use %in% DEmethods_counts()) {
817824
stop("The following tests cannot be used for differential expression on a reduction as they assume a count model: ",
818825
paste(DEmethods_counts(), collapse=", "))
@@ -927,7 +934,6 @@ FindMarkers.Seurat <- function(
927934
latent.vars = NULL,
928935
min.cells.feature = 3,
929936
min.cells.group = 3,
930-
pseudocount.use = 1,
931937
mean.fxn = NULL,
932938
fc.name = NULL,
933939
base = 2,
@@ -971,17 +977,14 @@ FindMarkers.Seurat <- function(
971977
}
972978
# check normalization method
973979
norm.command <- paste0("NormalizeData.", assay)
974-
if (norm.command %in% Command(object = object) && is.null(x = reduction)) {
975-
norm.method <- Command(
980+
norm.method <- if (norm.command %in% Command(object = object) && is.null(x = reduction)) {
981+
Command(
976982
object = object,
977983
command = norm.command,
978984
value = "normalization.method"
979985
)
980-
if (norm.method != "LogNormalize") {
981-
mean.fxn <- function(x) {
982-
return(log(x = rowMeans(x = x) + pseudocount.use, base = base))
983-
}
984-
}
986+
} else {
987+
NULL
985988
}
986989
de.results <- FindMarkers(
987990
object = data.use,
@@ -1000,11 +1003,11 @@ FindMarkers.Seurat <- function(
10001003
latent.vars = latent.vars,
10011004
min.cells.feature = min.cells.feature,
10021005
min.cells.group = min.cells.group,
1003-
pseudocount.use = pseudocount.use,
10041006
mean.fxn = mean.fxn,
10051007
base = base,
10061008
fc.name = fc.name,
10071009
densify = densify,
1010+
norm.method = norm.method,
10081011
...
10091012
)
10101013
return(de.results)
@@ -1050,7 +1053,9 @@ FoldChange.default <- function(
10501053
return(fc.results)
10511054
}
10521055

1053-
1056+
#' @param norm.method Normalization method for mean function selection
1057+
#' when \code{slot} is \dQuote{\code{data}}
1058+
#'
10541059
#' @importFrom Matrix rowMeans
10551060
#' @rdname FoldChange
10561061
#' @concept differential_expression
@@ -1066,18 +1071,25 @@ FoldChange.Assay <- function(
10661071
fc.name = NULL,
10671072
mean.fxn = NULL,
10681073
base = 2,
1074+
norm.method = NULL,
10691075
...
10701076
) {
1077+
pseudocount.use <- pseudocount.use %||% 1
10711078
data <- GetAssayData(object = object, slot = slot)
1079+
default.mean.fxn <- function(x) {
1080+
return(log(x = rowMeans(x = x) + pseudocount.use, base = base))
1081+
}
10721082
mean.fxn <- mean.fxn %||% switch(
10731083
EXPR = slot,
1074-
'data' = function(x) {
1075-
return(log(x = rowMeans(x = expm1(x = x)) + pseudocount.use, base = base))
1076-
},
1084+
'data' = switch(
1085+
EXPR = norm.method %||% '',
1086+
'LogNormalize' = function(x) {
1087+
return(log(x = rowMeans(x = expm1(x = x)) + pseudocount.use, base = base))
1088+
},
1089+
default.mean.fxn
1090+
),
10771091
'scale.data' = rowMeans,
1078-
function(x) {
1079-
return(log(x = rowMeans(x = x) + pseudocount.use, base = base))
1080-
}
1092+
default.mean.fxn
10811093
)
10821094
# Omit the decimal value of e from the column name if base == exp(1)
10831095
base.text <- ifelse(
@@ -1111,11 +1123,12 @@ FoldChange.DimReduc <- function(
11111123
cells.2,
11121124
features = NULL,
11131125
slot = NULL,
1114-
pseudocount.use = NULL,
1126+
pseudocount.use = 1,
11151127
fc.name = NULL,
11161128
mean.fxn = NULL,
11171129
...
11181130
) {
1131+
pseudocount.use <- pseudocount.use %||% 1
11191132
mean.fxn <- mean.fxn %||% rowMeans
11201133
fc.name <- fc.name %||% "avg_diff"
11211134
data <- t(x = Embeddings(object = object))
@@ -1143,7 +1156,7 @@ FoldChange.DimReduc <- function(
11431156
#' @param assay Assay to use in fold change calculation
11441157
#' @param slot Slot to pull data from
11451158
#' @param pseudocount.use Pseudocount to add to averaged expression values when
1146-
#' calculating logFC. 1 by default.
1159+
#' calculating logFC.
11471160
#' @param mean.fxn Function to use for fold change or average difference calculation
11481161
#' @param base The base with respect to which logarithms are computed.
11491162
#' @param fc.name Name of the fold change, average difference, or custom function column
@@ -1163,7 +1176,7 @@ FoldChange.Seurat <- function(
11631176
slot = 'data',
11641177
reduction = NULL,
11651178
features = NULL,
1166-
pseudocount.use = 1,
1179+
pseudocount.use = NULL,
11671180
mean.fxn = NULL,
11681181
base = 2,
11691182
fc.name = NULL,

R/dimensional_reduction.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,10 @@ RunUMAP.default <- function(
13791379
object = reduction.model,
13801380
slot = "model"
13811381
)
1382+
# add num_precomputed_nns to <v0.1.13 uwot models to prevent errors with newer versions of uwot
1383+
if (!"num_precomputed_nns" %in% names(model)) {
1384+
model$num_precomputed_nns <- 1
1385+
}
13821386
if (length(x = model) == 0) {
13831387
stop(
13841388
"The provided reduction.model does not have a model stored. Please try running umot-learn on the object first",
@@ -1388,7 +1392,7 @@ RunUMAP.default <- function(
13881392
if (is.list(x = object)) {
13891393
if (ncol(object$idx) != model$n_neighbors) {
13901394
warning("Number of neighbors between query and reference ",
1391-
"is not equal to the number of neighbros within reference")
1395+
"is not equal to the number of neighbors within reference")
13921396
model$n_neighbors <- ncol(object$idx)
13931397
}
13941398
umap_transform(

0 commit comments

Comments
 (0)