Relationship between vaccine coverage and vaccine-preventable disease outbreaks¶

Group 13¶

Anjelica Martinez & Jane Xu, ENGR 120

Purpose: Determine whether there is a correlation between vaccine coverage and disease outbreak between the years 2000 through 2018 around the world.
Method:

  1. Find the countries the highest incident rates.
    • Find the median number of cases per disease per country per capita
  2. Find the percentage of people in the country who were vaccinated (or protected) from that specific disease.
  3. See if there is a pattern with high incident rate and vaccination coverage.
    • Was the vaccination coverage for that disease low during the time of the outbreak or shortly before the outbreak?
    • Does the pattern of coverage for the vaccine reflect in the outbreak of that vaccine-preventable disease?
    • What were the factors are the time? Vaccine shortage? Anti-vaccination movement?
    • How significant was it?

Last Updated: 12/16/2019

A. Original Data Sources¶

  • Vaccination coverage per country (WHO)
  • All Vaccine-Preventable Disease outbreaks per country (WHO)
  • Population per country (World Bank)

B. Datasets Used¶

This is a list of the datasets we that we used to run our analysis. We cleaned up the data in the jupyter notebook group13_data_wrangling.ipynb

  • valid_countries_population_and_disease_cases.csv
  • valid_countries_all_vaccines_coverages.csv
  • valid_countries_incident_rates.csv
In [2]:
# import libraries
import numpy as np
import pandas as pd
import matplotlib
%matplotlib inline
from scipy import stats
import seaborn as sns
import matplotlib.pyplot as plt
from IPython.display import display

1. Data Manipulation and Preparation¶

1.1 Combine Disease Cases and Population Dataframes¶

We combined the dataframe with data for disease outbreak cases per year for each country to make it easier to calculate the incidence rate per capita (rate per every 100,000 people). We also focused on data from the years 2000-2018 only.

In [4]:
# load incidence cases and total population per country datasets
incidences_df = pd.read_csv('data/all_disease_incidences.csv')
tot_pop_df = pd.read_csv('data/tot_pop_per_country.csv')

# merge tot_pop_df and incidences_df
combined = pd.merge(incidences_df, tot_pop_df, how = 'left', on = ['country', 'year'])

# check header to make sure data is merged correctly
combined.head()
Out[4]:
country disease year cases population
0 Afghanistan measles 1980 32455 13356511.0
1 Afghanistan pertussis 1980 15748 13356511.0
2 Afghanistan measles 1981 31107 13171673.0
3 Afghanistan pertussis 1981 15388 13171673.0
4 Afghanistan measles 1982 20320 12882528.0

1.2 Filter out countries with missing data¶

Some of the countries had missing disease cases or vaccine coverage data for certain years or there was no data provided for some countries. We needed to remove those countries with missing data in order to make a more accurate analysis.. We saved the resulting dataframe into it's own csv file called valid_countries_population_and_disease_cases.csv.

In [7]:
# create set that includes years from 2000-2018
all_years = set(range(2000, 2019))

combined = combined.dropna()

dfs_to_include = []

for country_name in combined["country"].unique():
    country_rows = combined[combined["country"] == country_name]
    for disease_name in country_rows["disease"].unique():
        disease_rows = country_rows[country_rows["disease"] == disease_name]
        disease_years = set(disease_rows["year"])
        if all_years.issubset(disease_years):
            dfs_to_include.append(disease_rows)

included_df = pd.concat(dfs_to_include, ignore_index=True) if dfs_to_include else combined.iloc[0:0].copy()

included_df.head()
Out[7]:
country disease year cases population
0 Afghanistan measles 1980 32455 13356511.0
1 Afghanistan measles 1981 31107 13171673.0
2 Afghanistan measles 1982 20320 12882528.0
3 Afghanistan measles 1983 18808 12537730.0
4 Afghanistan measles 1984 16199 12204292.0

1.3 Calculating Incidence Rate Per Capita¶

We calculated the incidence rate as (number of cases)/(population of year) = ratio, then ratio * 100,000 to get the total incident rate per disease for each country.

  • The Per_Capita column represents the number of cases of the respective disease per 100,000 persons*.

We saved the Per Capita incident rate in its own csv file valid_countries_incident_rates_per_capita.csvto make it easier to do analyses.

In [9]:
# read in valid countries population and diseases csv file
included_df = pd.read_csv('data/valid_countries_population_and_disease_cases.csv')

