Output and render functions for using JBrowseR within Shiny applications and interactive Rmd documents.

JBrowseROutput(outputId, width = "100%", height = "400px")

renderJBrowseR(expr, env = parent.frame(), quoted = FALSE)

Arguments

outputId

output variable to read from

width

Must be a valid CSS unit or a number, which will be coerced to a string and have 'px' appended.

height

Must be a valid CSS unit or a number, which will be coerced to a string and have 'px' appended.

expr

An expression that generates a JBrowseR

env

The environment in which to evaluate expr.

quoted

Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.

Value

the Shiny UI bindings for a JBrowseR htmlwidget

the Shiny server bindings for a JBrowseR htmlwidget

Details

Clicking a feature sets input[[paste0(outputId, "_selected_feature")]], which is namespaced per output and so is safe with several browsers on a page or inside a Shiny module. It also sets the global input$selectedFeature for backwards compatibility; prefer the per-output id in new apps.

Panning or zooming sets input[[paste0(outputId, "_location")]] to the visible region, so the server can recompute for what the user is looking at. It settles after the gesture rather than firing per frame, and there is no global twin — use the namespaced id:

output$browser <- renderJBrowseR(JBrowseR("hg38", location = "BRCA1"))
output$region <- renderText(input$browser_location)

The value is the same string the location box displays, which means it is formatted for reading rather than for parsing: coordinates carry thousand separators ("17:43,044,295..43,125,483"), and a view showing several regions gives them space-separated. Strip the commas before doing arithmetic with it — as.numeric(gsub(",", "", x)). It feeds straight back into location = unchanged, though (JBrowse parses what it prints).

Note that reading it in a reactive that also feeds renderJBrowseR() builds a loop: the widget rebuilds on every change, and a rebuild resets the view. Read it to drive other outputs.