CerebralWeb Use Cases
CerebralWeb visualization of annotated networks implements two principal use cases:
  • Where an Unannotated Network is provided: in this case, which is perhaps the most frequent, CerebralWeb can fetch sub-cellular localization if the network node ids are in a standard format (Ensembl, Entrez, UniProt, InnateDB) for Mouse, Human and Bovine interaction networks, and stratify the visualzation according to this information.
  • Where an Annotated Network is provided: in this case sub-cellular localization (or any other other custom) annotations withn the network are interpreted by CerebralWeb and subsequently used to stratify the visualization.
In either case, the interaction network may be supplied host website feature, as a JSON object (see examples below), or alternatively CerebralWeb has a feature to allow the user to easily upload (drag-and-drop) a Cytoscape compatible XGMML file, that is subsequently parsed and interpreted automatically by CerebralWeb.
Benchmarking of Browser Rendering Times of CerebralWeb against Cerebral (Java Web Start mode)

Table 1. Benchmarking of CerebralWeb. Comparison of network rendering times for Java Web Start Cerebral and CerebralWeb (via the InnateDB web site) across Chrome, Safari and Firefox Web Browsers (MAC OS, Core i5, 16Gb). Mean rendering (N=5 trials) times (seconds) are given for small (198 IRAK1 interactors) and large (800 EGFR Interactors) protein-protein interaction networks.

JavaWebStart CerebralCerebralWeb 
 Network (Edges)Mean(sec)S.E.Mean(sec)S.E.Speed-up
ChromeIRAK1 (198)35.720.718.780.064.1
 EGFR (800)69.100.8410.580.376.5
SafariIRAK1 (198)39.420.429.910.194.0
 EGFR (800)78.520.5010.930.427.2
FireFoxIRAK1 (198)36.800.5010.180.183.6
 EGFR (800)78.280.5910.930.197.2

Step-by-Step Implementation
  1. Download the two CerebralWeb source files and include the path to them in your HTML.
  2. CerebralWeb also requires jQuery and Cytoscape.js to be included in your HTML (see below).
  3. For simple pages, the JavaScript code that builds the network can be placed directly into the HTML page and bounded by the <script type="text/javascript"> ... </script> tags.
  4. The network can be specified by a simple JSON network object within the JavaScript, see the "Annotated Network" example code below.
  5. To automatically fetch sub-celluar localization information (for Human, Mouse and Bovine molecular networks), the node (gene or protein) "id" attribute in the JSON node object must be in Ensembl, UniProt, Entrez or InnateDB format.
  6. Alternatively the localization may be supplied in the JSON using the "localization" attribute, see the "Annotated Network" example code below.
  7. To support compatibility we also include code below to parse the specific JSON format exported by Cytoscape (which contains only edge objects).
  8. CerebralWeb also provides a feature to allow the user to simply drag-and-drop a Cytoscape compatible XGMML file into the window which is then parsed and displayed.
  9. The CerebralWeb visualization style can be extensively customized using the formatting options, see the Options page and the interactive example on the Demo page.
  10. To place CerebralWeb in the webpage page include the line <div>id="cy"></div> at the desired location.
<!-- jQuery -->
<script type="text/javascript" charset="utf8" src="/path.to.jquery/jquery.min.js"></script>
<!-- Cytoscape.js -->
<script type="text/javascript" charset="utf8" src="/path.to.cytoscape/cytoscape.min.js"></script>
<!-- Cerebral: cerebral.js -->    
<script type="text/javascript" charset="utf8" src="/path.to.cerebral/cerebral.js"></script>
<!-- Cerebral: Horizontal layout -->
<script type="text/javascript" charset="utf8" src="/path.to.cerebral/layout.horizontal.js"></script>
            
Drag & drop your XGMML file here and wait ...
To add a drop box that allow users to upload their own XGMML files and converts them into CerebralWeb graphs, simply add the "cerebral-dropbox" class to one of your div in the HTML code and ensure to give it a unique id.
<!-- Div with an unique identifier and class "cerebral-dropbox" -->
<div class="cerebral-dropbox" style="height:400px;" id="unique_id">
    <div id="drag_text">
        <!-- Text with directions about how to upload the xgmml -->
        Drag & drop your XGMML file here and wait ... 
    </div>
</div>
                                    
