# NOT RUN {
# PDB server connection required - testing excluded
if (!requireNamespace("igraph", quietly = TRUE)) {
message('Need igraph installed to run this example')
} else {
###-- Build a CNA object
pdb <- read.pdb("4Q21")
modes <- nma(pdb)
cij <- dccm(modes)
net <- cna(cij, cutoff.cij=0.2)
##-- Reconstruct the community membership vector for each clustering step.
tree <- community.tree(net, rescale=TRUE)
## Plot modularity vs number of communities
plot( tree$num.of.comms, tree$modularity )
## Inspect the maximum modularity value partitioning
max.mod.ind <- which.max(tree$modularity)
## Number of communities (k) at max modularity
tree$num.of.comms[ max.mod.ind ]
## Membership vector at this partition point
tree$tree[max.mod.ind,]
# Should be the same as that contained in the original CNA network object
net$communities$membership == tree$tree[max.mod.ind,]
# Inspect a new membership partitioning (at k=7)
memb.k7 <- tree$tree[ tree$num.of.comms == 7, ]
## Produce a new k=7 community network
net.7 <- network.amendment(net, memb.k7)
plot(net.7, pdb)
#view.cna(net.7, trim.pdb(pdb, atom.select(pdb,"calpha")), launch=TRUE )
}
# }
Run the code above in your browser using DataLab