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

How to perform spateo interactive visualization on my Linux Server? #278

Open
uush99 opened this issue Oct 17, 2024 · 2 comments
Open

How to perform spateo interactive visualization on my Linux Server? #278

uush99 opened this issue Oct 17, 2024 · 2 comments

Comments

@uush99
Copy link

uush99 commented Oct 17, 2024

Dears,

Thank you very much for your wondeful work. At present, I also have a question, How to perform spateo interactive visualization on my Linux Server?
I have configed conda environment for spateo on my server. When I run the following code, it will shut my running and can't show the interactive visualization photo, if can't show the interactive visualization on my sever, it will be difficult for my work, so I want to know, what should I do for my linux server so that I could show the Pyvista console?

#The following is runned on my windows.

embryo_pc = st.tdr.interactive_rectangle_clip(model=embryo_pc, key="tissue", invert=True)[0]

image

Looking forward to your reply !

@YifanLu2000
Copy link
Contributor

Hi @uush99, thanks for raising this issue. Since Spateo's visualization is built on PyVista, and PyVista doesn't support performing interactive operations on a remote server (although it does support interactive visualization), we currently can't perform operations like st.tdr.interactive_rectangle_clip directly on the server. However, we can offer some useful suggestions—this is also the approach we typically take—to perform such operations.

On the server side:
You can create the point cloud model on the server and save it as a .vtk file using the following code:

embryo_pc, _ = st.tdr.construct_pc(
    adata=adata,
    spatial_key='spatial_3D',
    groupby='tissue',
    key_added="tissue",
    colormap='tab20c',
)
st.tdr.save_model(model=embryo_pc, filename='embryo.vtk')

Then, transfer the saved .vtk file to your local computer and perform operations like st.tdr.interactive_rectangle_clip (A useful tip: You can control the point size in the interactive window by pressing Shift + + to make the points bigger and - to make them smaller):

embryo_pc = st.tdr.read_model('embryo.vtk')
embryo_pc_cliped = st.tdr.interactive_rectangle_clip(model=embryo_pc, key="tissue", invert=True)[0]

If you feel that a single pass isn't sufficient, you can run the clipping multiple times:
embryo_pc_cliped = st.tdr.interactive_rectangle_clip(model=embryo_pc_cliped, key="tissue", invert=True)[0]

After obtaining satisfactory results, save the clipped point cloud model and transfer it back to the server:
st.tdr.save_model(model=embryo_pc_cliped, filename='embryo_cliped.vtk')

On the server, you can load the clipped point cloud model:
embryo_pc_cliped = st.tdr.read_model('embryo_cliped.vtk')

You can also use the clipped indices to subset your AnnData object:
adata_clip = adata[adata.obs_names.isin(embryo_pc_cliped['obs_index'])]

I hope this helps!

@uush99
Copy link
Author

uush99 commented Oct 18, 2024

Thanks for your answer for my question, I think this method will work. Thank you again!

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

2 participants