# Calculate incidence rate
included_df['per_capita'] = (included_df.cases / included_df.population) * 100000

# save dataframe as seperate csv file (commented out to not save file again)
# included_df.to_csv('datasets/csv/valid_countries_incident_rates_per_capita.csv')
In [10]:
# read in disease cases and population data
valid_cases_and_pop_df = pd.read_csv('data/valid_countries_incident_rates_per_capita.csv')

# select only data from years 2000 and up
cases_and_pop_df = valid_cases_and_pop_df[valid_cases_and_pop_df.year >= 2000]

# check header
cases_and_pop_df.head()
Out[10]:
country disease year cases population per_capita
17 Senegal measles 2000 5839 9797734 59.595413
18 Senegal measles 2001 24789 10036104 246.998238
19 Senegal measles 2002 18184 10283699 176.823534
20 Senegal measles 2003 1519 10541467 14.409759
21 Senegal measles 2004 31 10810083 0.286769

2. Determine Top 10 Countries with Highest and Lowest Incident Rates per Disease¶

2.1 Average Incident Rates per Capita¶

We decided on using an incident ratio that reflects number of cases per 100,000 people (per capita) instead of showing number of cases per country due to the variation of population size per country. This allows us to compare the countries on the same scale.

Per capita = number of cases per 100,000 people

To determine the top countries with the lowest and highest incident rates we calculated the average of per capita cases per disease per year. Based on the average cases we sorted them from largest to smallest only showing the top 5 highest as bar plots.

In [24]:
top_count = 5

# mean per-capita by (country, disease)
df = (
    cases_and_pop_df
    .groupby(["country", "disease"], as_index=False)["per_capita"]
    .mean()
    .rename(columns={"per_capita": "average_per_capita"})
)

disease_top_dfs = {}

for disease_name, disease_df in df.groupby("disease"):
    high = disease_df.sort_values("average_per_capita", ascending=False).head(top_count)
    low  = disease_df.sort_values("average_per_capita", ascending=True).head(top_count)  # low-to-high for plotting

    disease_top_dfs[disease_name] = {"high": high, "low": low}

sns.set_context("notebook", font_scale=1.5, rc={"lines.linewidth": 1.5})
sns.set_style("whitegrid")

for disease_name, slices in disease_top_dfs.items():
    for which in ["high", "low"]:
        d = slices[which]

        plt.figure(figsize=(20, 10))
        ax = sns.barplot(
           data=d,
           x="country",
           y="average_per_capita",
           hue="country",
           palette="Dark2",
           legend=False
           )
        ax.set_title(f"{'Highest' if which=='high' else 'Lowest'} Average Per Capita for {disease_name.title()}")
        ax.set_xlabel("")
        ax.set_ylabel("Average per capita")

        plt.xticks(rotation=45, ha="right")
        plt.tight_layout()
        plt.show()
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [25]:
disease_top_dfs['pertussis']['high']
Out[25]:
country disease average_per_capita
66 Estonia pertussis 23.499804
94 Israel pertussis 20.601153
126 Nepal pertussis 14.332623
131 Niger (the) pertussis 10.770807
42 Chile pertussis 9.095704
In [26]:
disease_top_dfs['pertussis']['low']
Out[26]:
country disease average_per_capita
4 Antigua and Barbuda pertussis 0.0
12 Bahamas (the) pertussis 0.0
17 Barbados pertussis 0.0
57 Dominica pertussis 0.0
71 Gambia pertussis 0.0

Data Visualization of Incident Rate per Capita for each disease per top 5 low and top 5 high countries¶

These figures show the incident rates per disease for the top highest and lowest countries.

Data represented as a pointplot¶

In [27]:
# Creates a PointPlot for Incident Rate per Capita for each disease per top 5 low and top 5 high countries
for disease_name in disease_top_dfs.keys():
    for classifier in ['high', 'low']:
        sns.set_context("notebook", font_scale = 1.5, rc = {"lines.linewidth": 1.5})
        sns.set_style("whitegrid")
        f, ax = plt.subplots(figsize=(25, 7))
        ax.set(title = 'Incidence Rate Per Capita for ' + disease_name + ' ' + classifier)
        df = cases_and_pop_df[(cases_and_pop_df.disease == disease_name) & (cases_and_pop_df.country.isin(disease_top_dfs[disease_name][classifier].country))]
        sns.pointplot(x = df.year, y = df.per_capita, hue = df.country, ax = ax )
        plt.show()
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Data represented as a heatmap¶

