Skip to contents

1 A list of plots

1.1 JavaScript

This figure starts with a default and is updated when selected for one of the two alternatives.

htmltools::tags$iframe(src ="lz.htm", width = "100%", height = "600px")

THe HTML skeleton (lz.htm) takes a file named top_hits.json containing the menu items,

[
  ["A1BG", "rs145685027", "19:58948122"],
  ["ACE", "rs4353", "17:61570422"]
]

each corresponds to a file for GWAS summary statistics as shown below

> d <- jsonlite::fromJSON("vignettes/data/ACE-rs4353.json")
> class(d)
[1] "list"
> lapply(d,class)
$ppid
[1] "character"

$data
[1] "data.frame"

> lapply(d,head,3)
$ppid
[1] "ACE-rs4353"

$data
          variant position ref_allele alt_allele_freq    beta log_pvalue
1 17:61322094_G/T 61322094          G          0.0154 -0.1899       0.69
2 17:61322221_G/A 61322221          G          0.1905  0.0190       0.22
3 17:61322307_G/T 61322307          G          0.9682  0.4065       5.65

> j <- jsonlite::toJSON(lapply(d,head,3))
> j
{"ppid":["ACE-rs4353"],"data":[{"variant":"17:61322094_G/T","position":61322094,"ref_allele":"G","alt_allele_freq":0.0154,"beta":-0.1899,"log_pvalue":0.69},{"variant":"17:61322221_G/A","position":61322221,"ref_allele":"G","alt_allele_freq":0.1905,"beta":0.019,"log_pvalue":0.22},{"variant":"17:61322307_G/T","position":61322307,"ref_allele":"G","alt_allele_freq":0.9682,"beta":0.4065,"log_pvalue":5.65}]}

1.2 Shiny

This is a skeleton for possibly interactive use.

library(shiny)

# Define a list of protein-pQTL pairs with named elements
protein_pqtl_pairs <- list(
  "A1BG" = c("A1BG", "rs145685027", "19:58948122"),
  "ACE" = c("ACE", "rs4353", "17:61570422")
)

# Define a list of image URLs corresponding to each protein-pQTL pair
image_urls <- c(
  "https://example.com/image1.jpg",
  "https://example.com/image2.jpg"
)

ui <- fluidPage(
  titlePanel("Protein-pQTL"),
  sidebarLayout(
    sidebarPanel(
      selectInput("imageSelect", "Protein-pQTL pair:",
                  choices = names(protein_pqtl_pairs),
                  selected = names(protein_pqtl_pairs)[1])
    ),
    mainPanel(
      imageOutput("selectedImage")
    )
  )
)

server <- function(input, output) {
  output$selectedImage <- renderImage({
    selected_pair <- protein_pqtl_pairs[[input$imageSelect]]
    
    # Use the first element of the vector returned by match
    selected_image_url <- image_urls[match(selected_pair, protein_pqtl_pairs)[1]]
    
    list(src = selected_image_url, alt = "Selected Image")
  }, deleteFile = FALSE)
}

shinyApp(ui, server)

2 Stacked association plots

The figure below contains three panels.