<jupyter_start><jupyter_text>Pymaceuticals Inc.--- Analysis* Overall, it is clear that Capomulin is a viable drug regimen to reduce tumor growth.* Capomulin had the most number of mice complete the study, with the exception of Remicane, all other regimens observed a number of mice deaths across the duration of the study. * There is a strong correlation between mouse weight and tumor volume, indicating that mouse weight may be contributing to the effectiveness of any drug regimen.* There was one potential outlier within the Infubinol regimen. While most mice showed tumor volume increase, there was one mouse that had a reduction in tumor growth in the study.<jupyter_code># Dependencies and Setup
import matplotlib.pyplot as plt
import pandas as pd
import scipy.stats as st
import numpy as np


# Study data files
mouse_metadata_path = "data/Mouse_metadata.csv"
study_results_path = "data/Study_results.csv"

# Read the mouse data and the study results
mouse_metadata = pd.read_csv(mouse_metadata_path)
study_results = pd.read_csv(study_results_path)

# Combine the data into a single dataset
study_data_complete = pd.merge(study_results, mouse_metadata, how="left", on="Mouse ID")

# Display the data table for preview
study_data_complete.head(10)<jupyter_output><empty_output><jupyter_text>Summary Statistics<jupyter_code># Generate a summary statistics table of mean, median, variance, standard deviation, and SEM of the tumor volume for each regimen
data_group = study_data_complete.groupby("Drug Regimen")["Tumor Volume (mm3)"]
# This method is the most straighforward, creating multiple series and putting them all together at the end.
pd.DataFrame({
     "Mean Tumor Volume":data_group.mean(),
    "Median Tumor Volume":data_group.median(),
    "Tumor Volume Variance":data_group.var(),
    "Tumor Volume STD Dev":data_group.std(),
    "Tumor Volume STD Err":data_group.sem()   
})

# Generate a summary statistics table of mean, median, variance, standard deviation, and SEM of the tumor volume for each regimen
data_group.agg(["mean","median","var","std","sem"])
# This method produces everything in a single groupby function<jupyter_output><empty_output><jupyter_text>Bar and Pie Charts<jupyter_code>num_data_points = data_group.count().plot(kind='bar').set_ylabel("Number of Data Points")
num_data_points
plt.show()
# Generate a bar plot showing number of data points for each treatment regimen using pyplot
y = data_group.count().array
x = data_group.count().index.array
plt.bar(x,y,color=["blue","orange","green","red","pink","gray","yellow","magenta","violet","brown"])
plt.xticks(rotation=45)
plt.xlabel("Drug Regimen")
plt.ylabel("Number of Data Points")
plt.savefig("Drug_Regimem_Treatment.png")
plt.show()

#Finds the quantitiy of Male vs. Female mice
study_data_complete.groupby("Sex").count()

#Finds the quantitiy of Male vs. Female mice
from pandas import DataFrame
Data = {"Sex": [935,958]}
df = DataFrame(Data,columns=['Sex'],index =['Female','Male'])
df.plot.pie(y="Sex", figsize=(5,5),autopct='%1.1f%%', startangle=90)

# Generate a pie plot showing the distribution of female versus male mice using pyplot

# Labels for the sections of our pie chart
gender = ["Female", "Male"]

# The values of each section of the pie chart
mice_sex = [935,958]

# The colors of each section of the pie chart
colors = ["pink","blue"]

#Tell matplotlib to create a pie cahart based upon the above data
plt.pie( mice_sex, labels=gender, colors=colors, autopct='%1.1f%%')

# Create axes which are equal so we have a perfect circle
plt.axis("equal")

plt.show()<jupyter_output><empty_output><jupyter_text>Quartiles, Outliers and Boxplots<jupyter_code>capo_mouse_data=study_data_complete.loc[study_data_complete['Drug Regimen']=='Capomulin']
ram_mouse_data=study_data_complete.loc[study_data_complete['Drug Regimen']=='Ramicane']
ceft_mouse_data=study_data_complete.loc[study_data_complete['Drug Regimen']=='Ceftamin']
prop_mouse_data=study_data_complete.loc[study_data_complete['Drug Regimen']=='Propriva']


# Calculate the final tumor volume of each mouse across four of the most promising treatment regimens. 
# Calculate the IQR and quantitatively determine if there are any potential outliers. 

# Start by getting the last (greatest) timepoint for each mouse

# Merge this group df with the original dataframe to get the tumor volume at the last timepoint

# Quantitatively determine capomulin outliers

# Quantitatively determine ramicane outliers

# Quantitatively determine infubinol outliers

# Quantitatively determine ceftamin outliers

# Generate a box plot of the final tumor volume of each mouse across four regimens of interest<jupyter_output><empty_output><jupyter_text>Line and Scatter Plots<jupyter_code># Generate a line plot of time point versus tumor volume for a mouse treated with Capomulin
# get data for Mouse l509 and all it's timepoints
one_mouse = study_data_complete.set_index("Mouse ID")
mouse_df = one_mouse.loc['l509', :]
mouse_df.head ()

time = mouse_df.iloc[:,1]
volume = mouse_df.iloc[:,2]
plt.plot(time,volume)


plt.title("Capomulim Treatment of Mouse l509")
plt.xlabel("Timepoint(Days)")
plt.ylabel("Tumor Volume (mm3)")


plt.show()



# Generate a line plot of time point versus tumor volume for a mouse treated with Capomulin

# get data for the Capomulin regimen 
one_drug = study_data_complete.set_index("Drug Regimen")
capo_df = one_drug.loc['Capomulin', :]
capo_df.head()

# Generate a scatter plot of mouse weight versus average tumor volume for the Capomulin regimen
x_values = capo_df['Weight (g)']
y_values = capo_df['Tumor Volume (mm3)']
plt.scatter(x_values,y_values)
plt.xlabel("Tumor Weight")
plt.ylabel("Mouse Weight")
plt.show()<jupyter_output><empty_output><jupyter_text>Correlation and Regression<jupyter_code># Calculate the correlation coefficient and linear regression model 
# for mouse weight and average tumor volume for the Capomulin regimen

vc_slope, vc_int, vc_r, vc_p, vc_std_err = st.linregress(x_values, y_values)
vc_slope, vc_int, vc_r, vc_p, vc_std_err




# Calculate the correlation coefficient and linear regression model 
# for mouse weight and average tumor volume for the Capomulin regimen
print(f"The correlation between mouse weight and average tumor volume is {linier_corr}.")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09330371310695018, 'fraction_numerical': 0.006029831799428753, 'mean_word_length': 6.261520737327189, 'pattern_counts': {'":': 6, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '555685', 'license': 'ADSL', 'n_tokens_mistral': 2069, 'n_tokens_neox': 1890, 'n_words': 663, 'path': 'Pymaceuticals/Pymaceuticals2.ipynb', 'repo_name': 'sruelle/matplotlib-challenge', 'size': '6302'}