hi,
I have two networks, i took intersection between them but i cant getting edge list from data.frame
who know the reason of the error please?
library(igraph)
clr <- read.table("clr.txt", header = T, sep = "\t")
head(clr[,1:4])
AT1G01060 AT1G01170 AT1G01260 AT1G01380
AT1G01060 0.0000000 0.6397474 0.0000000 2.6052533
AT1G01170 0.6397474 0.0000000 0.2676777 0.0000000
AT1G01260 0.0000000 0.2676777 0.0000000 0.5220432
AT1G01380 2.6052533 0.0000000 0.5220432 0.0000000
AT1G01490 2.5364855 2.5912206 1.6262291 0.6899495
AT1G01500 0.6131010 0.0000000 0.0000000 1.7374863
dim(clr)
[1] 2857 2857
clr <- as.matrix(clr)
GENEI3 <- read.table("GENEI3.txt", header = T, sep = "\t")
head(GENEI3[,1:4])
AT1G01060 AT1G01170 AT1G01260 AT1G01380
AT1G01060 0.000000e+00 3.397888e-04 5.573000e-04 8.577027e-05
AT1G01170 2.161158e-03 0.000000e+00 3.510125e-04 3.373863e-06
AT1G01260 4.630123e-07 1.294916e-05 0.000000e+00 9.821657e-05
AT1G01380 2.172965e-05 1.112968e-04 2.950147e-04 0.000000e+00
AT1G01490 1.987599e-03 7.534076e-06 1.634816e-06 3.346604e-05
AT1G01500 8.453009e-05 4.127081e-05 1.531739e-05 7.116557e-05
dim(GENEI3)
[1] 2857 2857
adj_1<- as.matrix(clr)
adj_2 <- as.matrix(GENIE3)
g_1 <- graph.adjacency(adj_1, mode="undirected", weighted=NULL, diag=TRUE)
g_2 <- graph.adjacency(adj_2, mode="undirected", weighted=NULL, diag=TRUE)
g_sim <- graph.intersection(g_1, g_2, byname = "auto", keep.all.vertices = FALSE)
adj_sim <- get.adjacency(g_sim, type="both")
g<- graph.adjacency(adj_sim,mode = "undirected",weighted = T)
edge_ara <- get.data.frame(g,what = "edges")
edge_ara<- edge_ara[order(abs(edge_ara$weight),decreasing = T),]
Error in abs(edge_ara$weight) : non-numeric argument to mathematical function
thank you
HI, I would suggest you to print out the
edge_ara$weight
to text file and check whether you find any suspicious non-numeric argument. if there is any, just remove them and run the script.thank you I inspect edge_ara <- get.data.frame(g,what = "edges") but file was empty then edge_ara<- edge_ara[order(abs(edge_ara$weight),decreasing = T),] gives me error but i don't know why file was empty
Just go step by step and check whether the data is there in a variable before you go for subsequent analysis
You need to check values of g_1, g_2 and g_sim and first see what is the overlap !