From 0497b0e09e7d4102d5ffb73e521411f14789f279 Mon Sep 17 00:00:00 2001 From: Joesph Beller Date: Thu, 16 Jan 2025 17:42:28 -0600 Subject: [PATCH 1/6] Changing subset technique to work for Seurat V5 for GroupCorrelation() as discussed in issue #9483 --- R/utilities.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/utilities.R b/R/utilities.R index f807ec298..ca2e7c710 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -986,7 +986,8 @@ GroupCorrelation <- function( grp.cors <- as.data.frame(x = grp.cors[which(x = !is.na(x = grp.cors))]) grp.cors$gene_grp <- gene.grp[rownames(x = grp.cors)] colnames(x = grp.cors) <- c(paste0(var, "_cor"), "feature.grp") - object[[assay]][] <- grp.cors + try(object[[assay]]@meta.data <- grp.cors, silent = T) + try(object[[assay]]@meta.features <- grp.cors, silent = T) if (isTRUE(x = do.plot)) { print(GroupCorrelationPlot( object = object, From 242510630d7436f3f2770bafac98460fd71f176c Mon Sep 17 00:00:00 2001 From: Joesph Beller Date: Thu, 16 Jan 2025 17:46:44 -0600 Subject: [PATCH 2/6] Changing subset technique to work for Seurat V5 for GroupCorrelationPlot() as discussed in issue #9483 --- R/visualization.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/visualization.R b/R/visualization.R index 65ef5c94a..50fbb7289 100644 --- a/R/visualization.R +++ b/R/visualization.R @@ -4700,7 +4700,8 @@ GroupCorrelationPlot <- function( cor = "nCount_RNA_cor" ) { assay <- assay %||% DefaultAssay(object = object) - data <- object[[assay]][c(feature.group, cor)] + try(data <- object[[assay]]@meta.data[, c(feature.group, cor)], silent=T) + try(data <- object[[assay]]@meta.features[, c(feature.group, cor)], silent=T) data <- data[complete.cases(data), ] colnames(x = data) <- c('grp', 'cor') data$grp <- as.character(data$grp) From 9cf5791f47038936655045ca574a22f96ce8bc2d Mon Sep 17 00:00:00 2001 From: Joesph Beller Date: Thu, 6 Feb 2025 17:37:59 -0600 Subject: [PATCH 3/6] Update R/utilities.R Correction to use AddMetaData function Co-authored-by: David Collins <23369610+dcollins15@users.noreply.github.com> --- R/utilities.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/utilities.R b/R/utilities.R index ca2e7c710..18653d19e 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -986,8 +986,7 @@ GroupCorrelation <- function( grp.cors <- as.data.frame(x = grp.cors[which(x = !is.na(x = grp.cors))]) grp.cors$gene_grp <- gene.grp[rownames(x = grp.cors)] colnames(x = grp.cors) <- c(paste0(var, "_cor"), "feature.grp") - try(object[[assay]]@meta.data <- grp.cors, silent = T) - try(object[[assay]]@meta.features <- grp.cors, silent = T) + object[[assay]] <- AddMetaData(object[[assay]], grp.cors) if (isTRUE(x = do.plot)) { print(GroupCorrelationPlot( object = object, From 7eccea9e3cf5f8cd3a0b09828a9232260b9a63ed Mon Sep 17 00:00:00 2001 From: Joesph Beller Date: Thu, 6 Feb 2025 17:48:33 -0600 Subject: [PATCH 4/6] Implementing @dcollins15 suggestion --- R/visualization.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/visualization.R b/R/visualization.R index 50fbb7289..66f53f409 100644 --- a/R/visualization.R +++ b/R/visualization.R @@ -4700,8 +4700,7 @@ GroupCorrelationPlot <- function( cor = "nCount_RNA_cor" ) { assay <- assay %||% DefaultAssay(object = object) - try(data <- object[[assay]]@meta.data[, c(feature.group, cor)], silent=T) - try(data <- object[[assay]]@meta.features[, c(feature.group, cor)], silent=T) + data <- object[[assay]][[c(feature.group, cor)]] data <- data[complete.cases(data), ] colnames(x = data) <- c('grp', 'cor') data$grp <- as.character(data$grp) From a8f8bb2c914bae24de6512e9cf443206f72206b5 Mon Sep 17 00:00:00 2001 From: David Collins Date: Fri, 7 Feb 2025 15:05:12 -0500 Subject: [PATCH 5/6] Update changelog --- NEWS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.md b/NEWS.md index c0269fdf8..02ce15b92 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# Unreleased + +## Changes +- Fixed `GroupCorrelation` and `GroupCorrelationPlot` to be compatible with `SeuratObject` >= 5.0.0 ([#9625](https://github.com/satijalab/seurat/pull/9625)) + # Seurat 5.2.1 (2025-01-23) ## Changes From e99bf99595d6c622967e160dcdeeab7c77881308 Mon Sep 17 00:00:00 2001 From: David Collins Date: Fri, 7 Feb 2025 15:05:36 -0500 Subject: [PATCH 6/6] Bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 99acc584b..baf2b0528 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: Seurat -Version: 5.2.99.9000 +Version: 5.2.99.9001 Title: Tools for Single Cell Genomics Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) , Macosko E, Basu A, Satija R, et al (2015) , Stuart T, Butler A, et al (2019) , and Hao, Hao, et al (2020) for more details. Authors@R: c(