Convert a Seurat object to .h5ad file
4
3
Entering edit mode
4.6 years ago
gaelgarcia05 ▴ 280

Hi,

I'm trying to build a single-cell browser using cellxgene from the Chan-Zuckerberg Intiative. However, I need to have a .h5ad file from the annpdata ackage in Python. I've done all my analysis in R, mainly using Seurat.

I was wondering if there's a way to convert a Seurat object to .h5ad within R. Seurat team seems to be working on this but as of Aug 2019 it's non-functional.

Thanks.

single-cell RNA-Seq seurat R scanpy • 27k views
ADD COMMENT
7
Entering edit mode
4.6 years ago

Looks like the way to do it is to write to loom format via loomR, then read that into anndata to be written as an .h5ad file.

Single cell folks need to a pick a file format/structure and stick with it.

EDIT (02/05/2021): The recent zellkonverter package from Bioc provides an easier way to do this.

ADD COMMENT
3
Entering edit mode

Could not have said it better. Thanks!

ADD REPLY
3
Entering edit mode
4.3 years ago
mmfiruleva ▴ 30

In R, you can convert Seurat object to h5ad and vice versa using sceasy.

ADD COMMENT
1
Entering edit mode
4.6 years ago
shoujun.gu ▴ 350

The best way now is to manually create your h5ad from seurat objects, such as put all normalized value as adata.X , raw counts to adata.raw, all gene annotations to adata.var and all cell annotations to adata.obs, etc

Or use scanpy from the very beginning.

ADD COMMENT
0
Entering edit mode

But then how do you actually make the conversion?

ADD REPLY
0
Entering edit mode
19 months ago
ZhangHao • 0

You can also try to use the srt_to_adata function of SCP package (https://github.com/zhanghao-njmu/SCP)

library(SCP)
data("pancreas1k")
adata <- srt_to_adata(pancreas1k)
adata$write_h5ad("pancreas1k.h5ad")
ADD COMMENT

Login before adding your answer.

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