我有节点、边和权重。我如何从R闪亮的节点、边、权重信息中绘制网络

问题描述 投票:0回答:1

我的网络如下:

p <- 100 # Number of nodes (genes) in the network.
n <- 100 # Number of samples to generate.
network <- random_network(p) # Create a random network of size p.
network <- gen_partial_correlations(network) # Generate weights.
df_ref <- SeqNet::reference$rnaseq  # The reference dataset
g <-network

现在从 g 中,我可以同样将节点和边提取为列表:

nodeslist<- list(g$modules[[1]]$nodes)
edgeslist<- list(g$modules[[1]]$edges)

注意:nodeslist和edgeslist包含以下信息: 边缘列表:



            weight
[1,] 1 49 0.13920793
[2,] 2 19 -0.16105155
[3,] 2 29 -0.11896011
[4,] 2 49 0.10574541
[5,] 3 29 -0.13120939
[6,] 3 49 0.17390062
[7,] 4 10 -0.10381197
[8,] 5 33 -0.13458892
[9,] 6 49 0.17523747
[10,] 7 19 0.18709664
[11,] 8 49 -0.10200550
[12,] 9 10 -0.16075495
[13,] 9 49 0.12597721
[14,] 10 11 0.12419045
[15,] 10 18 0.16554176
[16,] 10 23 0.12257816
[17,] 10 24 0.17552470
[18,] 10 25 -0.18485569
[19,] 10 28 -0.18851376
[20,] 10 29 -0.17173121
[21,] 10 32 0.14237557
[22,] 10 33 -0.15823895
[23,] 10 34 0.12432978
[24,] 10 35 -0.16700940
[25,] 10 37 0.17640358
[26,] 10 43 -0.10804470
[27,] 10 44 0.16079198
[28,] 10 45 -0.13074089
[29,] 10 47 -0.14941716
[30,] 10 48 0.17069436
[31,] 10 49 -0.14465740
[32,] 10 50 -0.16713456
[33,] 10 51 -0.12124140
[34,] 10 53 0.09832430
[35,] 10 55 -0.16044640
[36,] 10 62 0.15869645
[37,] 10 63 0.11175158
[38,] 12 49 -0.19139133
[39,] 13 29 0.14681721
[40,] 13 49 0.13493487
[41,] 14 33 -0.13364581
[42,] 15 19 0.10663959
[43,] 15 49 -0.11776805
[44,] 16 49 -0.17496817
[45,] 17 49 0.13980787
[46,] 19 24 0.16020803
[47,] 19 25 -0.12007548
[48,] 19 26 0.13061010
[49,] 19 30 0.18347088
[50,] 19 32 0.17066294
[51,] 19 33 -0.16345597
[52,] 19 37 0.12446608
[53,] 19 46 0.13531279
[54,] 19 49 0.10353267
[55,] 19 52 -0.12596833
[56,] 19 63 0.11966468
[57,] 20 49 -0.13018907
[58,] 21 33 -0.10584546
[59,] 21 49 -0.16366432
[60,] 22 29 -0.12769928
[61,] 24 29 0.09683651
[62,] 24 49 -0.17398705
[63,] 25 30 -0.18163093
[64,] 25 34 0.13093457
[65,] 25 35 0.18703481
[66,] 25 41 0.11050505
[67,] 25 44 -0.09962966
[68,] 25 47 0.18286832
[69,] 26 29 0.14178880
[70,] 26 33 -0.10631235
[71,] 27 37 -0.14746540
[72,] 28 33 0.09948649
[73,] 29 30 0.13360557
[74,] 29 31 -0.16245800
[75,] 29 32 -0.16785796
[76,] 29 33 -0.15289176
[77,] 29 39 -0.17283268
[78,] 29 43 0.10077533
[79,] 29 49 -0.13001863
[80,] 29 50 -0.11811612
[81,] 29 51 -0.17453024
[82,] 29 53 -0.12620716
[83,] 29 59 -0.16878030
[84,] 29 63 0.11351594
[85,] 30 37 0.15382473
[86,] 30 49 0.18885891
[87,] 31 49 0.16179096
[88,] 32 49 0.15855171
[89,] 33 34 -0.10088338
[90,] 33 41 0.12001003
[91,] 33 43 -0.18284373
[92,] 33 46 -0.16394107
[93,] 33 49 0.15275365
[94,] 33 53 -0.14424536
[95,] 33 62 -0.18298613
[96,] 35 49 0.15671584
[97,] 36 49 -0.19092302
[98,] 37 49 0.12580630
[99,] 37 59 -0.10462770
[100,] 38 49 -0.12257773
[101,] 40 49 -0.09667345
[102,] 41 49 0.10453115
[103,] 42 49 -0.11113257
[104,] 43 49 -0.10493318
[105,] 48 49 0.18244989
[106,] 49 51 0.15013766
[107,] 49 52 -0.15366076
[108,] 49 54 0.11142246
[109,] 49 56 -0.13114785
[110,] 49 57 -0.17502184
[111,] 49 58 0.18643826
[112,] 49 59 -0.17610071
[113,] 49 60 0.11064330
[114,] 49 61 -0.13522543

节点列表:

 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13

我有绘制该网络所需的信息,我该怎么做?如果我尝试类似的事情:

plot(g)

它仅在仪表板上绘制为图像,我如何绘制以使其具有交互性?

r shiny shinydashboard
1个回答
0
投票

您可以使用

plotly
将您的绘图转换为交互式绘图。

plotly::plotly_build

描述:

这个通用函数创建发送到plotly.js 进行渲染的列表对象。使用此函数对于覆盖 ggplotly/plot_ly 提供的默认值或调试渲染错误非常有用。

Plotly
R 开源图形库

Plotly 的 R 图形库可制作交互式、出版质量的图表。

plot_object<- plot(g)

plotly_object<-plotly::ggplotly(plot_object)

p<-plotly::plotly_build(plotly_objet)

p$elementId <- NULL

# display the interactive plot: 
p

尝试不使用

p$elementId <- NULL
,具体取决于
plotly
版本:

© www.soinside.com 2019 - 2024. All rights reserved.