GMOD / JBrowseR

R interface to the JBrowse 2 Linear Genome View.
https://gmod.github.io/JBrowseR/
Apache License 2.0
35 stars 3 forks source link

Configure defaultSession error using JSON file #35

Open 1027victor opened 4 months ago

1027victor commented 4 months ago

Hi, thanks for this excellent software. I have a genome browser working with JBrowseR but when I configure session in the JSON file, the code reports an error:Warning: bindFillRole() only works on htmltools::tag() objects (e.g., div(), p(), etc.), not objects of type 'shiny.tag.list'. then shiny don't work

"defaultSession": {     "name": "hg19",     "views": [       {         "id": "linearGenomeView",         "type": "LinearGenomeView",         "offsetPx": 99,         "bpPerPx": 10000,         "displayedRegions": [           {             "refName": "10",             "start": 0,             "end": 133797422,             "reversed": false,             "assemblyName": "hg19"           }         ],         "tracks": [           {             "id": "ljULB6OHl",             "type": "BasicTrack",             "height": 400,             "configuration": "ncbi_gff_hg19"           }         ],         "hideHeader": false,         "hideHeaderOverview": false,         "trackSelectorType": "hierarchical",         "showTrackLabels": true,         "showCenterLine": false       }     ]   }

1027victor commented 4 months ago

when I run code,I get the blank screen

cmdcolin commented 4 months ago

if possible, can you post your entire code? i could try to guess to debug but it might help to just see it :)

the blank screen issues are sort of a problem we could try to improve with better error reporting also. if you want to try to track down the error also, you can look at your browser devtools and look at the "console"

the bindFillRole is a known warning, it wouldn't be causing what you're seeing

1027victor commented 4 months ago

yeah,it is my entire code.

shiny app:


library(shiny)
library(JBrowseR)

ui <- fluidPage(
  titlePanel("JSON JBrowseR Example"),
  JBrowseROutput("browserOutput")
)

server <- function(input, output, session) {
  # using JBrowseR helper function to parse the config
  config <- json_config("./www/config.json")

  output$browserOutput <- renderJBrowseR(
    JBrowseR("JsonView",
             config = config,
             location = "chr11:88,999,378..89,020,295"
    )
  )
}

shinyApp(ui, server)

config.json:

{
  "assembly": {
    "name": "GRCh38",
    "aliases": ["GRCh38"],
    "sequence": {
      "type": "ReferenceSequenceTrack",
      "trackId": "Pd8Wh30ei9R",
      "adapter": {
        "type": "BgzipFastaAdapter",
        "fastaLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/fa/GRCh38.p14.genome.fa.gz",
          "locationType": "UriLocation"
        },
        "faiLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/fa/GRCh38.p14.genome.fa.gz.fai",
          "locationType": "UriLocation"
        },
        "gziLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/fa/GRCh38.p14.genome.fa.gz.gzi",
          "locationType": "UriLocation"
        }
      }
    },
    "refNameAliases": {
      "adapter": {
        "type": "RefNameAliasAdapter",
        "location": {
          "uri": "https://s3.amazonaws.com/jbrowse.org/genomes/hg19/hg19_aliases.txt",
          "locationType": "UriLocation"
        }
      }
    },
    "cytobands": {
      "adapter": {
        "type": "CytobandAdapter",
        "cytobandLocation": {
          "uri": "https://s3.amazonaws.com/jbrowse.org/genomes/hg19/cytoBand.txt"
        }
      }
    }
  },
    "defaultSession": {
    "id": "eXr4hv4VX",
    "name": "Session",
    "views": [
      {
        "id": "eXr4hv4VX-view",
        "type": "LinearGenomeView",
        "offsetPx": 14500,
        "bpPerPx": 1.7,
        "displayedRegions": [
          {
            "refName": "ctgA",
            "start": 0,
            "end": 50001,
            "reversed": false,
            "assemblyName": "GRCh38"
          }
        ]
      }
    ]
  },

  "tracks":[
  {
  "type": "MultiQuantitativeTrack",
  "trackId": "microarray_multi_groups",
  "name": "PRJEB30442",
  "category": ["ENCODE bigWigs"],
  "assemblyNames": ["GRCh38"],
  "adapter": {
    "type": "MultiWiggleAdapter",
    "subadapters": [
      {
        "type": "BigWigAdapter",
        "name": "B2+",
        "bigWigLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/bw/sortB2%2B_merged_output.bw"
        },
        "group": "group1"
      },
      {
        "type": "BigWigAdapter",
        "name": "B3",
        "bigWigLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/bw/sortB3_merged_output.bw"
        },
        "group": "group2"
      },
      {
        "type": "BigWigAdapter",
        "name": "B4",
        "bigWigLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/bw/sortB4_merged_output.bw"
        },
        "group": "group3"
      },
      {
        "type": "BigWigAdapter",
        "name": "B5",
        "bigWigLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/bw/sortB5_merged_output.bw"
        },
        "group": "group4"
      },
      {
        "type": "BigWigAdapter",
        "name": "MC",
        "bigWigLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/bw/sortMC_merged_output.bw"
        },
        "group": "group5"
      }
      ]
  }

  },
  {
  "type": "FeatureTrack",
      "trackId": "GENCODE_gff_GRCh38",
      "name": "GENCODE RefSeq",
      "formatDetails": {
        "subfeatures": "jexl:{name:'<a href=https://google.com/?q='+feature.name+'>'+feature.name+'</a>'}"
      },
      "assemblyNames": ["GRCh38"],
      "category": ["Genes"],
      "metadata": {
        "source": "https://www.ncbi.nlm.nih.gov/genome/guide/human/",
        "dateaccessed": "12/03/2020"
      },
      "adapter": {
        "type": "Gff3TabixAdapter",
        "gffGzLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/gff/gencode.v44.chr_patch_hapl_scaff.annotation.gff3.gz",
          "internetAccountId": "httpHeaders"
        },
        "index": {
          "location": {
            "uri": "https://scasdb.s3.amazonaws.com/gff/gencode.v44.chr_patch_hapl_scaff.annotation.gff3.gz.tbi",
            "internetAccountId": "httpHeaders"
          }
        }
      }
  }
  ]
}

when I run code,,I get the blank screen,but I delete defaultsession in the config,the code can run correctly

cmdcolin commented 4 months ago

this is actually a case where the session snapshots only have one view, so you change the "views array" to a single "view"

here is a working config.json that i believe fixes your use case

