{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#import libraries\n", "import pandas as pd\n", "import seaborn as sns\n", "import matplotlib.pyplot as plt\n", "import matplotlib.gridspec as gridspec\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Age Seroprevalence and Seroconversion Rate\n", "\n", "#read in the dataframes\n", "ageprev=pd.read_csv(\"ageseroprev.csv\") #age seroprevalence in the lab set all percentages are listed as whole numbers without '%' signs for ease of graphing\n", "ageprev.dropna()\n", "ageprev\n", "\n", "#set style\n", "sns.set(style=\"ticks\", color_codes=True)\n", "\n", "#read in SCR data with each age graph\n", "scrfacet=pd.read_csv(\"scrtable.csv\") #age seroprevalence in the lab set\n", "scrfacet\n", "\n", "#plot a facetgrid\n", "l=sns.FacetGrid(scrfacet, col=\"Method\", hue=\"Method\", sharex=True, sharey=True, xlim=[0,10], ylim=[0, 1.0])\n", "l=(l.map(plt.plot,\"Age (Years)\",\"MeanSCRAllAge\",color='black').set(xlim=(0,10), ylim=(0,1.0), \n", "\n", "#specify tick marks \n", "xticks=[1,2,3,4,5,6,7,8,9], \n", "yticks=[0,0.1,0.3,0.5,0.7,0.9,1.0]))\n", "\n", "#scatter plot\n", "l=(l.map(plt.scatter,\"Age (Years)\",\"Proportion Seropositive (%)\").set(xlim=(0,10), ylim=(0,1.0), \n", "\n", "#specify tick marks \n", "xticks=[1,2,3,4,5,6,7,8,9], \n", "yticks=[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]))\n", "\n", "#define axes\n", "plt.suptitle('Age Seroprevalence and Seroconversion Rate (n=2915)', fontweight='bold', y=1.08)\n", "plt.ylabel=(\"Proportion Seropositive (%)\")\n", "\n", "#save graph as jpeg\n", "l.savefig(\"scrfacets.jpeg\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#MFI HeatMap\n", "\n", "#set style\n", "sns.set(style=\"white\")\n", "\n", "#read in both dataframes\n", "#heatmap not log transformed\n", "heatmapnolog=pd.read_csv(\"heatmapnolog.csv\") \n", "#heatmap log transformed\n", "heatmaplog=pd.read_csv(\"heatmaplog.csv\")\n", "\n", "#define figure name\n", "h = plt.figure()\n", "\n", "#graph both log transformed and untransformed data to get both axes\n", "ax=sns.heatmap(heatmapnolog, cmap=(\"RdBu_r\"),cbar=True, xticklabels=True, yticklabels=False)\n", "ax=sns.heatmap(heatmaplog, cmap=(\"RdBu_r\"),cbar=True, xticklabels=True, yticklabels=False)\n", "\n", "#define axes\n", "ax.invert_yaxis()\n", "plt.xlabel(\"Antigen\")\n", "plt.title(\"(n=2915)\")\n", "plt.suptitle('Median Flouresence Intensity-Background', fontweight='bold' )\n", "plt.locator_params(nbins=10)\n", "plt.show()\n", "\n", "#save and export all lines to jpeg\n", "h.savefig(\"mfiheatmap.jpeg\", bbox_inches='tight')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Seroprevalence in the Lab Dataset\n", "\n", "#read in lab seroprevalence graph data\n", "seroprevlab=pd.read_csv(\"seroprevlab.csv\") \n", "\n", "#setup a category plot graph\n", "h =sns.catplot(x='Assay Method', y='Seroprevalence (%)', data=seroprevlab, kind=\"bar\").set(xlim=(0,4), ylim=(0,100), yticks=[0,10, 20, 30,40,50,60,70,80,90,100])\n", "\n", "#define axes\n", "plt.suptitle('Seroprevalence in the Lab Set (n=2915)', fontweight='bold', y=1.08)\n", "plt.axis([-0.75, 3, 0, 100])\n", "plt.show()\n", "\n", "#save as a jpeg\n", "h.savefig(\"seroposlab.jpeg\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "#Seroprevalence in Field Dataset\n", "\n", "#read in the dataframe\n", "seroposfieldeu=pd.read_csv(\"seroprevfield.csv\") \n", "seroposfieldeu #seropositivity across assays in the field set\n", "\n", "#graph a category plot\n", "s = sns.catplot(x='Assay Method', y=' Seroprevalence (%)', data=seroposfieldeu, kind=\"bar\").set(xlim=(0,4), ylim=(0,100), \n", "\n", "#define ticks and axes \n", "yticks=[0,10, 20, 30,40,50,60,70,80,90,100])\n", "plt.axis([-0.75, 3, 0, 100])\n", "plt.xticks(rotation=45)\n", "plt.axis([-1, 4, 0, 100])\n", "plt.suptitle('Seroprevalence in the Field Set (n=1914)', fontweight='bold', y=1.08)\n", "plt.show()\n", "\n", "#save as jpeg\n", "s.savefig(\"seroposfield.jpeg\")" ] } ], "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.7.1" } }, "nbformat": 4, "nbformat_minor": 2 }