Practical statistical network analysis (with R and igraph) G´ abor Cs´ ardi [email protected]Department of Biophysics, KFKI Research Institute for Nuclear and Particle Physics of the Hungarian Academy of Sciences, Budapest, Hungary Currently at Department of Medical Genetics, University of Lausanne, Lausanne, Switzerland
63
Embed
Practical statistical network analysis (with R and igraphstevel/504/igraph.pdf · Practical statistical network analysis (with R and igraph) G´abor Cs´ardi [email protected] Department
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Practical statistical network analysis(with R and igraph)
Practical statistical network analysis – WU Wien 6
The igraph“package”
• For classic graph theory and network science.• Core functionality is implemented as a C library.• High level interfaces from R and Python.• GNU GPL.• http://igraph.sf.net
Practical statistical network analysis – WU Wien 7
Vertex and edge ids
• Vertices are always numbered from zero (!).• Numbering is continual, form 0 to |V | − 1.
Vertex and edge ids
• Vertices are always numbered from zero (!).• Numbering is continual, form 0 to |V | − 1.• We have to“translate”vertex names to ids:
Practical statistical network analysis – WU Wien 22
Graph representation
• igraph. Flat data structures,indexed edge lists. Easy to handle,good for many kind of questions.
Practical statistical network analysis – WU Wien 23
Centrality in networks
• degree
Alice4
Bob4
Cecil3
Diana6
Esmeralda5
Fabien3
Gigi4
Helen7
Iannis2
Jennifer2
Practical statistical network analysis – WU Wien 24
Centrality in networks
• closeness
Cv =|V | − 1∑
i 6=v dvi
Alice0.6
Bob0.64
Cecil0.53
Diana0.75
Esmeralda0.69
Fabien0.6
Gigi0.64
Helen0.82
Iannis0.53
Jennifer0.5
Practical statistical network analysis – WU Wien 25
Centrality in networks
• betweenness
Bv =∑
i 6=j,i 6=v,j 6=v
givj/gij
Alice1.67
Bob1.12
Cecil0.83
Diana6.76
Esmeralda4.62
Fabien1.45
Gigi1.45
Helen10.1
Iannis0
Jennifer0
Practical statistical network analysis – WU Wien 26
Centrality in networks
• eigenvector centrality
Ev =1λ
|V |∑i=1
AivEi, Ax = λx
Alice0.63
Bob0.71
Cecil0.46
Diana0.88
Esmeralda0.75
Fabien0.49
Gigi0.68
Helen1
Iannis0.36
Jennifer0.36
Practical statistical network analysis – WU Wien 27
Centrality in networks
• page rank
Ev =1 − d
|V |+ d
|V |∑i=1
AivEi
Alice0.61
Bob0.59
Cecil0.47
Diana0.87
Esmeralda0.74
Fabien0.47
Gigi0.59
Helen1
Iannis0.34
Jennifer0.34
Practical statistical network analysis – WU Wien 28
Community structure in networks
• Organizing things, clustering itemsto see the structure.
M. E. J. Newman, PNAS, 103, 8577–8582
Practical statistical network analysis – WU Wien 29
Community structure in networks
• How to define what is modular?Many proposed definitions, here isa popular one:
Q =1
2|E|∑vw
[Avw−pvw]δ(cv, cw).
Community structure in networks
• How to define what is modular?Many proposed definitions, here isa popular one:
Q =1
2|E|∑vw
[Avw−pvw]δ(cv, cw).
• Random graph null model:
pvw = p =1
|V |(|V | − 1)
Community structure in networks
• How to define what is modular?Many proposed definitions, here isa popular one:
Q =1
2|E|∑vw
[Avw−pvw]δ(cv, cw).
• Random graph null model:
pvw = p =1
|V |(|V | − 1)
• Degree sequence based null model:
pvw =kvkw
2|E|
Practical statistical network analysis – WU Wien 30
Cohesive blocks
(Based on ‘Structural Cohesion and Embeddedness: a Hierarchical Concept of SocialGroups’ by J.Moody and D.White, Americal Sociological Review, 68, 103–127, 2003)
Definition 1: A collectivity is structurally cohesive to the extent that the socialrelations of its members hold it together.
Cohesive blocks
(Based on ‘Structural Cohesion and Embeddedness: a Hierarchical Concept of SocialGroups’ by J.Moody and D.White, Americal Sociological Review, 68, 103–127, 2003)
Definition 1: A collectivity is structurally cohesive to the extent that the socialrelations of its members hold it together.
Definition 2: A group is structurally cohesive to the extent that multipleindependent relational paths among all pairs of members hold it together.
Cohesive blocks
(Based on ‘Structural Cohesion and Embeddedness: a Hierarchical Concept of SocialGroups’ by J.Moody and D.White, Americal Sociological Review, 68, 103–127, 2003)
Definition 1: A collectivity is structurally cohesive to the extent that the socialrelations of its members hold it together.
Definition 2: A group is structurally cohesive to the extent that multipleindependent relational paths among all pairs of members hold it together.
• Vertex-independent paths and vertex connectivity.
Cohesive blocks
(Based on ‘Structural Cohesion and Embeddedness: a Hierarchical Concept of SocialGroups’ by J.Moody and D.White, Americal Sociological Review, 68, 103–127, 2003)
Definition 1: A collectivity is structurally cohesive to the extent that the socialrelations of its members hold it together.
Definition 2: A group is structurally cohesive to the extent that multipleindependent relational paths among all pairs of members hold it together.
• Vertex-independent paths and vertex connectivity.
• Vertex connectivity and network flows.
Practical statistical network analysis – WU Wien 31
Cohesive blocks
Practical statistical network analysis – WU Wien 32
Cohesive blocks
Practical statistical network analysis – WU Wien 33
Rapid prototyping
Weighted transitivity
c(i) =A3
ii
(A1A)ii
Rapid prototyping
Weighted transitivity
c(i) =A3
ii
(A1A)ii
cw(i) =W3
ii
(WWmaxW)ii
Rapid prototyping
Weighted transitivity
c(i) =A3
ii
(A1A)ii
cw(i) =W3
ii
(WWmaxW)ii
1 wtrans <- function(g) {
2 W <- get.adjacency(g, attr="weight")
3 WM <- matrix(max(W), nrow(W), ncol(W))
4 diag(WM) <- 0
5 diag( W %*% W %*% W ) /
6 diag( W %*% WM %*% W)
7 }
Practical statistical network analysis – WU Wien 34