# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
# Dependencies and Setup
# %matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

# Hide warning messages in notebook
import warnings
warnings.filterwarnings('ignore')

# File to Load (Remember to Change These)
mouse_drug_data_to_load = "data/mouse_drug_data.csv"
clinical_trial_data_to_load = "data/clinicaltrial_data.csv"

# Read the Mouse and Drug Data and the Clinical Trial Data
mouse_data = pd.read_csv("data/mouse_drug_data.csv")
drug_data = pd.read_csv("data/clinicaltrial_data.csv")

# Combine the data into a single dataset
combine_df =pd.merge(mouse_data, drug_data, on="Mouse ID")

# Display the data table for preview

combine_df.head()
#drug_data
#mouse_data
# -

# ## Tumor Response to Treatment

# +
# Store the Mean Tumor Volume Data Grouped by Drug and Timepoint

#tumor = combine_df.loc[combine_df["Drug"] == "Stelasyn"]
#print(tumor)
#tumor_data = tumor_data.groupby(["Drug"]).mean()
#tumor_data = tumor.groupby(["Timepoint"]).mean()
#tumorVOL_df = pd.DataFrame(tumor_data)


tumor_data = combine_df.groupby(["Drug", "Timepoint"])["Tumor Volume (mm3)"].mean()
tumorVOL_df = pd.DataFrame(tumor_data)
tumorVOL_df = tumorVOL_df.reset_index()
mean_pivot = tumorVOL_df.pivot(index="Timepoint", columns="Drug")["Tumor Volume (mm3)"]


uniques = tumorVOL_df["Drug"].unique()
print(uniques)
#tumorVOL_df
mean_pivot

# +
colors = ["red", "yellow", "blue", "green", "orange", "black", "cyan", "purple", "grey", "brown"]
alpha_list = ["1", "0", "1", "1", "0", "1", "0", "0", "0", "0"]
dfList = []
count = 0
for drug in uniques:
    newDf = tumorVOL_df.loc[tumorVOL_df["Drug"]==drug]
    dfList.append(newDf)
    
#print(dfList)

for df in dfList:
    plt.scatter(dfList[count]["Timepoint"], dfList[count]["Tumor Volume (mm3)"], color=colors[count], 
                alpha=alpha_list[count])
    count +=1


#capDF = tumorVOL_df.loc[tumorVOL_df["Drug"]=="Capomulin"]
#print(capDF)

plt.xlabel("Timepoint")
plt.ylabel("Tumor Volume")
plt.title("Tumor Volume Over Time")
plt.show()

#plt.scatter(DFList[0:]["Timepoint"], capDF["Tumor Volume (mm3)"], color=colors[0:])
#plt.scatter(DFList[1]["Timepoint"], capDF["Tumor Volume (mm3)"], color=colors[1])

# +
#scatter plot that shows how the tumor volume changes over time for each treatment.

#plt.scatter(tumorVol_df("Tumor Volume (mm3)")

# +
# Store the Standard Error of Tumor Volumes Grouped by Drug and Timepoint

# Convert to DataFrame

# Preview DataFrame


# -



# +
# Minor Data Munging to Re-Format the Data Frames

# Preview that Reformatting worked

# -



# +
# Generate the Plot (with Error Bars)

# Save the Figure


# -

# Show the Figure
plt.show()

# ![Tumor Response to Treatment](../Images/treatment.png)

# ## Metastatic Response to Treatment

# +
# Store the Mean Met. Site Data Grouped by Drug and Timepoint 

# Convert to DataFrame

# Preview DataFrame

# -



# +
# Store the Standard Error associated with Met. Sites Grouped by Drug and Timepoint 

# Convert to DataFrame

# Preview DataFrame

# -



# +
# Minor Data Munging to Re-Format the Data Frames

# Preview that Reformatting worked

# -



# +
# Generate the Plot (with Error Bars)

# Save the Figure

# Show the Figure

# -

# ![Metastatic Spread During Treatment](../Images/spread.png)

# ## Survival Rates

# +
# Store the Count of Mice Grouped by Drug and Timepoint (W can pass any metric)

# Convert to DataFrame

# Preview DataFrame

# -



# +
# Minor Data Munging to Re-Format the Data Frames

# Preview the Data Frame

# -



# +
# Generate the Plot (Accounting for percentages)

# Save the Figure

# Show the Figure
plt.show()
# -

# ![Metastatic Spread During Treatment](../Images/survival.png)

# ## Summary Bar Graph

# +
# Calculate the percent changes for each drug

# Display the data to confirm

# -



# +
# Store all Relevant Percent Changes into a Tuple


# Splice the data between passing and failing drugs


# Orient widths. Add labels, tick marks, etc. 


# Use functions to label the percentages of changes


# Call functions to implement the function calls


# Save the Figure


# Show the Figure
#fig.show()
# -

# ![Metastatic Spread During Treatment](../Images/change.png)



StarcoderdataJupyterScriptsDedupFiltered