From 95dd3a1f03a7ead013aef5f88e1983efbfa84c0f Mon Sep 17 00:00:00 2001 From: lahuuki Date: Wed, 10 Sep 2025 12:22:16 -0400 Subject: [PATCH] If gene_name and gene_id are in rowData, add gene_search as defined in check_sce_layer --- R/registration_pseudobulk.R | 9 ++++++++- man/registration_pseudobulk.Rd | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/R/registration_pseudobulk.R b/R/registration_pseudobulk.R index ffec8c4c..dcbcb8e6 100644 --- a/R/registration_pseudobulk.R +++ b/R/registration_pseudobulk.R @@ -57,7 +57,7 @@ #' sce$age <- ages[sce$sample_id] #' #' ## Add gene-level information -#' rowData(sce)$ensembl <- paste0("ENSG", seq_len(nrow(sce))) +#' rowData(sce)$gene_id <- paste0("ENSG", seq_len(nrow(sce))) #' rowData(sce)$gene_name <- paste0("gene", seq_len(nrow(sce))) #' #' ## Pseudo-bulk by Cell Cycle @@ -69,6 +69,7 @@ #' min_ncells = NULL #' ) #' colData(sce_pseudo) +#' rowData(sce_pseudo) registration_pseudobulk <- function( sce, @@ -230,6 +231,12 @@ registration_pseudobulk <- spatialCoords(sce_pseudo) <- NULL imgData(sce_pseudo) <- NULL } + + ## if gene_anme and gene_id cols are available add gene_search to rowData + if(all(c("gene_name", "gene_id") %in% colnames(rowData(sce_pseudo)))){ + rowData(sce_pseudo)$gene_search <- paste0(rowData(sce_pseudo)$gene_name, "; ", rowData(sce_pseudo)$gene_id) + } + if (!is.null(pseudobulk_rds_file)) { message(Sys.time(), " saving sce_pseudo to ", pseudobulk_rds_file) saveRDS(sce_pseudo, file = pseudobulk_rds_file) diff --git a/man/registration_pseudobulk.Rd b/man/registration_pseudobulk.Rd index 8d486941..8b8dd22a 100644 --- a/man/registration_pseudobulk.Rd +++ b/man/registration_pseudobulk.Rd @@ -76,7 +76,7 @@ names(ages) <- LETTERS[1:5] sce$age <- ages[sce$sample_id] ## Add gene-level information -rowData(sce)$ensembl <- paste0("ENSG", seq_len(nrow(sce))) +rowData(sce)$gene_id <- paste0("ENSG", seq_len(nrow(sce))) rowData(sce)$gene_name <- paste0("gene", seq_len(nrow(sce))) ## Pseudo-bulk by Cell Cycle @@ -88,6 +88,7 @@ sce_pseudo <- registration_pseudobulk( min_ncells = NULL ) colData(sce_pseudo) +rowData(sce_pseudo) } \seealso{ Other spatial registration and statistical modeling functions: