Search code examples
rexportigraphweightedcytoscape

Exporting weighted igraph object for Cytoscape use with NetPathMiner


I'm trying to export an igraph object for Cytoscape use with NetPathMiner package and while trying to load it in Cytoscape, I'm getting

Bad value associated with key weight

The code I'm using:

G_sub <- delete.edges( G,  E(G)[ E(G)$weight < threshold ] )
library(NetPathMiner)
plotCytoscapeGML(G_sub, file="toCytoScape.gml")

the G I built it using:

G <- graph.data.frame( rel.matrix, directed = FALSE )

where rel.matrix is a matirx like:

structure(list(from = c("TPM1", "TPM1", "TPM1", "TPM1", "TPM1", 
"TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", 
"TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", 
"TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", 
"TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", 
"TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", 
"TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", 
"TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", 
"TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", 
"TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", 
"TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", 
"TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "TPM1", 
"TPM1", "TPM1", "TPM1", "TPM1", "TPM1", "MT1G", "MT1G"), to = c("ACTA1", 
"TNNC2", "DBN1", "TNNT3", "DMD", "MYLPF", "MYBPC2", "PKM", "MYLK", 
"PXN", "LCP1", "MYO18A", "SPTBN1", "TMOD3", "PKD2", "SF3B1", 
"SMTN", "TMOD2", "NAA25", "VCL", "MYO5C", "TCAP", "ACTL8", "SPTAN1", 
"TMOD1", "PLS1", "ACTA2", "ACTL10", "EHBP1", "TAGLN", "ACTN4", 
"MYO5A", "COX4I1", "AHCYL1", "SEC23A", "RHOA", "MYH9", "SORBS3", 
"ACTRT1", "RAVER1", "FLNB", "NEB", "THOC1", "ACTN1", "TTN", "UQCRC2", 
"MYBPC3", "MYO5B", "MYBPC1", "SPTB", "CNN1", "ACTN2", "ACTR1B", 
"VIM", "SORD", "RAC3", "CFL1", "PFN4", "TPM3", "MYO1F", "KBTBD13", 
"SPTBN2", "MYH11", "SRXN1", "CFL2", "ACTB", "MYH7B", "MYL12A", 
"SPTA1", "MYH8", "FSCN3", "MYL4", "ACTR3B", "SLC25A4", "TNNT1", 
"VMP1", "ACTR1A", "MYH4", "ACTRT2", "MYH13", "MACF1", "MYO18B", 
"ATP5F1", "COX5A", "MYL10", "MYL12B", "TNNT2", "DSTN", "MYL3", 
"MYO1A", "PLS3", "TNNI3", "ACTL6A", "MYL6B", "MYOZ2", "NDUFB10", 
"MYH7", "RPS3", "MT2A", "MT1X"), weight = c(3.10788e-05, 5.958809e-05, 
6.384511e-05, 4.857867e-05, 3.833709e-05, 5.229225e-05, 4.924842e-05, 
3.225598e-05, 2.898718e-05, 8.135556e-06, 3.691475e-05, 5.009223e-05, 
2.241126e-05, 3.984557e-05, 4.087312e-05, 4.958667e-05, 5.482933e-05, 
7.170784e-05, 2.331922e-05, 2.8957e-05, 5.085006e-05, 4.037044e-05, 
5.287118e-05, 4.331423e-05, 4.904199e-05, 2.244811e-05, 2.444415e-05, 
3.39682e-05, 3.815621e-05, 6.097359e-05, 5.687818e-05, 5.921874e-05, 
5.489426e-05, 5.047384e-05, 4.028134e-05, 4.111754e-05, 6.317467e-05, 
4.741044e-05, 5.349051e-05, 8.419945e-05, 6.373862e-05, 2.202583e-05, 
5.292187e-05, 2.104257e-05, 3.063063e-05, 2.325379e-05, 2.897299e-05, 
5.694608e-05, 5.794348e-05, 3.419694e-05, 4.544227e-05, 5.685621e-05, 
3.70368e-05, 4.812005e-05, 4.707759e-05, 4.652025e-05, 3.1161e-05, 
2.135651e-05, 4.601607e-05, 4.217255e-05, 4.925196e-05, 2.101865e-05, 
5.812923e-05, 6.151076e-05, 3.965462e-05, 5.69303e-05, 4.145797e-05, 
4.619822e-05, 4.952048e-05, 5.969572e-05, 2.635453e-05, 2.956592e-05, 
4.576555e-05, 5.889256e-05, 5.63168e-05, 2.704127e-05, 2.10058e-05, 
4.418638e-05, 2.696945e-05, 5.0836e-05, 2.089578e-05, 3.58514e-05, 
6.042708e-05, 5.692903e-05, 5.903882e-05, 2.831509e-05, 4.728689e-05, 
2.156019e-05, 5.655941e-05, 3.334697e-05, 5.187546e-05, 6.976401e-05, 
2.068582e-05, 5.202582e-05, 4.009386e-05, 6.550041e-05, 2.20423e-05, 
5.175788e-05, 4.385124e-05, 2.531945e-05)), row.names = c(NA, 
100L), class = "data.frame")

But a lot bigger. Any idea on why I'm getting this error?


Solution

  • Well, this is appears to be an issue for the NetPathMiner R package rather than for Cytoscape. Here is the issue tracker for that project:

    https://github.com/ahmohamed/NetPathMiner/issues

    In the meantime, I can suggest an alternative approach that might work. The RCy3 package supports sending igraph objects directly to Cytoscape, rather than exporting as GML and then having to manually import them. Here is that package:

    https://bioconductor.org/packages/release/bioc/html/RCy3.html

    And here is a short vignette on working with igraph:

    https://bioconductor.org/packages/release/bioc/vignettes/RCy3/inst/doc/Cytoscape-and-iGraph.html