21 - Using CoNet with Cytoscape

CytoNet is an ensemble network analysis method that combines several similarity and dissimilarity methods into a single tool (Faust et al., 2012). False positives due to compositional effects are controlled through permutation and bootstrapping. CytoNet is available as a 'barebonesCoNet' function in the seqgroup package in R, but the full functionality is only available through the CoNet plug-in that works with Cytoscape (Faust and Raes, 2016; Faust, 2021). Using CoNet in R was a little challenging as the documentation is very abbreviated. Since I was having trouble customizing the analysis in R I switched to Cystoscape instead for more control. Here are the steps I took to get everything working right.


Step-by-step method for using CoNet with Cytoscape


  1. Check what version of java you have installed. I'm assuming you're working in linux at the command line. CoNet3 needs Cytoscape 3 that needs at least Java 7 (openjdk 1.7.0+).

java -XshowSettings:properties -version


  1. Set up a new conda environment called cytoscape. I'm assuming you already have miniconda3 or anaconda on your system.

conda create --name cytoscape -c bioconda cytoscape

  1. Set environment variables (and an alias if you like) in your .bashrc file. You can allocate more memory to java by setting the -Xmx to a higher number according to how much memory you have on your system, ex. -Xmx85g. CoNet is very memory intensive.

export LIB=/path/to/CoNet3/lib

export CLASSPATH=${CLASSPATH}:${LIB}/CoNet.jar

alias conet="java -Xmx800m be.ac.vub.bsb.cooccurrence.cmd.CooccurrenceAnalyser"


  1. Download CoNet from http://psbweb05.psb.ugent.be/conet/download.php and unzip it.

unzip CoNet3.zip


  1. Test CoNet, start it using the alias set above and use -h to see the help.

conet -h


  1. Start the cytoscape conda environment.

conda activate cytoscape


  1. Open Cytoscape at the command line. It will open up a graphical user interface.

Cytoscape


  1. Load the CoNet plug in for Cytoscape by clicking on the 'Apps' tab in Cytoscape, install from file, then browse to your CoNet installation /path/to/CoNet3/conet.jar .


  1. Launch CoNet from Cytoscape to use the graphical user interface to set up your initial run settings. Click on the 'Apps' tab in Cytoscape, then click on the CoNet app.


  1. Test that CoNet is working with Cytoscape, by clicking 'demo' in the CoNet app. After a moment, you should see a graph show up in the Cytoscape window. You can change the layout of this graph to your liking by clicking on the 'layout' tab in Cytoscape, and picking an alternative layout, ex. circular, or organic (this one needs to be installed via the menu options before it can be used).


  1. Now try loading settings from the tutorial files. Use wget to grab the Costello tutorial files available from http://psbweb05.psb.ugent.be/conet/tutorial1.php .

wget http://psbweb05.psb.ugent.be/conet/documents/Costello_2009_oral.txt

wget http://psbweb05.psb.ugent.be/conet/documents/Costello_2009_oral_metadata.txt

wget http://psbweb05.psb.ugent.be/conet/documents/tutorial1-settings.txt


  1. Next follow short version or long version instructions closely. If you follow the 'long version' instructions, you can start to get a feel for how to navigate through all the CoNet menus. After hitting GO, a graph should show up in the Cytoscape window. Feel free to change the layout as described above.


  1. Now that you can run small analyses, try running CoNet with your own files. First, you will need to prepare your infiles. You can refer to the CoNet tutorial page to see examples of input and metadata files http://psbweb05.psb.ugent.be/conet/tutorials.php . The infile is essentially a modified OTU table with OTUs in rows and samples in columns, note that OTUs from each 'group' should be present as their own row. The metadata here is a table including OTU names that match the infile, along with groups, lineage, and taxon columns. You should read more about this in the CoNet manual http://psbweb05.psb.ugent.be/conet/manual.php so that your lineage and taxon columns are formatted correctly (if using). You can also load features that can include additional sample data, ex. pH (if using). This will allow the construction of a bipartite network, showing nodes for OTUs as well as for pH. I prefer to do all this in R, but you can probably do this in Excel if your dataset isn't too large. Each column needs to have a name, so if you used OTU_group as rownames, then be sure to add the name 'col_names' to your tab delimited file (or CSV, just be sure to specify the delimiter in CoNet).


  1. Now let's run an analysis, first, open Cytoscape and the CoNet app. You will need to click on each menu in succession, picking settings as you go. Use the tutorial settings as a guide. After you are done, do NOT hit GO. If your files are large, you will need to run CoNet from the command line instead, then load the resulting file in Cytoscape for visualization. In CoNet, click on 'Generate command line call'. Assuming your have set your CLASSPATH as described above, copy and past the lines starting with 'java' and run them at the command line. Depending on how you set up your analysis, you may have to run a first java command, followed by a second java command. Be sure to allocate plenty of memory to java using the -Xmx command:

java -Xmx85g be.ac.vub.bsb.cooccurrence.cmd.CooccurrenceAnalyser followed by your run-specific commands that you copied


If you set up an alias for CoNet (with plenty of memory), then you can run:

conet followed by your run-specific commands


  1. I recommend running this using linux 'screen' or 'nohup', because these runs can take quite a while depending on the size of your dataset. I use 'top' to monitor memory usage. Error messages can be found in the Cytoscape folder in a log file (/path/to/miniconda3/envs/cytoscape/share/cytoscape-3.7.2-0/output.log).


Good luck.


References


Faust K (2021) seqgroup: Analysis of Sequencing Data with Groups. R package version 0.1.0. https://github.com/hallucigenia-sparsa/seqgroup


Faust K, Raes J (2016) CoNet app: inference of biological associataion networks using Cytoscape. F1000Research 5:1519. https://doi.org/doi: 10.12688/f1000research.9050.2


Faust K, Sathirapongsasuti JF, Izard J, et al (2012) Microbial Co-occurrence Relationships in the Human Microbiome. PLoS Comput Biol 8:e1002606. https://doi.org/10.1371/journal.pcbi.1002606