Is it possible to create a network by importing exported nodes and edges

24 vues
Accéder directement au premier message non lu

clayton.curtis.md

non lue,
9 juin 2022, 09:47:5809/06/2022
à cytoscape-helpdesk
I am still fairly new to Cytoscape, and using it for a non-bio & non-gene network creation / analysis project for which Cytoscape is the best tool I've found.  I apologize in advance for the long post, but I've tried to provide as much information as I can from the get-go.

I am trying to see if I can (re)create a network by exporting nodes and edges from an existing network and then importing them back into an empty network.  (There are reasons why I don't want to simply export the original network.)  My expectation was that this would result in recreating the original network. The .csv files created by exporting nodes and edges individually seem to have all of the necessary information, but I am unable to get any useful result from importing the exported nodes / edges.

I have been able to achieve partial success importing the nodes by removing the quotation marks surrounding the column values (which begs the question of what to do if the data contains quotation marks), but can't import edges at all. The export file for edges appears to contain interactions and =one= of the nodes connected, but not the other.

I have tried to do my homework. Searching the 'net, reading the documentation, and watching videos on importing found on YouTube. The only relevant information I could find was from a 2019 post here (https://groups.google.com/g/cytoscape-helpdesk/c/8-Q3HVVhVjo) where one potential cause of inability to import was addressed. I was unable to properly interpret and apply the "solution" described in the last response. ("Simply copy-pasting the edge table data in a new CSV file and using that file as the Edge table did the trick for me.")  I have attached the exported node and edge files that I used in the hopes that someone can recreate the problem and explain what I'm doing wrong.

I'd really appreciate some education that would lead me to a solution. A solution by itself would, of course, be appreciated! :)

Thanks in advance,
 Clayton Curtis

exported edges for Cytoscape help desk.csv
exported nodes for Cytoscape help desk.csv

Ruth Isserlin

non lue,
9 juin 2022, 10:18:3709/06/2022
à cytoscape...@googlegroups.com
Hi Clayton, 
In addition to exporting the edges it would be good if you export a sif file as well (File -> export-> Network to file…).  The sif file is a tab delimited text file that is easy to import back into cytoscape (https://manual.cytoscape.org/en/stable/Supported_Network_File_Formats.html#sif-format).  It is a text file so it is easy to modify if that is what you are looking to do  Once you have the network created you can then import the node and edge attributes onto the network from the nodes and edge table you exported (file -> Import —> Table from file …) (https://manual.cytoscape.org/en/stable/Node_and_Edge_Column_Data.html).    
Are you opening your node and edge tables in excel?  It might be excel that is introducing those quotes.  
Ruth 

On Jun 9, 2022, at 9:47 AM, clayton.curtis.md <clayton....@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpd...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cytoscape-helpdesk/321a689f-16f9-4a73-9858-8f92193f4dc5n%40googlegroups.com.
<exported edges for Cytoscape help desk.csv><exported nodes for Cytoscape help desk.csv>

Scooter Morris

non lue,
9 juin 2022, 10:22:0009/06/2022
à cytoscape-helpdesk
Hi Clayton,

Yes, it's difficult, but it *is* possible.  There are two approaches I can can suggest:
1) Both the source and target node names *are* there in the shared name column.  The pattern is source (interaction) target, so you would need to parse out the source and target manually.
2) You can do this with equations:
  • First create two new string columns in your edge table: "Source" and "Target". 
  • Then click into the first cell of the Source column and click the equations button (f(x)) in the edge table header.
  • Select "Apply to: Entire column"
  • Scroll down in the function list and find "STRINGTABLECELL" and click it, and then click on the little blue "insert" text
  • Now, find SOURCEID in the function list, click that and insert it.
  • Click into the argument for SOURCEID and look in the Attributes column for SUID.  Click that and insert it.
  • Finally, after the closing paren for SOURCEID, add ,"name"
  • It should look like: STRINGTABLECELL(SOURCEID($SUID,"name") if everything went well
  • Now, click on "Evaluate and insert Result".  That should fill the column with all of the source names.
  • Repeat for Target, replacing SOURCEID with TARGETID.
I wrote an app that did all that automatically, but never got around to releasing it.  I could e-mail it to you, if you're interested.

In any case, now that you have Source and Target columns, you can use those to import your edges -- remember to Import network from file first (that will be your edges) and then you can import table from file (that will be your nodes).

-- scooter

clayton.curtis.md

non lue,
9 juin 2022, 11:05:3709/06/2022
à cytoscape-helpdesk
Please see my original post. For brevity,  I didn't repeat it here. [As a n00b, please let me know if that's bad practice.]

On Thursday, June 9, 2022 at 10:22:00 AM UTC-4 ssbsm...@....com wrote:

Yes, it's difficult, but it *is* possible.
 
  >> Yay!   However, it looks like there is no way to =simply= start with a empty network and just import the node and edge files exported from another network :)
 
1) Both the source and target node names *are* there in the shared name column.  The pattern is source (interaction) target, so you would need to parse out the source and target manually.
 
>> Arrgghh!  I was looking at the  data in Excel, had to reduce the column width to get all the columns on the screen, and failed to expand the 'shared name' column enough to see the rest of the pattern! Boy, am I chagrined!  I will certainly experiment with that!
 
2) You can do this with equations: [process list provided] 
 
>> Yikes!  I understand what you are saying, but wow!  I =did= learn a lot about functions from your explanation! :)
 
Further: I wrote an app that did all that automatically, but never got around to releasing it.  I could e-mail it to you, if you're interested.
 
>> I am, thanks.!  Too bad that the functionality for importing an edge table doesn't have an option in "Advanced Options" to parse the edge file that way. After all, options are provided for input delimiter, decimal separator, etc. and it seems reasonable to be able to indicate that the format is that of the standard export and proceed accordingly.

Further: In any case, now that you have Source and Target columns, you can use those to import your edges -- remember to Import network from file first (that will be your edges) and then you can import table from file (that will be your nodes).
 
>> Got it!

Thanks VERY much for your helpful response AND your patience!! :))
 

clayton.curtis.md

non lue,
9 juin 2022, 11:18:3609/06/2022
à cytoscape-helpdesk
Thanks very much for your response!  I'm familiar with the .sif format and could certainly (with a certain amount of effort) create a rudimentary .sif file from the two Excel files. (Probably in Python) I was just hoping that there was a more straightforward approach.

To answer your question, both the node and edge files were created using the 'export' functions in Cytoscape, and that's where the quotation marks were generated. Use of quotation marks to enclose data, along with use of commas to separate such strings, is conventionally used in creating CSV files, so I was surprised to see the suggestion to remove the quotation marks -- kind of defeats the purpose of the convention.  (And surprised that Cytoscape apparently didn't want to accept a file it had produced itself.) 

The post by 'scooter' certainly provided a lot of useful information to me to use. :)

Scooter Morris

non lue,
16 juin 2022, 09:33:2016/06/2022
à cytoscape-helpdesk
Hi Clayton,

I put my little app up on my web site at https://www.cgl.ucsf.edu/home/scooter/mapSourceAndTarget-0.1.0.jar -- just drop it in your CytoscapeConfiguration/3/apps/installed directory.  Then there is a new app in your app menu "mapSourceAndTarget".  If you run that, it will ask you what node column you want to map, select the node column (e.g. name) and say OK.  There will not be two new columns in your edge table with source and target node names that you can use for the network import.

-- scooter
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message