converting an edge list of genes to a full matrix(adjacency)
1
0
Entering edit mode
8.2 years ago
zizigolu ★ 4.3k

Hi

I have an edge list derived from a gene regulatory network inferring algorithm like below

edge_list <- read.table("dream_GENIE3_predictions.txt", header = T, sep = "\t")
edge_list <- edge_list[!duplicated(edge_list),]

AT2G03750    AT5G16030    0.036228
AT5G05410    AT2G26150    0.035889
AT4G29780    AT4G34410    0.035248
AT2G22500    AT4G29780    0.034398
AT3G43120    AT3G01270    0.033944
AT1G07000    AT1G10340    0.033512
AT4G14090    AT5G42800    0.032743
AT4G39480    AT1G24260    0.032410
AT4G29780    AT2G46400    0.032203
AT1G21460    AT5G15800    0.031520
AT5G02030    AT3G50640    0.031176
AT1G30350    AT1G28430    0.031169
AT1G74930    AT4G29780    0.030951

I found this syntax to convert my list to an adjacency matrix but I can't adapt the code to my data

library(dils)

edgelist <- cbind(expand.grid(letters[1:2], letters[1:2]), runif(4))
AdjacencyFromEdgelist(edgelist)

who will help me?

gene software-error R • 11k views
ADD COMMENT
3
Entering edit mode
8.2 years ago

Use the igraph library:

library(igraph);
edge_list <- read.delim("data_file.txt", header = TRUE, sep = "\t");
G <- graph.data.frame(edge_list,directed=FALSE);
A <- as_adjacency_matrix(G,type="both",names=TRUE,sparse=FALSE,attr="weight");
ADD COMMENT
0
Entering edit mode

Thank you, I did so but telling

Error in get.adjacency.dense(graph, type = type, attr = attr, edges = edges,  : 
  no such edge attribute
ADD REPLY
1
Entering edit mode

Make sure that you replace weight in attr="weight" with the name of the column that contains the weights.

ADD REPLY
0
Entering edit mode

Thank you, you all right it worked but my values converted to most 0 for example 0.036228 converted to 0

ADD REPLY
1
Entering edit mode

It looks like a type conversion problem. You can coerce the column types with colClasses e.g.

edge_list <- read.delim("data_file.txt", header = TRUE, sep = "\t",colClasses=c("character","character","numeric");
ADD REPLY
0
Entering edit mode

Thank you so much, your kindly helps always work well

ADD REPLY

Login before adding your answer.

Traffic: 1559 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