## 注释:更改文件路径
library(shiny)
library(htmltools)
library(DT)
#install.packages("heatmaply")
library(heatmaply)
library(dplyr)
library(datasets)
sample <- data.frame(stringsAsFactors=FALSE,
NANA = c("ABCB1", "ACVR1B", "ACVR2A", "APC", "ARID1A", "ARID1B"),
NADriver = c(1, 1, 1, 1, 1, 1),
NAsnv_t_013 = c(0, 0, 0, 1, 0, 1),
NAsnv_o_013 = c(1, 0, 0, 1, 0, 1),
NAindel_t_013 = c(0, 0, 0, 0, 1, 1),
NAindel_o_013 = c(0, 0, 0, 0, 1, 1),
NADeleted_ot_013 = c(0, 0, 0, 0, 1, 1),
NADeleted_o_013 = c(0, 0, 0, 0, 0, 1))
## 文件路径改成wine的路径
wine = read.table('C:/Users/ping/Documents/Multi-Statis/shiny_demo/wine.data', sep=',')
q = wine$V1
q = gsub("1", "first", q, fixed = T)
q = gsub("2", "second", q, fixed = T)
q = gsub("3", "third", q, fixed = T)
wine$V1 = q
wine
plotHeight <- 800
obj <- list(sample = sample, iris = iris, wine=wine)
if (!"list" %in% class(obj))
obj = list(obj)
if (is.null(names(obj)))
names(obj) = paste0("data", seq(1, length(obj)))
#UI----
ui <- shiny::shinyUI(
shiny::fluidPage(
shiny::sidebarLayout(
shiny::sidebarPanel(
htmltools::h4('Data'),
shiny::uiOutput('data'),
shiny::checkboxInput('showSample','Subset Data'),
shiny::conditionalPanel('input.showSample',shiny::uiOutput('sample')),
# br(),
htmltools::hr(),htmltools::h4('Data Preprocessing'),
shiny::column(width=4,shiny::selectizeInput('transpose','Transpose',choices = c('No'=FALSE,'Yes'=TRUE),selected = FALSE)),
shiny::column(width=4,shiny::selectizeInput("transform_fun", "Transform", c(Identity=".",Sqrt='sqrt',log='log',Scale='scale',Normalize='normalize',Percentize='percentize',"Missing values"='is.na10', Correlation='cor'),selected = '.')),
shiny::uiOutput('annoVars'),
htmltools::br(),htmltools::hr(),htmltools::h4('Row dendrogram'),
shiny::column(width=6,shiny::selectizeInput("distFun_row", "Distance method", c(Euclidean="euclidean",Maximum='maximum',Manhattan='manhattan',Canberra='canberra',Binary='binary',Minkowski='minkowski'),selected = 'euclidean')),
shiny::column(width=6,shiny::selectizeInput("hclustFun_row", "Clustering linkage", c(Complete= "complete",Single= "single",Average= "average",Mcquitty= "mcquitty",Median= "median",Centroid= "centroid",Ward.D= "ward.D",Ward.D2= "ward.D2"),selected = 'complete')),
shiny::column(width=12,shiny::sliderInput("r", "Number of Clusters", min = 1, max = 15, value = 2)),
#column(width=4,numericInput("r", "Number of Clusters", min = 1, max = 20, value = 2, step = 1)),
htmltools::br(),htmltools::hr(),htmltools::h4('Column dendrogram'),
shiny::column(width=6,shiny::selectizeInput("distFun_col", "Distance method", c(Euclidean="euclidean",Maximum='maximum',Manhattan='manhattan',Canberra='canberra',Binary='binary',Minkowski='minkowski'),selected = 'euclidean')),
shiny::column(width=6,shiny::selectizeInput("hclustFun_col", "Clustering linkage", c(Complete= "complete",Single= "single",Average= "average",Mcquitty= "mcquitty",Median= "median",Centroid= "centroid",Ward.D= "ward.D",Ward.D2= "ward.D2"),selected = 'complete')),
shiny::column(width=12,shiny::sliderInput("c", "Number of Clusters", min = 1, max = 15, value = 2)),
#column(width=4,numericInput("c", "Number of Clusters", min = 1, max = 20, value = 2, step = 1)),
htmltools::br(),htmltools::hr(), htmltools::h4('Additional Parameters'),
shiny::column(3,shiny::checkboxInput('showColor','Color')),
shiny::column(3,shiny::checkboxInput('showMargin','Layout')),
shiny::column(3,shiny::checkboxInput('showDendo','Dendrogram')),
htmltools::hr(),
shiny::conditionalPanel('input.showColor==1',
htmltools::hr(),
htmltools::h4('Color Manipulation'),
shiny::uiOutput('colUI'),
shiny::sliderInput("ncol", "Set Number of Colors", min = 1, max = 256, value = 256),
shiny::checkboxInput('colRngAuto','Auto Color Range',value = T),
shiny::conditionalPanel('!input.colRngAuto',shiny::uiOutput('colRng'))
),
shiny::conditionalPanel('input.showDendo==1',
htmltools::hr(),
htmltools::h4('Dendrogram Manipulation'),
shiny::selectInput('dendrogram','Dendrogram Type',choices = c("both", "row", "column", "none"),selected = 'both'),
shiny::selectizeInput("seriation", "Seriation", c(OLO="OLO",GW="GW",Mean="mean",None="none"),selected = 'OLO'),
shiny::sliderInput('branches_lwd','Dendrogram Branch Width',value = 0.6,min=0,max=5,step = 0.1)
),
shiny::conditionalPanel('input.showMargin==1',
htmltools::hr(),
htmltools::h4('Widget Layout'),
shiny::column(4,shiny::textInput('main','Title','')),
shiny::column(4,shiny::textInput('xlab','X Title','')),
shiny::column(4,shiny::textInput('ylab','Y Title','')),
shiny::sliderInput('row_text_angle','Row Text Angle',value = 0,min=0,max=180),
shiny::sliderInput('column_text_angle','Column Text Angle',value = 45,min=0,max=180),
shiny::sliderInput("l", "Set Margin Width", min = 0, max = 200, value = 130),
shiny::sliderInput("b", "Set Margin Height", min = 0, max = 200, value = 40)
)
),
shiny::mainPanel(
shiny::tabsetPanel(
shiny::tabPanel("Heatmaply",
htmltools::tags$a(id = 'downloadData', class = paste("btn btn-default shiny-download-link",'mybutton'), href = "", target = "_blank", download = NA, shiny::icon("clone"), 'Download Heatmap as HTML'),
htmltools::tags$head(htmltools::tags$style(".mybutton{color:white;background-color:blue;} .skin-black .sidebar .mybutton{color: green;}") ),
plotly::plotlyOutput("heatout",height=paste0(plotHeight,'px'))
),
shiny::tabPanel("Data",
DT::dataTableOutput('tables')
)
)
)
)
)
)
#Server----
server <- function(input, output, session) {
output$data=shiny::renderUI({
d<-names(obj)
selData=d[1]
shiny::selectInput("data","Select Data",d,selected = selData)
})
data.sel=shiny::eventReactive(input$data,{
as.data.frame(obj[[input$data]])
})
shiny::observeEvent(data.sel(),{
output$annoVars<-shiny::renderUI({
data.in=data.sel()
NM=NULL
if(any(sapply(data.in,class)=='factor')){
NM=names(data.in)[which(sapply(data.in,class)=='factor')]
}
shiny::column(width=4,
shiny::selectizeInput('annoVar','Annotation',choices = names(data.in),selected=NM,multiple=T,options = list(placeholder = 'select columns',plugins = list("remove_button")))
)
})
#Sampling UI ----
output$sample<-shiny::renderUI({
list(
shiny::column(4,shiny::textInput(inputId = 'setSeed',label = 'Seed',value = sample(1:10000,1))),
shiny::column(4,shiny::numericInput(inputId = 'selRows',label = 'Number of Rows',min=1,max=pmin(500,nrow(data.sel())),value = pmin(
普通网友
- 粉丝: 1127
- 资源: 5292
最新资源
- FeiQ.rar 局域网内通信服务软件
- 172.16.100.195
- 光储并网simulink仿真模型,直流微电网 光伏系统采用扰动观察法是实现mppt控制,储能可由单独蓄电池构成,也可由蓄电池和超级电容构成的混合储能系统,并采用lpf进行功率分配 并网采用pq控制
- python编写微信读取smart200plc的数据发送给微信联系人
- 光储并网VSG系统Matlab simulink仿真模型,附参考文献 系统前级直流部分包括光伏阵列、变器、储能系统和双向dcdc变器,后级交流子系统包括逆变器LC滤波器,交流负载 光储并网VSG系
- file_241223_024438_84523.pdf
- 质子交膜燃料电池PEMFC Matlab simulink滑模控制模型,过氧比控制,温度控制,阴,阳极气压控制
- IMG20241223015444.jpg
- 模块化多电平变器(MMC),本模型为三相MMC整流器 控制策略:双闭环控制、桥臂电压均衡控制、模块电压均衡控制、环流抑制控制策略、载波移相调制,可供参考学习使用,默认发2020b版本及以上
- Delphi 12 控件之FlashAV FFMPEG VCL Player For Delphi v7.0 for D10-D11 Full Source.7z
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