Skip to content

Commit 3d78886

Browse files
authored
Update utilities.R
1 parent c89af7b commit 3d78886

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

R/utilities.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,13 @@ save_experiment_data <- function(data,
106106
#' @param sce A `SingleCellExperiment` object.
107107
#' @importFrom SummarizedExperiment assay assays colData
108108
#' @importFrom SingleCellExperiment SingleCellExperiment
109+
#' @importFrom rlang set_names
109110
#' @return A modified `SingleCellExperiment` object with the single-column assay
110111
#' duplicated if applicable. If the assay already has more than one column, the
111112
#' function returns the original object unchanged.
112113
duplicate_single_column_assay <- function(sce) {
113114

114-
assay = sce |> assays() |> names() |> magrittr::extract2(1)
115+
assay_name = sce |> assays() |> names() |> magrittr::extract2(1)
115116

116117
if(ncol(assay(sce)) == 1) {
117118

@@ -124,7 +125,7 @@ duplicate_single_column_assay <- function(sce) {
124125
cd = cd |> rbind(cd)
125126
rownames(cd)[2] = paste0("DUMMY", "___", rownames(cd)[2])
126127

127-
sce = SingleCellExperiment(assay = list(X = my_assay ), colData = cd)
128+
sce = SingleCellExperiment(assay = list(my_assay) |> set_names(assay_name), colData = cd)
128129
sce
129130
}
130131
sce

0 commit comments

Comments
 (0)