Ask a question from expert

Ask now

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
Network Analysis of Cancer Patient Data using igraph in R_1
[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)
Network Analysis of Cancer Patient Data using igraph in R_2
> #obtaining the measurements
> data1 <- graph.data.frame(data, directed=F)
> degree(net)
hsa-mir-383 hsa-mir-130a hsa-mir-452 hsa-mir-3653 hsa-mir-375 hsa-mir-30e
1 1 2 1 1 1
hsa-mir-744 hsa-mir-215 hsa-mir-204 gain loss
1 1 1 6 4
> eigen_centrality(net)
$`vector`
hsa-mir-383 hsa-mir-130a hsa-mir-452 hsa-mir-3653 hsa-mir-375 hsa-mir-30e
0.4082483 0.4082483 0.6232186 0.4082483 0.4082483 0.4082483
hsa-mir-744 hsa-mir-215 hsa-mir-204 gain loss
0.4082483 0.3116093 0.3116093 1.0000000 0.7632838
Network Analysis of Cancer Patient Data using igraph in R_3
$value
[1] 2.44949
$options
$options$`bmat`
[1] "I"
$options$n
[1] 11
$options$which
[1] "LA"
$options$nev
[1] 1
$options$tol
[1] 0
$options$ncv
[1] 0
$options$ldv
[1] 0
$options$ishift
[1] 1
$options$maxiter
[1] 1000
Network Analysis of Cancer Patient Data using igraph in R_4

End of preview

Want to access all the pages? Upload your documents or become a member.