In [ ]:
# Creates a Heatmap for Incident Rate per Capita for each disease per top 5 low and top 5 high countries
for disease_name in disease_top_dfs.keys():
    for classifier in ["high", "low"]:
        sns.set_context("notebook", font_scale=1.5, rc={"lines.linewidth": 1.5})
        sns.set_style("whitegrid")

        fig, ax = plt.subplots(figsize=(30, 5))
        ax.set_title(f"Incidence Rate Per Capita for {disease_name.title()} ({classifier})")

        sub = cases_and_pop_df[
            (cases_and_pop_df["disease"] == disease_name)
            & (cases_and_pop_df["country"].isin(disease_top_dfs[disease_name][classifier]["country"]))
        ]

        # safer than pivot: handles duplicates
        heat = sub.pivot_table(
            index="country",
            columns="year",
            values="per_capita",
            aggfunc="mean"
        )

        sns.heatmap(
            heat,
            annot=True,
            fmt=".1f",
            linewidths=0.5,
            ax=ax,
            cmap="Reds"
        )

        ax.set_xlabel("Year")
        ax.set_ylabel("Country")
        plt.tight_layout()
        plt.show()
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

3. Vaccine Coverage per Country¶

4.1 Data Cleanup¶

In [12]:
ir_with_null = pd.read_csv('datasets/csv/clean_data/incidence_rates_per_country.csv')

# # Calculate incidence rate
# ir_with_null['per_capita'] = (ir_with_null.cases / ir_with_null.population) * 100000

ir_with_null.head()
In [37]:
%%html
<style>
  table {margin-left: 0 !important;}
</style>

4.2 Diseases and Associated Vaccinations¶

There are two different vaccines that can be used for measles:

  • MMR is for vacination for mumps, measles, and rubella.
  • MCV1 & MCV2 are booster series of shots that are only used for vaccination for measles.

Table: Disease and vaccine pairings

DISEASE VACCINE
Mumps & Measles MMR
Measles MMR, MCV1, MCV2
Pertusis DTP1, DTP3
In [34]:
disease_to_vaccine_map = {
    'Mumps': ['MMR'],
    'measles': ['MMR', 'MCV1', 'MCV2'],
    'pertussis': ['DTP1', 'DTP3']
}
In [36]:
# read csv file
cleaned_coverage_df = pd.read_csv('data/valid_countries_all_vaccines_coverages.csv')

# check header
cleaned_coverage_df.head()

# filter by disease and list of countries with highest and lowest incident rates
Out[36]:
country vaccine year coverage_percentage
0 Afghanistan DTP1 1980 22.0
1 Afghanistan DTP1 1982 24.0
2 Afghanistan DTP1 1983 24.0
3 Afghanistan DTP1 1984 39.0
4 Afghanistan DTP1 1985 37.0

Determining if there is an association between vaccination coverage and disease outbreak¶

For this task, we took all the top 5 countries from each disease group and ran a Pearson Correlation to find the countries with the highest significant values. Then we plotted the countries coverage and disease incidence cases.

The countries with high Measles incident rates are also the countries that had no MMR data. From our research, it appears that these countries either ran out of the vaccine,

Definitions¶

Correlation Coefficient (r): summarizes direction of the association between variables and the strength of its straight-line trend. Denoted by r, it takes values between -1 and 1.

  • Positive association: r is positive
  • Negative association: r is negative
  • Strong assocoation: closer r is to ±1, closer the data points fall to a straight line
  • Weak association: closer r is to 0, the weaker the association.

P-Value: probability that the test statistic equals the observed value or a value more extreme, assuming that the null hypothesis is correct.

Calculate Pearson Correlation for Countries with Highest Incidence Rate¶

This loop returns a dictionary with the countries p-value, and correlation coefficient (r) for the most significant p < 0.05.

In [39]:
from scipy import stats
import numpy as np

countries_pr = []

