Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: tidySingleCellExperiment
Title: Brings SingleCellExperiment to the Tidyverse
Version: 1.9.4
Version: 1.9.5
Authors@R: c(person("Stefano", "Mangiola", email = "[email protected]",
role = c("aut", "cre")) )
Description: tidySingleCellExperiment is an adapter that abstracts the 'SingleCellExperiment' container
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ importFrom(tidyr,spread)
importFrom(tidyr,unite)
importFrom(tidyr,unnest)
importFrom(tidyselect,eval_select)
importFrom(ttservice,aggregate_cells)
importFrom(ttservice,join_features)
importFrom(utils,data)
importFrom(utils,tail)
Expand Down
22 changes: 18 additions & 4 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ tidy.SingleCellExperiment <- function(object) {
#' @importFrom rlang enquo
#' @importFrom tibble enframe
#' @importFrom Matrix rowSums
#'
#' @importFrom ttservice aggregate_cells
#'
#' @name aggregate_cells
#' @rdname aggregate_cells
#'
Expand All @@ -157,7 +158,20 @@ tidy.SingleCellExperiment <- function(object) {
#' aggregate_cells(c(groups, ident), assays = "counts")
#'
#' @export
aggregate_cells <- function(.data, .sample = NULL, slot = "data", assays = NULL, aggregation_function = rowSums) {
NULL

#' aggregate_cells
#'
#' @docType methods
#' @rdname aggregate_cells
#'
#' @return An object containing the information for the specified features
#'
setMethod("aggregate_cells", "SingleCellExperiment", function(.data,
.sample = NULL,
slot = "data",
assays = NULL,
aggregation_function = Matrix::rowSums){

.sample = enquo(.sample)

Expand Down Expand Up @@ -191,7 +205,7 @@ aggregate_cells <- function(.data, .sample = NULL, slot = "data", assays = NULL,
left_join(.data %>% as_tibble() %>% subset(!!.sample), by = quo_names(.sample)) %>%
unnest(data) %>%

drop_class("tidySingleCellExperiment_nested") |>
drop_class("tidySingleCellExperiment_nested") %>%

as_SummarizedExperiment(.sample = !!.sample, .transcript = feature, .abundance = !!as.symbol(names(.data@assays)))
}
})
8 changes: 6 additions & 2 deletions man/aggregate_cells.Rd

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