modu=membershipmodu_networkcolor_value =cyellow#66FFFF#7CCD7CpinkVnetwork$color = color_valuemodu parbg=white mar=c0000setseed123plotnetworkvertexframecolor=blackvertexsize=12vertexlabelcex=06 vertexl
-
modu=membership(modu_network)- This line assigns the module membership of each node in the networkmodu_networkto the vectormodu. -
color_value =c("yellow","#66FFFF","#7CCD7C","pink")- This line creates a vectorcolor_valuewith four colors that will be used to represent the different modules in the network. -
V(network)$color = color_value[modu]- This line assigns a color to each vertex in thenetworkbased on its module membership. Thecolor_valuevector is indexed by themoduvector to get the appropriate color for each vertex. -
par(bg="white", mar=c(0,0,0,0))- This line sets the background color of the plot to white and removes the plot margins. -
set.seed(123)- This line sets the random number generator seed used for generating the plot layout to a fixed value, ensuring that the plot will be reproducible. -
plot(network,vertex.frame.color="black",vertex.size=12,vertex.label.cex=0.6, vertex.label.cex=0.6,vertex.label.color="black")- This line plots thenetworkusing the assigned vertex colors and various vertex and label settings. -
legend("bottomleft",legend=c("Module 1","Module 2", "Module 3", "Module 4"),col=color_value, bty="n",fill=color_value,border=color_value)- This line adds a legend to the plot, showing the mapping between the module colors and their names. Thebty,fill, andborderarguments control the appearance of the legend box.
原文地址: https://www.cveoy.top/t/topic/b2h4 著作权归作者所有。请勿转载和采集!