Hi,
I have a gold standard in Arabidopsis thaliana( genes and transcription factors and their interaction) like below
TFLocus TargetLocus InteractionType
AT5G10140 AT1G65480 -1
AT5G11260 AT1G27480 -1
AT5G11260 AT5G53370 -1
AT5G11260 AT1G03630 -1
AT5G11260 AT1G13600 -1
AT5G11260 AT2G41670 -1
AT5G11260 AT2G05160 -1
AT5G11260 AT2G40170 -1
AT5G11260 AT1G62780 -1
I want to convert this data frame to graph by igraph package, I did like so
mycounts <- read.table("Ara_GoldST.txt", header = T, sep = "\t")
mycounts <- graph.data.frame(mycounts, directed=TRUE, vertices=NULL)
mycounts <- get.data.frame(mycounts, what=c("edges", "vertices", "both"))
Then I want to convert the graph to adjacency matrix but
> get.adjacency(mycounts, type=c("both", "upper", "lower"),
+ attr=NULL, names=TRUE, binary=FALSE, sparse=FALSE)
Error in get.adjacency(mycounts, type = c("both", "upper", "lower"), attr = NULL, :
unused argument (binary = FALSE)
How I can convert my data frame to a graph that can be converted to an adjacency matrix please?
Thank you
thank you so much,
now I have an adjacency matrix By your and Amir's code and another adjacency matrix inferred from minet package. by your previous code I made both of matrices the same dimension but rownames and colnames also shoud be the same and match,
please consider the head of my matrices
My another matrix
as you consider the matrices are not match. how I can make them match please?
thank you
sorry my list contain both +1 and -1. if this causes your suggested code go wrong?? actually i need a symmetric adjacency matrix contains only 0 and 1 might it comes from a directed graph. getting together can i use still your code again?
thank you
As I wrote, if you don't want edge weights, then set attr=NULL. In general a directed graph has an asymmetric adjacency matrix. If you require the adjacency matrix to be symmetric, consider your graph as being undirected.
thank you so much
sorry I did based on your suggested codes
but
max(A)
is 5 while I need a directed adjacency only contains 0 and 1. how I can get that please?thank you
Then you need to decide what you want to be 0 and what you want to be 1. 0 will mean no interaction and 1 will mean interaction between the nodes. So you need to decide if you want interactionType = -1 to mean interaction (replace 1 with 0 and replace -1 with 1) or no interaction (replace it with 0, keep the 1s). Because you're dealing with transcription factors and their targets, my guess is that interactionType indicates whether the TF represses (-1) or activates (1) expression of the target gene. If that's the case, you probably want to keep the -1/1 weights for your directed graph.
thank you so much
you all right but I have to use this adjacency matrix as a true net by validate function in minet package to compute fscore of my inferred network. but my true net (the adjacency matrix I derived by your code) is undirected and weighted. then I stock in this step.
The code in my first reply has directed=TRUE and thus makes a directed network. You then wrote that you wanted a symmetric adjacency matrix which means an undirected graph so check what code you're using. You need to decide if you want weights and if so what you want them to be. If not, set attr=NULL as already mentioned.
thanks a lot