Single Cell Experiment object to Seurat without losing rowData / colData
1
0
Entering edit mode
3.0 years ago
ZheFrench ▴ 550

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 • 6.2k views
ADD COMMENT
3
Entering edit mode
3.0 years ago

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))
ADD COMMENT
0
Entering edit mode

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: [[<- -> [[<-
ADD REPLY
0
Entering edit mode

Ah. I got that bit from this issue, which is a bit old at this point. I do not know French, so I can't comment on the error. It seems like maybe they're adding support for this soon at least.

ADD REPLY

Login before adding your answer.

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