Teichlab / cellphonedb

MIT License
342 stars 105 forks source link

Extracting data from Seurat #175

Closed singcell closed 4 years ago

singcell commented 4 years ago

I am new to Bioinformatics. I was trying to extract the CellPhoneDB input files from a Seurat object and using instructions as mentioned here. However, I am getting an error.

count_raw <- pbmc@raw.data[,pbmc@cell.names] Error: no slot of name "raw.data" for this object of class "Seurat"

If I use :

count_raw <- pbmc@assays[,pbmc@counts] Error: no slot of name "counts" for this object of class "Seurat"

I would like to know what are the default names of slot "raw.data" and "cell.names" in regular Seurat object or how to find it out in my object?

CellPhoneDB requires data be be normalized but not log-transformed but Seurat LogNormalizes the data. Can I still use Normalized Seurat output,

ryland-mortlock commented 4 years ago

Hi I have used CellPhoneDB on data exported from Seurat. You should be able to pull the raw counts data using this syntax. count_raw <- pbmc@assays$RNA@counts

I would note that in the CellPhoneDB paper, they recommend using normalized data. In my analysis, I performed SCTransform on my data and used that to run CellPhoneDB sample_data <- my_seurat_object@assays$SCT@scale.data

For your cell names, it depends on where they are stored in your Seurat object. Mine are my clustering results which can be accessed by Idents(my_seurat_object)

Hope this helps!

singcell commented 4 years ago

Than you, @ryland-mortlock for your help. Your suggestion helped me to get it working.

lima1 commented 4 years ago

@ryland-mortlock for SCTransform, wouldn't be the correct slot be counts (if non-transformed is really expected here)? Did anyone benchmark this?

    counts <- as.data.frame(
        GetAssayData(obj, slot = "counts", assay = "SCT")
    )

To assist with visualization and interpretation. we also convert Pearson residuals back to ‘corrected’ UMI counts. You can interpret these as the UMI counts we would expect to observe if all cells were sequenced to the same depth. If you want to see exactly how we do this, please look at the correct function here. The ‘corrected’ UMI counts are stored in pbmc[["SCT"]]@counts. We store log-normalized versions of these corrected counts in pbmc[["SCT"]]@data, which are very helpful for visualization.