tmuetze / Bioconductor_RCy3_the_new_RCytoscape

Update RCytoscape to work for Cytoscape 3.0 and higher using CyREST
16 stars 10 forks source link

having difficultes sending graph attributes to Cytoscape via RCy3 #25

Closed jooolia closed 8 years ago

jooolia commented 8 years ago

Have been trying to send graphs created from data frames to Cytoscape via RCy3 and having a few difficulties figuring out what I am doing wrong or what I could do to facilitate this. I tried to illustrate what I was trying to do here: https://github.com/jooolia/gsoc_Rcy3_vignettes/blob/master/testing_sending_data_edge_and_node_data_to_Cy/testing_igraph_properties.md

Any ideas or guidance are welcomed.

m-grimes commented 8 years ago

Julia

Have you tried cyPlot()? This function takes two data frames, one for nodes, one for edges, and puts them in a graph for RCy3.

I have done a little going from igraph to RCy3 because of the ability to make graphs out of adjacency matrices. Here is what I did to get a data frame out of that.

genenet.g <- graph.adjacency(as.matrix(adj_mat_tbl), mode="lower", 

diag=FALSE, weighted="Weight") genenet.edges <- data.frame(as_edgelist(genenet.g)) names(genenet.edges) <- c("Gene.1", "Gene.2") genenet.edges$Weight <- edge_attr(genenet.g)[[1]]

Maybe this helps?

Mark

University of Montana On 9 Jun 2016, at 9:06, Julia Gustavsen wrote:

Have been trying to send graphs created from data frames to Cytoscape via RCy3 and having a few difficulties figuring out what I am doing wrong or what I could do to facilitate this. I tried to illustrate what I was trying to do here: https://github.com/jooolia/gsoc_Rcy3_vignettes/blob/master/testing_sending_data_edge_and_node_data_to_Cy/testing_igraph_properties.md

Any ideas or guidance are welcomed.


You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/tmuetze/Bioconductor_RCy3_the_new_RCytoscape/issues/25

jooolia commented 8 years ago

Hi @m-grimes !

Thanks for the reply (and sorry for the delay). That is very helpful!

Cheers, Julia

jooolia commented 8 years ago

Hi again @m-grimes! I was playing around with cyPlot and had a question for you.

I successfully ran the example code from cyPlot():

node.tbl <- data.frame(Gene.Name=c("FOX", "CENT", "RTK"), Numeric.Data=as.numeric(c(10, 12, 7)), nodeType=c("ts factor", "nuclear porin", "receptor"))
  edge.tbl <- data.frame(Gene.1=c("FOX", "FOX", "CENT", "CENT"), Gene.2=c("CENT", "RTK", "FOX", "RTK"), Weight=as.numeric(c(0.1, 1, 2, 0.02)), edgeType="interaction")
  cg <- cyPlot(node.tbl, edge.tbl)

But if I only have node names e.g.

node.tbl <- data.frame(Gene.Name=c("FOX", "CENT", "RTK"))
edge.tbl <- data.frame(Gene.1=c("FOX", "FOX", "CENT", "CENT"), Gene.2=c("CENT", "RTK", "FOX", "RTK"), Weight=as.numeric(c(0.1, 1, 2, 0.02)), edgeType="interaction")
  cg <- cyPlot(node.tbl, edge.tbl)

I get an error: "Error in attr(nodeDataDefaults(graph, attr = attribute.name), "class") = attribute.type : attempt to set an attribute on NULL"

which seems to be related to this code in cyPlot():

  for (i in 2:length(grep("character", node.class))) {
    mydata <- initNodeAttribute (graph=mydata,  attribute.name=names(node.class[grep("character", node.class)])[i], attribute.type='char', default.value='undefined') 
    nodeData (mydata, n=as.character(node.df[, 1]), attr=names(node.class[grep("character", node.class)])[i]) <- as.character(node.df[,grep("character", node.class)[i]])       }

I will keep having a look, but wondered if you had any thoughts on what might be going on?

Thanks! Julia