Skip to content

Commit

Permalink
merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarks committed Nov 9, 2022
2 parents 20c0b15 + b23ae2e commit 2b3584c
Show file tree
Hide file tree
Showing 41 changed files with 410 additions and 289 deletions.
16 changes: 8 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Seurat
Version: 4.1.0.9007
Date: 2022-05-01
Version: 4.2.1.9000
Date: 2022-11-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) <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.
Authors@R: c(
Expand Down Expand Up @@ -48,7 +48,7 @@ Imports:
leiden (>= 0.3.1),
lmtest,
MASS,
Matrix (>= 1.2-14),
Matrix (>= 1.5-0),
matrixStats,
miniUI,
patchwork,
Expand All @@ -66,16 +66,16 @@ Imports:
Rtsne,
scales,
scattermore (>= 0.7),
sctransform (>= 0.3.3),
SeuratObject (>= 4.1.1),
sctransform (>= 0.3.5),
SeuratObject (>= 4.1.3),
shiny,
spatstat.core,
spatstat.explore,
spatstat.geom,
stats,
tibble,
tools,
utils,
uwot (>= 0.1.9)
uwot (>= 0.1.14)
LinkingTo: Rcpp (>= 0.11.0), RcppEigen, RcppProgress
License: MIT + file LICENSE
LazyData: true
Expand All @@ -96,7 +96,7 @@ Collate:
'tree.R'
'utilities.R'
'zzz.R'
RoxygenNote: 7.1.2
RoxygenNote: 7.2.1
Encoding: UTF-8
Suggests:
ape,
Expand Down
6 changes: 3 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ importFrom(SeuratObject,"Misc<-")
importFrom(SeuratObject,"Project<-")
importFrom(SeuratObject,"Tool<-")
importFrom(SeuratObject,"VariableFeatures<-")
importFrom(SeuratObject,.DefaultFOV)
importFrom(SeuratObject,AddMetaData)
importFrom(SeuratObject,Assays)
importFrom(SeuratObject,AttachDeps)
Expand All @@ -445,6 +444,7 @@ importFrom(SeuratObject,CreateSeuratObject)
importFrom(SeuratObject,DefaultAssay)
importFrom(SeuratObject,DefaultBoundary)
importFrom(SeuratObject,DefaultDimReduc)
importFrom(SeuratObject,DefaultFOV)
importFrom(SeuratObject,Distances)
importFrom(SeuratObject,Embeddings)
importFrom(SeuratObject,Features)
Expand Down Expand Up @@ -556,7 +556,6 @@ importFrom(ggplot2,scale_alpha)
importFrom(ggplot2,scale_alpha_manual)
importFrom(ggplot2,scale_alpha_ordinal)
importFrom(ggplot2,scale_color_brewer)
importFrom(ggplot2,scale_color_discrete)
importFrom(ggplot2,scale_color_distiller)
importFrom(ggplot2,scale_color_gradient)
importFrom(ggplot2,scale_color_gradientn)
Expand Down Expand Up @@ -643,6 +642,7 @@ importFrom(matrixStats,rowSums2)
importFrom(methods,"slot<-")
importFrom(methods,.hasSlot)
importFrom(methods,as)
importFrom(methods,getMethod)
importFrom(methods,is)
importFrom(methods,new)
importFrom(methods,setAs)
Expand Down Expand Up @@ -707,7 +707,7 @@ importFrom(shiny,sliderInput)
importFrom(shiny,stopApp)
importFrom(shiny,updateSelectInput)
importFrom(shiny,verbatimTextOutput)
importFrom(spatstat.core,markvario)
importFrom(spatstat.explore,markvario)
importFrom(spatstat.geom,ppp)
importFrom(stats,aggregate)
importFrom(stats,anova)
Expand Down
23 changes: 22 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
# Unreleased
# Seurat 4.2.1 (2022-11-07)

## Changes
- Replaced import from `spatstat.core` with `spatstat.explore`
- Fix bug in `FindMarkers()` when using `SCT` assay ([#6856](https://github.com/satijalab/seurat/issues/6586))

# Seurat 4.2.0 (2022-09-21)

## Changes
- Fix legend color in `DoHeatmap()` ([#5783](https://github.com/satijalab/seurat/issues/5783))
- Fix bug in `ScaleData()` when regressing out one gene ([#5970](https://github.com/satijalab/seurat/pull/5970))
- Fix name pulling in `PlotPerturbScore()` ([#6081](https://github.com/satijalab/seurat/pull/6081))
- Support spaceranger 2.0 ([#6208](https://github.com/satijalab/seurat/pull/6208))
- Fix bug in `SpatialDimPlot()` when using `group.by` ([#6179](https://github.com/satijalab/seurat/issues/6179))
- Add `add.noise` parameter in `VlnPlot()`
([#5756](https://github.com/satijalab/seurat/issues/5756))
- Fix uwot model backwards compatibility ([#6345](https://github.com/satijalab/seurat/issues/6345))
- Allow `pseudocount.use` in differential expression functions to be set at the `Assay` level

# Seurat 4.1.1 (2022-05-01)

## Changes
- Fix `giveCsparse` related warnings in `Read10X_h5`
Expand All @@ -7,6 +26,8 @@
- Fix `VlnPlot` to switch on rasterization only when required ([#5846](https://github.com/satijalab/seurat/pull/5846))
- Fix `ncol` behavior in `SpatialPlot` ([#5774](https://github.com/satijalab/seurat/issues/5774))
- Set `jitter` to FALSE in `FeatureScatter` ([#5876](https://github.com/satijalab/seurat/pull/5876))
- Update `Cells` methods to new signature (`x, ...`)
- Replace use of `default.stringsAsFactors()` with `getOption("stringsAsFactors")`

# Seurat 4.1.0 (2022-01-14)
## Added
Expand Down
6 changes: 2 additions & 4 deletions R/clustering.R
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ PredictAssay <- function(
)
colnames(x = predicted) <- Cells(x = object)
if (return.assay) {
# TODO: restore once check.matrix is implemented in SeuratObject
# predicted.assay <- CreateAssayObject(data = predicted, check.matrix = FALSE)
predicted.assay <- CreateAssayObject(data = predicted)
predicted.assay <- CreateAssayObject(data = predicted, check.matrix = FALSE)
return (predicted.assay)
} else {
return (predicted)
Expand Down Expand Up @@ -1689,7 +1687,7 @@ RunLeiden <- function(
graph_from_adj_list(adjlist = object)
} else if (inherits(x = object, what = c('dgCMatrix', 'matrix', 'Matrix'))) {
if (inherits(x = object, what = 'Graph')) {
object <- as(object = object, Class = "dgCMatrix")
object <- as.sparse(x = object)
}
graph_from_adjacency_matrix(adjmatrix = object, weighted = TRUE)
} else if (inherits(x = object, what = 'igraph')) {
Expand Down
65 changes: 42 additions & 23 deletions R/differential_expression.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ FindAllMarkers <- function(
latent.vars = NULL,
min.cells.feature = 3,
min.cells.group = 3,
pseudocount.use = 1,
mean.fxn = NULL,
fc.name = NULL,
base = 2,
Expand Down Expand Up @@ -136,7 +135,6 @@ FindAllMarkers <- function(
latent.vars = latent.vars,
min.cells.feature = min.cells.feature,
min.cells.group = min.cells.group,
pseudocount.use = pseudocount.use,
mean.fxn = mean.fxn,
fc.name = fc.name,
base = base,
Expand Down Expand Up @@ -512,6 +510,7 @@ FindMarkers.default <- function(
densify = FALSE,
...
) {
pseudocount.use <- pseudocount.use %||% 1
ValidateCellGroups(
object = object,
cells.1 = cells.1,
Expand Down Expand Up @@ -603,6 +602,9 @@ FindMarkers.default <- function(
return(de.results)
}

#' @param norm.method Normalization method for fold change calculation when
#' \code{slot} is \dQuote{\code{data}}
#'
#' @rdname FindMarkers
#' @concept differential_expression
#' @export
Expand Down Expand Up @@ -630,8 +632,10 @@ FindMarkers.Assay <- function(
fc.name = NULL,
base = 2,
densify = FALSE,
norm.method = NULL,
...
) {
pseudocount.use <- pseudocount.use %||% 1
data.slot <- ifelse(
test = test.use %in% DEmethods_counts(),
yes = 'counts',
Expand All @@ -652,7 +656,8 @@ FindMarkers.Assay <- function(
pseudocount.use = pseudocount.use,
mean.fxn = mean.fxn,
fc.name = fc.name,
base = base
base = base,
norm.method = norm.method
)
de.results <- FindMarkers(
object = data.use,
Expand Down Expand Up @@ -712,6 +717,7 @@ FindMarkers.SCTAssay <- function(
recorrect_umi = TRUE,
...
) {
pseudocount.use <- pseudocount.use %||% 1
data.slot <- ifelse(
test = test.use %in% DEmethods_counts(),
yes = 'counts',
Expand Down Expand Up @@ -746,6 +752,12 @@ FindMarkers.SCTAssay <- function(
'scale.data' = GetAssayData(object = object, slot = "counts"),
numeric()
)
if (is.null(x = mean.fxn)){
mean.fxn <- function(x) {
return(log(x = rowMeans(x = expm1(x = x)) + pseudocount.use, base = base))

}
}
fc.results <- FoldChange(
object = object,
slot = data.slot,
Expand All @@ -756,7 +768,7 @@ FindMarkers.SCTAssay <- function(
mean.fxn = mean.fxn,
fc.name = fc.name,
base = base
)
)
de.results <- FindMarkers(
object = data.use,
slot = data.slot,
Expand Down Expand Up @@ -813,6 +825,7 @@ FindMarkers.DimReduc <- function(
...

) {
pseudocount.use <- pseudocount.use %||% 1
if (test.use %in% DEmethods_counts()) {
stop("The following tests cannot be used for differential expression on a reduction as they assume a count model: ",
paste(DEmethods_counts(), collapse=", "))
Expand Down Expand Up @@ -927,7 +940,6 @@ FindMarkers.Seurat <- function(
latent.vars = NULL,
min.cells.feature = 3,
min.cells.group = 3,
pseudocount.use = 1,
mean.fxn = NULL,
fc.name = NULL,
base = 2,
Expand Down Expand Up @@ -971,17 +983,14 @@ FindMarkers.Seurat <- function(
}
# check normalization method
norm.command <- paste0("NormalizeData.", assay)
if (norm.command %in% Command(object = object) && is.null(x = reduction)) {
norm.method <- Command(
norm.method <- if (norm.command %in% Command(object = object) && is.null(x = reduction)) {
Command(
object = object,
command = norm.command,
value = "normalization.method"
)
if (norm.method != "LogNormalize") {
mean.fxn <- function(x) {
return(log(x = rowMeans(x = x) + pseudocount.use, base = base))
}
}
} else {
NULL
}
de.results <- FindMarkers(
object = data.use,
Expand All @@ -1000,11 +1009,11 @@ FindMarkers.Seurat <- function(
latent.vars = latent.vars,
min.cells.feature = min.cells.feature,
min.cells.group = min.cells.group,
pseudocount.use = pseudocount.use,
mean.fxn = mean.fxn,
base = base,
fc.name = fc.name,
densify = densify,
norm.method = norm.method,
...
)
return(de.results)
Expand Down Expand Up @@ -1050,7 +1059,9 @@ FoldChange.default <- function(
return(fc.results)
}


#' @param norm.method Normalization method for mean function selection
#' when \code{slot} is \dQuote{\code{data}}
#'
#' @importFrom Matrix rowMeans
#' @rdname FoldChange
#' @concept differential_expression
Expand All @@ -1066,18 +1077,25 @@ FoldChange.Assay <- function(
fc.name = NULL,
mean.fxn = NULL,
base = 2,
norm.method = NULL,
...
) {
pseudocount.use <- pseudocount.use %||% 1
data <- GetAssayData(object = object, slot = slot)
default.mean.fxn <- function(x) {
return(log(x = rowMeans(x = x) + pseudocount.use, base = base))
}
mean.fxn <- mean.fxn %||% switch(
EXPR = slot,
'data' = function(x) {
return(log(x = rowMeans(x = expm1(x = x)) + pseudocount.use, base = base))
},
'data' = switch(
EXPR = norm.method %||% '',
'LogNormalize' = function(x) {
return(log(x = rowMeans(x = expm1(x = x)) + pseudocount.use, base = base))
},
default.mean.fxn
),
'scale.data' = rowMeans,
function(x) {
return(log(x = rowMeans(x = x) + pseudocount.use, base = base))
}
default.mean.fxn
)
# Omit the decimal value of e from the column name if base == exp(1)
base.text <- ifelse(
Expand Down Expand Up @@ -1111,11 +1129,12 @@ FoldChange.DimReduc <- function(
cells.2,
features = NULL,
slot = NULL,
pseudocount.use = NULL,
pseudocount.use = 1,
fc.name = NULL,
mean.fxn = NULL,
...
) {
pseudocount.use <- pseudocount.use %||% 1
mean.fxn <- mean.fxn %||% rowMeans
fc.name <- fc.name %||% "avg_diff"
data <- t(x = Embeddings(object = object))
Expand Down Expand Up @@ -1143,7 +1162,7 @@ FoldChange.DimReduc <- function(
#' @param assay Assay to use in fold change calculation
#' @param slot Slot to pull data from
#' @param pseudocount.use Pseudocount to add to averaged expression values when
#' calculating logFC. 1 by default.
#' calculating logFC.
#' @param mean.fxn Function to use for fold change or average difference calculation
#' @param base The base with respect to which logarithms are computed.
#' @param fc.name Name of the fold change, average difference, or custom function column
Expand All @@ -1163,7 +1182,7 @@ FoldChange.Seurat <- function(
slot = 'data',
reduction = NULL,
features = NULL,
pseudocount.use = 1,
pseudocount.use = NULL,
mean.fxn = NULL,
base = 2,
fc.name = NULL,
Expand Down
6 changes: 5 additions & 1 deletion R/dimensional_reduction.R
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,10 @@ RunUMAP.default <- function(
object = reduction.model,
slot = "model"
)
# add num_precomputed_nns to <v0.1.13 uwot models to prevent errors with newer versions of uwot
if (!"num_precomputed_nns" %in% names(model)) {
model$num_precomputed_nns <- 1
}
if (length(x = model) == 0) {
stop(
"The provided reduction.model does not have a model stored. Please try running umot-learn on the object first",
Expand All @@ -1387,7 +1391,7 @@ RunUMAP.default <- function(
}
if (is.list(x = object)) {
if (ncol(object$idx) != model$n_neighbors) {
warning("Number of neighbors between query and reference ",
warning("Number of neighbors between query and reference ",
"is not equal to the number of neighbors within reference")
model$n_neighbors <- ncol(object$idx)
}
Expand Down
Loading

0 comments on commit 2b3584c

Please sign in to comment.