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

Option to allow SVG output #6

Closed
shunhuahan opened this issue May 2, 2022 · 11 comments
Closed

Option to allow SVG output #6

shunhuahan opened this issue May 2, 2022 · 11 comments

Comments

@shunhuahan
Copy link

Hi,

Thanks for creating this amazing python package! I'm trying to figure out ways automate generating IGV screenshots using igv-notebook and seems like it lacks the SVG output option (currently I need to manually right click the navigator panel to output SVG). I wonder if it's possible that you could enable an option to convert browser content to SVG/PNG format (https://github.com/igvteam/igv.js/wiki/Browser-API-2.0#tosvg)?

Thanks,
Shunhua

@jrobinso
Copy link
Contributor

jrobinso commented May 3, 2022

I am guessing you want to get the SVG on the python (server) side, correct? For which platform (Notebook, Lab, Colab). The client-server messaging options are different for each.

@shunhuahan
Copy link
Author

@jrobinso thanks for responding! Yes, I'm trying to get the SVG on the python side and I'm using Jupyter Notebook as the platform.

@jrobinso
Copy link
Contributor

jrobinso commented May 3, 2022

Yes I think this can be supported for Notebook and possibly Colab, but not for JupyterLab. Not in this project anyway. Leave this open, I will get to it when I can.

@jrobinso
Copy link
Contributor

jrobinso commented May 4, 2022

Its tricky because this will be asyncronous, the SVG will need to be returned to python via a "comm" message unless you know another way. However I think in python we'll want to make it appear synchronous so we can write something like

svg = b.get_svg()

... do stuff with svg

My idea right now is to poll until the comm message with the svg is received, with a timeout of a second or two. If you have other ideas please post them here.

@shunhuahan
Copy link
Author

Hi Jim, I think your idea to SVG appear synchronous makes sense. I currently don't know what other ways to get the SVG..

Related to SVG output, one feature that would be potentially nice to have is to have igv-notebook directly generates the SVG without having to render the browser and load alignments/annotations inside the Notebook. This would make sense if users need to generate large amount of IGV screenshots for many samples (Traditionally people have to use igv --batch via command line).

Shunhua

@jrobinso
Copy link
Contributor

jrobinso commented May 4, 2022

I'm not sure that's possible, well anything is possible but would be a substantial amount of work. What you see is dependent on the DOM, which the browser renders. BTW the equivalent is not possible with IGV either, you need a graphics system to render IGV to get screenshots. Some people use a virtual X emulator, but still from IGV's perspective it is rendered in a window.

@shunhuahan
Copy link
Author

@jrobinso Thanks for the explanation! I guess I should use this package in Jupyter Notebook to render a small set of IGV pileups instead of trying to do large amount of samples to maintain reasonable memory usage.

@jrobinso
Copy link
Contributor

jrobinso commented May 5, 2022 via email

@jrobinso
Copy link
Contributor

jrobinso commented May 5, 2022 via email

@shunhuahan
Copy link
Author

@jrobinso I see, thanks for explaining the asynchronous issue in more details! In this case I might need to think of alternative strategies if I want to generate large numbers of pileups automatically. Please feel free to close this SVG output request.

@jrobinso
Copy link
Contributor

jrobinso commented May 5, 2022

Yes, I didn't consider that myself at first I just realized it when working on this. igv.js is designed for user interaction, not serial blocking execution, which is at the root of this problem. IGV desktop goes into a special mode when running batch scripts where the UI is locked and everything is synchronous. There is already a python project for creating batch screenshots from IGV desktop, this project could perhaps be used from notebooks. The project is here: https://github.com/stevekm/IGV-snapshot-automator

@jrobinso jrobinso closed this as completed May 5, 2022
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