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

set-default-session --tracks generates incomplete session #2708

Closed
heavywatal opened this issue Feb 2, 2022 · 13 comments · Fixed by #4146
Closed

set-default-session --tracks generates incomplete session #2708

heavywatal opened this issue Feb 2, 2022 · 13 comments · Fixed by #4146
Labels
bug Something isn't working

Comments

@heavywatal
Copy link
Contributor

set-default-session --tracks generates tracks with minimal properties: "type" and "configuration":

    "views": [
      {
        "id": "LinearGenomeView-12",
        "type": "LinearGenomeView",
        "tracks": [
          {
            "type": "QuantitativeTrack",
            "configuration": "monocot"
          },
          {
            "type": "AlignmentsTrack",
            "configuration": "zea_mays"
          },

This config.json results in a fatal error TypeError: Cannot read properties of undefined (reading 'height').

To Reproduce

  1. jbrowse create
  2. jbrowse add-assembly
  3. jbrowse add-track
  4. jbrowse set-default-session --tracks
  5. Open the configured app in a web browser.

Expected behavior

  • App should allow unset properties like height and show tracks with some default values.
  • set-default-session should set all the required properties.

Screenshots

Screen Shot 2022-02-02 at 17 56 50

Version:

@jbrowse/cli/1.6.4 darwin-x64 node-v16.13.21

Additional context

I am trying to automate jbrowse configuration to handle many different conditions and data. I hope everything can be done via CLI.

@heavywatal heavywatal added the bug Something isn't working label Feb 2, 2022
@cmdcolin
Copy link
Collaborator

cmdcolin commented Feb 2, 2022

Hi there
I think this is indeed an issue, basically the code for set-default-session was created before we had the concept of "displays"

Probably for the time being, --tracks will not work

You could instead

a) Use File->Export session and load that file with jbrowse set-default-session -s exported_session.json
b) Use admin server to set the default session
c) Use URL linking to the session you want using the URL parameter API (newly released in 1.6.4) https://jbrowse.org/jb2/docs/urlparams/

@cmdcolin
Copy link
Collaborator

cmdcolin commented Feb 2, 2022

For us to fix the --tracks parameter we will either

  1. Fix the CLI behavior as is
  2. Add some sort of "session spec" (behavior similar to how &tracks works in the URL bar) to the CLI (which may either add a new config slot or overload the defaultSession config slot to have multiple meanings)

@heavywatal
Copy link
Contributor Author

Thank you for the suggestion for workaround. Now I have another problem that admin-server does not work with --target (or I am doing it wrong):

  1. npx jbrowse admin-server --target mytarget prints navigation to the URL like http://localhost:9090?adminKey=1q2w3e4r5t, which opens ./config.json not mytarget/config.json.
  2. Adding &config=mytarget%2Fconfig.json to the URL leads to the correct page, but the server tries to save changes to the wrong place, mytarget/mytarget/config.json.

Could you tell me what is wrong? or should I file a new issue for this?

@cmdcolin
Copy link
Collaborator

cmdcolin commented Feb 3, 2022

this is not a well documented behavior but you can use

npx jbrowse admin-server

in your jbrowse root directory, or make --out point at a root directory, not at the specific config, and then you can navigate to http://localhost:9090?adminKey=keyhere&config=mytarget/config.json

and it will write to root directory+'mytarget/config.json'

this behavior was added here just for reference #2139

can try to improve docs for this a bit

@heavywatal
Copy link
Contributor Author

Thank you, npx jbrowse admin-server in the root and adding &config=mytarget/config.json worked.

But --out/--target <root> did not work, and a browser only shows "Cannot GET /". (Even if it works, IMHO, it slightly diminishes the consistency of --target option. It is shared among many subcommands, but it has a special meaning/usage for admin-server)

@cmdcolin
Copy link
Collaborator

cmdcolin commented Feb 6, 2022

thanks for the continued patience with this. Indeed, --out was not working. I have proposed a fix that allows it to work in #2715

