Skip to content

nhsx/hypergraphical

Repository files navigation

Hypergraphical

About the project

status: experimental Code style: black

This repository contains two components:

  • Hypergraph Animations
  • Hypergraphs for Multimorbidity

The first components contains the code to create hypergraph animations using manim, explaining how hypergraphs are constructed.

The second component is a streamlit applet which provides an interactive walkthrough of calculating node centrality and PageRank scores of hypergraphs. This code supports the Transforming Healthcare Data with Graph-based Techniques Using SAIL DataBank project and a link to the original project proposal can be found here.

Note: Only public or fake data are shared in this repository.

⚠️ The repository uses pre-commit hooks to enforce code style using black, follows flake8, and performs a few other checks. See .pre-commit-config.yaml for more details. These hooks will also need installing locally via:

pre-commit autoupdate
pre-commit install

and then will be checked on commit.

Hypergraph Animations

A library of animations explaining hypergraphs using manim.

Installation Instructions

A detailed tutorial for installing manim can be found here:

Manim Docs

Quick Guide

  1. Clone the repository locally

  2. Install Manim in a virtual environment (use the instructions found above)

  3. Run virtual environment

       $ source venv/bin/activate venv
    
  4. Run the following command to create the Hypergraph Example

    $ manim -qm src/hypergraphs/hypergraphs.py HypergraphExample
    
  5. The mp4 will autoplay. If not please find the video in the following directory:

    $ media/videos/hypergraphs/720p30/
    
    

TL;DC (Too Long; Didn't Clone)

Please find a colab workbook here:

Open In Colab


Hypergraphs for Multimorbidity

This prototype tool has been built using Streamlit, a Python app framework that can be used to create web apps. This Streamlit app allows users to explore hypergraphs in the context of multimoribidity.

This is not an official NHS England product or service but instead is an interactive applet prototype containing ongoing work. This prototype aims only to demonstrate work that may be of interest to others. Opinions expressed in this applet are not representative of the views of NHS England and any content here should not be regarded as official output in any form. For more information about NHS England please visit our official website.

The Streamlit applet explains what multimorbidity is, what hypergraphs are and why hypergraphs are useful for modelling multimoribidity. This applet randomly generates a set of fictious 'patients' and their disease pathways to demonstrate the use of hypergraphs in understanding multimorbidity. The sidebar on the left of this page can be used to change the number of 'patients' to generate and the maximum number of diseases to include in their pathways. In changing the number of patients and diseases, the hypergraph outputs will change and this is purposeful to enable you to observe how population alterations result in different outcomes.

Users can follow through the examples to find out how the hypergraph-mm works by generating hyperedge and hyperarc weights for the population, followed by calculating centrality to show the importance of different diseases within the population.

Hypergraphs for Multimoribidity Tool

Deployment (local) Instructions

To deploy the streamlit app locally we advise following the instructions below:

To clone the repository:

git clone https:github.com/nhsx/hypergraphical

To create a suitable environment, in the terminal run the following command:

  • Build conda environment via conda create --name hg-streamlit python=3.8

  • Activate environment conda activate hg-streamlit

  • Install requirements via python -m pip install -r ./requirements.txt

To run the tool locally, open a terminal whilst in the directory containing the app and run

streamlit run streamlit_hypergraphs.py

Streamlit will then render the tool and display it in your default web browser at

http://localhost:8501/

Testing

Run tests by using pytest test_streamlit/test_edge_count.py.


Roadmap

See the repo Issues for a list of proposed features (and known problems).

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

See CONTRIBUTING.md for detailed guidance.

License

Unless stated otherwise, the codebase is released under the MIT Licence. This covers both the codebase and any sample code in the documentation.

See LICENSE for more information.

The project specific documentation is © Crown copyright and available under the terms of the Open Government 3.0 licence.

Contact

To find out more about DART visit our project website or get in touch here.

About

Repository for Hypergraph Animations and the Hypergraphs for Multimorbidity streamlit App

Resources

License

Stars

Watchers

Forks

Packages

No packages published