Если вы хотите использовать plotly
, вы можете использовать heatmaply
, например:
library(shiny)
library(plotly)
library(heatmaply)
alph <- c("A"=1, "C"=2, "G"=3, "T"=4, "I"=5, "U"=6, "N"=7)
seq <- factor(names(alph), unique(names(alph)))
# matsample <- cbind(c("A","A","A","T"),c("A","A","A","T"),c("A","A","A","G"))
matsample <- matrix(sample(names(alph), 4000, replace = TRUE), nrow=4)
ms <- matrix(alph[matsample], ncol = ncol(matsample), byrow=FALSE)
rownames(matsample) <- c("R1","R2","R3","R4")
rownames(ms) <- rownames(matsample)
mm <- data.frame(do.call(rbind, lapply(rownames(ms), rep, ncol(matsample))))
ui <- plotlyOutput("matimage", width = 160 + (ncol(matsample)*20))
server <- shinyServer(function(input, output, session) {
output$matimage <- renderPlotly({
heatmaply(ms, custom_hovertext = mm,
cellnote = matsample,
show_dendrogram = c(FALSE, FALSE),
Rowv=NULL, Colv=NULL, color=rainbow(7),
hide_colorbar=TRUE,
plot_method = "plotly")
})
})
shinyApp(ui = ui, server = server)