Skip to content

Commit

Permalink
pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danjscho committed Jul 5, 2023
1 parent 5fe6ecb commit 08f1cb0
Show file tree
Hide file tree
Showing 19 changed files with 252 additions and 1,232 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ venv/
__pycache__/
drawing_test.ipynb
patient_converter_playground.ipynb
remove_dead_end.ipynb
remove_dead_end.ipynb
2 changes: 1 addition & 1 deletion .streamlit/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ primaryColor="#0072CE"
backgroundColor="#ffffff"
secondaryBackgroundColor="#e8eef9"
textColor="#000000"
font="sans serif"
font="sans serif"
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"editor.defaultFormatter": "ms-python.black-formatter"
},
"python.formatting.provider": "none"
}
}
25 changes: 11 additions & 14 deletions markdown_text/dir_hypergraphs.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
You can explore and visualise how undirected population-based hypergraphs are built from multiple fictitious patients in the
You can explore and visualise how undirected population-based hypergraphs are built from multiple fictitious patients in the
`Undirected Hypergraph` tab at the top of this page.

#### Directed B-Hypergraphs

Directed hypergraphs expand on undirected hypergraphs, but have the advantage that they can represent directionality between
Directed hypergraphs expand on undirected hypergraphs, but have the advantage that they can represent directionality between
relationships i.e. the sequence in which conditions occur in patients.

A directed hypergraph $\mathcal{H}_D(V, \mathcal{E})$ is a collection of nodes stored in $V = \{v_1, \dots, v_n\}$, and hyperarcs,
A directed hypergraph $\mathcal{H}_D(V, \mathcal{E})$ is a collection of nodes stored in $V = \{v_1, \dots, v_n\}$, and hyperarcs,
$\mathcal{E} = \{e_1, \dots,e_m\}$. Each hyperarc $e_i = \langle T(e_i), H(e_i)\rangle$ where $T(e_i), H(e_i) \subseteq V$ represents
a collection of nodes such that those $v_i \in T(e_i)$ are the tails of the hyperarc and those $v_j \in H(e_i)$ are the heads of
the hyperarc.
a collection of nodes such that those $v_i \in T(e_i)$ are the tails of the hyperarc and those $v_j \in H(e_i)$ are the heads of
the hyperarc.

There are various types of directed hypergraphs, B-hypergraphs, F-hypergraphs, and BF-hypergraphs to name a few.
B-hypergraphs are restricted to have only one head node for each hyperarc, but can have unlimited tail nodes. For example, someone
might have disease $C$ and $A$ (tail nodes) and then gain disease $B$ (head node) (see visual below). In the opposite case,
B-hypergraphs are restricted to have only one head node for each hyperarc, but can have unlimited tail nodes. For example, someone
might have disease $C$ and $A$ (tail nodes) and then gain disease $B$ (head node) (see visual below). In the opposite case,
F-hypergraphs can have only one tail node but unlimited head nodes. BF-hypergraphs have no restriction on the number of tail or head
nodes.

We chose to use B-hypergraphs due to the computational complexity being high in the BF-hypergraph variation and because the
clinical way that conditions tend to aggregate can be well represented with B-hypergraphs. However, we do appreciate the
limitation here that someone may gain two diseases simultaneously, which could be better represented using BF-hypergraphs, but we
We chose to use B-hypergraphs due to the computational complexity being high in the BF-hypergraph variation and because the
clinical way that conditions tend to aggregate can be well represented with B-hypergraphs. However, we do appreciate the
limitation here that someone may gain two diseases simultaneously, which could be better represented using BF-hypergraphs, but we
apply a workaround to this. This is out of the scope of this dashboard, but further information can be found in an upcoming
publication and code base.

Undirected, parent hyperedges give rise to children hyperarcs (directed hyperedges). Sibling hyperarcs are hyperarcs which have the
same parent hyperedge and thus have the same set of nodes as the hyperarc in question. An example of a hyperarc with its siblings
and parent hyperedge are shown in the image below. You can explore and visualise how directed hypergraphs are built from multiple
and parent hyperedge are shown in the image below. You can explore and visualise how directed hypergraphs are built from multiple
fictitious patients in the `Directed Hypergraph` tab at the top of this page.



18 changes: 8 additions & 10 deletions markdown_text/graphs.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
_What are graphs and hypergraphs and why do we want to use them?_
Using hypergraphs enables more complexities and relationships from the data to be included.
_Why?_ Let's start by describing __undirected graphs__, __directed graphs__, __undirected hypergraphs__ and __directed
hypergraphs__.
Using hypergraphs enables more complexities and relationships from the data to be included.
_Why?_ Let's start by describing __undirected graphs__, __directed graphs__, __undirected hypergraphs__ and __directed
hypergraphs__.

Graphs are very good at structuring interactivity and networks, which makes them particularly useful in healthcare where healthcare
Graphs are very good at structuring interactivity and networks, which makes them particularly useful in healthcare where healthcare
data can be sparse.

A standard graph $\mathcal{G}(v,e)$ can connect only 2 objects/nodes ($v$) with one edge ($e$). Only pairwise connections can exist.

