Command Line Dialog Cytoscape

32 views
Skip to first unread message

Sergio Avero

unread,
May 14, 2019, 12:46:10 PM5/14/19
to cytoscape-helpdesk
Hi everybody!!

I am a master student who is trying to do something apparently simple: import a network, import a table, apply color from the attribute table and export a PNG of that table. But, I need to do it +9000 times. So, I really need to automatize the process. 

So, I would like to write a "for loop" in Python in order to obtain a script with the command lines for the Command Line Dialog in Cytoscape. It sounds good! Not difficult! Lets start from the beggining in order you could see how I am working.(Ill let the 2 .txt files in order you could test the code, using just a simple 3 nodes network).

i)        First of all, we can write the following command if we have a .txt with 2 columns: 

network import file delimiters=";" file="insert a path here" indexColumnSourceInteraction=1 firstRowasColumnNames=false indexColumnSourceInteraction=1 indexColumnTargetInteraction=2 

(You can use network1.txt that I uploaded)

Doing that, we obtain the first network and we can repeat it easily just by changing the name of the .txt data. (for instance: import network1.txt, network2.txt and so on).

ii)       Now, we are going to import the table data. I am going to use the following command line:

table import file delimiters=";" file="insert a path here" keyColumnIndex=1 startLoadRow=1 firstRowAsColumnNames=false

(You can use table1.txt that I uploaded)

As you can see at this point, we obtain a table... an empty table! Do you know why does it happen? Ill really appreciate any help you could bring it to me. 

*I know that we can do it via Py2Cytoscape or using R but I would like to do it in this way. 
table1.txt
network1.txt

Scooter Morris

unread,
May 23, 2019, 10:07:47 AM5/23/19
to cytoscape-helpdesk
Hi Sergio,
   The problem is actually pretty simple, but *really* subtle.  The issue is that when you import a network, the name of the nodes are *always* Strings.  So, your integers get converted to strings automatically when the network is created.  However, when you import your table, that isn't the case.   This may be a symptom of your test case -- not sure if you want your node names to be integers.  If you do, then what you need to add to your table import is:

table import file delimiters=";" file="insert a path here" keyColumnIndex=1 startLoadRow=1 firstRowAsColumnNames=false dataTypeList="s,i"

That tells the importer that the data type of the first column is a string and the data type of the second column is an integer.  That fixes everything and it all imports.

-- scooter
Reply all
Reply to author
Forward
0 new messages