Skip to content

Commit

Permalink
Merge pull request satijalab#666 from satijalab/fix/fix_findmarkers
Browse files Browse the repository at this point in the history
Fix FindMarkers post Integration/Transfer
  • Loading branch information
saketkc authored Nov 18, 2022
2 parents 22f0134 + e13a494 commit dfd6713
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: Seurat
Version: 4.2.0.9001
Version: 4.2.1.9001
Date: 2022-09-21
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.
Expand Down Expand Up @@ -95,7 +95,7 @@ Collate:
'tree.R'
'utilities.R'
'zzz.R'
RoxygenNote: 7.2.1
RoxygenNote: 7.2.2
Encoding: UTF-8
Suggests:
ape,
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Unreleased
# Unreleased

## Changes
- Fix bug in `FindMarkers()` when run post Integration/Transfer ([#6856](https://github.com/satijalab/seurat/issues/6586))

# Seurat 4.2.1 (2022-11-08)

## Changes
- Replaced import from `spatstat.core` with `spatstat.explore`
Expand Down
11 changes: 9 additions & 2 deletions R/differential_expression.R
Original file line number Diff line number Diff line change
Expand Up @@ -989,9 +989,16 @@ FindMarkers.Seurat <- function(
command = norm.command,
value = "normalization.method"
)
} else {
} else if (length(x = intersect(x = c("FindIntegrationAnchors", "FindTransferAnchors"), y = Command(object = object)))) {
command <- intersect(x = c("FindIntegrationAnchors", "FindTransferAnchors"), y = Command(object = object))[1]
Command(
object = object,
command = command,
value = "normalization.method"
)
} else {
NULL
}
}
de.results <- FindMarkers(
object = data.use,
slot = slot,
Expand Down
2 changes: 1 addition & 1 deletion man/reexports.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions tests/testthat/test_differential_expression.R
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,34 @@ test_that("FindAllMarkers works as expected", {
expect_equal(rownames(results.pseudo)[1], "HLA-DPB1")
})


# Tests for running FindMarkers post integration/transfer
ref <- pbmc_small
ref <- FindVariableFeatures(object = ref, verbose = FALSE, nfeatures = 100)
query <- CreateSeuratObject(
counts = GetAssayData(object = pbmc_small[['RNA']], slot = "counts") + rpois(n = ncol(pbmc_small), lambda = 1)
)
query2 <- CreateSeuratObject(
counts = GetAssayData(object = pbmc_small[['RNA']], slot = "counts")[, 1:40] + rpois(n = ncol(pbmc_small), lambda = 1)
)
query.list <- list(query, query2)
query.list <- lapply(X = query.list, FUN = NormalizeData, verbose = FALSE)
query.list <- lapply(X = query.list, FUN = FindVariableFeatures, verbose = FALSE, nfeatures = 100)
query.list <- lapply(X = query.list, FUN = ScaleData, verbose = FALSE)
query.list <- suppressWarnings(lapply(X = query.list, FUN = RunPCA, verbose = FALSE, npcs = 20))

anchors <- suppressMessages(suppressWarnings(FindIntegrationAnchors(object.list = c(ref, query.list), k.filter = NA, verbose = FALSE)))
object <- suppressMessages(IntegrateData(anchorset = anchors, k.weight = 25, verbose = FALSE))
object <- suppressMessages(ScaleData(object, verbose = FALSE))
object <- suppressMessages(RunPCA(object, verbose = FALSE))
object <- suppressMessages(FindNeighbors(object = object, verbose = FALSE))
object <- suppressMessages(FindClusters(object, verbose = FALSE))
markers <- FindMarkers(object = object, ident.1="0", ident.2="1")
test_that("FindMarkers recognizes log normalizatio", {
expect_equal(markers[1, "p_val"], 1.598053e-14)
expect_equal(markers[1, "avg_log2FC"], -2.614686, tolerance = 1e-6)
})

# Tests for FindConservedMarkers
# -------------------------------------------------------------------------------

Expand Down

0 comments on commit dfd6713

Please sign in to comment.