{
  "assembly": {
    "name": "GRCh38",
    "aliases": ["GRCh38"],
    "sequence": {
      "type": "ReferenceSequenceTrack",
      "trackId": "Pd8Wh30ei9R",
      "adapter": {
        "type": "BgzipFastaAdapter",
        "fastaLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/fa/GRCh38.p14.genome.fa.gz",
          "locationType": "UriLocation"
        },
        "faiLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/fa/GRCh38.p14.genome.fa.gz.fai",
          "locationType": "UriLocation"
        },
        "gziLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/fa/GRCh38.p14.genome.fa.gz.gzi",
          "locationType": "UriLocation"
        }
      }
    },
    "refNameAliases": {
      "adapter": {
        "type": "RefNameAliasAdapter",
        "location": {
          "uri": "https://s3.amazonaws.com/jbrowse.org/genomes/hg19/hg19_aliases.txt",
          "locationType": "UriLocation"
        }
      }
    },
    "cytobands": {
      "adapter": {
        "type": "CytobandAdapter",
        "cytobandLocation": {
          "uri": "https://s3.amazonaws.com/jbrowse.org/genomes/hg19/cytoBand.txt"
        }
      }
    }
  },
  "defaultSession": {
    "id": "eXr4hv4VX",
    "name": "Session",
    "view": {
      "id": "eXr4hv4VX-view",
      "type": "LinearGenomeView",
      "offsetPx": 14500,
      "bpPerPx": 1.7,
      "displayedRegions": [
        {
          "refName": "ctgA",
          "start": 0,
          "end": 50001,
          "reversed": false,
          "assemblyName": "GRCh38"
        }
      ]
    }
  },

  "tracks": [
    {
      "type": "MultiQuantitativeTrack",
      "trackId": "microarray_multi_groups",
      "name": "PRJEB30442",
      "category": ["ENCODE bigWigs"],
      "assemblyNames": ["GRCh38"],
      "adapter": {
        "type": "MultiWiggleAdapter",
        "subadapters": [
          {
            "type": "BigWigAdapter",
            "name": "B2+",
            "bigWigLocation": {
              "uri": "https://scasdb.s3.amazonaws.com/bw/sortB2%2B_merged_output.bw"
            },
            "group": "group1"
          },
          {
            "type": "BigWigAdapter",
            "name": "B3",
            "bigWigLocation": {
              "uri": "https://scasdb.s3.amazonaws.com/bw/sortB3_merged_output.bw"
            },
            "group": "group2"
          },
          {
            "type": "BigWigAdapter",
            "name": "B4",
            "bigWigLocation": {
              "uri": "https://scasdb.s3.amazonaws.com/bw/sortB4_merged_output.bw"
            },
            "group": "group3"
          },
          {
            "type": "BigWigAdapter",
            "name": "B5",
            "bigWigLocation": {
              "uri": "https://scasdb.s3.amazonaws.com/bw/sortB5_merged_output.bw"
            },
            "group": "group4"
          },
          {
            "type": "BigWigAdapter",
            "name": "MC",
            "bigWigLocation": {
              "uri": "https://scasdb.s3.amazonaws.com/bw/sortMC_merged_output.bw"
            },
            "group": "group5"
          }
        ]
      }
    },
    {
      "type": "FeatureTrack",
      "trackId": "GENCODE_gff_GRCh38",
      "name": "GENCODE RefSeq",
      "formatDetails": {
        "subfeatures": "jexl:{name:'<a href=https://google.com/?q='+feature.name+'>'+feature.name+'</a>'}"
      },
      "assemblyNames": ["GRCh38"],
      "category": ["Genes"],
      "metadata": {
        "source": "https://www.ncbi.nlm.nih.gov/genome/guide/human/",
        "dateaccessed": "12/03/2020"
      },
      "adapter": {
        "type": "Gff3TabixAdapter",
        "gffGzLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/gff/gencode.v44.chr_patch_hapl_scaff.annotation.gff3.gz",
          "internetAccountId": "httpHeaders"
        },
        "index": {
          "location": {
            "uri": "https://scasdb.s3.amazonaws.com/gff/gencode.v44.chr_patch_hapl_scaff.annotation.gff3.gz.tbi",
            "internetAccountId": "httpHeaders"
          }
        }
      }
    }
  ]
}

hope that helps. potentially we could allow the views array and just select views[0] in import, that might improve compatibility with snapshots from the main app

1027victor commented 4 months ago

yeah,it is useful,but I want add views,now,Can't it be supported

excample

  "defaultSession": {
    "name": "GRCh38",
    "views": [
      {
        "id": "linearGenomeView",
        "type": "LinearGenomeView",
        "offsetPx": 99,
        "bpPerPx": 10000,
        "displayedRegions": [
          {
            "refName": "chr10",
            "start": 0,
            "end": 133797422,
            "reversed": false,
            "assemblyName": "GRCh38"
          }
        ],
        "tracks": [
          {
            "id": "ljULB6OHl",
            "type": "BasicTrack",
            "height": 400,
            "configuration": "GENCODE RefSeq"
          }
        ],
        "hideHeader": false,
        "hideHeaderOverview": false,
        "trackSelectorType": "hierarchical",
        "showTrackLabels": true,
        "showCenterLine": false
      }
    ]
  },
1027victor commented 4 months ago

When I want to initialize the genome browser, I will directly display the data I have configured,According to the example I provided above, it cannot be displayed correctly

cmdcolin commented 4 months ago

Not sure I understand...can you explain more

1027victor commented 4 months ago

