-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviz.Rmd
113 lines (95 loc) · 2.69 KB
/
viz.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
title: "Omictools Visualization"
author: "gahoolee"
date: "Friday, August 28, 2015"
output: html_document
runtime: shiny
---
```{r, echo=FALSE, eval=T, warning=FALSE, message=FALSE}
library(shiny)
library(jsonlite)
library(d3treeR)
library(DT)
library(reshape2)
library(dplyr)
load('omictools.RData')
load('omictools_tree.RData')
software_df<-software_df %>%
mutate(id = gsub('^.*-', '', gsub('.html', '', omictools_link)) )
ui <- fluidPage(fluidRow(
column(6,
d3tree2Output( 'tree' ),
textOutput( "clickedinfo", container = p ),
DT::dataTableOutput('catalog')),
column(6, DT::dataTableOutput('detail'))
#textOutput( "detail", container = p )
)
)
server <- function( input, output, session ){
output$tree <- renderD3tree2({
d3tree2(toJSON(omictools, auto_unbox = T),
celltext = "name")
})
# from https://github.com/rstudio/leaflet/blob/master/inst/examples/shiny.R
v <- reactiveValues(table = NULL)
observeEvent(input$tree_click, {
v$table <- subset(catalog_tree_df, parent.name == input$tree_click$name)
if(nrow(v$table)==0){
v$table <- subset(software_tree_df, parent.name == input$tree_click$name)
}
})
output$clickedinfo <- renderText(input$tree_click$name)
output$catalog <- DT::renderDataTable({
datatable(v$table, selection = 'single') %>%
formatStyle(
'size',
background = styleColorBar(v$table$size, 'steelblue'),
backgroundSize = '100% 90%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'center'
)
})
output$detail <- DT::renderDataTable({
sid = v$table[input$catalog_row_last_clicked,]$id
message(sid)
software_df %>%
filter(id == sid) %>%
melt(id.vars='omictools_link', na.rm=T) %>%
select(-omictools_link) %>%
datatable %>%
formatStyle('variable', fontWeight='bold')
})
}
shinyApp( ui, server,
options=list(
width="100%", height="1440")
)
```
```{r, echo=FALSE, eval=FALSE}
library(jsonlite)
library(d3treeR)
library(DT)
library(listviewer)
library(reshape2)
load('omictools_tree.RData')
renderD3tree2({
d3tree2(toJSON(omictools, auto_unbox = T),
celltext = "name")
})
msg<-paste0(ls(), collapse = '\t')
selectInput('variables', 'variables',
choices=ls(),
selected=NULL)
v <- reactiveValues(msg = msg,
table = NULL,
m = list(aa=1))
renderJsonedit({
jsonedit(get(input$variables))
})
observeEvent(input$tree_click, {
v$msg <- input$tree_click$name
v$table <- subset(software_tree_df, parent.name == input$tree_click$name)
})
renderText(input$tree_click$name)
DT::renderDataTable(v$table)
```