Created
January 13, 2021 16:29
-
-
Save airalcorn2/c21c9a9041404e7271f6cc22308322e3 to your computer and use it in GitHub Desktop.
Inspecting data from: https://github.com/gradlab/CtTrajectories.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
import seaborn as sns | |
csv_url = "https://raw.githubusercontent.com/gradlab/CtTrajectories/main/data/ct_dat_clean.csv" | |
df = pd.read_csv(csv_url) | |
person_ids = df["Person.ID"].unique() | |
(min_x, max_x) = (df["Date.Index"].min(), df["Date.Index"].max()) | |
(min_y, max_y) = (df["CT.Mean"].min(), df["CT.Mean"].max()) | |
(rows, cols) = (8, 9) | |
(fig, axs) = plt.subplots(rows, cols) | |
symptom_min_ct = [] | |
asymptom_min_ct = [] | |
for (person_idx, person_id) in enumerate(person_ids): | |
(row, col) = (person_idx // cols, person_idx % cols) | |
ax = axs[row][col] | |
person_data = df[df["Person.ID"] == person_id] | |
first_symptoms = person_data[person_data["Symptomatic"] == "Yes"] | |
color = "red" if len(first_symptoms) > 0 else "blue" | |
sns.lineplot( | |
x="Date.Index", | |
y="CT.Mean", | |
data=person_data, | |
# marker=markers[state_idx % len(markers)], | |
color=color, | |
ax=ax, | |
) | |
ax.set_xlim(min_x, max_x) | |
ax.set_ylim(min_y, max_y) | |
axs[row][col].invert_yaxis() | |
ax.set_xlabel("") | |
ax.set_ylabel("") | |
ax.set_title(person_id, fontsize="small") | |
if len(first_symptoms) > 0: | |
ax.axvline(first_symptoms["Date.Index"].item(), color="black") | |
symptom_min_ct.append(person_data["CT.Mean"].min()) | |
else: | |
asymptom_min_ct.append(person_data["CT.Mean"].min()) | |
plt.subplots_adjust(0.021, 0.036, 0.98, 0.967, 0.326, 0.707) | |
plt.show() | |
asymptom_min_ct.sort() | |
symptom_min_ct.sort() | |
print(np.median(symptom_min_ct)) | |
print(np.median(asymptom_min_ct)) | |
sns.histplot(symptom_min_ct) | |
plt.show() | |
sns.histplot(asymptom_min_ct) | |
plt.show() | |
symptom_days = df[df["Symptomatic"] == "Yes"] | |
symptom_and_positive_days = df[(df["Symptomatic"] == "Yes") & (df["CT.Mean"] < 40)] | |
symptom_and_negative_days = df[(df["Symptomatic"] == "Yes") & (df["CT.Mean"] == 40)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment