Graph rcytoscapejs:可变参数-';渲染图';功能不可用
我需要允许用户上传一个文件来定义应用程序中呈现的网络 我想改变参数以重新呈现一个交互式闪亮图,该图通过一个特殊的闪亮github包——“rcytoscapejs”部署: 虽然图部署得很好,但我的问题是它只能从UI独立于服务器进行部署Graph rcytoscapejs:可变参数-';渲染图';功能不可用,graph,shiny,shinyjs,Graph,Shiny,Shinyjs,我需要允许用户上传一个文件来定义应用程序中呈现的网络 我想改变参数以重新呈现一个交互式闪亮图,该图通过一个特殊的闪亮github包——“rcytoscapejs”部署: 虽然图部署得很好,但我的问题是它只能从UI独立于服务器进行部署 g<-createCytoscapeJsNetwork(nodeData = nodes, edgeData = edge) #ui.R dashboardBody( sliderInput(inputId="num", label="Choose
g<-createCytoscapeJsNetwork(nodeData = nodes, edgeData = edge)
#ui.R
dashboardBody(
sliderInput(inputId="num", label="Choose coef", value=2, min=1, max=3),
rcytoscapejs(g$nodes, g$edges)
)
但该软件包的版本为0.1,自2014年以来从未更新过
因此,最终我的问题是,如何改变“ui.R”代码中的某些内容的参数
类似于以下内容(文件上载代码取自:):
server使用函数renderRcytoscapejs(用于服务器)和rcytoscapejsOutput(用于用户界面)对其进行排序,还必须使用read.csv(用于隔离())将正在读取的数据文件的类保存为反应值:
库(ShinydaShashboard)
图书馆(rcytoscapejs)
p1
#ui.R
graphOutput("graph")
#server.R
output$graph<-renderGraph({rcytoscapejs(g$nodes, g$edges)})
devtools::install_github("mfontcada/renderGraph");
Downloading GitHub repo mfontcada/renderGraph@master
from URL https://api.github.com/repos/mfontcada/renderGraph/zipball/master
Error: Does not appear to be an R package (no DESCRIPTION)
server <- function(input, output) {
dataInput <- eventReactive(input$choices, {
inFile <- input$file1
if (is.null(inFile))
return(NULL)
read.csv(inFile$datapath, header = input$header, sep = input$sep, quote = input$quote)
createCytoscapeJsNetwork(nodeData = nodes, edgeData = edge)
})
}
#ui.R
actionButton("choices", "Run analyses"),
fileInput('file1', 'Choose file to upload',
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv'
),
rcytoscapejs(dataInput()$nodes, dataInput()$edges),
library(shinydashboard)
library(rcytoscapejs)
p1<-cor(t(E.rna_small[1:20,1:20]),use="p") #correlations taken from sample of matrix
library(graph) #as per P Shannon's help must convert to way that is compatible with RCyjs
library(RCyjs)
library(igraph)
g<-igraph.to.graphNEL(simplify(graph_from_adjacency_matrix(p1, weighted=T)))
edge<-as.data.frame(get.edgelist(simplify(graph_from_adjacency_matrix(p1, weighted=T))))
colnames(edge)<-c("source", "target")
nodes<-cbind(id=colnames(p1), name=rownames(p1))
class(nodes)
nodes<-as.data.frame(nodes)
b<-createCytoscapeJsNetwork(nodeData = nodes, edgeData = edge)
uiactual <- dashboardPage(
dashboardHeader(title="zoom"),
dashboardSidebar(menuItem(
checkboxInput('header', 'Header', TRUE),
radioButtons('sep', 'Separator',
c(Comma=',',
Semicolon=';',
Tab='\t')
)),
menuItem(p('If you want a sample .csv or .tsv file to upload,',
'you can first download the sample',
a(href = 'mtcars.csv', 'mtcars.csv'), 'or',
a(href = 'pressure.tsv', 'pressure.tsv'),
'files, and then try uploading them.'
))),
dashboardBody(
sliderInput(inputId="num", label="Choose coef", value=2, min=1, max=3),
rcytoscapejsOutput("g3plot"),
fileInput('file1', 'Choose file to upload',
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv'
)
)
)
)
serveractual <- function(input, output) {
g3 <- reactive({
inFile <- input$file1
if (is.null(inFile))
return(NULL)
isolate(t<-read.table(inFile$datapath, header = T,
sep = "\t"))
#t<-for(i in colnames(t)){
# as.numeric(t[,i])
#}
p1<-cor(t(t),use="p") #correlations taken from sample of matrix
simplify(graph_from_adjacency_matrix(p1, weighted=T))
edge<-as.data.frame(get.edgelist(simplify(graph_from_adjacency_matrix(p1, weighted=T))))
colnames(edge)<-c("source", "target")
nodes<-cbind(id=colnames(p1), name=rownames(p1))
nodes<-as.data.frame(nodes)
createCytoscapeJsNetwork(nodeData = nodes, edgeData = edge)
})
output$g3plot = renderRcytoscapejs({
rcytoscapejs(g3()$nodes, g3()$edges)
})
}
shinyApp(uiactual, serveractual)