I am trying to use igraph/ggraph to plot a network, in which some of the edges are directed and others are not.
A small example from my edgelist. Here the protein-site edges are what I want to represent as undirected and the phosphorylation edge as directed.
df <- data.frame(
stringsAsFactors = FALSE,
from = c("RPS6KA3", "RPS6KA3", "RPS6KA3", "RPS6KA3", "RPS6KA3"),
to = c("RPS6KA3_Y529-p",
"RPS6KA3_S227-p","RPS6KA3_S369-p","RPS6KA3_T577-p","ATF4"),
action = c("protein-site","protein-site",
"protein-site","protein-site","phosphorylation")
)
I have tried subsetting the undirected edges and specifying them as such, but it didn't work:
library(igraph)
nw <- graph_from_data_frame(df)
E(nw)[E(nw)$action == "protein-site"] <- as.undirected(subgraph.edges(nw, E(nw)[E(nw)$action == "protein-site"] ))
Does anyone have any other suggestions? As I say, I am really only wanting to plot this (using ggraph).
Thanks!