For Seurat v5 this is a little bit more complicated as in a merged object, individual counts/data/scale.data are split into unique layers.
If you had just one sample then:
counts.mat <- GetAssayData(seurat.object, assay = "RNA", layer = "counts")
data.mat <- GetAssayData(seurat.object, assay = "RNA", layer = "data")
scale.data.mat <- GetAssayData(seurat.object, assay = "RNA", layer = "scale.data")
View(as.matrix(counts.mat))
View(as.matrix(data.mat))
View(as.matrix(scale.data.mat))
If you have multiple samples merged together, you could run:
seurat.object <- JoinLayers(seurat.object)
And then run the previous
But as @ATpoint has already said, these are large, sparse matrices and the View()
function is extremely inefficient with what it would be able to show you as columns will end up being truncated.
pseudobulk.list <- AggregateExpression(seurat.object, assays = "RNA", group.by = "some.factor.of.interest")
Will, for example, return you a list of the layers as pseudobulk counts/data/scale.data (provided they're not split into layers at which point you'd need to JoinLayers()
before doing anything).
Other options available to you are things like:
rowSums
rowSds
matrixStats::rowMedians()
... etc
Maybe if you told us what you are specifically looking to do we could suggest a better approach?
Thank you very much! Honestly I just wanted to see the matrices, I have already created UMAPs, heatmaps, etc... but everything felt so abstract without being able to see the real data.
Again, you don't "see" anything in there other than a lot of numbers. Don't tell me that you can see patterns by looking at a 10.000x10.000 matrix. If you can, my respect.