DEMO XGMML FILES
In this simple example the network is supplied as JSON file, containing sub-cellular locations, which is then directly displayed in the Cerebral style

Place the fllowing line within the HTML page:
<!-- Div with an unique identifier -->
<div id="cy"></div>
                                
The following JavaScript can also be placed within the HTML directly or within an included *.js file:
<!-- List of Cytoscape objects: nodes and edges. Nodes contain the localisation attribute  -->
elements = [
    {
        "data": {
            "id": "1",
            "name": "Node 1",
            "localization": "Nucleus",
            "color": defaultNodeColor
        },
        "group": "nodes"
    },
    {
        "data": {
            "id": "2",
            "name": "Node 2",
            "localization": "Extracellular",
            "color": defaultNodeColor
        },
        "group": "nodes"
    },
    {
        "data": {
            "id": "3",
            "name": "Node 3",
            "localization": "Cytoplasm",
            "color": defaultNodeColor
        },
        "group": "nodes"
    },
    {
        "data": {
            "id": "12",
            "name": "name of interaction 12",
            "source": "1",
            "target": "2",
            "idgroup": "12"
        },
        "group": "edges"
    },
    {
        "data": {
            "id": "23",
            "name": "name of interaction 23",
            "source": "2",
            "target": "3",
            "idgroup": "23"
        },
        "group": "edges"
    },
    {
        "data": {
            "id": "22",
            "name": "name of interaction 22",
            "source": "2",
            "target": "2",
            "idgroup": "22"
        },
        "group": "edges"
    },
];

<!-- Inizialization of the Cytoscape object.  -->
$('#cy').cytoscape({
    layout: options,
    showOverlay: false,
    zoom: 1,
    style: cerebral_style,
    elements: elements,
    ready: function() {
        cy = this;
        cerebral_ready(cy);
    }
});
                                
In this example the network is supplied as a Cytoscape exportable JSON file, which is then parsed, passed to the Web Service to retrive sub-cellular locations and then displayed in the Cerebral style

Place the fllowing line within the HTML page:
<!-- Div with an unique identifier -->
<div id="cy"></div>
                                
The following JavaScript can also be placed within the HTML directly or within an included *.js file:
<!-- Map of genes: id_gene: name_gene. The id_gene can be any of the accepted ids on the subcellular localisation WebService :InnateDB,Ensembl,Entrez,UniProt -->
var genes = {"ENSG00000160691": "SHC1", "ENSG00000142192": "APP", "ENSG00000169783": "LINGO1", "ENSG00000105290": "APLP1"};
<!-- List of Cytoscape objects: only edges.  -->
var edges = [
  {
    "data": {
      "id": "375184",
      "name": "physical interaction",
      "source": "ENSG00000142192",
      "target": "ENSG00000160691",
      "idgroup": "375184"
    },
    "group": "edges"
  },
  {
    "data": {
      "id": "367978",
      "name": "direct interaction",
      "source": "ENSG00000142192",
      "target": "ENSG00000105290",
      "idgroup": "367978"
    },
    "group": "edges"
  },
  {
    "data": {
      "id": "26032",
      "name": "interologs mapping",
      "source": "ENSG00000142192",
      "target": "ENSG00000169783",
      "idgroup": "26032"
    },
    "group": "edges"
  }
];

var elements = [];
<!-- Ajax function to query the webservice to get the subcellular localisation from InnateDB.  -->
$.ajax({
    dataType: "json",
    async: false,
    type: "GET",
    url: "http://www.innatedb.com/cerebralLocalizationWS.do",
    data: 'xref=Ensembl&ids=' + JSON.stringify(Object.keys(genes)).replace('\[', '').replace('\]', '').replaceAll('"', ''),
    success: function(data){
        for (d in data) {
            var obj = {
                data: {
                    id: d,
                    name: genes[d],
                    localization: data[d],
                    color: defaultNodeColor
                },
                group: "nodes"
            };
            elements.push(obj)
        }
        elements = elements.concat(edges);
    },
    error: function(jqXHR, textStatus, errorThrown)
    {
        console.log(errorThrown);
    }
});
<!-- Inizialization of the Cytoscape_object.  -->
$('#cy').cytoscape({
    layout: options,
    showOverlay: false,
    zoom: 1,
    style: cerebral_style,
    elements: elements,
    ready: function() {
        cy = this;
        cerebral_ready(cy);
    }
});