Guest User

Untitled

a guest
Nov 14th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. library(igraph)
  2. g <- graph.adjacency(
  3. as.matrix(as.dist(cor(t(POS_testing), method="pearson"))),
  4. mode="undirected",
  5. weighted=TRUE,
  6. diag=FALSE
  7. )
  8. g <- simplify(g, remove.multiple=TRUE, remove.loops=TRUE)
  9. g <- delete_edges(g, E(g)[which(E(g)$weight<0.9)])
  10.  
  11. V(g)$comp <- components(g)$membership
  12. V(g)$comp
  13. [1] 1 2 3 4 3 5 6 7 3 8 9 10 11 12 13 14 15 16 3 3 3 17 18 19 20 15 3 21 3
  14. [30] 3 3 3 22 23 3 3 3 3 24 25 3 26 27 28 3 29 3 3 3 30 31 3 3 3 3 3 3 32
  15. [59] 3 33 3 3 34 35 3 3 28 28 36 37 38 3 39 28 3 3 3 3 40 21 21 3 41 3 3 42 3
  16. [88] 3 3 3 3 3 43 44 3 45 3 46 3 47 48 3 3 3 3 3 3 49 3 3 3 3 50 3 3 3
  17. [117] 3 51 3 3 52 53 52 52 54 55 52 3 56 57 58 55 59 3 60 61 3 62 3 63 64 65 66 67 3
  18. [146] 3 3 3 68 3 69 64 70 71 3 72 3 73 74 3 3 75 3 3 3 3 32 76 3 77 3 78 3 3
  19. [175] 79 80 3 81 82 3 3 73 3 3 3 83 84 85 73 3 3 3 3 3 86 32 87
  20.  
  21. g <- induced_subgraph(g, V(g)$comp == 3)
  22. V(g)$comp
  23. [1] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
  24. [45] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
  25. [89] 3 3 3 3 3 3 3 3
  26.  
  27. t <- delete_vertices(g, comps$Var1)
  28.  
  29. V(g)$comp <- c(rep(3, 96), rep(21, 3), rep(28, 4), rep(32, 3), rep(52, 4), rep(73, 3)).
  30.  
  31. t <- add_edges(g, c(which(V(g)$comp == 3), which(V(g)$comp == 21), which(V(g)$comp == 28)))
  32.  
  33. g <- induced_subgraph(g, c(V(g)$comp == 3 & V(g)$comp == 21 & V(g)$comp ==29))
Add Comment
Please, Sign In to add comment