Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Seurat or SingleCellExperiment object as input #17

Open
navi202306 opened this issue Jun 16, 2023 · 15 comments
Open

Use Seurat or SingleCellExperiment object as input #17

navi202306 opened this issue Jun 16, 2023 · 15 comments

Comments

@navi202306
Copy link

hello, is there a way to upload a SingleCellExperiment or seurat object with spatial coordinates as input?

@beibeiru
Copy link
Collaborator

Hi,

Thank you for your interest in our package.
I will create a function that can convert SingleCellExperiment or seurat to SpaCET_obj.
Once done, I will let you know. Thanks.

Best,
Beibei

@BenjaminDEMAILLE
Copy link

And also if it's possible a function to take back PropMatrix as assay in Seurat

@beibeiru
Copy link
Collaborator

Hi, @spatial2023,

I have created a new function convert.Seurat that can convert Seurat objects to SpaCET objects.
Please reinstall our package and have a try.
Just let me know if you have any further questions.

library(SpaCET)
visiumPath <- file.path(system.file(package = "SpaCET"), "extdata/Visium_BC")
Seurat_obj <- Seurat::Load10X_Spatial(data.dir = visiumPath)
SpaCET_obj <- convert.Seurat(Seurat_obj)

Best,
Beibei

@beibeiru
Copy link
Collaborator

Hi, @BenjaminDEMAILLE,

You suggestion is really great. I have created a new function addTo.Seurat which can add SpaCET deconvolution results to Seurat as a new assay.
Please reinstall our package and try it.
Feel free to let me know if you have other concerns

library(SpaCET)
visiumPath <- file.path(system.file(package = "SpaCET"), "extdata/Visium_BC")
Seurat_obj <- Seurat::Load10X_Spatial(data.dir = visiumPath)
SpaCET_obj <- convert.Seurat(Seurat_obj)
SpaCET_obj <- SpaCET.deconvolution(SpaCET_obj, cancerType="BRCA", coreNo=8)
Seurat_obj <- addTo.Seurat(SpaCET_obj, Seurat_obj)
Seurat::DefaultAssay(Seurat_obj) <- "propMatFromSpaCET"
Seurat::SpatialFeaturePlot(Seurat_obj, features = c("CAF", "Macrophage"))

Best,
Beibei

@yunbokai
Copy link

Hi, @spatial2023,

I have created a new function convert.Seurat that can convert Seurat objects to SpaCET objects. Please reinstall our package and have a try. Just let me know if you have any further questions.

library(SpaCET)
visiumPath <- file.path(system.file(package = "SpaCET"), "extdata/Visium_BC")
Seurat_obj <- Seurat::Load10X_Spatial(data.dir = visiumPath)
SpaCET_obj <- convert.Seurat(Seurat_obj)

Best, Beibei

Hi,I just find that if I have renamed my SeuratObj images name, I will get Error. Then I need to rename it as "slice1" to avoid the Error. Maybe you can make the function more friendly.

@shaniAmare
Copy link

Hi @beibeiru

Thank you for these wonderful hacks. Unfortunately, when I also use the function convert.Seurat() on a merged Seurat object with several images, it gives me following error:

