Skip to content

Commit

Permalink
Merge pull request #170 from mojaveazure/release/5.0.1
Browse files Browse the repository at this point in the history
Release/5.0.1
  • Loading branch information
mojaveazure authored Nov 18, 2023
2 parents 78f71fe + dd1072f commit 4d3739b
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 100 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: SeuratObject
Type: Package
Title: Data Structures for Single Cell Data
Version: 5.0.0
Version: 5.0.1
Authors@R: c(
person(given = 'Rahul', family = 'Satija', email = 'rsatija@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0001-9448-8833')),
person(given = 'Paul', family = 'Hoffman', email = 'seurat@nygenome.org', role = c('aut', 'cre'), comment = c(ORCID = '0000-0002-7693-8957')),
Expand Down Expand Up @@ -46,7 +46,7 @@ Imports:
future.apply,
grDevices,
grid,
Matrix (>= 1.6.1),
Matrix (>= 1.6.3),
methods,
progressr,
Rcpp (>= 1.0.5),
Expand Down
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,12 @@ exportMethods(show)
importClassesFrom(Matrix,CsparseMatrix)
importClassesFrom(Matrix,Matrix)
importClassesFrom(Matrix,RsparseMatrix)
importClassesFrom(Matrix,compMatrix)
importClassesFrom(Matrix,dMatrix)
importClassesFrom(Matrix,dgCMatrix)
importClassesFrom(Matrix,dsparseMatrix)
importClassesFrom(Matrix,generalMatrix)
importClassesFrom(Matrix,sparseMatrix)
importClassesFrom(sp,CRS)
importClassesFrom(sp,Spatial)
importClassesFrom(sp,SpatialPoints)
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# SeuratObject 5.0.1

