Skip to content

Commit

Permalink
updated epimatrix chord2 color scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
hetmanb committed Nov 18, 2014
1 parent ca54a85 commit 23efeff
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
22 changes: 22 additions & 0 deletions helpers/chord_helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@ chordcolor <- function(data, low, high){
chord_table$color <- (colors)
# chord_table <- subset(chord_table, subset = (chord_table$count >= low) & (chord_table$count <= high) )

palette <- as.vector(as.character(chord_table$color))
return(palette)
}
chord2color <- function(data, low, high){

chord_table <- data
colnames(chord_table) <- c("has", "prefers", "count")
chord_table <- unique(chord_table)
chord_table <- subset(chord_table, subset = (chord_table$count >= low) & (chord_table$count <= high) )


values <- chord_table$count


ii <- cut(values, breaks = seq(min(values), max(values), len = length(values)),
include.lowest = TRUE)

colors <- colorRampPalette(c("#F7FCF5","#E5F5E0","#C7E9C0","#A1D99B","#74C476","#41AB5D","#238B45","#005A32"))(length(ii))[ii]

chord_table$color <- (colors)
# chord_table <- subset(chord_table, subset = (chord_table$count >= low) & (chord_table$count <= high) )

palette <- as.vector(as.character(chord_table$color))
return(palette)
}
17 changes: 6 additions & 11 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,10 @@ shinyServer(function(input, output, session) {
if(is.null(input$strain_data)) { inFile <- read.table('data/demo_data/demo_58_strainlist.txt', header=T, sep='\t') }
else { inFile <- read.table(input$strain_data$datapath, header=T, sep='\t') }
return(EpiMap(inFile))

# # inFile <- read.table(file = 'data/strain_data.txt' , header = T)
# # markerlist <- list(c(inFile$Latitude, inFile$Longitude))
# epimap <- Leaflet$new()
# epimap$setView(c(49.6942, -112.8328), zoom = 6)
# # epimap$marker <- markerlist
# #epimap$marker(c(51.5, -0.09), bindPopup = "<p> Hi. I am a popup </p>")
# #epimap$marker(c(51.495, -0.083), bindPopup = "<p> Hi. I am another popup </p>")
# epimap

})

############ Functions for the Source Chord Diagram JS Output: #############################
############ Functions for the Epi-Chord Diagram JS Output: #############################

chord2_in <- reactive({
melt(EpiMatrix(table()))
Expand All @@ -188,12 +180,15 @@ chord2_in <- reactive({
chord2_file <- reactive({
chord_table(chord2_in(), input$chord2_low, input$chord2_high)
})
chord2_color <- reactive({
chord2color(chord2_in(), input$chord2_low, input$chord2_high)
})

output$jschord2 <- reactive({
# List of arguments given to the chord.js file
list(
filepath = as.matrix(chord2_file()),
color = brewer.pal(n = 8, name = "Greens")
color = chord2_color()
)
})

Expand Down
2 changes: 1 addition & 1 deletion ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ shinyUI(navbarPage(theme = "united.css",
shiny_alert_container('epi_chord_alert'),
br(),
#shiny_alert_container('source_chord_alert'),
sliderInput("chord2_low", "Low Threshold for Similarity", min=0, max=1.0, value=0.9, step=0.01),
sliderInput("chord2_low", "Low Threshold for Similarity", min=0, max=1.0, value=0.7, step=0.01),
sliderInput("chord2_high", "High Threshold for Similarity", min=0, max=1.0, value=.95, step=0.01),
br(),
busyIndicator("Processing...", wait = 500),
Expand Down

0 comments on commit 23efeff

Please sign in to comment.