This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to make amazing UMAP to spatialPlot GIF

Hi everyone,

Any clues how to make this amazing gif which transitions from UMAP to spatial dimplot or similar. Link to the gif is here, otherwise see screenshots below:

https://crukscotlandinstitute.b-cdn.net/images/stories/beatson_research_group/DasGupta/image001.gif

enter image description here

enter image description here

umap spatial

1 answer

Looks to me to be a sequence of intermediate linear interpolations. For each point you have coordinates (U1, U2) for the UMAP plot, (S1, S2) for the spatial plot. Define:

X_i(t) = t * U_i + (1-t) * S_i

for t = 0, 0.05, 0.1, ..., 0.95, 1.0

Create 21 images.

In python use the pillow library to open the images and create a gif, e.g.

frames = [Image.open(f'imagename_{j}' for j in range(21)]
frames[0].save('output.gif', format='GIF', append_images=frames[1:], save_all=True, duration=30, loop=0)

Thank you @LChart, wow that sounds like a very elegant solution! I've got the seurat currently in R. I'll export to python and give it a bash.

Log in to answer this question.