Skip to content

Commit

Permalink
Merge pull request #76 from stemangiola/aggregate-fix-assay-subset-fo…
Browse files Browse the repository at this point in the history
…r-complex-seurats

use DietSeurat instead of manual subsetting
  • Loading branch information
stemangiola authored Oct 30, 2023
2 parents 81ddf3f + 1af3dae commit c4aafa8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: tidyseurat
Title: Brings Seurat to the Tidyverse
Version: 0.7.4
Version: 0.7.5
Authors@R: c(person("Stefano", "Mangiola", email = "[email protected]",
role = c("aut", "cre")),
person("Maria", "Doyle", email = "[email protected]",
Expand All @@ -15,7 +15,7 @@ Depends:
ttservice (>= 0.3.8),
SeuratObject
Imports:
Seurat,
Seurat (>= 4.3.0),
tibble,
dplyr,
magrittr,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ exportMethods(aggregate_cells)
exportMethods(join_features)
importFrom(Matrix,rowSums)
importFrom(Seurat,Assays)
importFrom(Seurat,DietSeurat)
importFrom(Seurat,GetAssayData)
importFrom(Seurat,SplitObject)
importFrom(Seurat,VariableFeatures)
Expand Down
9 changes: 5 additions & 4 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ setMethod("join_features", "Seurat", function(.data,
#' @importFrom Matrix rowSums
#' @importFrom ttservice aggregate_cells
#' @importFrom SeuratObject DefaultAssay
#' @importFrom Seurat DietSeurat
#' @importFrom purrr map_int
#' @export
setMethod("aggregate_cells", "Seurat", function(.data,
Expand All @@ -140,7 +141,7 @@ setMethod("aggregate_cells", "Seurat", function(.data,
# Subset only wanted assays
if(!is.null(assays)){
DefaultAssay(.data) <- assays[1]
.data@assays <- .data@assays[assays]
.data = .data |> DietSeurat(assays = assays)
}

.data %>%
Expand All @@ -159,9 +160,9 @@ setMethod("aggregate_cells", "Seurat", function(.data,
) %>%
mutate(.feature=as.character(.feature))
) %>%
Reduce(function(...) full_join(..., by=c(".feature")), .)
)
) %>%
Reduce(function(...) full_join(..., by=c(".feature")), .),
.progress = TRUE
)) %>%
left_join(
.data %>%
as_tibble() %>%
Expand Down

0 comments on commit c4aafa8

Please sign in to comment.