Network Analysis of Cancer Patient Data using igraph in R
11 Pages1315 Words51 Views
Added on 2021-11-15
About This Document
Learn how to perform network analysis on cancer patient data using igraph package in R. Extract top 10 and bottom 10 rows, plot the network, and obtain measurements like degree, eigen centrality, betweenness, closeness, and subgraph centrality.
Network Analysis of Cancer Patient Data using igraph in R
Added on 2021-11-15
BookmarkShareRelated Documents
data = read.csv('CancerPatient.csv') > > #extracting the top 10 rows from the imported data > dim(data) [1] 20661 4 > cp=data[1:10,] > head(cp) mRNA microRNA weight role 1 OBFC1 hsa-mir-383 0.2250745 gain 2 SHROOM2 hsa-mir-130a 0.3535406 gain 3 GABBR2 hsa-mir-452 0.3048922 loss 4 ZNF90 hsa-mir-452 0.2964542 loss 5 GIGYF1 hsa-mir-3653 0.2580920 gain 6 MICALL1 hsa-mir-375 0.2958907 gain > library(igraph) > # subsetting the rows that shows networking > y = data.frame(cp$microRNA,cp$role) > #conveting it to matrix > net =graph.data.frame(y,directed = T) > as.matrix(net) IGRAPH 7c1688d DN-- 11 10 -- + attr: name (v/c) + edges from 7c1688d (vertex names): [1] hsa-mir-383 ->gain hsa-mir-130a->gain hsa-mir-452 ->loss hsa-mir-452 ->loss [5] hsa-mir-3653->gain hsa-mir-375 ->gain hsa-mir-30e ->gain hsa-mir-744 ->gain [9] hsa-mir-215 ->loss hsa-mir-204 ->loss > #obtaining the vertices of the matrix > V(net) + 11/11 vertices, named, from 7c1688d: [1] hsa-mir-383 hsa-mir-130a hsa-mir-452 hsa-mir-3653 hsa-mir-375
[6] hsa-mir-30e hsa-mir-744 hsa-mir-215 hsa-mir-204 gain [11] loss > #obtaining the edges of the matrix > E(net) + 10/10 edges from 7c1688d (vertex names): [1] hsa-mir-383 ->gain hsa-mir-130a->gain hsa-mir-452 ->loss hsa-mir-452 ->loss [5] hsa-mir-3653->gain hsa-mir-375 ->gain hsa-mir-30e ->gain hsa-mir-744 ->gain [9] hsa-mir-215 ->loss hsa-mir-204 ->loss > V(net)$label =V(net)$name > > #plotting the network of the data > set.seed(123) > plot(net, + vertex.color =rainbow(52), + + edge.arrow.size =0.3, + layout=layout.fruchterman.reingold)