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

Conversion of sfe Object to AnnData #56

Open
aasingh2 opened this issue Nov 14, 2024 · 12 comments
Open

Conversion of sfe Object to AnnData #56

aasingh2 opened this issue Nov 14, 2024 · 12 comments

Comments

@aasingh2
Copy link

Hello,

I wanted to ask if there is a built-in function to convert a sfe object to AnnData object, or if there is a way to save the sfe object as a h5ad file to facilitate interoperability with Python.

Thanks!

@alikhuseynov
Copy link
Collaborator

I don't think it is planned right now, but maybe @lambdamoses has some ideas.
FYI, there is VoyagerPy and updated python workflow for Xenium
There will hopefully be integration with SpatialData pachterlab/voyagerpy#29

@lambdamoses
Copy link
Collaborator

lambdamoses commented Nov 14, 2024

For now you can use some package that converts between SCE and AnnData such as zellkonverter because SFE inherits from SCE, and then deal with the spatial part separately in a manner that is consistent with squidpy. I think it would be a valuable new feature to incorporate.

Also, the ArtifactDB project has the alabaster packages for language agnostic serialization of Bioc objects from R; the Python counterpart are the dolomite packages. I just submitted alabaster.sfe to Bioc recently; there's no dolomite for SFE yet, but I should we should write it.

@vraghu90
Copy link

On the same lines, I have an AnnData object which I would like to convert to spatial feature experiment. Is there a workflow to do this and and run the Moran's I calculation?

@lambdamoses
Copy link
Collaborator

Not yet, but I think there should be. For now, you can convert AnnData to SCE with something like zellkonverter first and then add the geometries and coordinates. Please consider opening a pull request.

@lambdamoses
Copy link
Collaborator

Also, you don't need to convert AnnData to SFE to compute Moran' I. Squidpy can do that, so can voyagerpy: https://github.com/pachterlab/voyagerpy/tree/dev2 Although at present only the R implementation of Voyager has the bivariate and multivariate spatial statistics.

@vraghu90
Copy link

vraghu90 commented Nov 15, 2024 via email

@lambdamoses
Copy link
Collaborator

What kind of heatmap? Do you mean plotting local Moran's I's at spatial locations or global Moran's I across genes and samples?

@vraghu90
Copy link

vraghu90 commented Nov 15, 2024 via email

@lambdamoses
Copy link
Collaborator

You can plot local Moran's I with the plotLocalResult function in Voyager (I think it's snake case in the Python implementation) but you need to do some data wrangling yourself to plot Moran's I across genes and samples. In the R implementation, global spatial results for gene expression are stored in rowData and the column names indicate sample_id. rowData is an S4 DataFrame; you can extract the relevant columns and convert that into a matrix which can be plotted as a heatmap with the pheatmap package. I'm not sure how well the Python implementation of Voyager handles different samples though.

@lambdamoses
Copy link
Collaborator

Any more questions? If not then I'll close the issue.

@vraghu90
Copy link

Quick question on this. Is there a workflow where I can convert a previously analyzed/processed seurat object(Xenium) into a SFE to perform Voyager operations?

@alikhuseynov
Copy link
Collaborator

Quick question on this. Is there a workflow where I can convert a previously analyzed/processed seurat object(Xenium) into a SFE to perform Voyager operations?

Yes, take a look here -> https://pachterlab.github.io/SpatialFeatureExperiment/dev/articles/SFE.html#coercion-from-seurat

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

4 participants