Network visualization from a matrix (filled with 0 &1 values only) using R/bioconductor.
3
2
Entering edit mode
9.7 years ago
Abdul Rawoof ▴ 60

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..

R bioconductor packages network gene • 5.1k views
ADD COMMENT
1
Entering edit mode
9.7 years ago
Jimbou ▴ 950

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

ADD COMMENT
1
Entering edit mode
9.7 years ago

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 COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode
9.7 years ago

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 COMMENT

Login before adding your answer.

Traffic: 1454 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6