Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seurat v4.0.3 #4608

Merged
merged 57 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
47cdb22
check reference.reduction in FindTransferAnchors
yuhanH Apr 30, 2021
0091105
Bugfix to as.SingleCellExperiment
bbimber May 25, 2021
85d5ea0
add CIPR to wrappers table
andrewwbutler May 26, 2021
05edace
Merge branch 'develop' into feat/store_ref.reduction
andrewwbutler May 27, 2021
d40234c
Merge pull request #565 from satijalab/docs/add_cipr
mojaveazure May 27, 2021
78c2c94
explicitly specify reference.reduction
andrewwbutler May 27, 2021
8b32544
Merge pull request #566 from satijalab/docs/mapping_vignette_update
andrewwbutler May 27, 2021
586afba
Merge branch 'develop' into feat/store_ref.reduction
andrewwbutler May 27, 2021
c93899a
minor style changes, update NEWS, bump version
andrewwbutler May 27, 2021
469dd48
Merge pull request #558 from satijalab/feat/store_ref.reduction
andrewwbutler May 28, 2021
3a80651
Minor style fixes
mojaveazure May 28, 2021
b152aed
Skip SCE tests on CRAN
mojaveazure May 28, 2021
410f968
Bump develop version
mojaveazure May 28, 2021
b83acea
Merge pull request #4532 from bbimber/SingleCellExperiment
mojaveazure May 28, 2021
ec9dbe2
Merge branch 'develop' of github.com:satijalab/seurat-private into de…
mojaveazure May 28, 2021
2d7beb5
fix assay metadata setting error
andrewwbutler May 28, 2021
892096f
UpdateSymbolList no longer searches aliases
mojaveazure May 28, 2021
b2abc82
Merge branch 'develop' into fix/sce_convert
andrewwbutler May 28, 2021
7990019
transfer scale.data slot to assay in SCE conversion
andrewwbutler May 28, 2021
7b817c0
enable alpha parameter for SpatialDimPlot
andrewwbutler May 28, 2021
b7ad561
add doc entry
andrewwbutler May 28, 2021
2287748
fix DimReduc conversion
andrewwbutler May 31, 2021
129920b
fix seuratdata
andrewwbutler May 31, 2021
e1abe08
another seuratdata fix
andrewwbutler May 31, 2021
75417fe
forgot quotes
andrewwbutler May 31, 2021
8d45e29
altExp fix
andrewwbutler Jun 1, 2021
66cbaee
fix multiassay in both versions
andrewwbutler Jun 1, 2021
ff626fe
Merge pull request #567 from satijalab/fix/sce_convert
mojaveazure Jun 1, 2021
a5cb5ed
bump version
andrewwbutler Jun 1, 2021
5f39ee9
Merge branch 'develop' into fix/UpdateSymbolList
andrewwbutler Jun 1, 2021
5991ca0
bump version, update NEWS
andrewwbutler Jun 2, 2021
8616d90
Merge pull request #568 from satijalab/fix/UpdateSymbolList
andrewwbutler Jun 2, 2021
42d4a01
merge
andrewwbutler Jun 2, 2021
7a996cf
bump version, update NEWS
andrewwbutler Jun 2, 2021
01a8a0c
Merge pull request #569 from satijalab/feat/sce_scaledata
andrewwbutler Jun 2, 2021
7a0e25e
Merge branch 'develop' into fix/SpatialPlot_alpha
andrewwbutler Jun 2, 2021
29a6331
add jitter option to FeatureScatter + related fxns
jaisonj708 Jun 4, 2021
aa18912
docs
jaisonj708 Jun 4, 2021
2506757
fix sce conversion when reducedDim is missing names
andrewwbutler Jun 4, 2021
53cc056
bump verion, update NEWS
andrewwbutler Jun 7, 2021
8debeb1
fix colname dropping issue in feature metadata
andrewwbutler Jun 7, 2021
60230d6
Merge pull request #570 from satijalab/fix/SpatialPlot_alpha
andrewwbutler Jun 7, 2021
dfa68df
Merge branch 'develop' into fix/sce_conversion
andrewwbutler Jun 7, 2021
8482f75
fix altExp convert
andrewwbutler Jun 7, 2021
ec94c09
make roundtrip names consistent when possible
andrewwbutler Jun 7, 2021
0ca5130
update NEWS, bump version
andrewwbutler Jun 7, 2021
ae27911
Merge pull request #572 from satijalab/fix/sce_conversion
andrewwbutler Jun 8, 2021
5e4037e
Merge branch 'develop' into feat/scatterJitter
andrewwbutler Jun 8, 2021
04ba209
bump version, update NEWS
andrewwbutler Jun 8, 2021
3ccb993
Merge pull request #571 from satijalab/feat/scatterJitter
andrewwbutler Jun 8, 2021
57217d8
release prep
andrewwbutler Jun 8, 2021
c3a2583
replace v4preprint with paper
andrewwbutler Jun 8, 2021
fa10ca2
Pin latest version of SeuratObject
mojaveazure Jun 9, 2021
0714eb0
Update CRAN comments
mojaveazure Jun 9, 2021
599d8ba
Fix broken documentation
mojaveazure Jun 9, 2021
7ffd355
Update dates
mojaveazure Jun 10, 2021
d0cd778
Merge pull request #573 from satijalab/release/4.0.3
mojaveazure Jun 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.2
Date: 2021-05-20
Version: 4.0.2.9002
Date: 2021-05-28
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
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Seurat develop

