graph-visualizationcytoscape

Cytoscape3 Desktop: Dual Labels (from two columns) per Node?


I have a cytoscape graph for which I would like to present two labels simultaneously per node in the desktop application. Is there a way to do this ? Here is an example (image and export to cyjs). I would like to in addition to the current label (name), have the classID or the synonyms (note that this label is a list).

Alzheimer's Disease Ontology in Cytoscape 3

Here is the cyjs (Cytoscape JSON) for this network:

{
  "format_version" : "1.0",
  "generated_by" : "cytoscape-3.9.1",
  "target_cytoscapejs_version" : "~2.1",
  "data" : {
    "shared_name" : "Alzheimer's Disease Ontology",
    "name" : "Alzheimer's Disease Ontology",
    "SUID" : 124,
    "shared_name" : "Alzheimer's Disease Ontology",
    "selected" : true
  },
  "elements" : {
    "nodes" : [ {
      "data" : {
        "id" : "191",
        "shared_name" : "NEURODEGENERATIVE DISEASE",
        "classID" : "DOID_1289",
        "synonyms" : [ "NEURODEGENERATIVE DISEASE", "DEGENERATIVE DISEASE" ],
        "name" : "NEURODEGENERATIVE DISEASE",
        "SUID" : 191,
        "id_original" : "155",
        "_foretell_labels" : [ "Disease" ],
        "selected" : false
      },
      "position" : {
        "x" : 18.285714285714292,
        "y" : 67.0
      },
      "selected" : false
    }, {
      "data" : {
        "id" : "188",
        "shared_name" : "CENTRAL NERVOUS SYSTEM DISEASE",
        "classID" : "DOID_331",
        "name" : "CENTRAL NERVOUS SYSTEM DISEASE",
        "SUID" : 188,
        "id_original" : "182",
        "_foretell_labels" : [ "Disease" ],
        "selected" : false
      },
      "position" : {
        "x" : 18.285714285714292,
        "y" : 0.0
      },
      "selected" : false
    }, {
      "data" : {
        "id" : "185",
        "shared_name" : "NERVOUS SYSTEM DISEASE",
        "classID" : "DOID_863",
        "name" : "NERVOUS SYSTEM DISEASE",
        "SUID" : 185,
        "id_original" : "185",
        "_foretell_labels" : [ "Disease" ],
        "selected" : false
      },
      "position" : {
        "x" : 18.079472132200525,
        "y" : -73.37937578464862
      },
      "selected" : false
    }, {
      "data" : {
        "id" : "182",
        "shared_name" : "DISEASE",
        "classID" : "DOID_4",
        "name" : "DISEASE",
        "SUID" : 182,
        "id_original" : "188",
        "_foretell_labels" : [ "Disease" ],
        "selected" : false
      },
      "position" : {
        "x" : 18.285714285714292,
        "y" : -201.0
      },
      "selected" : false
    }, {
      "data" : {
        "id" : "179",
        "shared_name" : "DISEASE OF ANATOMICAL ENTITY",
        "classID" : "DOID_7",
        "name" : "DISEASE OF ANATOMICAL ENTITY",
        "SUID" : 179,
        "id_original" : "191",
        "_foretell_labels" : [ "Disease" ],
        "selected" : false
      },
      "position" : {
        "x" : -103.76660535458818,
        "y" : -137.18968789232434
      },
      "selected" : false
    }, {
      "data" : {
        "id" : "176",
        "shared_name" : "TAUOPATHY",
        "classID" : "DOID_680",
        "name" : "TAUOPATHY",
        "SUID" : 176,
        "id_original" : "194",
        "_foretell_labels" : [ "Disease" ],
        "selected" : false
      },
      "position" : {
        "x" : 18.285714285714292,
        "y" : 134.0
      },
      "selected" : false
    }, {
      "data" : {
        "id" : "155",
        "shared_name" : "ALZHEIMER'S DISEASE",
        "classID" : "DOID_10652",
        "synonyms" : [ "ALZHEIMERS DEMENTIA", "ALZHEIMER DISEASE" ],
        "name" : "ALZHEIMER'S DISEASE",
        "SUID" : 155,
        "id_original" : "197",
        "_foretell_labels" : [ "Disease" ],
        "selected" : false
      },
      "position" : {
        "x" : 18.285714285714292,
        "y" : 201.0
      },
      "selected" : false
    } ],
    "edges" : [ {
      "data" : {
        "id" : "242",
        "source" : "191",
        "target" : "188",
        "id_original" : "235",
        "shared_interaction" : "IS_CHILD",
        "source_original" : "155",
        "shared_name" : "IS_CHILD",
        "source_original" : "223",
        "target_original" : "182",
        "shared_name" : "IS_CHILD",
        "shared_interaction" : "IS_CHILD",
        "name" : "IS_CHILD",
        "interaction" : "IS_CHILD",
        "SUID" : 242,
        "id_original" : "200",
        "refid" : 903.0,
        "selected" : false,
        "target_original" : "220"
      },
      "selected" : false
    }, {
      "data" : {
        "id" : "239",
        "source" : "188",
        "target" : "182",
        "id_original" : "244",
        "shared_interaction" : "IS_CHILD",
        "source_original" : "182",
        "shared_name" : "IS_CHILD",
        "source_original" : "220",
        "target_original" : "188",
        "shared_name" : "IS_CHILD",
        "shared_interaction" : "IS_CHILD",
        "name" : "IS_CHILD",
        "interaction" : "IS_CHILD",
        "SUID" : 239,
        "id_original" : "221",
        "refid" : 6410.0,
        "selected" : false,
        "target_original" : "214"
      },
      "selected" : false
    }, {
      "data" : {
        "id" : "236",
        "source" : "188",
        "target" : "185",
        "id_original" : "238",
        "shared_interaction" : "IS_CHILD",
        "source_original" : "182",
        "shared_name" : "IS_CHILD",
        "source_original" : "220",
        "target_original" : "185",
        "shared_name" : "IS_CHILD",
        "shared_interaction" : "IS_CHILD",
        "name" : "IS_CHILD",
        "interaction" : "IS_CHILD",
        "SUID" : 236,
        "id_original" : "224",
        "refid" : 6409.0,
        "selected" : false,
        "target_original" : "217"
      },
      "selected" : false
    }, {
      "data" : {
        "id" : "233",
        "source" : "185",
        "target" : "182",
        "id_original" : "232",
        "shared_interaction" : "IS_CHILD",
        "source_original" : "185",
        "shared_name" : "IS_CHILD",
        "source_original" : "217",
        "target_original" : "188",
        "shared_name" : "IS_CHILD",
        "shared_interaction" : "IS_CHILD",
        "name" : "IS_CHILD",
        "interaction" : "IS_CHILD",
        "SUID" : 233,
        "id_original" : "227",
        "refid" : 6951.0,
        "selected" : false,
        "target_original" : "214"
      },
      "selected" : false
    }, {
      "data" : {
        "id" : "230",
        "source" : "185",
        "target" : "179",
        "id_original" : "229",
        "shared_interaction" : "IS_CHILD",
        "source_original" : "185",
        "shared_name" : "IS_CHILD",
        "source_original" : "217",
        "target_original" : "191",
        "shared_name" : "IS_CHILD",
        "shared_interaction" : "IS_CHILD",
        "name" : "IS_CHILD",
        "interaction" : "IS_CHILD",
        "SUID" : 230,
        "id_original" : "230",
        "refid" : 6950.0,
        "selected" : false,
        "target_original" : "211"
      },
      "selected" : false
    }, {
      "data" : {
        "id" : "227",
        "source" : "179",
        "target" : "182",
        "id_original" : "226",
        "shared_interaction" : "IS_CHILD",
        "source_original" : "191",
        "shared_name" : "IS_CHILD",
        "source_original" : "211",
        "target_original" : "188",
        "shared_name" : "IS_CHILD",
        "shared_interaction" : "IS_CHILD",
        "name" : "IS_CHILD",
        "interaction" : "IS_CHILD",
        "SUID" : 227,
        "id_original" : "233",
        "refid" : 854.0,
        "selected" : false,
        "target_original" : "214"
      },
      "selected" : false
    }, {
      "data" : {
        "id" : "224",
        "source" : "176",
        "target" : "191",
        "id_original" : "241",
        "shared_interaction" : "IS_CHILD",
        "source_original" : "194",
        "shared_name" : "IS_CHILD",
        "source_original" : "208",
        "target_original" : "155",
        "shared_name" : "IS_CHILD",
        "shared_interaction" : "IS_CHILD",
        "name" : "IS_CHILD",
        "interaction" : "IS_CHILD",
        "SUID" : 224,
        "id_original" : "236",
        "refid" : 7129.0,
        "selected" : false,
        "target_original" : "223"
      },
      "selected" : false
    }, {
      "data" : {
        "id" : "194",
        "source" : "155",
        "target" : "176",
        "id_original" : "247",
        "shared_interaction" : "IS_CHILD",
        "source_original" : "197",
        "shared_name" : "IS_CHILD",
        "source_original" : "184",
        "target_original" : "194",
        "shared_name" : "IS_CHILD",
        "shared_interaction" : "IS_CHILD",
        "name" : "IS_CHILD",
        "interaction" : "IS_CHILD",
        "SUID" : 194,
        "id_original" : "239",
        "refid" : 14236.0,
        "selected" : false,
        "target_original" : "208"
      },
      "selected" : false
    } ]
  }
}

Solution

  • A solution to having two labels simultaneously for a graph in Cytoscape 3 Desktop is to concatenate two columns (containing the desired labels) either by using the CONCATENATE function or the & operator. In the example, the following was done to achieve this:

    1. In the node Table panel, Add a new single column of the type String (see image below)
    2. Using the function builder (see image below), add the function to concatenate the two columns, note that in this case the line break character was used "\n". Either CONCATENATE($name,"\n",$classID) or $name & "\n" & $classID and insert formula for the entire column.
    3. On the Style pannel, under Label select the newly created column, in this case nameANDclassID.

    Formula builder (concatenate the two columns): Cytoscape formula builder concatenate two columns

    Cytoscape Node Table with column (formula has been already inserted in entire column): Cytoscape node table with formula containing two labels

    Alzheimer's Disease Ontology showing Ontological names and classID: Alzheimer's Disease Ontology including Labels and Class