{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Application: differential diagnosis\n", "\n", "_The purpose of this series of notebooks on Bayesian logic in clinical diagnostics is to give a mathematically robust and intelligible summary to help physicians, epidemiologists, nurses, NPs and in the field, as well as their consumers, understand clinical decisionmaking as an objective process amenable to analysis and quantification rather than using 'instinct' or 'experience' as a surrogate explanation for a process that can – and should – be made explicable, interpretable and if need be, interrogable. **This does not mean to simplify diagnostics (the practice) or imply that it's in any way an automatic processhat can be reduced to a simple algorithm. But diagnosis (the logical process) is, and should be.** The purpose of these notebooks is to help with that process._\n", "\n", "_About the author: I'm [Chris von Csefalvay](http://www.chrisvoncsefalvay.com), a clinical computational epidemiologist and expert in filoviridae working for [CBRD](http://www.cbrd.co). You can find me on [Twitter](https://twitter.com/chrisvcsefalvay), [Facebook](https://www.facebook.com/chrisvcsefalvay) and, of course, [Github](https://github.com/chrisvoncsefalvay). Please feel free to let me know if you have any questions, corrections or suggestions._\n", "\n", "---\n", "\n", "Differential diagnosis describes the process of finding a list of potential diagnostic solutions for a particular set of symptoms, then determining the solution with the greatest probability given the symptoms. Or, formally defined: given a patient exhibiting the symptoms $ \\mathcal{S} = S_{1 \\ldots m} $ and potential diagnostic solutions $ \\mathcal{Dx} $, which solution $ Dx_{\\sigma} \\in \\mathcal{Dx} $ maximises $ f(x \\in \\mathcal{Dx}) = p(x \\mid \\mathcal{S}) $? In other words, the objective is to find \n", "\n", "$$ \\underset{x \\in \\mathcal{Dx}} {\\operatorname{arg\\,max}} \\ \\ f(x) = \\underset{x \\in \\mathcal{Dx}} {\\operatorname{arg\\,max}} \\ \\ p(x \\mid \\bigcap_{i = 1}^{m} S_i) $$\n", "\n", "Here, the $ \\bigcap_{i=1}^{m} S_i $ operator describes the intersection of symptoms $ S_{1 \\ldots m} $, i.e.  $ S_1 \\cap \\ldots \\cap S_m $. In practice, the inverse probability (the probability of a symptom occurring given a diagnosis, i.e. $ p(S_q \\mid D_r) \\mid S_q \\in \\mathcal{S}, D_r \\in \\mathcal{D} $, is typically more available. For this reason, we will need to rely on Bayesian logic to reverse patterns of causality." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We will consider two specific situations of two patients, denoted as Alice and Bob, presenting with identical symptoms $ S $. Their differential diagnosis $ \\mathcal{Dx}_{Alice} $ and $ \\mathcal{Dx}_{Bob} $ includes, among others, a vaccine-preventable disease $ D_{VPD} $, against which Alice is vaccinated, but Bob is not. The vaccine has a failure rate of 2%. Amongst the unvaccinated, $ D_{VPD} $ is present in about 0.1% of all who turn up at this particular hospital. For simplicity's sake, we are treating the conjunction of symptoms as a binary event and consider all of them indispensable for a diagnosis of $ D_{VPD} $, so that patients either exhibit ($ S^+ $) or do not exhibit ($ S^- $) the totality of the symptoms defined to be pathognomonic of the disease. We know that overall 8.0% of the population reporting for treatment at this facility exhibit all of the pathognomonic symptoms (with or without others), as these symptoms are fairly nonspecific. We further know 'by definition' that everyone who _does_ have $ D_{VPD} $ is $ S^+ $, i.e. exhibits all symptoms." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Bob's case\n", "\n", "Bob's case is somewhat simpler, so let's start with that. What's the probability for Bob, who exhibits the symptom combination $ S $ (i.e. $ S^+ $), to have $ D_{VPD} $, against which he is not vaccinated? In other words, what is the probability $ p(D_{VPD} \\mid S^+) $ in an unvaccinated individual?\n", "\n", "Bayes' theorem states that\n", "\n", "$$ p(D_{VPD} \\mid S^+)_{unvax} = \\frac{p(S^+ \\mid D_{VPD}) p(D_{VPD})}{p(S^+)} $$\n", "\n", "where $ p(D_{VPD}) $ denotes the probability that an unvaccinated person presenting at this particular hospital has $ D_{VPD} $ and $ p(S^+) $ denotes the probability that a person presenting at this hospital will exhibit the symptoms $ S $ pathognomonic for $ D_{VPD} $.\n", "\n", "We know $ p(D_{VPD}) $ is 0.1% or $ 0.001 $ and $ p(S^+) $ is 8% or $ 0.08 $. Finally, since the symptoms $ S $ are deemed to be conclusively pathognomonic of $ D_{VPD} $, i.e. they occur in every case without exception, we can eliminate $ p(S^+ \\mid D_{VPD}) $ as its value is 1. This leaves a probability\n", "\n", "$$ p(D_{VPD} \\mid S^+)_{unvax} \\\n", " = \\frac{p(D_{VPD})}{p(S^+)} \\\n", " = \\frac{0.001}{0.08} = 0.0125 \\ \\ \\ \\ (1.25 \\times 10^{-2}) $$\n", "\n", "In other words, a probability of $1.25\\%$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Alice's case\n", "\n", "In Alice's case, we know she is vaccinated but we do not know if she is immune. Therefore, we compensate for this by calculating $ p(D_{VPD})_{vax} $ to account for the risk of her being susceptible despite vaccination – in other words, we take the baseline risk $ p(D_{VPD})_{naive} $, which is $ 0.1\\% $, and multiply it by the risk of vaccine failure, $ 1 - E_{vax} $, i.e. $ 2\\% $, since by definition $ p(D_{VPD})_{immune} = 0 $.\n", "\n", "$$ p(D_{VPD})_{vaxed} \\\n", " = (1 - E_{vax}) \\cdot p(D_{VPD} \\mid naive) \\\n", " = 0.02 \\cdot 0.001 = 0.00002 $$\n", "\n", "Since the other terms, $ p(S^+) $ and $ p(S^+ \\mid D_{VPD}) $, were calculated by reference to the whole population, they do not necessarily have to be adjusted, although this introduces a small margin of error: the unvaccinated do tend to present with more specific symptoms $ S^+ $ more often than the vaccinated. However, unless exact data to this effect are available, it is best not to compensate for that effect unless symptoms are extremely specific – which, for most VPDs, they are not.\n", "\n", "Presenting with the symptoms $ S $, her probability of $ p(D_{VPD} \\mid S^+)_{vaxed} $ is given by Bayes' theorem as\n", "\n", "$$ p(D_{VPD} \\mid S^+)_{vaxed} \\\n", " = \\frac{p(S^+ \\mid D_{VPD})p(D_{VPD})_{vaxed}}{p(S^+)} \\\n", " = \\frac{p(D_{VPD})_{vaxed}}{p(S^+)} = \\frac{0.00002}{0.08} \\ \n", " = 0.0000016 \\ \\ \\ \\ \\ (1.6 \\times 10^{-6}) $$\n", " \n", "In other words, **the likelihood of Bob having $D_{VPD}$ is 7,800 times as high as that of Alice.**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Why is this relevant?\n", "\n", "It is a frequently raised accusation of anti-vaccine activists that doctors routinely rule out diseases against which a person is vaccinated. This is **quite simply not true**. Rather, the probability of an unvaccinated person having the disease is **four orders of magnitude higher** in this quite typical case. A difference that significant is likely to alter the order of differential diagnosis priorities, putting other causes ahead of $ D_{VPD} $. This is **not** because doctors 'refuse' to diagnose diseases one is vaccinated against, but for the simple reason that such a person has a **much lower** risk of having $ D_{VPD} $ than an unvaccinated but identically symptomatic counterpart.\n", "\n", "Another accusation so levelled is that because of this, either occurrence statistics are unreliable because they would be misdiagnosed as other illnesses due to the refusal of diagnosing a vaccinated-against condition, or vaccine efficacy numbers are incorrect, because the knowledge of vaccination affects the diagnostic process. **This is false**. To illustrate this point, it is important to look at what factored into our calculation of $ p(D_{VPD} \\mid S^+) $:\n", "\n", "* $p(S^+ \\mid D_{VPD})$: this figure derives from an analysis of confirmed (almost always serologically confirmed, e.g. RT-PCR) cases and reported symptoms/CCs at admission. Note that for this, it's irrelevant if the patient was vaccinated or not, because it _presupposes_ that the patient has $ D_{VPD} $, i.e. either their vaccine failed or they were immunonaive.\n", "* $p(D_{VPD})$: it is true that we changed this variable to factor in vaccination and vaccine efficacy. We did so by reference to $ E_{vax} $, which is externally defined in controlled trials. Thus, once again it doesn't matter if patient were or weren't vaccinated, because the relevant values for $ E_{vax} $, and the consequent value $ p(D_{VPD}) $,                               and therefore unaffected by diagnostic practices.\n", "* $p(S^+)$: The frequency of the particular symptom ensemble also has nothing to do with the vaccine. Sure, people who vaccinate are statistically less likely to present with measles like rashes. But that is irrelevant because $p(S^+)$ is the probability of a rash on a person who comes through the door, regardless of vaccine status.\n", "\n", "In other words, the above **can be, and was, deduced without tautology**, and is _not_ circular. You can trace the steps yourself. It **disproves** the anti-vaccination trope that either\n", "\n", "* vaccine effectiveness rates ($ E_v $) are affected by the practice of 'ignoring' conditions the patient is vaccinated against and therefore unreliable; or that\n", "* occurrence statistics ($ p(D_{VPD}) $) are affected by the practice of 'ignoring' conditions the patient is vaccinated against and therefore unreliable.\n", "\n", "Note that **no such 'practice' actually exists**, but is rather a misunderstanding of the fact that vaccination _does_, undeniably, makes disease less likely, and therefore the probability of $ D_{VPD} $ is lower in such patients, all things being equal, as the case of Alice vs Bob shows." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# TL;DR\n", "\n", "* Doctors don't ignore diseases a patient is vaccinated against as part of the differential diagnosis process. This is either a **misunderstanding** or a **lie**.\n", "* Rather, the probability of such diseases is **smaller** because **vaccines work**. We know this **independently from** the rates of diagnosis in the clinic: we know this from separate studies controlled, usually, by serology or RT-PCR.\n", "* Every time an anti-vaccination meme dies, **an angel gets his wings and a kitten gets a cookie**." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.2" } }, "nbformat": 4, "nbformat_minor": 2 }