Python-bloggers

shiny.gosling is Now on Bioconductor – An Open-Source Software for Bioinformatics

This article was first published on Appsilon | Enterprise R Shiny Dashboards , and kindly contributed to python-bloggers. (You can report issue about the content on this page here)
Want to share your content on python-bloggers? click here.

Inclusion of our shiny.gosling package on Bioconductor is a three-fold milestone for us. First, it gives our developers the recognition they deserve. Second, it strengthens our position as a leading voice in bioinformatics software development. And finally, it amplifies our visibility and credibility within the scientific community.

For you, as a user, developer, or researcher, it means you’ll now have a much easier time incorporating genomics visualizations into your bioinformatics research projects and Shiny dashboards.

Today’s article will show you how to get started with shiny.gosling and Bioconductor in general.

Looking for practical genomics visualization examples? These 7 should get you started in with shiny.gosling R and R Shiny.

Table of contents:

What is shiny.gosling and Why Should You Care?

Genomics is a fascinating field, but one of the most challenging to bridge with computer science. There are too many niches within the field for any single R package to bridge the gap. No matter what you do, you simply can’t cover everyone’s point of interest and research.

Our shiny.gosling package is an R Shiny wrapper for gosling.js powered by shiny.react. In other words, it’s a grammar-based toolkit for scalable and interactive data visualization.

Image 1 – shiny.gosling new hex logo

Let’s go over the main functionalities and benefits of using shiny.gosling for genomics data visualization.

Main Functionalities

You now know what shiny.gosling is, but how exactly is it tied with Bioconductor? And what is Bioconductor in the first place? Let’s answer that next.

Why the Inclusion of shiny.gosling in Bioconductor is a Significant Milestone

We already mentioned that having an R package included in Bioconductor is a huge accomplishment, both for our developers and for Appsilon as a company. This section will provide more details into why, and will also show how you can benefit from it.

What is Bioconductor?

Bioconductor is a project that aims to develop and share open-source software for precise and repeatable analysis of biological data. It’s updated twice a year, and the latest version includes exactly 2300 packages!

Image 2 – Bioconductor hex logo

So, it’s clear that many companies and developers around the world are contributing to Bioconductor with the same goal in mind. We’re proud to be on that list.

Inclusion Benefits for Users and Developers

If you’re thinking about switching to Bioconductor for your bioinformatics research, here are a couple of reasons to go for it:

On the other hand, if you’re a developer in the field of bioinformatics, submitting an R package to Bioconductor also has its fair share of advantages:

To conclude, having a package accepted by Bioconductor means you’re on the right track to becoming a subject matter expert in bioinformatics – both as a company and as an individual. Our recent inclusion did just that for Appsilon as a company and our team of expert developers.

Starting Small – How to Run Basic shiny.gosling examples

Before diving deeper into Shiny examples, let’s take a peek at a couple of examples that are available to you in a single function call.

The shiny.gosling::run_example() function can be used to run any of the 17 examples that come by default with the package installation. You can pass one of the following values into the function:

Let’s see one of these in action:

shiny.gosling::run_example("circularVisualEncoding")

This is the output you’ll see after running the example:

Image 3 – Shiny Gosling circular visual encoding example

That was simple, wasn’t it?

Up next, we’re about to complicate things slightly.

R Shiny is transforming processes in the Pharmaceutical industry? Read (and watch) our latest talk in R/Basel to find out how.

shiny.gosling in Action – How to Get Started in R and R Shiny

The BiocManager package in R allows you to install the mentioned 2300 approved packages straight from the R console. The alternative way is to get started through a Docker container. We’ll proceed with the first option.

Assuming you have R installed (R version 4.4.0 or above is required for Bioconductor 3.19), get the BiocManager package by running the following command from the R console:

if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install(version = "3.19")

Once installed, proceed with shiny.gosling installation:

BiocManager::install("shiny.gosling")

You can see how the package was installed through BiocManager instead of your typical install.packages() command.

When it comes to R Shiny, the shiny.gosling package provides a couple of functions you must know about:

