我有一个交互网络,我使用以下代码制作邻接矩阵,然后计算网络节点之间的相异度,然后将它们聚类以形成模块:
ADJ1=abs(adjacent-mat)^6
dissADJ1<-1-ADJ1
hierADJ<-hclust(as.dist(dissADJ1), method = "average")
Run Code Online (Sandbox Code Playgroud)
现在我希望在绘制 igraph 时出现这些模块。
g<-simplify(graph_from_adjacency_matrix(adjacent-mat, weighted=T))
plot.igraph(g)
Run Code Online (Sandbox Code Playgroud)
但是,到目前为止,我发现将 hclust 输出转换为图形的唯一方法是按照以下教程:http ://gastonsanchez.com/resources/2014/07/05/Pretty-tree-graph/
phylo_tree = as.phylo(hierADJ)
graph_edges = phylo_tree$edge
graph_net = graph.edgelist(graph_edges)
plot(graph_net)
Run Code Online (Sandbox Code Playgroud)
这对分层沿袭很有用,但我只想要与集群密切交互的节点,如下所示:
任何人都可以推荐如何使用命令(例如 igraph 中的组件)来显示这些集群?
我已经合并了不同的代码源来制作一个允许上传文件(数据框)的应用程序。
但是,除此之外,我还希望能够从数据框中选择特定列并对其进行分析。然而,这很困难,因为必须预先定义给定的数据框,以便能够在 ui.R 脚本中引用它....在 ui.R 中,因为它是在服务器中定义的....
预定义变量
vchoices <- 1:ncol(mtcars)
names(vchoices) <- names(mtcars)
Run Code Online (Sandbox Code Playgroud)
用户界面
runApp(
ui = basicPage(
h2('The uploaded file data'),
dataTableOutput('mytable'),
fileInput('file', 'Choose info-file to upload',
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv'
)
),
actionButton("choice", "incorporate external information"),
selectInput("columns", "Select Columns", choices=vchoices, inline = T),
#notice that the 'choices' in selectInput are set to the predefined
#variables above whereas I would like to set them equal to the
#not yet defined uploaded file below in …Run Code Online (Sandbox Code Playgroud)