for disease_name, vaccine_list in disease_to_vaccine_map.items():
    print("Processing", disease_name)

    top_list = disease_top_dfs[disease_name]["high"]

    for country_name in top_list["country"]:
        print("│├ In", country_name)

        disease_data = cases_and_pop_df[
            (cases_and_pop_df["country"] == country_name)
            & (cases_and_pop_df["disease"] == disease_name)
            & (cases_and_pop_df["year"].between(2000, 2017, inclusive="both"))
        ][["year", "per_capita"]].dropna()

        if disease_data.empty:
            print("││├ Missing disease data:", country_name, disease_name)
            continue

        for vaccine_name in vaccine_list:
            vaccine_data = cleaned_coverage_df[
                (cleaned_coverage_df["country"] == country_name)
                & (cleaned_coverage_df["vaccine"] == vaccine_name)
                & (cleaned_coverage_df["year"].between(2000, 2017, inclusive="both"))
            ][["year", "coverage_percentage"]].dropna()

            if vaccine_data.empty:
                print("││├ Missing vaccine data:", country_name, disease_name, vaccine_name)
                continue

            # ALIGN BY YEAR
            aligned = disease_data.merge(vaccine_data, on="year", how="inner")

            if len(aligned) < 5:
                print("││├ Too few overlapping years:", country_name, disease_name, vaccine_name, "n=", len(aligned))
                continue

            x = aligned["coverage_percentage"].to_numpy()
            y = aligned["per_capita"].to_numpy()

            # guard against constant series
            if np.std(x) == 0 or np.std(y) == 0:
                print("││├ Constant series:", country_name, disease_name, vaccine_name)
                continue

            r, p = stats.pearsonr(x, y)

            if p <= 0.05:
                print("││├ Adding:", country_name, disease_name, vaccine_name, "p=", p, "r=", r)
                countries_pr.append({
                    "r": r,
                    "p": p,
                    "n": len(aligned),
                    "country": country_name,
                    "disease": disease_name,
                    "vaccine": vaccine_name,
                    # store aligned data only (not the unaligned originals)
                    "aligned": aligned
                })
            else:
                print("││├ Skipping high p:", country_name, disease_name, vaccine_name, "p=", p, "r=", r)

    print()

countries_pr
Processing Mumps
│├ In Romania
││├ Missing vaccine data: Romania Mumps MMR
│├ In Mongolia
││├ Missing vaccine data: Mongolia Mumps MMR
│├ In Oman
││├ Missing vaccine data: Oman Mumps MMR
│├ In Jordan
││├ Missing vaccine data: Jordan Mumps MMR
│├ In Belarus
││├ Missing vaccine data: Belarus Mumps MMR

Processing measles
│├ In Mongolia
││├ Missing vaccine data: Mongolia measles MMR
││├ Skipping high p: Mongolia measles MCV1 p= 0.9880702417677072 r= 0.0037968868248925494
││├ Skipping high p: Mongolia measles MCV2 p= 0.4883440928886658 r= -0.17460206774827103
│├ In Niger (the)
││├ Missing vaccine data: Niger (the) measles MMR
││├ Adding: Niger (the) measles MCV1 p= 0.0007717729569843735 r= -0.7190323185423895
││├ Too few overlapping years: Niger (the) measles MCV2 n= 4
│├ In Zambia
││├ Missing vaccine data: Zambia measles MMR
││├ Skipping high p: Zambia measles MCV1 p= 0.5279584247318554 r= -0.15923545063340905
││├ Missing vaccine data: Zambia measles MCV2
│├ In Malawi
││├ Missing vaccine data: Malawi measles MMR
││├ Skipping high p: Malawi measles MCV1 p= 0.19386160972464406 r= 0.32109977509122545
││├ Missing vaccine data: Malawi measles MCV2
│├ In Maldives
││├ Missing vaccine data: Maldives measles MMR
││├ Skipping high p: Maldives measles MCV1 p= 0.2814101282387875 r= -0.26846397533532057
││├ Missing vaccine data: Maldives measles MCV2

Processing pertussis
│├ In Estonia
││├ Skipping high p: Estonia pertussis DTP1 p= 0.5093351722492543 r= 0.16638895101481338
││├ Skipping high p: Estonia pertussis DTP3 p= 0.6323619052944208 r= 0.12103426770366486
│├ In Israel
││├ Skipping high p: Israel pertussis DTP1 p= 0.4071981350753786 r= -0.20814798799519246
││├ Skipping high p: Israel pertussis DTP3 p= 0.4200948193840942 r= 0.20259828105450994
│├ In Nepal
││├ Skipping high p: Nepal pertussis DTP1 p= 0.8923355306934494 r= 0.034359692141713395
││├ Skipping high p: Nepal pertussis DTP3 p= 0.4198701528214518 r= -0.20269417633151515
│├ In Niger (the)
││├ Adding: Niger (the) pertussis DTP1 p= 2.313491879951386e-05 r= -0.8269476834512346
││├ Adding: Niger (the) pertussis DTP3 p= 4.154399574591382e-05 r= -0.8126923800871034
│├ In Chile
││├ Skipping high p: Chile pertussis DTP1 p= 0.1725404538027095 r= -0.33620224474305016
││├ Adding: Chile pertussis DTP3 p= 0.017881671867534952 r= -0.5506320035106999

