-
Notifications
You must be signed in to change notification settings - Fork 47
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
Feedback on concatenate() #541
Comments
I am a bit swamped at the moment, but I will look into implementing your suggestions. As you said it would be worthwhile to handle dicts. |
I have the same issue ! |
And it's better to have a way to retrieve (subset) each objects from the concatenated objects. |
@wangjiawen2013 does |
What I mean is how to concatenate multi spatialdata objects and subset each objects from the concatenated objects according to the sample names (each object have a unique name) again. The SpatialData objects from xenium all have the same names for images, shapes and coordinate systems, so I cannot concatenate them because |
Hi, getting back to this today.
What I suggest here is, for each sample, to map all its geometry to a coordinate system called "sample_XXX", with Please let me know if it works for you. |
Currently what you implemented is basically I would do it. An idea would be to wrap that into an official helper function, or have the |
|
But one comment on this. In
So, renaming the
|
Ok actually I have implemented all the above. @wangjiawen2013 @grst it would be great if you could try this out please 😊 |
Good news! I'll try later. |
@LucaMarconato |
Yes, it's available in the released version. |
Thank you @LucaMarconato. I can confirm these new improvements work. This saved me a bunch of time! I was unsure for a while on exactly what to do for merging two Xenium datasets together with identical element names. I had to learn some of the I also had to look through the For me (using two Loading both
Creating the
and then finally, merge:
|
This feature maybe useful when we compare two samples. If we don't merge the two datasets, we cannot assign the same color to the same cell type easily, and it's impossible to compare cellular niches (i.e., regions with distinct compositions of cell types). For example, If we use separated datasets, we find niche1, niche2 and niche3 in dataset1, and niche1, niche2, nich3 in dataset2, how can we know niche1 in dataset1 is niche1 in dataset2 ? If we use concatenated datasets and find niche1, niche2, niche3 using niches discovery algorithm for the whole datasets, we can compare the niches distribution among samples. |
Hi,
Another question, How to separate or subset each object from the concatenated object ?
|
@wangjiawen2013 I have not tried this myself, yet, but may need to soon. @LucaMarconato provided links above (#541 (comment)) to the MIBI-TOF tutorial which shows how this could be done (and also a similar method using |
While I in the end was able to concatenate the data the way I like, the user experience wasn't as great as I had hoped, so wanted to drop some feedback. As I'm not that familiar with spatialdata yet, it might be that there are already better solutions -- please let me know if there are.
Starting situation
I have ~20 Visium Cytassist samples from a clinical trial processed with nf-core/spatialtranscriptomics (using the nf-core/spatialvi#67 branch that already uses spatialdata). The pipeline generates a single
.zarr
folder for each sample.Desired outcome
I would like to have all samples in a single SpatialData object. The AnnData table should contain the gene expression from all samples.
Pain points
sd.concatenate
enforces that the input is a list. Is there a reason this can't accept anySequence
type (e.g.dict_values
)?Usually, I pass a dictionary
sample_id -> AnnData
toanndata.concat
, which nicely makes unique obs_names in combination withconcat(..., index_unique="_")
. This doesn't work with spatialdata.concatenate, which leaves me with either manipulating theobs_names
for each object before concatenation, or ugly obs names with numeric sufficies (e.g.AACTCAACCTTGACCA-1_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0
). IMO it would be great to support a dict as input to spatialdata.concatenate, too.The per-sample SpatialData objects all have the same names for images, shapes and coordinate systems. I currently rename them like this:
which seems a bit cumbersome. I'm wondering if there's a better solution or what's the intended way of handling such cases. It could also be worth adding a process to the nf-core/spatialtranscriptomics pipeline that already does the concatenation step.
The text was updated successfully, but these errors were encountered: