Git Product home page Git Product logo

umls-kg's Introduction

Load, Visualize, Query UMLS Knowledge graph with Neo4j

Overview

On this repo, you can load UMLS knowledge graph and Visualize with Neo4j and you can use Neo4j python driver to query nodes or relationships what you want.

First, you need to install UMLS dataset and load it into mysql.

Usage

Requirement

  • python >= 3.9
  • pymysql >= 1.0.2
  • csv >= 1.0
  • neo4j python driver >= 4.4.5
  • Docker

Create your graph

Run this code below:

python build_graph.py --host ${host} --user ${user} --password ${password} --database ${database}

Example:

python build_graph.py --host localhost --user root --password root --database umls2022

Ouput:

3618459 concepts
7577026 atoms
25004792 relationships

Import UMLS data into Neo4j

Run this code below:

docker run -it -v /d/umls/2022AA/META:/data -v /d/umls/2022AA/META:/var/lib/neo4j/import neo4j:3.5 bin/neo4j-admin import --nodes=import/MRCONSO.processed.csv /--nodes=import/MRAUI.processed.csv --relationships=import/MRREL.processed.csv

In the above script, --nodes represents specifying location of node tables used, and --relationships represents specifying location of relationship tables. You can specify multiple nodes or relationships table for importing various types of nodes and relationships.


Now you can visualize and query nodes or subgraphs what you want.

Befor to do that, you should shutdown docker container of neo4j image and run this code below:

docker run -it -p7474:7474 -p7687:7687 -v /d/umls/2022AA/META:/data -v /d/umls/2022AA/META:/var/lib/neo4j/import --env NEO4J_AUTH=neo4j/test neo4j:3.5 

In the above script, neo4j is user and test is password.

For example, I will query nodes that have relationship with CUI C0000039.

Using Neo4j python driver to query database

First you need to install neo4j package:

pip install neo4j

Run this code below:

import neo4j 
from neo4j import GraphDatabase
graphdb= GraphDatabase.driver(uri= "bolt://localhost:7687", auth=("neo4j", "test"))
session= graphdb.session()
q1="match (p: Concept {CUI: 'C0000039'}) return p"
nodes= session.run(q1)
for node in nodes: 
    print(node)

Output:

<Record p=<Node id=1 labels=frozenset({'Concept'}) properties={'name': '1,2-dipalmitoylphosphatidylcholine', 'CUI': 'C0000039'}>>

umls-kg's People

Contributors

nguyendat-bit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.