ventolab / CellphoneDB

CellPhoneDB can be used to search for a particular ligand/receptor, or interrogate your own HUMAN single-cell transcriptomics data.
https://www.cellphonedb.org/
MIT License
305 stars 52 forks source link

Converting Seurat object into counts input file #146

Open nea-k opened 8 months ago

nea-k commented 8 months ago

Hi! I'm having trouble converting my Seurat object into a text counts input file for CellphoneDB. I followed the instructions here but I'm getting a ParseCountsException: Invalid Counts data from the counts_preprocessor. The error seems to be the result of this error: ValueError: could not convert string to float. I also tried converting the Seurat object into a 10x .mtx format but didn't manage to apply the rowData function to my Seurat object. I would greatly appreciate any tips on how to solve this!

datasome commented 8 months ago

Hi nea-k,

Thank you for using CellphoneDB and my apologies for the delayed reply. To help me understand why the text counts file you've extracted from your Seurat object contains strings instead of floats, would you mind sharing your Seurat object with me and also letting me have the exact commands from here you used to extract the counts data from the Seurat object? Please send access details to the Seurat object to contact@cellphonedb.org. Thanks!

Best,

Robert

wfaalajr commented 7 months ago

Hi nea-k,

I also use Seurat (v5). The approach that worked for me was to just convert the entire object to anndata format. I use sceasy to convert the object to an anndata (.h5ad) format:

`seurat[["RNA3"]] <- as(object = seurat[["RNA"]], Class = "Assay") DefaultAssay(seurat) <- "RNA3" seurat[["RNA"]] <- NULL seurat <- RenameAssays(object = seurat, RNA3 = 'RNA')

sceasy::convertFormat(obj = seurat, from = "seurat", to = "anndata", outFile = "cellphonedb/whole/seurat.h5ad")`

If you are using Seurat V4 you don't need to conver to RNA3 assay.