This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Single Cell Experiment object to Seurat without losing rowData / colData

I try to convert sce object to seurat . it works but I'm loosing features containes in rowData/colData. How to get them in the seurat object ? What am I missing ? (https://satijalab.org/seurat/archive/v3.0/conversion_vignette.html)

> sce.to.seurat <- as.Seurat(seurat.to.sce)

class: SingleCellExperiment 
dim: 33694 4570 
metadata(0):
assays(2): counts logcounts
rownames(33694): RP11-34P13.3 FAM138A ... AC213203.1 FAM231B
rowData names(9): vst.mean vst.variance ... **feature_ensembl**
  **feature_symbol**
colnames(4570): OSI_TIPI_Vertes_AAACCCAAGGTAAGGA-1
  OSI_TIPI_Vertes_AAACCCATCGAACACT-1 ...
  OSI_TIPI_Rouges_TTTGTTGGTCCAATCA-1 OSI_TIPI_Rouges_TTTGTTGGTGGTCTTA-1
colData names(12): orig.ident nCount_RNA ... detected total
reducedDimNames(0):
altExpNames(0):

>head(sce.to.seurat@meta.data))

OSI_TIPI_Vertes      36827         6424
OSI_TIPI_Vertes_AAACCCATCGAACACT-1 OSI_TIPI_Vertes      56588         7438

                                   log10GenesPerUMI  mitoRatio     S.Score
OSI_TIPI_Vertes_AAACCCAAGGTAAGGA-1        0.8339174 2.51989030 -0.04258605

                                     G2M.Score Phase           ident   sum
OSI_TIPI_Vertes_AAACCCAAGGTAAGGA-1 -0.09878542    G1 OSI_TIPI_Vertes 36827

                                   detected total
scrna-seq seurat sce

1 answer

You're honestly better off recreating the Seurat object manually via CreateSeuratObject(). The as.Seurat() function doesn't transfer info well and has been mildly broken for years at this point. It doesn't even attempt to transfer rowData if I remember correctly.

Something like this is your best bet:

sce.to.seurat <- CreateSeuratObject(counts = counts(seurat.to.sce), meta.data = as.data.frame(colData(seurat.to.sce)))
sce.to.seurat <- SetAssayData(object = sce.to.seurat, slot = "data", new.data = logcounts(seurat.to.sce))

# Set feature metadata, AKA rowData. Super intuitive, right?
sce.to.seurat[["RNA"]][[]] <- as.data.frame(rowData(seurat.to.sce))

Thanks a lot. That worked for colData but not for rowData(the super intuitive one :).

Error in `[[<-`(`*tmp*`, , value = list(vst.mean = c(0, 0, 0,
0.00623376623376623,  :    l'argument "i" est manquant, avec aucune valeur par défaut Calls: [[<- -> [[<-

Log in to answer this question.