also changes the name of the flag to be --root instead of --out/--target because it is indeed inconsistent, and since --out was not working anyways, hopefully the change is not disruptive.

@abretaud
Copy link

Hi!
I've just encountered the same kind of problem while working on the jbrowse2 galaxy tool: when displaying the result of the galaxy tool, I'd like the default session to display the assembly and a list of tracks.
My code modifies the config.json to do it but:

  • I'm forced to add a display block with height: 100 to avoid the error described above: it would be nice if jbrowse could guess a default display
  • I always get the "Select assembly to view" dialog, unless I add a displayedRegions in the default session. The problem is that my code knows nothing about the content of the genome (contigs and their lengths): wouldn't it be possible to just make the default session open the assembly at a default location, wisely chosen by jbrowse?

Any thoughts on that? Not sure if it matches with the kind of "session spec" you are referring to above

@garrettjstevens
Copy link
Collaborator

@abretaud The "session spec" solution would allow us to specify a reduced representation of the session that JBrowse interprets and loads. As an example, the same kind of JSON that you can use in a URL like is described here could be placed in a config file.

@cmdcolin and I discussed some solutions for this today. If we want to be able to put a "session spec" in the config file, it would probably need its own key (like "defaultSessionSpec"). That does leave open the question of whether "defaultSession" or "defaultSessionSpec" would have priority if both were specified.

We also tried adding a snapshot preprocessor to the BaseTrackModel with the idea that we might be able to add displays on load, which would allow the current set-default-session code to work. The snapshot processors had some odd behavior, though. We tried .preProcessSnapshot, and for some reason the snapshot processer seemed to run ~20 on page load with only a single track open, and then several more times for each new track that was opened. We also tried using types.snapshotProcessor, but that caused the page to freeze when opening a new track.

@abretaud
Copy link

Ok, session spec looks like a good idea! There's a loc in the example: could it be optional = jbrowse would bring you to a default location?

(I'd say defaultSessionSpec could be ignored when a defaultSession is present)

@abretaud
Copy link

Another related thing: is there (or could there be?) a way to specify some display settings for tracks that are not shown? For example, I'd like to add a bam track, hidden by default, but I would like it to use LinearSNPCoverageDisplay by default when the user shows it

@cmdcolin
Copy link
Collaborator

@abretaud one way to force a SNPCoverage display by default is via the config file

our volvox sample config has an entry that does this that looks like this, the crucial part being the "displays" array

{
      "type": "AlignmentsTrack",
      "trackId": "volvox_cram_snpcoverage",
      "name": "volvox-sorted.cram (contigA, LinearSNPCoverageDisplay)",
      "assemblyNames": ["volvox"],
      "adapter": {
        "type": "CramAdapter",
        "cramLocation": {
          "uri": "volvox-sorted-altname.cram",
          "locationType": "UriLocation"
        },
        "craiLocation": {
          "uri": "volvox-sorted-altname.cram.crai",
          "locationType": "UriLocation"
        },
        "sequenceAdapter": {
          "type": "TwoBitAdapter",
          "twoBitLocation": {
            "uri": "volvox.2bit",
            "locationType": "UriLocation"
          }
        }
      },
      "displays": [
        {
          "type": "LinearSNPCoverageDisplay",
          "displayId": "volvox_cram_snpcoverage_snpcoverage"
        }
      ]
    },

https://jbrowse.org/code/jb2/v1.6.5/?config=test_data%2Fvolvox%2Fconfig.json&session=share-pwzCQXhz9F&password=fLJAO

@abretaud
Copy link

@abretaud one way to force a SNPCoverage display by default is via the config file

With a little delay: thanks, it works!
I'd also like to set some display options, I've tried adding "displayCrossHatches": true in the displays block, but it seems like it's ignored. Is it normal/is there another way?

@cmdcolin
Copy link
Collaborator

@abretaud can you create a new issue or discussion for this? it's hard to track too many branches on a thread :)

just to try to address, I think displayCrossHatches is part of the "renderer" config. It is also part of the state model of the display to allow the user to select it via the UI. we could probably add it as a config of the display to make that easier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants