Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
alanocallaghan committed Mar 12, 2021
2 parents b4d9355 + 04dabdd commit a81090c
Show file tree
Hide file tree
Showing 44 changed files with 307 additions and 67 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Seurat
Version: 4.0.0
Date: 2021-01-27
Version: 4.0.0.9011
Date: 2021-02-26
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
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
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
16 changes: 16 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Seurat develop

## Added
- Add direction option to `PlotClusterTree()`
- Add `cols` parameter to `JackStrawPlot()`

## 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.

# Seurat 4.0.0 (2020-01-27)
## Added
- Expose `FoldChange()` component in `FindMarkers()`.
Expand All @@ -18,6 +32,7 @@
- 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"
Expand All @@ -32,6 +47,7 @@
- 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
40 changes: 21 additions & 19 deletions R/integration.R
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit a81090c

Please sign in to comment.