## Added

## Changes
- Fix issues with `as.SingleCellExperiment.Seurat` for the latest verion of SingleCellExperiment ([#4532](https://github.com/satijalab/seurat/pull/4532))
- Ensure proper reference.reduction is used in `MapQuery()`

# Seurat 4.0.2 (2020-03-20)
## Added
- New `AddAzimuthScores()` and `AddAzimuthResults()` functions
Expand Down
10 changes: 10 additions & 0 deletions R/integration.R
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ FindTransferAnchors <- function(
projected <- ifelse(test = reduction == "pcaproject", yes = TRUE, no = FALSE)
reduction.2 <- character()
feature.mean <- NULL
reference.reduction.init <- reference.reduction
if (normalization.method == "SCT") {
# ensure all residuals required are computed
query <- suppressWarnings(expr = GetResidual(object = query, assay = query.assay, features = features, verbose = FALSE))
Expand Down Expand Up @@ -1139,6 +1140,7 @@ FindTransferAnchors <- function(
}
slot(object = combined.ob, name = "reductions") <- reductions
command <- LogSeuratCommand(object = combined.ob, return.command = TRUE)
slot(command, name = 'params')$reference.reduction <- reference.reduction.init
anchor.set <- new(
Class = "TransferAnchorSet",
object.list = list(combined.ob),
Expand Down Expand Up @@ -1902,9 +1904,16 @@ MapQuery <- function(
projectumap.args = list(),
verbose = TRUE
) {

# determine anchor type
if (grepl(pattern = "pca", x = slot(object = anchorset, name = "command")$reduction)) {
anchor.reduction <- "pcaproject"
# check if the anchorset can be used for mapping
if (is.null(x = slot(object = anchorset, name = "command")$reference.reduction)) {
stop('The reference.reduction parameter was not set when running ',
'FindTransferAnchors, so the resulting AnchorSet object cannot be used ',
'in the MapQuery function.')
}
} else if (grepl(pattern = "cca", x = slot(object = anchorset, name = "command")$reduction)) {
anchor.reduction <- "cca"
ref.cca.embedding <- Embeddings(
Expand Down Expand Up @@ -1941,6 +1950,7 @@ MapQuery <- function(
stop("unkown type of anchors")
}


reference.reduction <- reference.reduction %||%
slot(object = anchorset, name = "command")$reference.reduction %||%
anchor.reduction
Expand Down
41 changes: 31 additions & 10 deletions R/objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) {
stop("One or more of the assays you are trying to convert is not in the Seurat object")
}
experiments <- list()
for (assayn in assay){
for (assayn in assay) {
assays = list(
counts = GetAssayData(object = x, assay = assayn, slot = "counts"),
logcounts = GetAssayData(object = x, assay = assayn, slot = "data"))
Expand All @@ -1187,24 +1187,45 @@ as.SingleCellExperiment.Seurat <- function(x, assay = NULL, ...) {
sce <- as(object = experiments[[1]], Class = "SingleCellExperiment")
sce <- SingleCellExperiment::SingleCellExperiment(sce, altExps = experiments)
orig.exp.name <- names(x = experiments[1])
sce <- SingleCellExperiment::swapAltExp(x = sce, name = orig.exp.name, saved = NULL)
sce <- SingleCellExperiment::swapAltExp(
x = sce,
name = orig.exp.name,
saved = NULL
)
metadata <- x[[]]
metadata$ident <- Idents(object = x)
SummarizedExperiment::colData(x = sce) <- S4Vectors::DataFrame(metadata)
for (assayn in assay){
sce <- SingleCellExperiment::swapAltExp(x = sce, name = assayn, saved = orig.exp.name)
SummarizedExperiment::rowData(x = sce) <- S4Vectors::DataFrame(x[[assayn]][[]])
sce <- SingleCellExperiment::swapAltExp(x = sce, name = orig.exp.name, saved = assayn)
for (assayn in assay) {
if (assayn != orig.exp.name) {
sce <- SingleCellExperiment::swapAltExp(
x = sce,
name = assayn,
saved = orig.exp.name
)
SummarizedExperiment::rowData(x = sce) <- S4Vectors::DataFrame(x[[assayn]][[]])
sce <- SingleCellExperiment::swapAltExp(
x = sce,
name = orig.exp.name,
saved = assayn
)
}
}
for (dr in FilterObjects(object = x, classes.keep = "DimReduc")) {
assay.used <- DefaultAssay(object = x[[dr]])
if (assay.used %in% SingleCellExperiment::altExpNames(x = sce)) {
sce <- SingleCellExperiment::swapAltExp(x = sce, name = assay.used, saved = orig.exp.name)
SingleCellExperiment::reducedDim(x = sce, toupper(x = dr)) <- Embeddings(object = x[[dr]])
sce <- SingleCellExperiment::swapAltExp(x = sce, name = orig.exp.name, saved = assay.used)
sce <- SingleCellExperiment::swapAltExp(
x = sce,
name = assay.used,
saved = orig.exp.name
)
SingleCellExperiment::reducedDim(x = sce, type = toupper(x = dr)) <- Embeddings(object = x[[dr]])
sce <- SingleCellExperiment::swapAltExp(
x = sce,
name = orig.exp.name,
saved = assay.used
)
}
}
sce <- SingleCellExperiment::swapAltExp(x = sce, name = orig.exp.name, saved = NULL)
return(sce)
}

Expand Down
27 changes: 27 additions & 0 deletions tests/testthat/test_objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,30 @@ test_that("Top works", {
expect_equal(length(tpc1.sub[[1]]), 40)
expect_equal(length(tpc1.sub[[2]]), 39)
})


# Tests for SCE conversion
# ------------------------------------------------------------------------------
test_that("as.SingleCellExperiment works", {
skip_on_cran()
if (requireNamespace('SingleCellExperiment', quietly = TRUE)) {
mat <- matrix(1:100, ncol = 10)
colnames(mat) <- LETTERS[1:10]
rownames(mat) <- LETTERS[1:10]
seuratObj <- Seurat::CreateSeuratObject(mat)
sce <- as.SingleCellExperiment(seuratObj)

expect_equal(ncol(sce), 10)
expect_equal(nrow(sce), 10)
# expect_equal(length(SingleCellExperiment::altExps(sce)), 0)
# expect_equal(SingleCellExperiment::mainExpName(sce), 'RNA')

seuratObj <- Seurat::CreateSeuratObject(mat)
seuratObj[['ADT']] <- CreateAssayObject(mat)
sce <- as.SingleCellExperiment(seuratObj)
expect_equal(ncol(sce), 10)
expect_equal(nrow(sce), 10)
# expect_equal(names(SingleCellExperiment::altExps(sce)), 'ADT')
# expect_equal(SingleCellExperiment::mainExpName(sce), 'RNA')
}
})