Graphs can be directed or undirected. Directed graphs give directionality to node interactions. For a temporal example lets imagine
$node_1$ is diabetes which could happen prior to $node_2$ which is chronic kidney disease, directionality shows the temporal order
Graphs can be directed or undirected. Directed graphs give directionality to node interactions. For a temporal example lets imagine
$node_1$ is diabetes which could happen prior to $node_2$ which is chronic kidney disease, directionality shows the temporal order
or sequence of events.
Alternatively, in an undirected graph edges connecting two nodes/diseases simply imply there is a relationship between the two.
Here we should emphasize that standard graphs only enable __pairwise__ relationships to be represented.


Graphs have the benefit of allowing extra information to be stored in the nodes or edges, these can be weights or attributes. For
example, you may wish to store more details about a condition within a node or the elapsed time between disease contraction within
Graphs have the benefit of allowing extra information to be stored in the nodes or edges, these can be weights or attributes. For
example, you may wish to store more details about a condition within a node or the elapsed time between disease contraction within
an edge.

4 changes: 1 addition & 3 deletions markdown_text/mm_description.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Multimorbidity is defined as having 2 or more long term chronic health conditions simultaneously. Multimorbidity is associated with increased health service utilisation (Cassell et al., 2018).

People are living longer and so the population is ageing. This is due to
improvements in lifestyle through things such as having healthier diets, exercising and not smoking. Treatment improvements mean that more people are surviving acute conditions. The number of hospitals and other healthcare services are not increasing fast enough to keep up with this rising ageing population and increased health service utilisation required by patients with multimorbidity, so healthcare services are being burdened.
People are living longer and so the population is ageing. This is due to improvements in lifestyle through things such as having healthier diets, exercising and not smoking. Treatment improvements mean that more people are surviving acute conditions. The number of hospitals and other healthcare services are not increasing fast enough to keep up with this rising ageing population and increased health service utilisation required by patients with multimorbidity, so healthcare services are being burdened.

Frameworks and policies in healthcare management are designed for individual conditions, rather than multiple. Patients with multiple long-term conditions can be difficult to treat as medications may interact and conditions require different management strategies. If departments could be placed more optimally distally when multimorbidity occurs, access for patients could be easier and quicker. Which is especially important for those with frailties. Additionally, having departments closer together allows them to communicate to better integrate treatment plans for their in common patients.

Expand All @@ -10,4 +9,3 @@ Approximately 1 in 4 patients in primary care within the UK had multiple chronic
One study using data from around 14 million patients in 2012 found that hypertension, depression/anxiety and then chronic pain were the most prevalent multimorbidity conditions. They also found than females (30\%) were more likely to have multimorbidity than males (24.4\%). And those with a low socioeconomic status had 4.2\% more people with multimorbidity than the highest socioeconomic status group. Additionally, around half of GP consultations and hospital admissions were for multimorbidity. 78.7\% of prescriptions were for multimorbidity (Cassell et al., 2018).

As multimorbidity becomes more prevalent its important that research in multimorbidity develops so that strategies can be backed up to change health frameworks and policies, to prevent accumulation of conditions, better manage those with multiple condition and reduce the burden on healthcare.

19 changes: 9 additions & 10 deletions markdown_text/overview.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

This work is a continuation of the hypergraphs work carried out by Rafferty et al. 2021:

