{"id":25535969,"url":"https://github.com/incatools/obographviz","last_synced_at":"2025-04-11T14:40:29.506Z","repository":{"id":40493319,"uuid":"67056605","full_name":"INCATools/obographviz","owner":"INCATools","description":"Customizable translation of OBO graphs to dot for visualization using graphviz and other tools","archived":false,"fork":false,"pushed_at":"2025-02-21T00:05:13.000Z","size":19245,"stargazers_count":24,"open_issues_count":13,"forks_count":6,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-25T10:42:45.683Z","etag":null,"topics":["graph-visualization","graphviz","javascript","json","node","obofoundry","obographs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/INCATools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-08-31T16:54:54.000Z","updated_at":"2024-10-19T05:50:51.000Z","dependencies_parsed_at":"2022-07-11T21:52:09.616Z","dependency_job_id":"c1495dc4-6e93-4d81-b049-6299cb9e99f5","html_url":"https://github.com/INCATools/obographviz","commit_stats":{"total_commits":96,"total_committers":3,"mean_commits":32.0,"dds":"0.39583333333333337","last_synced_commit":"6f16634a9b6828b93fbc41668ecd1624341566fa"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/INCATools%2Fobographviz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/INCATools%2Fobographviz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/INCATools%2Fobographviz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/INCATools%2Fobographviz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/INCATools","download_url":"https://codeload.github.com/INCATools/obographviz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248420135,"owners_count":21100320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graph-visualization","graphviz","javascript","json","node","obofoundry","obographs"],"created_at":"2025-02-20T04:24:36.359Z","updated_at":"2025-04-11T14:40:29.490Z","avatar_url":"https://github.com/INCATools.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM version](https://badge.fury.io/js/obographviz.svg)](http://badge.fury.io/js/obographviz)\n\n# Translate OBO Graphs into Dot/Graphviz\n\n * Input: a [OBO Graph JSON](https://github.com/geneontology/obographs) object\n * Optional: a JSON ontology stylesheet\n * Output: a Dot-format / Graphviz file\n\n## Requirements\n\n* Node.js ≥ 14.16\n\n## Installation\n\nThe `obographviz` package can be installed via NPM either locally or globally. If you're not familiar with NPM, see the following to get started:\n\n* [Downloading and installing Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)\n* [Getting packages from the registry](https://docs.npmjs.com/packages-and-modules/getting-packages-from-the-registry)\n\nIf you intend to primarily use the command line tool provided by this package or you're using a tool like [Ontology Access Kit](https://github.com/INCATools/ontology-access-kit) which depends on it, install globally:\n\n```bash\nnpm install -g obographviz\n```\n\nOnce installed globally, the `og2dot` executable will automatically be added to your `PATH`.\n\nOtherwise, if you want to use the package in an existing Node.js project install it locally:\n\n```bash\nnpm install obographviz\n```\n\n## Quickstart\n\n### Command line\n\n**All examples in this README assume `obographviz` has been installed globally. If it was installed locally to a project, call `og2dot` via [`npx`](https://www.npmjs.com/package/npx) or an [npm script](https://docs.npmjs.com/cli/v8/using-npm/scripts).**\n\nSee the `examples` directory in this repositories for sample OBO Graph JSON files and stylesheets.\n\n```bash\nog2dot simple-og.json \u003e test.dot\ndot test.dot -Tpng -Grankdir=BT \u003e test.png\n```\n\n### API\n\n```javascript\nimport { OboGraphViz } from \"obographviz\";\n\nconst obograph = { ... }\n\nconst compoundRelations = ['BFO:0000050']\nconst styleMap = {}\nconst gv = new OboGraphViz(obograph)\nconst dot = gv.renderDot(compoundRelations, styleMap)\nconsole.log(dot)\n```\n\n\n# Features\n\n## Nesting\n\nOne or more predicates can be designated as 'compound', i.e. used for nesting.\n\nOn the command line, use `-c`. In the API, use `compoundRelations`\n\nExample:\n\n```bash\nog2dot -c is_a simple-og.json \u003e test.dot\n```\n\nGenerates:\n\n![img](https://github.com/cmungall/obographviz/raw/master/examples/nested-example.png)\n\nNote only works for subgraphs that exhibit disjointness over this property, acyclicity\n\nUse the `-I` option for inverting the containment relation (e.g. to use `has part` rather than `part of`).\n\n\n## Stylesheets\n\nIn the API can be passed using `styleMap`. On the command line, by using either `-s` (to pass a JSON file) or `-S` (to pass stringified JSON object directly on command line)\n\nE.g.\n\n```bash\nog2dot -s example-style.json -c is_a simple-og.json \u003e test.dot\n```\n\n### Stylesheet Standard\n\nThis is now documented separately:\n\n[kgviz-model](https://berkeleybop.github.io/kgviz-model/)\n\n\n### Global stylemap properties\n\nThese go in the root of the stylemap object\n\n```json\n{\n    \"style\": \"filled\",\n    \"fillcolor\": \"green\"\n}\n```\n\nthis sets all nodes to be filled green\n\n### Edge properties by relationship type\n\nEach relationship type can have its own individual style, by passing relationProperties. This is keyed by the CURIE for the relation (or \"is_a\" for subClassOf):\n\n```json\n{\n    \"relationProperties\": {\n        \"is_a\": {\n            \"color\": \"black\",\n            \"penwith\": 3,\n            \"arrowhead\": \"open\",\n            \"label\": \"\"\n        },\n        \"BFO:0000050\": {\n            \"arrowhead\": \"tee\",\n            \"color\": \"blue\"\n        }\n    }\n}\n```\n\n### Node properties by prefix\n\nPass in prefixProperties to be able to assign individual properties for ontology prefixes. This can be useful when visualization graphs that combine multiple ontologies\n\n```json\n{\n    \"prefixProperties\": {\n        \"SO\": {\n            \"fillcolor\": \"yellow\"\n        },\n        \"RO\": {\n            \"fillcolor\": \"pink\"\n        },\n        \"BFO\": {\n            \"fillcolor\": \"cyan\"\n        }\n    }\n}\n```\n\n### Conditional properties\n\nArbitrary conditions can be set using `conditionalProperties` for example:\n\n```json\n{\n    \"conditionalProperties\": [\n        {\n            \"conditions\": {\n                \"subset\":\"efo_slim\"\n            },\n            \"properties\": {\n                \"fillcolor\": \"blue\"\n            }\n        }\n    ]\n}\n```\n\nThis will color any node in the `efo_slim` subset blue.\n\n\n## Combined Example\n\nThe following example uses all subclasses of digit in Uberon, plus their ancestors, which forms a complex lattic structure.\n\nSee [digit.json](examples/digit.json) for the underlying ontology. See [examples/uberon-style.json](examples/uberon-style.json) for the stylesheet.\n\n```bash\nog2dot -s uberon-style.json digit.json -t png -o digit.png\n```\n\nRenders:\n\n![img](examples/digit.png)\n\n## Nesting of Equivalence Sets\n\nOptionally, cliques of classes interconnected with either equivalence axioms or xrefs will be clustered.\n\nThe file\n[uberon-zfa-xref-example.json](examples/uberon-zfa-xref-example.json)\ncontains a subset of both UBERON, ZFA, and two Allen brain ontologies, with UBERON classes xref-ing\nequivalent ZFA classes.\n\n```bash\nog2dot -s uberon-zfa-style.json uberon-zfa-xref-example.json -t png -o uberon-zfa-xref-example.png\n```\n\nRenders:\n\n![img](examples/uberon-zfa-xref-example.png)\n\n(Uberon: yellow, ZFA:black, MBA: pink, HBA: grey, black lines = IS_A, blue lines = part_of, equivalence sets as bounding boxes)\n\nThe predicates used to build these can be configured in the json style file, e.g.:\n\n```json\n\"cliqueRelations\": [\n    \"xref\", \"equivalent_to\", \"same_as\"\n]\n```\n\nNote: to style the bounding box in a stylesheet, the cliques are considered to be in the ID space `%CLIQUE`\n\n```json\n\"prefixProperties\": {\n    \"%CLIQUE\": {\n        \"fillcolor\": \"hotpink\"\n    },\n    \"GO\": {\n        \"fillcolor\": \"yellow\"\n    },\n}\n```\n\n## Rendering anonymous and pseudo-anonymous individuals\n\nE.g. GO-CAM models\n\n```json\n{\n    \"nodeFilter\" : {\n        \"type\": \"INDIVIDUAL\"\n    },\n    \"labelFrom\": \"type\"\n}\n```\n\n\n```bash\nog2dot -c BFO:0000050 -c RO:0002333 -s gocam-style.json lego-example2.json\n```\n\n![img](examples/lego-example2.png)\n\n\n# Integration with other components\n\n## Configuring individual nodes or edges\n\nAs well as configuring via style sheets, an individual node or edge can configure its display by using an annotation assertion with a property in `https://w3id.org/kgviz/`, e.g.:\n\n```json\n{\n    \"sub\": \"GO:0031090\",\n    \"pred\": \"BFO:0000050\",\n    \"obj\": \"GO:0043227\",\n    \"meta\": {\n        \"basicPropertyValues\": [\n            {\n                \"pred\": \"https://w3id.org/kgviz/penwidth\",\n                \"val\": 10\n            }\n        ]\n    }\n}\n```\n\n## Ontology Access Kit\n\nThis library is integrated into [Ontology Access Kit (OAK)](https://github.com/INCATools/ontology-access-kit) to support its [`viz` subcommand](https://incatools.github.io/ontology-access-kit/cli.html#runoak-viz). For example:\n\n```bash\nrunoak -i ontobee: viz HP:0000787\n```\n\nThis proceeds by:\n\n 1. Using the [python oaklib library](https://incatools.github.io/ontology-access-kit/intro/tutorial02.html) to extract a subgraph around the specified node\n 2. Write as obographs-json\n 3. Calls og2dot\n\n## Use from biolink-api REST\n\nGo to http://api.monarchinitiative.org/api/\n\nSee the `/ontol/subgraph/` route\n\nThis exports obographs which can be fed in to this js lib\n\nTODO - link to demo site\n\n## Use with AmiGO\n\nAmiGO uses bbop-graphs; these are similar enough that they can be passed in instead of obographs.\n\n# Development\n\nJavascript and TypeScript files in the `lib` directory are compiled using [`tsc`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) into the `dist` directory. To compile once use:\n\n```bash\nnpm run build\n```\n\nTo watch for file changes and compile incrementally use:\n\n```bash\nnpm run dev\n```\n\nBefore committing changes run the test suite with:\n\n```bash\nnpm test\n```\n\n# FAQ\n\n## Why Dot/GraphViz?\n\nWhy not D3, cytoscape js etc?\n\nThese are all very nice and pretty, but GraphViz has some powerful\nfeatures that I have not found in any other framework (or have been\ntoo lazy to find out how to do). In particular:\n\n * Easy to run on command line\n * The ability to _nest_ relationships (update: compound graphs in cytoscape.js)\n * simple control over box and edge visual attributes\n * embedding arbitrary HTML\n\nThis is intended to replace blipkit graphviz generation. For some\nexamples, see [mondo report](https://github.com/monarch-initiative/monarch-disease-ontology/blob/master/reports/genes/ABCC9.md)\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fincatools%2Fobographviz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fincatools%2Fobographviz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fincatools%2Fobographviz/lists"}