Closed milddaa closed 4 months ago
Hi @milddaa, For question 1, absolutely! It can work with any label assigned to cells, so it can be used for cell types :)
For question 2, I need to understand first if the images are from the exact sample slide. In that case, what would be the advantage of having multiple images instead of one? I am genuinely asking because it's something I never thought about and I could think of possible ways to leverage them. If the images are from the same samples but multiple slides, you can just treat every image as a different sample and you will hopefully see that slides from the same sample have the same niches.
Thank you very much for your quick response! It is great to hear that I can use it for cell types too. As for the second question, the different images per sample correspond to consecutive fresh frozen tissue sections from the same subject's (sample's) piece of tissue. They were placed on the same glass slide but are not related to each other in terms of cell coordinates so imaged separately. I think treating each image as a sample perhaps would not make sense in such case because it would seem like I have a higher number of samples whereas these are just replicates of the same thing. Does it make sense?
Then whether to include them or not does not depend on CellCharter but on your research question :) Unless they are huge samples it doesn't hurt to find niches also for them, and observing that consecutive sections have the same niches is still a nice confirmation that the analysis is going well and you and not just clustering noise for some reason.
Then whether to include the replicates in downstream analyses depends a lot on what are you studying. In some cases, fo example if you reason at the cell or niche level, having more tissue area gives you more statistical power. In other cases, if you reason at the sample level, this may give a false impression that you have many samples while it's just very similar slides from the same sample, as you said. But this depends a lot on what you are doing!
I think I would like to include all images in the analysis because it would be, as you said, more tissue area, and I would not want to exclude any data from the analysis. But I would also not like to treat images as separate samples. My thinking was, perhaps I could have several unlinked graphs in one for each sample? For example, I could have anndata object for each image separately, generate the cellular graph using sq.gr.spatial_neighbors for each, and then merge these anndata objects for each sample to generate one graph where nodes from individual images would have no links. And as final step merge anndata object from all samples together to run downstream analyses on?
There is no need to do all these different steps! The library_key
parameter in sq.gr.spatial_neighbors
allows to do exactly that. It creates one graph with all the images where nodes from different images are not connected. You just have to step the parameter to the column that contains the image unique IDs.
So this means that you can concatenate the anndata objects from all the samples (and images) from the beginning, run spatial_neighbors and CellCharter on the concatenated object, but once you do the downstream analysis you do it by at the level of samples (so multiple images) rather than individual images.
Oh perfect then! I'll give it a go. Thank you for all your help!
Description of feature
Hello! As I understand, CellCharter uses cc.gr.diff_nhood_enrichment to compare proximity of cellular niches between two conditions. I was wondering if it would be possible to use the same function to compare proximity of cell types rather than niches. Perhaps by specifying cluster_key to cell type rather than the cluster. Also, another question: can CellCharter can deal with multiple spatial images per sample? Some context: I have two conditions, each condition has several samples and each sample has 1-3 images (with unrelated x and y coordinates between the images). Thank you!