Skip to content

Commit

Permalink
Merge pull request #4247 from satijalab/develop
Browse files Browse the repository at this point in the history
Seurat v4.0.1
  • Loading branch information
mojaveazure committed Mar 18, 2021
2 parents 29e7eb7 + e17c94d commit 4e868fc
Show file tree
Hide file tree
Showing 53 changed files with 678 additions and 92 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
@@ -1,6 +1,6 @@
Package: Seurat
Version: 4.0.0
Date: 2021-01-27
Version: 4.0.1
Date: 2021-03-17
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 @@ -68,7 +68,8 @@ Imports:
sctransform (>= 0.3.2),
SeuratObject,
shiny,
spatstat,
spatstat.core,
spatstat.geom,
stats,
tibble,
tools,
Expand Down
8 changes: 6 additions & 2 deletions NAMESPACE
Expand Up @@ -40,6 +40,7 @@ S3method(GetImage,VisiumV1)
S3method(GetTissueCoordinates,STARmap)
S3method(GetTissueCoordinates,SlideSeq)
S3method(GetTissueCoordinates,VisiumV1)
S3method(HVFInfo,SCTAssay)
S3method(IntegrateEmbeddings,IntegrationAnchorSet)
S3method(IntegrateEmbeddings,TransferAnchorSet)
S3method(MappingScore,AnchorSet)
Expand Down Expand Up @@ -261,6 +262,7 @@ export(Radius)
export(Read10X)
export(Read10X_Image)
export(Read10X_h5)
export(ReadMtx)
export(ReadSlideSeq)
export(Reductions)
export(RegroupIdents)
Expand Down Expand Up @@ -555,7 +557,9 @@ importFrom(grid,unit)
importFrom(grid,viewport)
importFrom(httr,GET)
importFrom(httr,accept_json)
importFrom(httr,build_url)
importFrom(httr,content)
importFrom(httr,parse_url)
importFrom(httr,status_code)
importFrom(httr,timeout)
importFrom(ica,icafast)
Expand Down Expand Up @@ -636,8 +640,8 @@ importFrom(shiny,sliderInput)
importFrom(shiny,stopApp)
importFrom(shiny,updateSelectInput)
importFrom(shiny,verbatimTextOutput)
importFrom(spatstat,markvario)
importFrom(spatstat,ppp)
importFrom(spatstat.core,markvario)
importFrom(spatstat.geom,ppp)
importFrom(stats,aggregate)
importFrom(stats,anova)
importFrom(stats,approxfun)
Expand Down
27 changes: 23 additions & 4 deletions NEWS.md
@@ -1,6 +1,23 @@
# Seurat 4.0.0 (2020-01-27)
# Seurat 4.0.1 (2020-03-17)
## Added
- Expose `FoldChange()` component in `FindMarkers()`.
- Add direction option to `PlotClusterTree()`
- Add `cols` parameter to `JackStrawPlot()`
- Add `ReadMtx()` to read local and remote mtx files with associated cell and feature name files

