我正在按照这个例子说明如何用带有R's的树状图创建聚簇热图plotly.这是一个例子:
library(ggplot2)
library(ggdendro)
library(plotly)
#dendogram data
x <- as.matrix(scale(mtcars))
dd.col <- as.dendrogram(hclust(dist(x)))
dd.row <- as.dendrogram(hclust(dist(t(x))))
dx <- dendro_data(dd.row)
dy <- dendro_data(dd.col)
# helper function for creating dendograms
ggdend <- function(df) {
ggplot() +
geom_segment(data = df, aes(x=x, y=y, xend=xend, yend=yend)) +
labs(x = "", y = "") + theme_minimal() +
theme(axis.text = element_blank(), axis.ticks = element_blank(),
panel.grid = element_blank())
}
# x/y dendograms
px <- ggdend(dx$segments)
py <- ggdend(dy$segments) + coord_flip()
# heatmap
col.ord …Run Code Online (Sandbox Code Playgroud) 有没有人有办法corrplot用树状图装饰 R相关图?
我正在尝试将交互式热图部署为闪亮的应用程序,但不仅仅是交互式热图,而是 Shinyheatmaply 的精美热图,但是当我运行 deployapp 时,什么也没有发生
这是我的用户界面
library(shiny)
library(heatmaply)
library(shinyHeatmaply)
data(mtcars)
shinyUI(fluidPage(
titlePanel("Interactive heatmap"),
fluidRow(plotlyOutput("heatmap"))
))
Run Code Online (Sandbox Code Playgroud)
这是我的服务器
library(shiny)
library(heatmaply)
library(shinyHeatmaply)
data(mtcars)
shinyServer(function(input,output) {
output$heatmap <- if(interactive()){
data(mtcars)
launch_heatmaply(mtcars)
}
})
Run Code Online (Sandbox Code Playgroud)
通过跑步
rsconnect::deployApp("/Users/temporal.UOS-12599/Desktop/New folder")
Run Code Online (Sandbox Code Playgroud)
说
DONE
Uploading bundle for application: 977528...DONE
Deploying bundle: 2147989 for application: 977528 ...
Waiting for task: 621761993
building: Parsing manifest
building: Building image: 2264908
building: Installing system dependencies
building: Fetching packages
building: Installing packages
building: Installing files
building: Pushing image: 2264908
deploying: Starting instances
rollforward: Activating new …Run Code Online (Sandbox Code Playgroud) 在 R 中使用 heatmaply 后,我试图获取所有行元素的 5 个列表。我设置 k_row = 5,以便树状图显示 5 种不同的颜色。我只想返回一个包含 5 个列表的列表,其中每个列表都包含簇内的行元素。行是名称,列是类别。
我正在尝试使用 heatmaply 包来绘制热图,并且效果很好。
另一方面,当我尝试在 Shiny 中执行相同的绘图时,它不会出现在界面中(当我单击“运行应用程序”时)。但是,当我突然关闭窗口时,绘图会出现在 R 查看器中。heatmaply 包是否可能无法与 Shiny 一起使用?
这是我在 R 中绘制的代码。
library(heatmaply)
x <- as.matrix(datasets::mtcars)
rc <- colorspace::rainbow_hcl(nrow(x))
heatmaply(
x[, -c(8, 9)],
col_side_colors = rc[1:9],
showticklabels=FALSE,
Rowv = TRUE,
Colv = FALSE
)
Run Code Online (Sandbox Code Playgroud)
这是我在 Shiny 中的代码。
library(shiny)
library(heatmaply)
ui <- fluidPage(
# Application title
titlePanel("Heatmap"),
sidebarLayout(
sidebarPanel(
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
x <- as.matrix(datasets::mtcars)
rc <- colorspace::rainbow_hcl(nrow(x))
server <- function(input, output) {
output$distPlot <- renderPlot({
heatmaply(
x[, …Run Code Online (Sandbox Code Playgroud) heatmaply ×5
r ×5
heatmap ×3
dendrogram ×2
plotly ×2
shiny ×2
dendextend ×1
ggplot2 ×1
r-corrplot ×1