> SpaCET_obj <- convert.Seurat(control_merge)
Error in data.frame(pxl_row = Seurat_obj@images$slice1@coordinates$imagerow *  : 
  trying to get slot "coordinates" from an object of a basic class ("NULL") with no slots

But then I tried to rename the image names to slice1, slice2 etc, and it gives me the error below:

> SpaCET_obj <- convert.Seurat(control_merge)
Error in data.frame(pxl_row = Seurat_obj@images$slice1@coordinates$imagerow *  : 
  arguments imply differing number of rows: 4529, 16922

suggesting to me that this function doesn't know how to interpret merged information.

Hoping you will have some time to make it a bit more refined to address some of these issues at least in the near future!

thanks,
Shani.

@beibeiru
Copy link
Collaborator

beibeiru commented Sep 9, 2023

Hi, @shaniAmare

Thank you for your interest in our package.

These issues are caused by that convert.Seurat() does not support multiple slices.
Please reinstall our latest version SpaCET, which has been upgraded to process multiple slices.

library(SpaCET)
visiumPath <- file.path(system.file(package = "SpaCET"), "extdata/Visium_BC")
Seurat_obj1 <- Seurat::Load10X_Spatial(data.dir = visiumPath)
Seurat_obj2 <- Seurat::Load10X_Spatial(data.dir = visiumPath)
Seurat_obj <- merge(Seurat_obj1 ,Seurat_obj2)
SpaCET_obj_list <- convert.Seurat(Seurat_obj)
for(n in 1:length(SpaCET_obj_list) )
{
  SpaCET_obj_list[[n]] <- SpaCET.deconvolution(SpaCET_obj_list[[n]], cancerType="BRCA", coreNo=8)
}
Seurat_obj <- addTo.Seurat(SpaCET_obj_list, Seurat_obj)
Seurat::DefaultAssay(Seurat_obj) <- "propMatFromSpaCET"
Seurat::SpatialFeaturePlot(Seurat_obj, features = c("CAF", "Macrophage"))

Just let me know if you have any further concerns.

Best,
Beibei

@beibeiru beibeiru changed the title use SingleCellExperiment object as input Use Seurat or SingleCellExperiment object as input Sep 14, 2023
@shaniAmare
Copy link

That's fantastic! Thanks for your efforts and the response @beibeiru . I'll have a go and see.

I have another issue with not being able to use mouse data with the package - do you have a workaround for that by any chance?

many thanks,
Shani.

@heksaani
Copy link

heksaani commented Nov 13, 2023

Hey I am am having problems with this datacet:
https://www.10xgenomics.com/resources/datasets/human-ovarian-cancer-11-mm-capture-area-ffpe-2-standard
tried to convert it to seurat object with the following error;

Error in file(file, "rt") : invalid 'description' argument

Also tried to follow this example:
https://data2intelligence.github.io/SpaCET/articles/visium_BC.html
but received another error:

Error in barcode[, "pxl_row_in_fullres"] * jsonFile$tissue_lowres_scalef : non-numeric argument to binary operator

Can you help me resolve what is going on ?

@beibeiru
Copy link
Collaborator

Hi, @heksaani,

Thanks for showing a firm interest in our package.
Would you please show the code you have run?
It will help me find the bug easily.

Best,
Beibei

@beibeiru
Copy link
Collaborator

That's fantastic! Thanks for your efforts and the response @beibeiru . I'll have a go and see.

I have another issue with not being able to use mouse data with the package - do you have a workaround for that by any chance?

many thanks, Shani.

Hi, @shaniAmare,

I missed your comments accidentally.
Is your issue addressed?
Please let me know if you have any further questions.

Best,
Beibei

@Zjianglin
Copy link

hi @beibeiru @shaniAmare Do you have any new solutions or recommendations for mouse ST data workflow of SpaCET? thanks.

@beibeiru
Copy link
Collaborator

Hi, @Zjianglin

Malignant dictionary and non-malignant cell reference in SpaCET are sourced from human species. We have not systematically evaluated them for non-human species. One user has applied SpaCET to canine and got good results #29.

My suggestion is that you can try SpaCET on your mouse ST data. If the results make no sense, SpaCET.deconvolution.matched.scRNAseq is an alternative way, which requires a scRNAseq dataset with all possible cell types in your ST data. You need to find such a scRNAseq dataset from other publications.

Best,
Beibei

@Zjianglin
Copy link

Zjianglin commented Aug 14, 2024

Hi @beibeiru , I have tried to run SpaCET to my BGI Stereo-seq mouse ST data. The results seems good.

The workflow is below:

  1. subset the genes that have orthologs in human genome, change the genes/rownames to human genes using babelgene, create a new SeuratObject tmp_sbj_hgene;
  2. run the steps according to Cell type deconvolution.
paCET_obj <- convert.Seurat(tmp_sbj_hgene)
SpaCET_obj@input$image$path <- NA
SpaCET_obj@input$image$grob <- NA
SpaCET_obj@input$platform <- "Stereo-seq"
SpaCET_obj <- SpaCET.quality.control(SpaCET_obj)
SpaCET.visualize.spatialFeature(SpaCET_obj, spatialType = "QualityControl", spatialFeatures=c("UMI","Gene"))
str(SpaCET_obj)
SpaCET_obj <- SpaCET.deconvolution(SpaCET_obj, cancerType="LIHC", coreNo=12)

My ST data from mouse liver cancel model, so I used LIHC as cancerType input. The deconvolution result consisted of 35 cell typs as below:

rownames(SpaCET_obj@results$deconvolution$propMat)
 [1] "Malignant"                  "CAF"                        "Endothelial"                "Plasma"                     "B cell"                    
 [6] "T CD4"                      "T CD8"                      "NK"                         "cDC"                        "pDC"                       
[11] "Macrophage"                 "Mast"                       "Neutrophil"                 "Unidentifiable"             "B cell naive"              
[16] "B cell non-switched memory" "B cell switched memory"     "B cell exhausted"           "T CD4 naive"                "Th1"                       
[21] "Th2"                        "Th17"                       "Tfh"                        "Treg"                       "T CD8 naive"               
[26] "T CD8 central memory"       "T CD8 effector memory"      "T CD8 effector"             "T CD8 exhausted"            "cDC1 CLEC9A"               
[31] "cDC2 CD1C"                  "cDC3 LAMP3"                 "Macrophage M1"              "Macrophage M2"              "Macrophage other"   

The slice/sample is from a median-level mouse liver caner sample. However, I can not find any hepatocytes in the deconvolution results. Is there any mistakes in my workflow? or, how should I interpret this result? thanks.

Btw, is it possible to Estimate cell-cell interactions in this othologous transferred dataset for a mouse dataset?
I I tried to run this pipeline and get a 'colocation' result as below:
Screenshot from 2024-08-14 11-13-11

It seems that there is a colocation between CAF and Macrophae, but I can not run SpaCET.CCI.cellTypePair for this pair: "Based on colocalization analysis and L-R enrichment analysis, the intercellular interaction is not significant for the current cell-type pair. Please check other cell-type pairs.". How do you intepret this results? And how could I get a summary of significant interaction pairs list? Thanks.

@beibeiru
Copy link
Collaborator

beibeiru commented Aug 15, 2024

Hi, @Zjianglin

Glad to know that SpaCET works on your mouse Stereo-seq data.

1.hepatocytes
When you run SpaCET.deconvolution, SpaCET will use the default cell-type reference from our package. This reference includes the common cell types in the tumor microenvironment, i.e., the 35 cell types you listed. It misses the tissue-specific cell-types, such as hepatocytes. Instead, you can search for a liver cancer scRNA-seq dataset (including hepatocytes) from publications, and build a customized reference by following this tutorial. Then run SpaCET.deconvolution.matched.scRNAseq.

2.cell-cell interactions
2.1 Is it possible to Estimate cell-cell interactions in this orthologous transferred dataset for a mouse dataset?
Yes, the orthologous transfer does not influence the interaction analysis.

2.2 How do you interpret these results?
Cell colocalization does not directly indicate physical interaction. Your result means although CAF and M2 are colocalized together, the colocalized spots with both CAF and M2 do not have more substantial ligand-receptor coexpressed pairs. Thus, our method thinks the current interaction is not significant for the current cell-type pair. You can see our method has very strict standards for cell-cell interaction. Most other methods only calculate the colocalization.

2.3 How could I get a summary of the significant interaction pairs list?
The SpaCET_obj does not have a such list. You can use SpaCET_obj@results$CCI$colocalization to get the colocalization results. Then, select the top colocalized cell-types to run SpaCET.CCI.cellTypePair.

Best,
Beibei

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants