PathwayCommons / cpath2

Biological pathway data integration and access platform (Pathway Commons)
http://www.pathwaycommons.org/pc2/
MIT License
6 stars 5 forks source link

A JSON output data format for network/graph visualization #303

Open IgorRodchenkov opened 5 years ago

IgorRodchenkov commented 5 years ago

We are to define and make /graph and /get web queries optionally generate rich JSON network/graph data (new OutputFormat), such as our web app uses internally:

{
  network : {
    nodes : [
      {"data":{"class":"ball","id":"ABCB11","label":"ABCB11","queried":false,"parsedMetadata":
        [["Type","bp:Protein"],["Database IDs",[["uniprot knowledgebase","O95342"],
        ["hgnc symbol","ABCB11"]]]]}}, 
      {"data":{"class":"ball","id":"TNF","label":"TNF","queried":false,"parsedMetadata":[["Type","bp:Protein"],
        ["Database IDs",[["uniprot knowledgebase","P01375"],["hgnc symbol","TNF"]]]]}},
...
    ],
    edges : [
      {"data":{"id":"ABCB11\tcontrols-expression-of\tTNF",
        "label":"ABCB11 controls expression of TNF","source":"ABCB11",
        "target":"TNF","class":"Expression",
        "parsedMetadata":[["List",[["PubMed","28505368"]]],["Detailed Views",[["Pathway Commons","Control_9cf09917764babde4fd448610fa38927"],["Pathway Commons","TemplateReaction_79ba1b1dc9889c1e4f25bcbf2249cef7"]]]]},
        "classes":"Expression"},
      {"data":{"id":"ABCB6\tinteracts-with\tSMAD1",
        "label":"ABCB6 interacts with SMAD1","source":"ABCB6","target":"SMAD1","class":"Binding",
        "parsedMetadata":[["List",[["PubMed","15761153"]]],["Detailed Views",[["Pathway Commons","MolecularInteraction_6dbdc98a-5ce8-4184-92a7-95369e98467e___null__1517956_"]]]]},
        "classes":"Binding"},
...
    ]
}

and also make what is used here for the biopax-sbgn pathway views:

{
 graph : { 
nodes : [
{"data":{"id":"http://pathwaycommons.org/pc2/Protein_ea518c37f72116263e0c265603eeec7f","class":"macromolecule","label":"SMAD6","parent":"cytosol","clonemarker":false,"stateVariables":[{"id":null,"class":"state variable","state":{"variable":"","value":"x[1 - 496]"}}],"unitsOfInformation":[],"bbox":{"x":24,"y":15,"w":48,"h":30},"parsedMetadata":[["Type","bp:Protein"],["Data Source","http://pathwaycommons.org/pc2/reactome"],["Display Name","SMAD6"],["Comment",["Reactome DB_ID: 3006350","REPLACED http://www.reactome.org/biopax/64/48887#Protein7405"]],["Names",["SMAD6_HUMAN","Mothers against decapentaplegic homolog 6","hSMAD6","Smad6","SMAD 6","SMAD6","MAD homolog 6","Mothers against DPP homolog 6","SMAD family member 6","MADH6"]],["Database IDs",[["reactome","R-HSA-3006350"],["hgnc symbol","SMAD6"],["uniprot knowledgebase","O43541"]]],["Standard Name","Mothers against decapentaplegic homolog 6"]],"geneSynonyms":[]}},
{"data":{"id":"http://identifiers.org/reactome/R-HSA-8877941_LEFTTORIGHT","class":"process","label":"","parent":"nucleoplasm","clonemarker":false,"stateVariables":[],"unitsOfInformation":[],"bbox":{"x":7.5,"y":7.5,"w":15,"h":15},"parsedMetadata":[["Type","bp:BiochemicalReaction"],["Data Source","http://pathwaycommons.org/pc2/reactome"],["Display Name","RUNX2 binds SMAD1 in the nucleus"],["Comment",["Edited: Orlic-Milacic, Marija, 2017-08-09","Reviewed: Ducy, Patricia, 2017-08-04","In response to BMP2 treatment, RUNX2 (presumably associated with CBFB) forms a complex with SMAD1 (Wang et al. 2006). Phosphorylation of SMAD1 in response to BMP signaling and formation of a heterotrimeric complex between phosphorylated SMAD1 and SMAD4 are prerequisites for SMAD1 retention in the nucleus (Qin et al. 2001, Xiao et al. 2001).<p>BMP2 signaling is implicated in promoting formation of a complex between RUNX2, SMAD1 and acetyltransferase EP300 (p300) and facilitating EP300-mediated acetylation of RUNX2, which activates RUNX2 transcriptional activity. This may involve ERK-mediated phosphorylation of RUNX2 and/or EP300 downstream of BMP2, but the exact mechanism has not been elucidated (Jun et al. 2010).","Authored: Orlic-Milacic, Marija, 2016-06-28"]],["Database IDs",[["pubmed","17215250"],["pubmed","11779505"],["pubmed","11509558"],["pubmed","20851880"],["reactome","R-HSA-8877941"]]]],"geneSynonyms":[]}},
... ],
edges : [
{"data":{"id":"OUT_http://identifiers.org/reactome/R-HSA-8938356_LEFTTORIGHT--TO--http://pathwaycommons.org/pc2/Complex_029c2be399f6c4e20fac1344b30cf615","class":"production","cardinality":0,"source":"http://identifiers.org/reactome/R-HSA-8938356_LEFTTORIGHT","target":"http://pathwaycommons.org/pc2/Complex_029c2be399f6c4e20fac1344b30cf615","bendPointPositions":[],"portSource":"http://identifiers.org/reactome/R-HSA-8938356_LEFTTORIGHT","portTarget":"http://pathwaycommons.org/pc2/Complex_029c2be399f6c4e20fac1344b30cf615"}},
{"data":{"id":"http://pathwaycommons.org/pc2/Protein_dfe49ca23c2925eebe90a01615d12782--TO--INP_http://identifiers.org/reactome/R-HSA-8938356_LEFTTORIGHT","class":"consumption","cardinality":0,"source":"http://pathwaycommons.org/pc2/Protein_dfe49ca23c2925eebe90a01615d12782","target":"http://identifiers.org/reactome/R-HSA-8938356_LEFTTORIGHT","bendPointPositions":[],"portSource":"http://pathwaycommons.org/pc2/Protein_dfe49ca23c2925eebe90a01615d12782","portTarget":"http://identifiers.org/reactome/R-HSA-8938356_LEFTTORIGHT"}}
... ]
 }
}

This should make Pathway Commons' Cytoscape.js based web app development easier.

Refs PathwayCommons/app-ui#916, PathwayCommons/app-ui#938, etc.

IgorRodchenkov commented 5 years ago

@d2fong @jvwong @maxkfranz Does this JSON look good or do you (like me) think it would make sense to come up with a slightly more simple data model/schema that it's in the examples above; e.g., don't use arrays of arrays, "classes" field, etc.?

d2fong commented 5 years ago

I strongly suggest not using the existing parsedMetadata structure.

IMO the key should not be parsedMetadata it should just be metadata. Also the format for the parsedMetadata is extremely frustrating to work with. It should be object key value pairs instead of nested arrays.

IgorRodchenkov commented 5 years ago

Regarding the biopax-sbgn-cytoscape conversion path (the second JSON "graph" example), it is in fact possible (and perfectly standard way) to inject own xml elements into e.g., glyph/extension element; e.g.:

<glyph class="macromolecule" id="http://pathwaycommons.org/pc2/Protein_refseq_XP_011530265_identity_1524631616617">
  <extension>
    <bp:Protein xmlns:bp="http://www.biopax.org/release/biopax-level3.owl#" uri="http://pathwaycommons.org/pc2/Protein_refseq_XP_011530265_identity_1524631616617"/>
  </extension>
  <label text="SMAD1"/>
  <bbox w="48.0" h="25.0" x="0.0" y="0.0"/>
 </glyph>

And PC v10 web service does currently inserts a biopax entity element with uri into SBGN-ML, which nobody's using at the moment (sbgnml-to-cytoscape js module ignores elements) but we'd easily change that later - insert metadata, such type, some tag, states, original URI, standard identifiers, names, data sources, organism, etc. - as needed.

Metadata could be also inserted there as JSON or text all at once using a single XML element and CDATA:

<extension>
  <metadata>
    <![CDATA[
{"class":"process","label":"","parent":"nucleoplasm","clonemarker":false,"stateVariables":[],"unitsOfInformation":[],"bbox":{"x":7.5,"y":7.5,"w":15,"h":15},"parsedMetadata":[["Type","bp:BiochemicalReaction"],["Data Source","http://pathwaycommons.org/pc2/reactome"],["Display Name","RUNX2 binds SMAD1 in the nucleus"],["Comment",["Edited: Orlic-Milacic, Marija, 2017-08-09","Reviewed: Ducy, Patricia, 2017-08-04","In response to BMP2 treatment, RUNX2 (presumably associated with CBFB) forms a complex with SMAD1 (Wang et al. 2006). Phosphorylation of SMAD1 in response to BMP signaling and formation of a heterotrimeric complex between phosphorylated SMAD1 and SMAD4 are prerequisites for SMAD1 retention in the nucleus (Qin et al. 2001, Xiao et al. 2001).<p>BMP2 signaling is implicated in promoting formation of a complex between RUNX2, SMAD1 and acetyltransferase EP300 (p300) and facilitating EP300-mediated acetylation of RUNX2, which activates RUNX2 transcriptional activity. This may involve ERK-mediated phosphorylation of RUNX2 and/or EP300 downstream of BMP2, but the exact mechanism has not been elucidated (Jun et al. 2010).","Authored: Orlic-Milacic, Marija, 2016-06-28"]],["Database IDs",[["pubmed","17215250"],["pubmed","11779505"],["pubmed","11509558"],["pubmed","20851880"],["reactome","R-HSA-8877941"]]]],"geneSynonyms":[]}
 ]]>
  </metadata>
</extension>

PS: try http://www.pathwaycommons.org/pc2/graph?source=SMAD1&pattern=IN_COMPLEX_WITH&kind=NEIGHBORHOOD&format=SBGN

jvwong commented 5 years ago

Re: biopax-sbgn Pathways/Painter off the top of my head: