igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[igraph] Add 1st column of vertices to a subgraph where the 2nd column m


From: Benika H
Subject: [igraph] Add 1st column of vertices to a subgraph where the 2nd column matches in the subgraph
Date: Thu, 5 Feb 2015 11:20:16 -0500

Hi everyone,

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.

hgnc_mapped.txt  looks like this 
ABCB7 FECH
ABCB7 GANAB


combined.txt looks like this

SNP/miRNA gene
hsa-let-7f-2 CCDC152
hsa-let-7f-2 CMAS
hsa-let-7f-2 MRPS35

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.

Thanks in advance,

Beni

reply via email to

[Prev in Thread] Current Thread [Next in Thread]