Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

interactive correlation heatmap in shiny

Tags:

heatmap

shiny

I want to reproduce the example at: https://scip.shinyapps.io/scip_app/

Basically, I have a 300 by 300 adjusted correlation matrix and a 300 by 300 unadjusted correlation matrix and want to show them interactively with zoom in and zoom out function. The text descriptions should display the point estimates and confidence intervals.

Is there any template I can quickly refer to?

like image 390
Sheldon Avatar asked Sep 05 '26 19:09

Sheldon


1 Answers

Building on the data from Mike, you can use the d3heatmap library

library(d3heatmap)
library(shiny)
n1 <- 100
n2 <- 100
nr <- 30
nc <- 30
set.seed(1)
x <- matrix(rnorm(n1), nrow=nr, ncol=nc)
y <- matrix(rnorm(n2), nrow=nr, ncol=nc)
MAT <- cor(x,y)
ui <- fluidPage(
  mainPanel(
    d3heatmapOutput("heatmap", width = "100%", height="600px")
  )
)

## server.R
server <- function(input, output) {
  output$heatmap <- renderD3heatmap({d3heatmap(MAT)})
}

shinyApp(ui = ui, server = server)

enter image description here

Edit: Specify the colours if needs to be and display the data as is, note that Colv = T by default, which means it will group the correlated items together

output$heatmap <- renderD3heatmap({d3heatmap(MAT, colors = "Blues", Colv = FALSE)})

enter image description here

like image 176
Pork Chop Avatar answered Sep 10 '26 21:09

Pork Chop



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!