Open the Seurat count matrix in RStudio
1
0
Entering edit mode
6 months ago
solo.albif • 0

Hi,

Is there a way to open the Seurat counts, data and scale.data layers in RStudio?

I am thinking of something along the lines of:

View(seurat_obj@assays$RNA$counts)

This does not work because seurat_obj@assays$RNA$counts is a S4 object.

If this is not possible, is there any other way to look at the count matrix?

Seurat RStudio • 747 views
ADD COMMENT
3
Entering edit mode
6 months ago

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?

ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
1
Entering edit mode

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.

ADD REPLY

Login before adding your answer.

Traffic: 1499 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6