How to convert Seurat object to sce object retaining the HVG
1
0
Entering edit mode
22 months ago
paria ▴ 90

Hello everyone,

I am trying to convert my single cell Seurat object to single cell experiment object. When I set the DefaultAssay to "RNA" the sce object does not retain HVGs and when it is set to "integrated" it does not retain count slot. I was wondering how I can retain all of the assays in sce object. Or if I apply the getTopHVGs(als, n=1000) on sce object does it return the same HVGs?

Any comment would be appreciated.

Paria

HVG single-cell SingleCellExperiment seurat • 2.0k views
ADD COMMENT
1
Entering edit mode
22 months ago
theHumanBorch ▴ 240

My understanding is there is not a slot for variable genes in a single-cell experiment object. You can retain the calculated variable genes from seurat and store them as a vector to be used in the single-cell experiment workflow using:

var.features <- SeuratObject::VariableFeatures(seuratObj)

There are different assumptions that the Seurat and OSCA/Single-cell experiment workflows use to identify variable features (at default settings), but also a lot of parameters in each function that make them customizable. Likely you will not have the same variable features identified, but hopefully a large overlap.

ADD COMMENT
1
Entering edit mode

This, or (preferred imo) assign it to a column in rowData() to pin it to the sce. For example as a logical column, rowData(sce)$hvg

ADD REPLY
0
Entering edit mode

Thanks for your help. When I am trying to pin the hog to my sce object I aim getting the below error.

variable.feature <- VariableFeatures(ALS)

rowData(als)$hvg <- variable.feature

Error in [[<-(*tmp*, name, value = c("CFAP299", "GALNTL6", "FLT1", : 1000 elements in value to replace 31808 elements

Do you know how to fix this? Thanks

ADD REPLY
0
Entering edit mode

The error says you have tried to create a new column with 1000 elements (length of variable.feature) while it was supposed to be a vector with 31808 elements (all genes present in your dataset). Based on the above comment, you may do the following to specify variable features in your sce dataset:

var.features <- SeuratObject::VariableFeatures(seuratObj)
rowData(sce)$hvg <- ifelse(rownames(rowData(sce)) %in% var.features, TRUE, FALSE)
ADD REPLY

Login before adding your answer.

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