-
Notifications
You must be signed in to change notification settings - Fork 5
Description
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()
Connectome/R/PercentExpression_v2.R
Line 18 in 57c44b1
object.assays <- Seurat:::FilterObjects(object = object, classes.keep = "Assay") |
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 :)