Manually logging TPM count matrix in Seurat
2
0
Entering edit mode
3.7 years ago
ww22runner ▴ 60

Hello everyone,

I have some TPM data for single cell RNA sequencing but I am unsure of how to manually log transform the count matrix in the SeuratObject created. So far, this is what I have:

df <- read.table(file="...",nrows=2000, sep = "\t", row.names=1, header=T)

proj <- CreateSeuratObject(counts = df, project = "proj", min.cells = 3, min.features = 200) 

proj <- subset(proj, subset = nFeature_RNA > 200 & nFeature_RNA < 2500 )

GetAssayData(object = proj) = log(GetAssayData(object = proj)@x)

I am trying to log the tpm counts in the last step but I get an error so I am assuming that I am accessing the data incorrectly. Any help would be greatly appreciated!

Seurat • 4.1k views
ADD COMMENT
1
Entering edit mode
3.7 years ago

This will work.

proj[["RNA"]] <- CreateAssayObject(counts = log(proj[["RNA"]]@counts))

You might want to log+1 transform though, since there are going to be a ton of 0 values that will evaluate to -Infinity in R.

As a suggestion, if you can get a hold of the raw counts, you should use Seurat's SCTransform normalization, which is their preferred normalization scheme. Relevant paper, and the accompanying vignette.

ADD COMMENT
0
Entering edit mode

Thank you for your reply, when I try this, I get this error:

Error in (function (cl, name, valueClass)  : 
  assignment of an object of class “dgeMatrix” is not valid for @‘counts’ in an object of class “Assay”; is(value, "AnyMatrix") is not TRUE
ADD REPLY
0
Entering edit mode

I edited the answer to fix the error. I confirmed it is now working.

ADD REPLY
0
Entering edit mode

Thank you, that worked! Is there any resource that can better help me understand how to access the different components of the Seurat object?

ADD REPLY
0
Entering edit mode

When they updated from version 2 to 3, they created a cheat sheet that is a nice overview of how to access different parts of the data.

ADD REPLY
0
Entering edit mode

Yes, I was referring to this: https://satijalab.org/seurat/essential_commands.html from which I gathered that I could access the count data by using GetAssayData(object = object) but I was wondering how I could have derived at CreateAssayObject(counts = ...) or if there is some other documentation I might have missed.

ADD REPLY
1
Entering edit mode

If you type help(package = Seurat) and scroll down a bit, it lists each function in the package with a short description of it. You can then open up the help documentation for any of those functions for more information.

ADD REPLY
0
Entering edit mode

Thank you, appreciate it!

ADD REPLY

Login before adding your answer.

Traffic: 2573 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