I want to use defaultsession in config.json and directly display my configured track, assembly, and bw when opening the genome browser, without the need to manually add them after opening. But my example doesn't work

example

  "defaultSession": {
    "name": "GRCh38",
    "views": [
      {
        "id": "linearGenomeView",
        "type": "LinearGenomeView",
        "offsetPx": 99,
        "bpPerPx": 10000,
        "displayedRegions": [
          {
            "refName": "chr10",
            "start": 0,
            "end": 133797422,
            "reversed": false,
            "assemblyName": "GRCh38"
          }
        ],
        "tracks": [
          {
            "id": "ljULB6OHl",
            "type": "BasicTrack",
            "height": 400,
            "configuration": "GENCODE RefSeq"
          }
        ],
        "hideHeader": false,
        "hideHeaderOverview": false,
        "trackSelectorType": "hierarchical",
        "showTrackLabels": true,
        "showCenterLine": false
      }
    ]
  },
1027victor commented 4 months ago

I actually want to create a default session for custom JBrowse views and directly display my configuration data,but my above example dosen't work

cmdcolin commented 4 months ago

from my previous note, there is just a technical thing where you have to change the format of the defaultSession to use a single "view" object instead of a "views" array as I noted previously (https://github.com/GMOD/JBrowseR/issues/35#issuecomment-1990083716)

you can alternatively use the "default_session" helper function described here https://gmod.github.io/JBrowseR/articles/custom-browser-tutorial.html#setting-a-default-session

default sessions are unfortunately just kind of a tricky issue, they are just a bit tricky to use programmatically, it's a bit of our fault. i am happy to try to advise but just let me know what you need in clear terms

cmdcolin commented 4 months ago

i have tried to triage a couple extra issues from this thread including #36 #37 and #38

1027victor commented 4 months ago

Sorry, I may not have explained my problem clearly. I want to open the genome browser, the default display is the reference genome alignment, gff3 file, and bw file. Below are my shiny app and configuration files, which cannot work.

shiny app

library(shiny)
library(JBrowseR)

ui <- fluidPage(
  titlePanel("JSON JBrowseR Example"),
  JBrowseROutput("browserOutput")
)

server <- function(input, output, session) {
  # using JBrowseR helper function to parse the config
  config <- json_config("./www/config.json")

  output$browserOutput <- renderJBrowseR(
    JBrowseR("JsonView",
             config = config
    )
  )
}

shinyApp(ui, server)

config.json

{
  "assembly": {
    "name": "GRCh38",
    "aliases": ["GRCh38"],
    "sequence": {
      "type": "ReferenceSequenceTrack",
      "trackId": "Pd8Wh30ei9R",
      "adapter": {
        "type": "BgzipFastaAdapter",
        "fastaLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/fa/GRCh38.p14.genome.fa.gz",
          "locationType": "UriLocation"
        },
        "faiLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/fa/GRCh38.p14.genome.fa.gz.fai",
          "locationType": "UriLocation"
        },
        "gziLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/fa/GRCh38.p14.genome.fa.gz.gzi",
          "locationType": "UriLocation"
        }
      }
    },
    "refNameAliases": {
      "adapter": {
        "type": "RefNameAliasAdapter",
        "location": {
          "uri": "https://s3.amazonaws.com/jbrowse.org/genomes/hg19/hg19_aliases.txt",
          "locationType": "UriLocation"
        }
      }
    },
    "cytobands": {
      "adapter": {
        "type": "CytobandAdapter",
        "cytobandLocation": {
          "uri": "https://s3.amazonaws.com/jbrowse.org/genomes/hg19/cytoBand.txt"
        }
      }
    },
    "displays": [
    {
      "type": "LinearReferenceSequenceDisplay",
      "displayId": "GRCm38-ReferenceSequenceTrack-LinearReferenceSequenceDisplay"
    }
  ]

  },

  "tracks": [
    {
      "type": "MultiQuantitativeTrack",
      "trackId": "microarray_multi_groups",
      "name": "PRJEB30442",
      "category": ["ENCODE bigWigs"],
      "assemblyNames": ["GRCh38"],
      "adapter": {
        "type": "MultiWiggleAdapter",
        "subadapters": [
          {
            "type": "BigWigAdapter",
            "name": "B2+",
            "bigWigLocation": {
              "uri": "https://scasdb.s3.amazonaws.com/bw/sortB2%2B_merged_output.bw"
            },
            "group": "group1"
          },
          {
            "type": "BigWigAdapter",
            "name": "B3",
            "bigWigLocation": {
              "uri": "https://scasdb.s3.amazonaws.com/bw/sortB3_merged_output.bw"
            },
            "group": "group2"
          },
          {
            "type": "BigWigAdapter",
            "name": "B4",
            "bigWigLocation": {
              "uri": "https://scasdb.s3.amazonaws.com/bw/sortB4_merged_output.bw"
            },
            "group": "group3"
          },
          {
            "type": "BigWigAdapter",
            "name": "B5",
            "bigWigLocation": {
              "uri": "https://scasdb.s3.amazonaws.com/bw/sortB5_merged_output.bw"
            },
            "group": "group4"
          },
          {
            "type": "BigWigAdapter",
            "name": "MC",
            "bigWigLocation": {
              "uri": "https://scasdb.s3.amazonaws.com/bw/sortMC_merged_output.bw"
            },
            "group": "group5"
          }
        ]
      },
      "displays": [
    {
      "type": "MultiLinearWiggleDisplay",
      "displayId": "microarray_multi-MultiLinearWiggleDisplay"
    }
  ]
    },

    {
      "type": "FeatureTrack",
      "trackId": "GENCODE_gff_GRCh38",
      "name": "GENCODE RefSeq",
       "formatDetails": {
    "subfeatures": "jexl:{name:'<a href=https://google.com/?q='+feature.name+'>'+feature.name+'</a>',newfield:'Custom contents here: '+feature.name,type:undefined }"
  },
      "assemblyNames": ["GRCh38"],
      "category": ["Genes"],
      "metadata": {
        "source": "https://www.ncbi.nlm.nih.gov/genome/guide/human/",
        "dateaccessed": "12/03/2020"
      },
      "adapter": {
        "type": "Gff3TabixAdapter",
        "gffGzLocation": {
          "uri": "https://scasdb.s3.amazonaws.com/gff/gencode.v44.chr_patch_hapl_scaff.annotation.gff3.gz",
          "internetAccountId": "httpHeaders"
        },
        "index": {
          "location": {
            "uri": "https://scasdb.s3.amazonaws.com/gff/gencode.v44.chr_patch_hapl_scaff.annotation.gff3.gz.tbi",
            "internetAccountId": "httpHeaders"
          }
        }
      },

   "displays": [
    {
      "type": "LinearBasicDisplay",
      "displayId": "sorted.gff3-LinearBasicDisplay"
    }
  ]

    }
  ],

     "defaultSession": {
    "name": "mysession",
    "view": {
      "id": "linearGenomeView",
      "type": "LinearGenomeView",
      "tracks": [
        {
             "type": "ReferenceSequenceTrack",
              "configuration": "Pd8Wh30ei9R",
          "displays": [
            {
              "type": "LinearReferenceSequenceDisplay",
              "configuration": "GRCm38-ReferenceSequenceTrack-LinearReferenceSequenceDisplay"
            }
          ]
        },
        {
          "type": "MultiQuantitativeTrack",
          "configuration": "microarray_multi_groups",
          "displays": [
            {
              "type": "MultiLinearWiggleDisplay",
              "configuration": "microarray_multi-MultiLinearWiggleDisplay",
              "height": "300"
            }
          ]
        },
        {

           "type": "FeatureTrack",
            "configuration": "GRCm38-ReferenceSequenceTrack",
          "displays": [
            {
              "type": "LinearBasicDisplay",
              "configuration": "sorted.gff3-LinearBasicDisplay",
              "height": "80"
            }
          ]
        }
      ]
    }
  }
}