## Changes:
- Update internal calls to `GetAssayData()` to use `layer` instead of `slot` (#160)
- Update Matrix version to 1.6-2 (#164)
- Change layer-saving in `SaveSeuratRds()` to move all layers instead of just those in `tempdir()` (#169)
- Update internal calls to `SetAssayData()` to use `layer` instead of `slot` (#171)
- Replace internal calls of `FilterObjects()` to `.FilterObjects()` (#171)

# SeuratObject 5.0.0
## Added
- New `Assay5` class with support for layers; layers provide support for:
Expand Down
34 changes: 17 additions & 17 deletions R/assay.R
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ Features.Assay <- function(
}
layer <- layer[1L] %||% 'data'
layer <- match.arg(arg = layer)
features <- rownames(x = GetAssayData(object = x, slot = layer))
features <- rownames(x = GetAssayData(object = x, layer = layer))
if (!length(x = features)) {
features <- NULL
}
Expand Down Expand Up @@ -370,7 +370,7 @@ FetchData.Assay <- function(
x = vars
)
# Pull expression information
mat <- GetAssayData(object = object, slot = layer)
mat <- GetAssayData(object = object, layer = layer)
if (IsMatrixEmpty(x = mat)) {
abort(message = paste("Layer", sQuote(x = layer), "is empty in this assay"))
}
Expand Down Expand Up @@ -736,7 +736,7 @@ RenameCells.Assay <- function(object, new.names = NULL, ...) {
CheckDots(...)
names(new.names) <- NULL
for (data.slot in c("counts", "data", "scale.data")) {
old.data <- GetAssayData(object = object, slot = data.slot)
old.data <- GetAssayData(object = object, layer = data.slot)
if (ncol(x = old.data) <= 1) {
next
}
Expand Down Expand Up @@ -1370,7 +1370,7 @@ merge.Assay <- function(
}
combined.assay <- SetAssayData(
object = combined.assay,
slot = "data",
layer = "data",
new.data = merged.data
)
}
Expand Down Expand Up @@ -1465,17 +1465,17 @@ subset.Assay <- function(x, cells = NULL, features = NULL, ...) {
if (length(x = features) == 0) {
abort(message = "Cannot find features provided")
}
if (ncol(x = GetAssayData(object = x, slot = 'counts')) == ncol(x = x)) {
slot(object = x, name = "counts") <- GetAssayData(object = x, slot = "counts")[features, cells, drop = FALSE]
if (ncol(x = GetAssayData(object = x, layer = 'counts')) == ncol(x = x)) {
slot(object = x, name = "counts") <- GetAssayData(object = x, layer = "counts")[features, cells, drop = FALSE]
}
slot(object = x, name = "data") <- GetAssayData(object = x, slot = "data")[features, cells, drop = FALSE]
cells.scaled <- colnames(x = GetAssayData(object = x, slot = "scale.data"))
slot(object = x, name = "data") <- GetAssayData(object = x, layer = "data")[features, cells, drop = FALSE]
cells.scaled <- colnames(x = GetAssayData(object = x, layer = "scale.data"))
cells.scaled <- cells.scaled[cells.scaled %in% cells]
cells.scaled <- cells.scaled[na.omit(object = match(x = colnames(x = x), table = cells.scaled))]
features.scaled <- rownames(x = GetAssayData(object = x, slot = 'scale.data'))
features.scaled <- rownames(x = GetAssayData(object = x, layer = 'scale.data'))
features.scaled <- intersect(x = features, y = features.scaled)
slot(object = x, name = "scale.data") <- if (length(x = cells.scaled) > 0 && length(x = features.scaled) > 0) {
GetAssayData(object = x, slot = "scale.data")[features.scaled, cells.scaled, drop = FALSE]
GetAssayData(object = x, layer = "scale.data")[features.scaled, cells.scaled, drop = FALSE]
} else {
new(Class = 'matrix')
}
Expand Down Expand Up @@ -1625,7 +1625,7 @@ setMethod(
signature = c(x = 'Assay'),
definition = function(x, na.rm = FALSE, dims = 1, ..., slot = 'data') {
return(Matrix::colMeans(
x = GetAssayData(object = x, slot = slot),
x = GetAssayData(object = x, layer = slot),
na.rm = na.rm,
dims = dims,
...
Expand All @@ -1649,7 +1649,7 @@ setMethod(
signature = c(x = 'Assay'),
definition = function(x, na.rm = FALSE, dims = 1, ..., slot = 'data') {
return(Matrix::colSums(
x = GetAssayData(object = x, slot = slot),
x = GetAssayData(object = x, layer = slot),
na.rm = na.rm,
dims = dims,
...
Expand All @@ -1673,7 +1673,7 @@ setMethod(
signature = c(x = 'Assay'),
definition = function(x, na.rm = FALSE, dims = 1, ..., slot = 'data') {
return(Matrix::rowMeans(
x = GetAssayData(object = x, slot = slot),
x = GetAssayData(object = x, layer = slot),
na.rm = na.rm,
dims = dims,
...
Expand All @@ -1697,7 +1697,7 @@ setMethod(
signature = c(x = 'Assay'),
definition = function(x, na.rm = FALSE, dims = 1, ..., slot = 'data') {
return(Matrix::rowSums(
x = GetAssayData(object = x, slot = slot),
x = GetAssayData(object = x, layer = slot),
na.rm = na.rm,
dims = dims,
...
Expand Down Expand Up @@ -1927,11 +1927,11 @@ SubsetVST <- function(sct.info, cells, features) {
#' @noRd
#'
ValidateDataForMerge <- function(assay, slot) {
mat <- GetAssayData(object = assay, slot = slot)
mat <- GetAssayData(object = assay, layer = slot)
if (any(dim(x = mat) == c(0, 0))) {
slots.to.check <- setdiff(x = c("counts", "data", "scale.data"), y = slot)
for (ss in slots.to.check) {
data.dims <- dim(x = GetAssayData(object = assay, slot = ss))
data.dims <- dim(x = GetAssayData(object = assay, layer = ss))
data.slot <- ss
if (!any(data.dims == c(0, 0))) {
break
Expand All @@ -1944,7 +1944,7 @@ ValidateDataForMerge <- function(assay, slot) {
data = 0,
nrow = data.dims[1],
ncol = data.dims[2],
dimnames = dimnames(x = GetAssayData(object = assay, slot = data.slot))
dimnames = dimnames(x = GetAssayData(object = assay, layer = data.slot))
)
mat <- as.sparse(x = mat)
}
Expand Down
4 changes: 2 additions & 2 deletions R/assay5.R
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ SetAssayData.StdAssay <- function(
)
layer <- slot
}
LayerData(object = object, layer = slot) <- new.data
LayerData(object = object, layer = layer) <- new.data
return(object)
}

Expand Down Expand Up @@ -2733,7 +2733,7 @@ setAs(
# browser()
# Add the expression matrices
for (i in c('counts', 'data', 'scale.data')) {
adata <- GetAssayData(object = from, slot = i)
adata <- GetAssayData(object = from, layer = i)
if (IsMatrixEmpty(x = adata)) {
next
}
Expand Down
Loading

0 comments on commit 4d3739b

Please sign in to comment.