Skip to content

Commit 978da51

Browse files
authored
Merge pull request #104 from stemangiola/fix-aggregate-with-rowdata
Fix aggregate with rowdata
2 parents 8a9dedf + e2f7428 commit 978da51

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: tidySingleCellExperiment
33
Title: Brings SingleCellExperiment to the Tidyverse
4-
Version: 1.13.3
4+
Version: 1.15.1
55
Authors@R: c(person("Stefano", "Mangiola",
66
comment=c(ORCID="0000-0001-7474-836X"),
77
@@ -68,6 +68,6 @@ biocViews:
6868
AssayDomain, Infrastructure, RNASeq, DifferentialExpression, SingleCell,
6969
GeneExpression, Normalization, Clustering, QualityControl, Sequencing
7070
Encoding: UTF-8
71-
RoxygenNote: 7.2.3
71+
RoxygenNote: 7.3.1
7272
URL: https://github.com/stemangiola/tidySingleCellExperiment
7373
BugReports: https://github.com/stemangiola/tidySingleCellExperiment/issues

R/methods.R

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,20 +204,32 @@ setMethod("aggregate_cells", "SingleCellExperiment", function(.data,
204204
~ .x |> mutate(.aggregated_cells = .y)
205205
)
206206

207-
208-
do.call(rbind, list_assays) |>
209-
210-
left_join(
211-
.data |>
212-
colData() |>
213-
as_tibble() |>
214-
subset(!!.sample) |>
215-
unite("my_id_to_split_by___", !!.sample, remove=FALSE, sep = "___"),
216-
by= join_by(".sample" == "my_id_to_split_by___")
217-
) |>
207+
aggregated_sce =
208+
do.call(rbind, list_assays) |>
218209

219210
as_SummarizedExperiment(
220211
.sample=.sample,
221212
.transcript=.feature,
222-
.abundance=!!as.symbol(names(.data@assays)))
213+
.abundance=!!as.symbol(names(.data@assays))
214+
)
215+
216+
new_col_data =
217+
.data |>
218+
colData() |>
219+
as_tibble() |>
220+
subset(!!.sample) |>
221+
unite("my_id_to_split_by___", !!.sample, remove=FALSE, sep = "___")
222+
223+
new_col_data = new_col_data |> DataFrame(row.names = new_col_data$my_id_to_split_by___) |> _[,-1]
224+
225+
colData(aggregated_sce) =
226+
colData(aggregated_sce) |>
227+
cbind(
228+
new_col_data[match(rownames(colData(aggregated_sce)), rownames(new_col_data)),]
229+
)
230+
231+
rowData(aggregated_sce) = rowData(.data)
232+
233+
aggregated_sce
234+
223235
})

man/ggplot.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)