Out[39]:
[{'r': np.float64(-0.7190323185423895),
  'p': np.float64(0.0007717729569843735),
  'n': 18,
  'country': 'Niger (the)',
  'disease': 'measles',
  'vaccine': 'MCV1',
  'aligned':     year  per_capita  coverage_percentage
  0   2000  188.138311                 37.0
  1   2001  520.858641                 39.0
  2   2002  259.097982                 41.0
  3   2003  428.447727                 43.0
  4   2004  480.400758                 45.0
  5   2005   16.022645                 47.0
  6   2006    0.417139                 53.0
  7   2007    1.920275                 60.0
  8   2008    8.635551                 66.0
  9   2009    5.055818                 69.0
  10  2010    2.259472                 67.0
  11  2011    4.504883                 69.0
  12  2012    1.528503                 75.0
  13  2013    6.614695                 80.0
  14  2014    5.935503                 80.0
  15  2015   38.461802                 85.0
  16  2016    3.732772                 76.0
  17  2017    5.420676                 82.0},
 {'r': np.float64(-0.8269476834512346),
  'p': np.float64(2.313491879951386e-05),
  'n': 18,
  'country': 'Niger (the)',
  'disease': 'pertussis',
  'vaccine': 'DTP1',
  'aligned':     year  per_capita  coverage_percentage
  0   2000   49.287137                 46.0
  1   2001   23.052641                 48.0
  2   2002   21.435633                 51.0
  3   2003   16.674594                 53.0
  4   2004   16.448376                 56.0
  5   2005    8.851722                 58.0
  6   2006   14.034248                 63.0
  7   2007   21.817589                 68.0
  8   2008    7.861827                 76.0
  9   2009    8.546289                 81.0
  10  2010    0.182215                 83.0
  11  2011    5.743580                 86.0
  12  2012    0.000000                 87.0
  13  2013    4.777280                 89.0
  14  2014    0.000000                 95.0
  15  2015    0.000000                 93.0
  16  2016    2.318552                 92.0
  17  2017    1.310035                 95.0},
 {'r': np.float64(-0.8126923800871034),
  'p': np.float64(4.154399574591382e-05),
  'n': 18,
  'country': 'Niger (the)',
  'disease': 'pertussis',
  'vaccine': 'DTP3',
  'aligned':     year  per_capita  coverage_percentage
  0   2000   49.287137                 34.0
  1   2001   23.052641                 36.0
  2   2002   21.435633                 39.0
  3   2003   16.674594                 41.0
  4   2004   16.448376                 43.0
  5   2005    8.851722                 45.0
  6   2006   14.034248                 51.0
  7   2007   21.817589                 57.0
  8   2008    7.861827                 67.0
  9   2009    8.546289                 71.0
  10  2010    0.182215                 70.0
  11  2011    5.743580                 75.0
  12  2012    0.000000                 71.0
  13  2013    4.777280                 73.0
  14  2014    0.000000                 81.0
  15  2015    0.000000                 84.0
  16  2016    2.318552                 80.0
  17  2017    1.310035                 85.0},
 {'r': np.float64(-0.5506320035106999),
  'p': np.float64(0.017881671867534952),
  'n': 18,
  'country': 'Chile',
  'disease': 'pertussis',
  'vaccine': 'DTP3',
  'aligned':     year  per_capita  coverage_percentage
  0   2000   23.164635                 91.0
  1   2001   10.382755                 97.0
  2   2002    7.466013                 97.0
  3   2003    6.978071                 96.0
  4   2004    6.612563                 93.0
  5   2005    7.495649                 91.0
  6   2006    7.875506                 94.0
  7   2007    6.231021                 96.0
  8   2008    5.799527                 95.0
  9   2009    4.098024                 94.0
  10  2010    4.653470                 92.0
  11  2011   14.982381                 94.0
  12  2012   33.114282                 90.0
  13  2013   11.177186                 91.0
  14  2014    6.334831                 95.0
  15  2015    4.084732                 96.0
  16  2016    4.129810                 95.0
  17  2017    4.596534                 93.0}]

