/
LocusZoom.js.Rmd
84 lines (70 loc) · 1.87 KB
/
LocusZoom.js.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
title: "LocusZoom.js"
output:
bookdown::html_document2:
toc: true
toc_float: true
fontsize: 11pt
bibliography: '`r system.file("REFERENCES.bib", package="pQTLtools")`'
csl: nature-genetics.csl
pkgdown:
as_is: true
vignette: >
%\VignetteIndexEntry{LocusZoom.js}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include=FALSE}
set.seed(0)
knitr::opts_chunk$set(
out.extra = 'style="display:block; margin: auto"',
fig.align = "center",
fig.path = "LocusZoom.js/",
collapse = TRUE,
comment = "#>",
dev = "png")
```
# JavaScript
This calls `caprion_dr.js`.
```{r, results='asis', echo=FALSE}
library(htmltools)
lz <- tags$iframe(src ="lz.htm", width = "100%", height = "800px")
print(lz)
```
# Shiny
This is a skeleton for possibly interactive use.
```r
library(shiny)
# Define a list of protein-pQTL pairs with named elements
protein_pqtl_pairs <- list(
"A1BG" = c("A1BG", "rs145685027", "19:58948122", "0"),
"ACE" = c("ACE", "rs4353", "17:61570422", "1")
)
# 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)
```