Error in Connectome:::PercentExpression_v2() None of the requested assays are present in the object: Assay5 / Seurat v5 format not recognized
Hey,
I was really curious about Connectome and wanted to give it a go :)
However I encountered an error when running CreateConnectome() while using a Seurat v5 object. I believe the function fails because the Assay5 format used by Seurat v5 is not recognized, causing the error
Error in Connectome:::PercentExpression_v2(object, features = genes.use, slot = "counts", assays = assay): None of the requested assays are present in the object
when runnning:
obj.con <- CreateConnectome(obj, species = 'mouse', assay = 'RNA', min.cells.per.ident = 25, p.values = FALSE, calculate.DOR = FALSE)
I assume this is due to PercentExpression_v2()
https://github.com/msraredon/Connectome/blob/57c44b1a2cde4521c6192da3570cb215370eb0b5/R/PercentExpression_v2.R#L18
expecting obj[['RNA']] to be of class 'Assay' - when using Seurat v5 (or just in my case, I don't know) it is 'Assay5'.
So when working with Seurat v5 the following workaround might be of help for those facing a similar issue: `## extract relevant data counts_data <- obj[['RNA']]$counts data_data <- obj[['RNA']]$data scale_data <- obj[['RNA']]$scale.data
create a Seurat v4 style assay object
new_assay <- CreateAssayObject(counts = counts_data) new_assay@data <- data_data [email protected] <- scale_data
assign back to Seurat object
obj[['RNA']] <- new_assay
check - should return 'Assay' now
class(obj[['RNA']]) `
Maybe worth considering to modify PercentExpression_v2() to check for 'Assay' vs. 'Assay5' and handle them respectively, to ensure smooth compatibility with difffernt Seurat version :)