Linear Regression Models showing the relationship between disease outbreak and vaccination¶

In [40]:
# Creates regression models for the countries with most significant p-values.
for country_disease in countries_pr:
    sns.set_context("notebook", font_scale = 1.5, rc = {"lines.linewidth": 1.5})
    sns.set_style("whitegrid")
    f, ax = plt.subplots(figsize=(20, 10))
    ax.set(title = 'Association between disease outbreak: ' + country_disease['disease'] + ' and ' + country_disease['vaccine'] + ' coverage for ' + country_disease['country'])
    bar = sns.regplot(x = country_disease['disease_data'].per_capita, y = country_disease['vaccine_data'].coverage_percentage, ax = ax)
    plt.show()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[40], line 7
      5 f, ax = plt.subplots(figsize=(20, 10))
      6 ax.set(title = 'Association between disease outbreak: ' + country_disease['disease'] + ' and ' + country_disease['vaccine'] + ' coverage for ' + country_disease['country'])
----> 7 bar = sns.regplot(x = country_disease['disease_data'].per_capita, y = country_disease['vaccine_data'].coverage_percentage, ax = ax)
      8 plt.show()

KeyError: 'disease_data'

Vaccine Coverage¶

In [18]:
for country_disease in countries_pr:
    sns.set_context("notebook", font_scale = 1.5, rc = {"lines.linewidth": 1.5})
    sns.set_style("whitegrid")
    f, ax = plt.subplots(figsize=(20, 10))
    ax.set(title = country_disease['vaccine'] + ' vaccine coverage for ' + country_disease['country'])
    bar = sns.pointplot(x = country_disease['vaccine_data'].year, y = country_disease['vaccine_data'].coverage_percentage, hue = country_disease['vaccine_data'].vaccine, ax = ax )
    plt.show()
    
    
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
  • Graph MCV2 for Niger
  • Graph Chile all vaccines

Results¶

The two countries with the most significant results were The Niger, and Chile.

The Niger had a higher association rate between outbreak and coverage. Explain how, what the data shows. List possible factors.

Chile (fill in)

Possibly do an analysis on just the United States to get an overall idea?

Include the fact that there were no MMR vaccine data available due to (insert problem) and that causes a spike in outbreaks.


Functions¶

Vaccination Coverage Data Viz Functions¶

In [19]:
def heatmap_vac_cov(country):
    """Creates a heatmap of all vaccination coverage for desired country. Pulls from cleaned dataset. No null data."""
    
    # create dataset with these parameters
    cov = cleaned_coverage_df[(cleaned_coverage_df.country == country) & (cleaned_coverage_df.vaccine) & (cleaned_coverage_df.year >= 2000) ]
    covs = cov.pivot("vaccine", "year", "coverage_percentage")

    # Draw a heatmap with the numeric values in each cell
    f, ax = plt.subplots(figsize = (30, 3))
    ax.set(title = 'Vaccine Coverage for ' + country)
    sns.heatmap(covs, annot = True, fmt = ".0f", linewidths = .5, ax = ax, cmap = 'Purples')
In [20]:
def heatmap_vac_cov_with_null(country):
    """Creates a heatmap of all vaccination coverage for desired country. Pulls from dataset with null data."""
    
    # create dataset with these parameters
    cov = coverage_df[(coverage_df.country == country) & (cleaned_coverage_df.year >= 2000)]
    covs = cov.pivot("vaccine", "year", "coverage_percentage")

    # Draw a heatmap with the numeric values in each cell
    f, ax = plt.subplots(figsize = (30, 3))
    ax.set(title = 'Vaccine Coverage for ' + country)
    sns.heatmap(covs, vmin = 0, vmax = None, annot = True, fmt = ".0f", linewidths = .5, ax = ax, cmap = 'Purples')
In [21]:
def pointplot_vac_cov(country):
    """Creates a point plot with the vaccine coverage percentage per year for the desired country. Pulls from cleaned dataset. No null data."""
    
    # create dataset with these parameters
    vaccines = ['MCV1', 'MCV2', 'DTP1', 'DTP3', 'MMR']
    cov = cleaned_coverage_df[(cleaned_coverage_df.country == country) & (cleaned_coverage_df.vaccine.isin(vaccines)) & (cleaned_coverage_df.year >= 2000) ]
    
    # styling of plot
    sns.set_context('notebook', font_scale = 1.5, rc = {'lines.linewidth': 1.5})
    sns.set_style('whitegrid')
    f, ax = plt.subplots(figsize = (25, 7))
    ax.set(title = 'Vaccine Coverage for ' + country)

    # create plot
    bar = sns.pointplot(x = cov.year, y = cov.coverage_percentage, hue = cov.vaccine, ax = ax )