## Changes
- Equality added to differential expression thresholds in `FindMarkers` (e.g, >= logfc.threshold rather than >)
- `Read10X()` now prepends dataset number for first dataset when reading multiple datasets
- Bug fix for `subset.AnchorSet()`
- Bug fix for fold change values in `FindMarkers()` when setting a different pseudocount ([#4111](https://github.com/satijalab/seurat/pull/4111))
- Bug fix for `RunLDA()` related to proper passing of assay parameter.
- When using `order=TRUE` in `SingleDimPlot()`, print NA points under all others.
- Remove default parameter value for `data.dir` in `Read10X()`
- Import spatstat fxns from subpackages (spatstat.core, spatstat.geom)
- `RunUMAP` now checks for graph/neighbor consistency

# Seurat 4.0.0 (2020-01-27)
## Added
- Expose `FoldChange()` component in `FindMarkers()`.
- Add the `merge.DimReduc` method
- Add `IntegrateEmbeddings()` to correct embeddings of `DimReduc`s
- Add `ProjectUMAP()` to project query cells into a reference UMAP space
Expand All @@ -11,27 +28,29 @@
- Add `FindSubCluster()` to further cluster existing clusters
- Add supervised PCA functionality via `RunSPCA()`
- Add functionality to enable weighted nearest neighbor analyses via `FindMultiModalNeighbors()`
- Add neighbor visualization plot via `NNPlot()`.
- Add neighbor visualization plot via `NNPlot()`.
- Add `PredictAssay()` to impute expression or embeddings from nearest neighbors
- Add `Graphs()` function to access the names of the stored Graph objects or pull a specific one
- Add checks for NA, NaN, logical, non-integer, and infinite values during CreateAssayObject and NormalizeData.default
- Add `AnnotateAnchors()` to aid in AnchorSet interpretation as well as `subset.AnchorSet()`
- Add flexibility of choice for cell column in `Read10X()`
- Add rasterization option to `FeatureScatter()` and `VariableFeaturePlot()`
- Add step1 feature parameters in the SCTModel via `PrepVSTResults()`

## Changes
- Default neighbor finding algorithm changed from "rann" to "annoy"
- Default `ncells` parameter in `SCTransform()` changed to 5000
- Default fold change in `FindMarkers()` changed from ln to log2
- Implementation improvements to `AverageExpression()`
- `AnchorSet` class re-implemented as a virtual class from which `IntegrationAnchorSet` and `TransferAnchorSet` now inherit.
- `AnchorSet` class re-implemented as a virtual class from which `IntegrationAnchorSet` and `TransferAnchorSet` now inherit.
- Point size in `VlnPlot()` now set automatically if not specified
- Return the sample.tree properly when integrating with a single reference dataset
- Replace `as.character.quosure` usage with `as_label` due to deprecation
- Minor changes to the exact calculation of the anchor weight matrix
- Default rasterization limit in `DimPlot()` and `FeaturePlot()` changed from 50,000 to 100,000
- `SCTransform()` now returns a formalized `Assay` subclass `SCTAssay()`
- When using `normalization.method='SCT'` in `FindTransferAnchors()`, normalize query using reference SCT model when possible.
- Change default Neighbor name in `FindNeighbors` to `Assay.nn`

## Removed
- `CreateGeneActivityMatrix` replaced by `Signac::GeneActivity()`
Expand Down
21 changes: 19 additions & 2 deletions R/clustering.R
Expand Up @@ -559,7 +559,11 @@ FindNeighbors.default <- function(
# find the k-nearest neighbors for each single cell
if (!distance.matrix) {
if (verbose) {
message("Computing nearest neighbor graph")
if (return.neighbor) {
message("Computing nearest neighbors")
} else {
message("Computing nearest neighbor graph")
}
}
nn.ranked <- NNHelper(
data = object,
Expand Down Expand Up @@ -709,6 +713,11 @@ FindNeighbors.dist <- function(
#' @param do.plot Plot SNN graph on tSNE coordinates
#' @param graph.name Optional naming parameter for stored (S)NN graph
#' (or Neighbor object, if return.neighbor = TRUE). Default is assay.name_(s)nn.
#' To store both the neighbor graph and the shared nearest neighbor (SNN) graph,
#' you must supply a vector containing two names to the \code{graph.name}
#' parameter. The first element in the vector will be used to store the nearest
#' neighbor (NN) graph, and the second element used to store the SNN graph. If
#' only one name is supplied, only the NN graph is stored.
#'
#' @importFrom igraph graph.adjacency plot.igraph E
#'
Expand Down Expand Up @@ -787,7 +796,15 @@ FindNeighbors.Seurat <- function(
if (length(x = neighbor.graphs) == 1) {
neighbor.graphs <- list(nn = neighbor.graphs)
}
graph.name <- graph.name %||% paste0(assay, "_", names(x = neighbor.graphs))
graph.name <- graph.name %||%
if (return.neighbor) {
paste0(assay, ".", names(x = neighbor.graphs))
} else {
paste0(assay, "_", names(x = neighbor.graphs))
}
if (length(x = graph.name) == 1) {
message("Only one graph name supplied, storing nearest-neighbor graph only")
}
for (ii in 1:length(x = graph.name)) {
if (inherits(x = neighbor.graphs[[ii]], what = "Graph")) {
DefaultAssay(object = neighbor.graphs[[ii]]) <- assay
Expand Down
2 changes: 2 additions & 0 deletions R/convenience.R
Expand Up @@ -32,6 +32,7 @@ PCAPlot <- function(object, ...) {

#' @rdname SpatialPlot
#' @concept convenience
#' @concept spatial
#' @export
#'
SpatialDimPlot <- function(
Expand Down Expand Up @@ -82,6 +83,7 @@ SpatialDimPlot <- function(

#' @rdname SpatialPlot
#' @concept convenience
#' @concept spatial
#' @export
#'
SpatialFeaturePlot <- function(
Expand Down
14 changes: 9 additions & 5 deletions R/differential_expression.R
Expand Up @@ -513,14 +513,14 @@ FindMarkers.default <- function(
# feature selection (based on percentages)
alpha.min <- pmax(fc.results$pct.1, fc.results$pct.2)
names(x = alpha.min) <- rownames(x = fc.results)
features <- names(x = which(x = alpha.min > min.pct))
features <- names(x = which(x = alpha.min >= min.pct))
if (length(x = features) == 0) {
warning("No features pass min.pct threshold; returning empty data.frame")
return(fc.results[features, ])
}
alpha.diff <- alpha.min - pmin(fc.results$pct.1, fc.results$pct.2)
features <- names(
x = which(x = alpha.min > min.pct & alpha.diff > min.diff.pct)
x = which(x = alpha.min >= min.pct & alpha.diff >= min.diff.pct)
)
if (length(x = features) == 0) {
warning("No features pass min.diff.pct threshold; returning empty data.frame")
Expand All @@ -531,9 +531,9 @@ FindMarkers.default <- function(
total.diff <- fc.results[, 1] #first column is logFC
names(total.diff) <- rownames(fc.results)
features.diff <- if (only.pos) {
names(x = which(x = total.diff > logfc.threshold))
names(x = which(x = total.diff >= logfc.threshold))
} else {
names(x = which(x = abs(x = total.diff) > logfc.threshold))
names(x = which(x = abs(x = total.diff) >= logfc.threshold))
}
features <- intersect(x = features, y = features.diff)
if (length(x = features) == 0) {
Expand Down Expand Up @@ -627,6 +627,7 @@ FindMarkers.Assay <- function(
cells.1 = cells.1,
cells.2 = cells.2,
features = features,
pseudocount.use = pseudocount.use,
mean.fxn = mean.fxn,
fc.name = fc.name,
base = base
Expand Down Expand Up @@ -680,6 +681,7 @@ FindMarkers.DimReduc <- function(
min.cells.group = 3,
pseudocount.use = 1,
mean.fxn = rowMeans,
fc.name = NULL,
...

) {
Expand All @@ -705,7 +707,9 @@ FindMarkers.DimReduc <- function(
object = object,
cells.1 = cells.1,
cells.2 = cells.2,
features = features
features = features,
mean.fxn = mean.fxn,
fc.name = fc.name
)
# subsample cell groups if they are too large
if (max.cells.per.ident < Inf) {
Expand Down
20 changes: 19 additions & 1 deletion R/dimensional_reduction.R
Expand Up @@ -1654,9 +1654,27 @@ RunUMAP.Seurat <- function(
call. = FALSE
)
}
} else if (!is.null( x = nn.name)){
} else if (!is.null(x = nn.name)) {
if (!inherits(x = object[[nn.name]], what = "Neighbor")) {
stop(
"Please specify a Neighbor object name, ",
"instead of the name of a ",
class(object[[nn.name]]),
" object",
call. = FALSE
)
}
data.use <- object[[nn.name]]
} else if (!is.null(x = graph)) {
if (!inherits(x = object[[graph]], what = "Graph")) {
stop(
"Please specify a Graph object name, ",
"instead of the name of a ",
class(object[[graph]]),
" object",
call. = FALSE
)
}
data.use <- object[[graph]]
} else {
stop("Please specify one of dims, features, or graph")
Expand Down
40 changes: 21 additions & 19 deletions R/integration.R
Expand Up @@ -492,7 +492,8 @@ FindIntegrationAnchors <- function(
#' }
#' @param reference.reduction Name of dimensional reduction to use from the
#' reference if running the pcaproject workflow. Optionally enables reuse of
#' precomputed reference dimensional reduction.
#' precomputed reference dimensional reduction. If NULL (default), use a PCA
#' computed on the reference object.
#' @param project.query Project the PCA from the query dataset onto the
#' reference. Use only in rare cases where the query dataset has a much larger
#' cell number, but the reference dataset has a unique assay for transfer. In
Expand Down Expand Up @@ -627,25 +628,25 @@ FindTransferAnchors <- function(
if (normalization.method == "SCT") {
# ensure all residuals required are computed
query <- suppressWarnings(expr = GetResidual(object = query, assay = query.assay, features = features, verbose = FALSE))
if (is.null(x = reference.reduction)) {
reference <- suppressWarnings(expr = GetResidual(object = reference, assay = reference.assay, features = features, verbose = FALSE))
features <- intersect(
x = features,
y = intersect(
x = rownames(x = GetAssayData(object = query[[query.assay]], slot = "scale.data")),
y = rownames(x = GetAssayData(object = reference[[reference.assay]], slot = "scale.data"))
if (is.null(x = reference.reduction)) {
reference <- suppressWarnings(expr = GetResidual(object = reference, assay = reference.assay, features = features, verbose = FALSE))
features <- intersect(
x = features,
y = intersect(
x = rownames(x = GetAssayData(object = query[[query.assay]], slot = "scale.data")),
y = rownames(x = GetAssayData(object = reference[[reference.assay]], slot = "scale.data"))
)
)
)
reference[[reference.assay]] <- as(
object = CreateAssayObject(
data = GetAssayData(object = reference[[reference.assay]], slot = "scale.data")[features, ]),
Class = "SCTAssay"
)
reference <- SetAssayData(
object = reference,
slot = "scale.data",
assay = reference.assay,
new.data = as.matrix(x = GetAssayData(object = reference[[reference.assay]], slot = "data"))
reference[[reference.assay]] <- as(
object = CreateAssayObject(
data = GetAssayData(object = reference[[reference.assay]], slot = "scale.data")[features, ]),
Class = "SCTAssay"
)
reference <- SetAssayData(
object = reference,
slot = "scale.data",
assay = reference.assay,
new.data = as.matrix(x = GetAssayData(object = reference[[reference.assay]], slot = "data"))
)
}
query[[query.assay]] <- as(
Expand Down Expand Up @@ -2675,6 +2676,7 @@ TransferData <- function(
#' @rdname AnnotateAnchors
#' @export
#' @method AnnotateAnchors default
#' @concept integration
#'
AnnotateAnchors.default <- function(
anchors,
Expand Down
3 changes: 2 additions & 1 deletion R/mixscape.R
Expand Up @@ -532,7 +532,7 @@ RunLDA.default <- function(
#'
RunLDA.Assay <- function(
object,
assay,
assay = NULL,
labels,
features = NULL,
verbose = TRUE,
Expand Down Expand Up @@ -595,6 +595,7 @@ RunLDA.Seurat <- function(
assay.data <- GetAssay(object = object, assay = assay)
reduction.data <- RunLDA(
object = assay.data,
assay = assay,
labels = labels,
features = features,
verbose = verbose,
Expand Down

0 comments on commit 4e868fc

Please sign in to comment.