Hello,
I have an igraph object g and I want to subset g by using vertex ids, for
instance by
zu
[1] "16052618" "rs3013006".
I want to keep all edges of each defined vertix, also the edges my vertices
share with other vertices. So induced.subgraph is not an option, isn't it?
I tried subgraph.edges but I guess my approach is very clumsy. So I ask for
an amelioration.
I tried:
idx <- unique (as.vector (g[zu, edges=TRUE])) # get edges ids for vertices
of interest
idx <- idx[-1] # remove 0
ggzu <- subgraph.edges (g, idx)
Do you have any suggestions?
Thanks
Hermann
dput (g)
structure(list(9, FALSE, c(6, 2, 7, 8, 7, 5), c(0, 1, 1, 1, 2,
3), c(1, 5, 0, 2, 4, 3), c(0, 1, 2, 3, 4, 5), c(0, 0, 0, 1, 1,
1, 2, 3, 5, 6), c(0, 1, 4, 5, 6, 6, 6, 6, 6, 6), list(c(1, 0,
1), structure(list(), .Names = character(0)), structure(list(
name = c("16052361", "16052513", "16052618", "16052962",
"rs11703994", "rs62224614", "rs78724352", "rs3013006", "rs55926024"
), x = c(16052361L, 16052513L, 16052618L, 16052962L, 16053791L,
16053862L, 16053863L, 16054667L, 16054740L), y = c(2.156147,
2.547104, 1.587586, 4.037532, 3.734964, 5.026869, 2.514876,
1.543943, 0.579408)), .Names = c("name", "x", "y")), structure(list(
weight = c(0.526203, 0.725426, 0.681783, 0.579408, 0.86216,
0.718093), color = c("grey", "blue", "grey", "grey", "red",
"blue")), .Names = c("weight", "color")))), class = "igraph")
dput (zu)
c("16052618", "rs3013006")
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help