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
Visual clue to the level of zoom on a genome #254
Comments
Yes, subtracting 123,456,700 from 123,467,800 to figure out the scale is quite burdensome! The most straightforward way to implement the measure is to provide a new lazy data source similar to axis ticks (source), which would generate a datum that represents a measure centered in the current domain. That could then be used to build the measure by layering some The generated datum could be something like this: {
"startChrom": "chr5",
"startPos": 123465000,
"endChrom": "chr5",
"endPos": 123475000,
"span": "10k",
"zoomLevel": 123,
"genomeAssembly": "hg38" // If it's useful to have it visible
} There are some (minor) issues, however:
This should be quite straightforward to implement. I could do this in near future, but now I have to focus on finalizing the revised version of my manuscript. PRs are welcome, of course 🙏. |
In fact, the datum could be even simpler, as the chromosomes/contigs are not really needed. Linearized coordinates (that GenomeSpy uses internally) could be used instead. This would also make the measure applicable to other scales, such {
"startPos": 1123465000,
"endPos": 1123475000,
"span": "10k",
"zoomLevel": 123,
"genomeAssembly": "hg38" // If it's useful to have it visible
} |
I'll give it a go! May I ask for a quick word of advice: what tooling (IDE, debugger, linter, etc.) do you use for development? The part that scares me the most about Javascript development are the asynchronous calls and promises - I have never had to deal with that and it looks to me that is the part that requires the most adjustment coming from "classical" synchronous programming. I'm reading about it https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous but I need to experiment with real-life scenarios. |
Awesome, @razsultana! I sketched a I'm using plain JavaScript (well, some recent version of EcmaScript) with JSDoc type annotations. Thus, no transpiling (Babel) is needed. Callbacks and promises may look formidable, but |
This is very useful, thank you! |
The initialization process is indeed quite intricate and I'm not entirely satisfied of its current state. Using a debugger and setting breakpoints is indeed a good idea. There are quite a few factors that complicate the initialization:
These are largely initiated at: genome-spy/packages/core/src/genomeSpy.js Line 430 in aa34a6a
Particularly the resolution of scales and domains (which behave similarly to Vega-Lite) is quite tricky. Ideally, it should be possible to add and remove views dynamically, but that's not quite compatible with the current design. When it comes to the implementation, you basically need to implement the It may not be necessary to publish new data every time the domain changes. For instance, the axisTickSource publishes data only when the Hope this helps! |
There are basically three ways. The static casegenome-spy/packages/core/src/genomeSpy.js Line 607 in aa34a6a
Named data through the APIThe genome-spy/packages/core/src/genomeSpy.js Line 218 in aa34a6a
... which is exposed through the API:
Lazy dataAnd then there are the lazy data sources that attach a listener to a
|
Thanks a lot for the very detailed explanation! |
Hi Kari, just letting you know I was away for a week with kids, camping (it's school holiday now) so I didn't get to do much, but I'm back now. The development environment that you recommended works like a charm - I have started to dig in the layered/hierarchical view and data sources initialisation and it's indeed complex. I'm though going up the steep part of the learning curve and hope to be able to get some results soon. |
Take your time! You may find the following function useful:
I'm using that in tests that initialize the view hierarchy and data flow. I have plenty of tests for most of the flow nodes (transforms and eager data sources) but lazy sources lack tests – mostly because I would have to mock network requests and I've been ... lazy! |
I pushed my minimal implementation of AxisMeasureSource to the master on my fork of the repository https://github.com/razsultana/genome-spy As you have correctly anticipated, when showing the measure at very high zoom levels, where the measure is 10 bases or 1 base wide, it is very jittery because of rounding. I actually don't want to show a measure at these levels, as it provides nothing in addition to seeing the ticks, coordinates and possibly FASTA sequence, but I can't figure a way to have an "empty" measure track, except to publish nulls for startPos and endPos and "" for spanLabel, which generate "undefined" values for the rules - not clean... I also would like to have way to trigger this datasource for a particular axis, the same way that ticks=True does it for axisTicksSource. I almost did it, but because the axisView class
Any suggestions for dealing with the above two problems would be appreciated! |
Awesome! I have yet to give it a try, but at least the code looks good! Please make a PR. It's easier for me to comment and propose changes that way.
Just publish an empty dataset:
Hmm. Interesting idea! Axes are currently somewhat hacky. There are several challenges:
Anyway, these may not be a problem when integrating the measure to axis for convenience.
That's not necessarily a problem. You may, however, stumble upon some challenges related to sizing of the views, etc. Feel free to try it out, but please make another branch/PR for it. And the last thing, please don't put stuff under |
I submitted a proper PR (sorry it took so long). pip cache purge
pip install mkdocs material mkdocs-material mkdocs-material-extensions --upgrade
pip install mkdocs-git-revision-date-localized-plugin
pip install "mkdocs-material[imaging]"
conda install cairo
cd utils/markdown_extension
pip install --editable .
npm run build:docs
cd site
python3 -m http.server --bind 127.0.0.1 I thought it might be helpful as a starting point for the mkdocs bootstrapping section in |
I think that a visual clue to the level of zooming on the genome would be very useful, similar with how UCSC does it here (shows a segment below the chromosome ideogram and it labels with its size, in this case 5kb):
.
I think that creating an element in the top banner of the genomespy-app (using maybe 1/3 of it and centered), showing the size of a genomic segment closest to 5, 50, 500, 5kb, 50kb, 500kb, 5 Mb, 50 Mb genomic size (or the 1-versions of these), which fits that area, would accomplish this goal very well.
When zooming in and out of an area that has no other elements (genes, chromosomal bands, FASTA sequence, etc), the user only has the coordinates to give a clue at which zoom level the visualisation is located and it takes extra effort and calculations to get that sense of scale. A visual clue provides that in an instant, without any efort.
The text was updated successfully, but these errors were encountered: