我想在 R
shiny
中创建圆形热图。但是,我无法在 R shiny
中创建我在 R 中创建的圆形热图。
library(circlize)
# data
data <- matrix(rnorm(100), ncol = 10)
# Create a circular heatmap
circos.clear()
circos.par("track.height" = 0.2)
chm <- circos.heatmap(data, col = colorRamp2(c(-2, 2), c("blue", "red")))
# Display the circular heatmap
circos.trackPlotRegion(chm)
应该没有什么特别的。您可以将热图包装在
renderPlot
内并使用 plotOutput
显示它。这是一个最小的例子。
library(circlize)
set.seed(0)
ui <- shinyUI(fluidPage(headerPanel("Circular Heatmap"),
fluidRow(column(
12,
plotOutput("heatmap")
))))
server <- function (input, output, session) {
data <- reactive({
matrix(rnorm(100), ncol = 10)
})
output$heatmap <- renderPlot({
circos.clear()
circos.par(track.height = 0.2)
circos.heatmap(data(), col = colorRamp2(c(-2, 2), c("blue", "red")))
})
}
shinyApp(ui = ui, server = server)