In [22]:
def pointplot_vac_cov_with_null(country):
    """Creates a point plot with the vaccine coverage percentage per year for the desired country. Pulls from dataset with null data."""
    
    # create dataset with these parameters
    vaccines = ['MCV1', 'MCV2', 'DTP1', 'DTP3', 'MMR']
    cov = coverage_df[(coverage_df.country == country) & (coverage_df.vaccine.isin(vaccines)) & (coverage_df.year >= 2000) ]
    
    # styling of plot
    sns.set_context('notebook', font_scale = 1.5, rc = {'lines.linewidth': 1.5})
    sns.set_style('whitegrid')
    f, ax = plt.subplots(figsize = (25, 7))
    ax.set(title = 'Vaccine Coverage for ' + country)
    
    # create plot
    bar = sns.pointplot(x = cov.year, y = cov.coverage_percentage, hue = cov.vaccine, ax = ax )
In [23]:
def pointplot_specific_vac_cov(country, disease):
    """Creates a point plot with the vaccine coverage percentage per year for the desired country and disease."""
    
    # create dataset with these parameters
    vaccine = disease_to_vaccine_map[disease]   
    cov = cleaned_coverage_df[(cleaned_coverage_df.country == country) & (cleaned_coverage_df.vaccine.isin(vaccine)) & (cleaned_coverage_df.year >= 2000) ]
    
    if 0 == len(cov) or 0 == len(vaccine):
        print(country + ' is missing data for the ' + str(vaccine) + '.')
        return
    
    # styling of plot
    sns.set_context('notebook', font_scale = 1.5, rc = {'lines.linewidth': 1.5})
    sns.set_style('whitegrid')
    f, ax = plt.subplots(figsize = (25, 7))
    ax.set(title = 'Vaccine Coverage for ' + country)

    # create plot
    bar = sns.pointplot(x = cov.year, y = cov.coverage_percentage, hue = cov.vaccine, ax = ax )
    plt.show()

Incident Rate Data Viz Functions¶

In [24]:
def heatmap_ir_with_null(country):
    """Creates a heatmap with the incident rate per capita per year for the desired country. Excludes null data."""
    
    # styling of plot
    sns.set_context('notebook', font_scale = 1.5, rc = {'lines.linewidth': 1.5})
    sns.set_style('whitegrid')
    f, ax = plt.subplots(figsize = (30, 3))
    ax.set(title = 'Disease Outbreak per 100,000 people in ' + country)
    
    # create dataset with these parameters
    country_cases = ir_with_null[(ir_with_null.country == country) & (ir_with_null.year >= 2000)]
    df = country_cases.pivot('disease', 'year', 'incidence_per_capita')
    
    # Draw a heatmap with the numeric values in each cell
    sns.heatmap(df, annot = True, fmt = '.1f', linewidths = .5, ax = ax, cmap = 'Reds')
    plt.show()
In [25]:
def heatmap_ir(country):
    """Creates a heatmap with the incident rate per capita per year for the desired country. Excludes null data."""
    
    # styling of plot
    sns.set_context('notebook', font_scale = 1.5, rc = {'lines.linewidth': 1.5})
    sns.set_style('whitegrid')
    f, ax = plt.subplots(figsize = (30, 3))
    ax.set(title = 'Disease Outbreak per 100,000 people in ' + country)

    # create dataset with these parameters
    country_cases = cases_and_pop_df[(cases_and_pop_df.country == country) & (cases_and_pop_df.year >= 2000)]
    df = country_cases.pivot('disease', 'year', 'per_capita')
    
    # Draw a heatmap with the numeric values in each cell
    sns.heatmap(df, annot = True, fmt = '.1f', linewidths = .5, ax = ax, cmap = 'Reds')
    plt.show()
