Skip to content

Commit

Permalink
Merge pull request satijalab#260 from satijalab/fix/SCTMerge
Browse files Browse the repository at this point in the history
Fix for multi-sct merges
  • Loading branch information
mojaveazure authored Feb 19, 2020
2 parents 6828853 + af4d106 commit 8b55a01
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: Seurat
Version: 3.1.3.9003
Version: 3.1.3.9004
Date: 2020-02-13
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>, and Butler A and Satija R (2017) <doi:10.1101/164889> for more details.
Expand Down
5 changes: 5 additions & 0 deletions R/objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -5667,19 +5667,24 @@ merge.Assay <- function(
if (all(IsSCT(assay = assays))) {
vst.set.new <- list()
idx <- 1
umi.assay.new <- list()
for (i in 1:length(x = assays)) {
vst.set.old <- Misc(object = assays[[i]], slot = "vst.set")
umi.assay.old <- Misc(object = assays[[i]], slot = "umi.assay")
if (!is.null(x = vst.set.old)) {
for (j in 1:length(x = vst.set.old)) {
vst.set.new[[idx]] <- vst.set.old[[j]]
umi.assay.new[[idx]] <- umi.assay.old[[j]]
idx <- idx + 1
}
} else if (!is.null(x = Misc(object = assays[[i]], slot = "vst.out"))) {
vst.set.new[[idx]] <- Misc(object = assays[[i]], slot = "vst.out")
umi.assay.new[[idx]] <- Misc(object = assays[[i]], slot = "umi.assay")
idx <- idx + 1
}
}
Misc(object = combined.assay, slot = "vst.set") <- vst.set.new
Misc(object = combined.assay, slot = "umi.assay") <- umi.assay.new
scale.data <- do.call(
what = cbind,
args = lapply(X = assays, FUN = function(x) GetAssayData(object = x, slot = "scale.data"))
Expand Down
7 changes: 5 additions & 2 deletions R/preprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,16 @@ GetResidual <- function(
object,
features,
assay = "SCT",
umi.assay = "RNA",
umi.assay = NULL,
clip.range = NULL,
replace.value = FALSE,
verbose = TRUE
) {
if (!IsSCT(assay = object[[assay]])) {
stop(assay, " assay was not generated by SCTransform")
}
umi.assay <- umi.assay %||% Misc(object = object[[assay]], slot = "umi.assay")
umi.assay <- umi.assay %||% "RNA" # for object created in 3.1.1 or earlier, default to RNA
if (replace.value) {
new_features <- features
} else {
Expand Down Expand Up @@ -534,7 +536,7 @@ GetResidual <- function(
object.v <- GetResidualVstOut(
object = object.v,
assay = assay,
umi.assay = umi.assay,
umi.assay = umi.assay[[v]],
new_features = new_features,
vst_out = vst_out,
clip.range = clip.range,
Expand Down Expand Up @@ -1353,6 +1355,7 @@ SCTransform <- function(
# save clip.range into vst model
vst.out$arguments$sct.clip.range <- clip.range
Misc(object = assay.out, slot = 'vst.out') <- vst.out
Misc(object = assay.out, slot = 'umi.assay') <- assay
# also put gene attributes in meta.features
assay.out[[paste0('sct.', names(x = vst.out$gene_attr))]] <- vst.out$gene_attr
assay.out[['sct.variable']] <- rownames(x = assay.out[[]]) %in% top.features
Expand Down
2 changes: 1 addition & 1 deletion man/GetResidual.Rd

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

0 comments on commit 8b55a01

Please sign in to comment.