[Multimorbidity Hypergraphs GitHub](https://github.com/SwanseaUniversityMedical/multimorbidity_hypergraphs),
[Original Paper](https://www.sciencedirect.com/science/article/pii/S1532046421002458).
[Multimorbidity Hypergraphs GitHub](https://github.com/SwanseaUniversityMedical/multimorbidity_hypergraphs), [Original Paper](https://www.sciencedirect.com/science/article/pii/S1532046421002458).

We wish to demonstrate how hypergraphs can be used to capture relationships between multiple diseases
rather than relationships between pairs of diseases. For example, looking at multimorbidity
patterns instead of just comorbidities, which standard graphs tend to do. More people are suffering
from multiple chronic diseases at the same time, so it's important to think about how we can find
patterns in the uptake of multimoribidities, to see if prevention techniques or treatments could
be put in place sooner to improve the quality of life in patients.
We wish to demonstrate how hypergraphs can be used to capture relationships between multiple diseases
rather than relationships between pairs of diseases. For example, looking at multimorbidity
patterns instead of just comorbidities, which standard graphs tend to do. More people are suffering
from multiple chronic diseases at the same time, so it's important to think about how we can find
patterns in the uptake of multimoribidities, to see if prevention techniques or treatments could
be put in place sooner to improve the quality of life in patients.

On this page you can find out the [aims of this project](#project-aims), find out a bit more about
what [multimorbidity](#multimorbidity) is and what types of [graphs](#graphs) we talk about within this project
On this page you can find out the [aims of this project](#project-aims), find out a bit more about
what [multimorbidity](#multimorbidity) is and what types of [graphs](#graphs) we talk about within this project
(including standard graphs, undirected hypergraphs and directed hypergraphs).
1 change: 0 additions & 1 deletion markdown_text/project_aims.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ This project has various overarching objectives which we are aiming to achieve.
* Help prioritise care services.

* Optimise treatment and management to improve pain and reduce healthcare costs.

4 changes: 1 addition & 3 deletions markdown_text/prototype.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ __:blue[Prototype:]__ _This is not an official NHS England product or service bu
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
For more information about NHS England please visit our official
[website](https://www.england.nhs.uk/)._


14 changes: 7 additions & 7 deletions markdown_text/purpose.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
### Purpose of This Applet

The model shown in this applet builds upon the work carried out in Rafferty et al., 2021.
This Streamlit applet can be used to learn about how the hypergraphs multimorbidity model works with fictitious patient data.
It provides test cases to allow users to understand the model and apply the `hypergraphs_mm` package to their own data
This Streamlit applet can be used to learn about how the hypergraphs multimorbidity model works with fictitious patient data.
It provides test cases to allow users to understand the model and apply the `hypergraphs_mm` package to their own data
(the `hypergraph-mm` package is currently held within a private NHSX GitHub repository but will soon become available publically and as a PyPI package).
It aims to explain graphs and hypergraphs in a health setting. It can be used to demonstrate the complexity of different types of
It aims to explain graphs and hypergraphs in a health setting. It can be used to demonstrate the complexity of different types of
graphs (left sidebar 'Show Maximum Number of Edges').
This website gives a interactive walkthrough of how to calulcate hyperedge weights, hyperarc weights, undirected hypergraph centrality,
transition matrices and PageRank. The user can navigate between the pages using the tabs `Undirected Hypergraph`, `Directed Hypergraph`
This website gives a interactive walkthrough of how to calulcate hyperedge weights, hyperarc weights, undirected hypergraph centrality,
transition matrices and PageRank. The user can navigate between the pages using the tabs `Undirected Hypergraph`, `Directed Hypergraph`
and `Successors` at the top of each page.
It demonstrates a method to draw B-hypergraphs using the NetworkX package, where psuedonodes are used for hyperarc tails to
transition to hyperarc heads.
It demonstrates a method to draw B-hypergraphs using the NetworkX package, where psuedonodes are used for hyperarc tails to
transition to hyperarc heads.
1 change: 0 additions & 1 deletion markdown_text/ref_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ the Population Ageing and Care Simulation (PACSim) model. Age and Ageing, 47(3):
James Rafferty, Alan Watkins, Jane Lyons, Ronan A Lyons, Ashley Akbari, Niels Peek, Farideh Jalali-
Najafabadi, Thamer Ba Dhafari, Alexander Pate, Glen P Martin, et al. Ranking sets of morbidities using
hypergraph centrality. Journal of Biomedical Informatics, 122:103916, 2021.

10 changes: 5 additions & 5 deletions markdown_text/summary.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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
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 outputs will change
and this is purposeful to enable you to observe how population alterations result in different outcomes.
In changing the number of patients and diseases, the outputs will change
and this is purposeful to enable you to observe how population alterations result in different outcomes.
16 changes: 8 additions & 8 deletions markdown_text/undir_hypergraphs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
Hypergraphs $\mathcal{H}(v,e)$ can connect 2 or more nodes per edge.

Hypergraphs were defined by Berge 1976, Berge defined hypergraphs to be an extension of graphs which enable relationships between
many nodes, rather than just pairwise relationships.
many nodes, rather than just pairwise relationships.

Hypergraphs enable multimorbidity edge connections between diseases to be established rather than only co-morbidity. Where the nodes
Hypergraphs enable multimorbidity edge connections between diseases to be established rather than only co-morbidity. Where the nodes
are the diseases and the hyperedges are the multimorbidity sets.

Both graphs and hypergraphs can be undirected or directed. The key difference when directionality is involved is that the hypergraph
edges (hyperedges), become hyperarcs due to their directionality, and can have different numbers of inputs and outputs (heads and
Both graphs and hypergraphs can be undirected or directed. The key difference when directionality is involved is that the hypergraph
edges (hyperedges), become hyperarcs due to their directionality, and can have different numbers of inputs and outputs (heads and
tails).

#### Undirected Hypergraphs

The edges connecting nodes in undirected hypergraphs are called hyperedges. These hyperedges can be visualised as 'elastic bands' or
with line connections (shown below).
Similar to the example given for standard graphs, the nodes in undirected hypergraphs can be diseases and the hyperedges represent
relationships between these diseases. For example, showing that a person with disease $x$ will likely have disease $y$.
Similar to the example given for standard graphs, the nodes in undirected hypergraphs can be diseases and the hyperedges represent
relationships between these diseases. For example, showing that a person with disease $x$ will likely have disease $y$.

The hyperedges can also store additonal information about the connection, such as how common/prevalent the relationship is between
nodes/diseases.
The hyperedges can also store additonal information about the connection, such as how common/prevalent the relationship is between
nodes/diseases.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[build-system]
requires = ["setuptools", "wheel", "cython"]
build-backend = "setuptools.build_meta"


2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ exclude =

[options.entry_points]
console_scripts =
hypergraph = hypergraph.hypergraph:main
hypergraph = hypergraph.hypergraph:main
Loading

0 comments on commit 08f1cb0

Please sign in to comment.