In [26]:
def pointplot_ir_with_null(country):
    """Creates a point plot with the incident rate per capita per year for the desired country. Includes null data."""
    # create dataset with these parameters
    country_cases = ir_with_null[(ir_with_null.country == country) & (ir_with_null.year >= 2000)]
    
    # styling of plot
    sns.set_context('notebook', font_scale = 1.5, rc = {'lines.linewidth': 1.5})
    sns.set_style('whitegrid')
    f, ax = plt.subplots(figsize = (25, 7))
    ax.set(title = 'Disease Outbreak per 100,000 people in ' + country)
    
    # create pointplot
    plot = sns.pointplot(x = country_cases.year, y = country_cases.incidence_per_capita, hue = country_cases.disease, ax = ax)
In [27]:
def pointplot_ir(country):
    """Creates a point plot with the incident rate per capita per year for the desired country. Excludes null data."""
    
    # create dataset with these parameters
    country_cases = cases_and_pop_df[(cases_and_pop_df.country == country) & (cases_and_pop_df.year >= 2000)]
    
    # styling of plot
    sns.set_context('notebook', font_scale = 1.5, rc = {'lines.linewidth': 1.5})
    sns.set_style('whitegrid')
    f, ax = plt.subplots(figsize = (25, 7))
    ax.set(title = 'Disease Outbreak per 100,000 people in ' + country)
    
    # create pointplot
    plot = sns.pointplot(x = country_cases.year, y = country_cases.per_capita, hue = country_cases.disease, ax = ax )

Vaccine Coverage for Most Significant P-values¶

Chile¶

In [28]:
# Vaccination coverage
pointplot_vac_cov_with_null('Chile')
heatmap_vac_cov_with_null('Chile')

# Disease incident rate per capita
pointplot_ir_with_null('Chile')
heatmap_ir_with_null('Chile')
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

The Niger¶

Heatmap and pointplot of vaccination coverage percentage per vaccine.¶

In [29]:
# Vaccination coverage
pointplot_vac_cov_with_null('Niger (the)')
heatmap_vac_cov('Niger (the)')

# Disease incident rate per capita
pointplot_ir_with_null('Niger (the)')
heatmap_ir_with_null('Niger (the)')
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Top 5 Mump Countries¶

  1. Belarus
  2. Jordan
  3. Mongolia
  4. Oman
  5. Romania

All have missing MMR Data, only the United States has MMR data, and the correlation was not significant.

Belarus¶

In [30]:
# Vaccination coverage
pointplot_vac_cov_with_null('Belarus')
heatmap_vac_cov('Belarus')

# Disease incident rate per capita
pointplot_ir_with_null('Belarus')
heatmap_ir_with_null('Belarus')
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Jordan¶

In [31]:
# Vaccination coverage
pointplot_vac_cov_with_null('Jordan')
heatmap_vac_cov('Jordan')

# Disease incident rate per capita
pointplot_ir_with_null('Jordan')
heatmap_ir_with_null('Jordan')
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Mongolia¶

In [32]:
# Vaccination coverage
pointplot_vac_cov_with_null('Mongolia')
heatmap_vac_cov('Mongolia')

# Disease incident rate per capita
pointplot_ir_with_null('Mongolia')
heatmap_ir_with_null('Mongolia')
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Oman¶

In [33]:
# Vaccination coverage
pointplot_vac_cov_with_null('Oman')
heatmap_vac_cov('Oman')

# Disease incident rate per capita
pointplot_ir_with_null('Oman')
heatmap_ir_with_null('Oman')
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Romania¶

In [34]:
# Vaccination coverage
pointplot_vac_cov_with_null('Romania')
heatmap_vac_cov('Romania')

# Disease incident rate per capita
pointplot_ir_with_null('Romania')
heatmap_ir_with_null('Romania')
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Reviewing the United States of America¶

Only the United States has MMR data.

The relationship between vaccination coverage and disease outbreak was not significant p > 0.05 for any of the disease (at this time).

Measles, MCV1
r = 0.07066041989009271
p-value = 0.7875561582456897

Measles, MCV2
r = 0.41016730581127747
p-value = 0.10199878305653776

Measles & Mumps, MMR
r = -0.06217594169581256
p-value = 0.8126103998083598

Pertussis, DTP1
r = -0.2538837962645967
p-value = 0.32546314156231715

Pertussis, DTP3
r = -0.19445645208455434
p-value = 0.45453372224166383

In [35]:
# Vaccination coverage
pointplot_vac_cov_with_null('United States of America (the)')
heatmap_vac_cov('United States of America (the)')

# Disease incident rate per capita
pointplot_ir_with_null('United States of America (the)')
heatmap_ir_with_null('United States of America (the)')
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image