Now with this knowledge, we’ll build a multi-scale sequence track application that displays DNA base counts and annotations, allowing the user to explore genomic data related to the SARS-CoV-2 virus. The code snippet below will fetch the base counts data organized into rows and columns with attributes such as base, position, count, and categories (A, T, G, C).

For a more detailed description of the data processing pipeline, visit the official example documentation.

Anyhow, here’s the entire code snippet:

library(shiny)
library(shiny.gosling)

track1_data <- track_data(
  url = "https://server.gosling-lang.org/api/v1/tileset_info/?d=NC_045512_2-multivec",
  type = "multivec",
  row = "base",
  column = "position",
  value = "count",
  categories = c("A", "T", "G", "C"),
  start = "start",
  end = "end"
)

track1 <- add_single_track(
  mark = "bar",
  y = visual_channel_y(
    field = "count", type = "quantitative", axis = "none"
  )
)

track2 <- add_single_track(
  dataTransform = track_data_transform(
    type = "filter",
    field = "count",
    oneOf = list(0),
    not = TRUE
  ),
  mark = "text",
  x = visual_channel_x(
    field = "start", type = "genomic"
  ),
  xe = visual_channel_x(
    field = "end", type = "genomic"
  ),
  size = 24,
  color = "white",
  visibility = list(
    list(
      operation = "less-than",
      measure = "width",
      threshold = "|xe-x|",
      transitionPadding = 30,
      target = "mark"
    ),
    list(
      operation = "LT",
      measure = "zoomLevel",
      threshold = 40,
      target = "track"
    )
  )
)

track1_x <- visual_channel_x(
  field = "position", type = "genomic"
)

track1_color <- visual_channel_color(
  field = "base",
  type = "nominal",
  domain = c("A", "T", "G", "C"),
  legend = TRUE
)

track1_text <- visual_channel_text(
  field = "base", type = "nominal"
)

track1_style <- default_track_styles(
  inlineLegend = TRUE
)

track3 <- add_single_track(
  title = "NC_045512.2 Sequence",
  alignment = "overlay",
  data = track1_data,
  tracks = add_multi_tracks(
    track1, track2
  ),
  x = track1_x,
  color = track1_color,
  text = track1_text,
  style = track1_style,
  width = 800, height = 40
)

view1 <- compose_view(
  multi = TRUE,
  centerRadius = 0,
  xDomain = list(interval = c(1, 29903)),
  linkingId = "detail",
  alignment = "stack",
  tracks = add_multi_tracks(
    track3
  )
)

combined_view <- arrange_views(
  title = "SARS-CoV-2",
  subtitle = "Data Source: WashU Virus Genome Browser, NCBI, GISAID",
  assembly = list(list("NC_045512.2", 29903)),
  layout = "linear",
  spacing = 50,
  views = list(view1),
  listify = FALSE
)

ui <- fluidPage(
  use_gosling(),
  fluidRow(
    column(6, goslingOutput("gosling_plot"))
  )
)

server <- function(input, output, session) {
  output$gosling_plot <- renderGosling({
    gosling(
      component_id = "sars_cov2",
      combined_view
    )
  })
}

shinyApp(ui, server)

You can see that ~ 85% of the code has to do with data gathering and processing. The convenient shiny.gosling functions do most of the heavy lifting when it comes to visualization – you just have to call the functions.

This is the R Shiny dashboard you’ll end up with:

Image 4 – The resulting shiny.gosling application

There are many more well-documented examples on the official Bioconductor shiny.gosling documentation page, so make sure to pay a visit.

Summing up shiny.gosling

Having a package included in a trusted and reputable platform such as Bioconductor is a huge accomplishment for Appsilon as a company and our team of expert developers. It validates months of hard work and makes future development that much more rewarding.

We’re excited to see how will developers and researchers use our package to help them tackle the biggest challenges in bioinformatics. If you fit into this group, we’d love to hear from you! Make sure to try shiny.gosling and provide feedback.

Did you find this blog post helpful? Sign up to Shiny Weekly to stay up to date on shiny.gosling and other open-source packages.

The post appeared first on appsilon.com/blog/.

To leave a comment for the author, please follow the link and comment on their blog: Appsilon | Enterprise R Shiny Dashboards .

Want to share your content on python-bloggers? click here.
Exit mobile version