Question: Network visualization from a matrix (filled with 0 &1 values only) using R/bioconductor.
2
gravatar for Abdul Rawoof
5.0 years ago by
Abdul Rawoof60
United States
Abdul Rawoof60 wrote:

Hello everyone,

I have a matrix based on binary concept as follows,

  T1 T2 T3
Gene1 0 1 1
Gene2 1 0 1
.. 0 0 0
.. 0 1 0
Gene nth 0 0 1

 

I want to make a network using this matrix in R/bioconductor. Please suggest me some package.

Any help will be appreciated.

Thanks..

 

ADD COMMENTlink modified 5.0 years ago by mikhail.shugay3.3k • written 5.0 years ago by Abdul Rawoof60
1
gravatar for Jimbou
5.0 years ago by
Jimbou690
Germany
Jimbou690 wrote:

Take a look at http://igraph.org/r/ You can find also many tutorials out there.

ADD COMMENTlink modified 5.0 years ago • written 5.0 years ago by Jimbou690
1
gravatar for Alex Reynolds
5.0 years ago by
Alex Reynolds28k
Seattle, WA USA
Alex Reynolds28k wrote:

You could use the igraph R package. For example, given your input matrix, you could turn it into a set of vertices and edges and then plot its network:

> install.packages("igraph")
> library("igraph")
> verts <- data.frame(name=c("Gene1", "Gene2", "Gene3", "Gene4", "Gene5", "T1", "T2", "T3"))
> edges <- data.frame(from=c("Gene1", "Gene1", "Gene2", "Gene2", "Gene4", "Gene5"), to=c("T2", "T3", "T1", "T3", "T2", "T3"))
> g <- graph.data.frame(edges, directed=TRUE, vertices=verts)
> png("graph.png")
> plot(g)
> dev.off()

The file graph.png might look something like this:

ADD COMMENTlink modified 5.0 years ago • written 5.0 years ago by Alex Reynolds28k

if values are between 0 to 1, then what will be the script. can we mention the edge distance.

ADD REPLYlink written 4.2 years ago by jaichandpatel210
0
gravatar for mikhail.shugay
5.0 years ago by
mikhail.shugay3.3k
Czech Republic, Brno, CEITEC
mikhail.shugay3.3k wrote:

Essentially the same solution as above, but allows parsing arbitrary tables

install.packages("igraph", "reshape")
library(igraph); library(reshape)

# read input
# could also read from file with read.delim(file_name)
input <- "gene\tT1\tT2\tT3\nG1\t0\t1\t1\nG2\t1\t0\t0\nG3\t0\t0\t0\nG4\t0\t1\t0\nG5\t0\t0\t1"
df <- read.delim(text = input)

# collapse table, select existing edges
df <- melt(df)
df <- df[,df$value>0]

# build graph
e <- data.frame(from = df$gene, to = df$variable)
g <- graph.data.frame(e)

plot(g)
ADD COMMENTlink modified 5.0 years ago • written 5.0 years ago by mikhail.shugay3.3k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 931 users visited in the last hour