I need help adding a list of nodes to my subgraph that have the matching targets in my first graph.
here is my code so far.
edgeList <- read.table("~/Desktop/hgnc_mapped.txt", header=TRUE, sep="\t")
t <- as.data.frame(edgeList)
y <- graph.data.frame(t, directed=FALSE, vertices=NULL)
y <- simplify(y)
genelist <- read.table("~/Desktop/combined.txt", header=TRUE, sep="\t")
matches <- as.data.frame(genelist)
snps <- (matches$SNP.miRNA)
genes <- (matches$gene)
z <- graph.data.frame(matches, directed=FALSE, vertices=NULL)
wc <- walktrap.community(y, weights = edgeList$Weight, steps=20, merges =
TRUE, modularity = TRUE, membership = TRUE)
scc <- clusters(y, "strong")
vx_id = which(scc$csize<8 & scc$csize>=2)
vx_id
colors <- rainbow(max(membership(wc)))
V(y)$color <- membership(wc)
layout <- layout.kamada.kawai(y)
plot(y,layout=layout)
sub <- induced.subgraph(y,which(scc$membership %in% vx_id))
sub
sub <- add.vertices(sub, z[from=c(snps), to=c(genes), directed=TRUE, nv=1:length(z)])
When printing sub, it does not contain the new vertices.
Any help would be greatly appreciated.