{"id":25924873,"url":"https://github.com/tinaland101/carcinoma-regression-project","last_synced_at":"2026-05-08T01:38:00.944Z","repository":{"id":268186108,"uuid":"903542030","full_name":"tinaland101/Carcinoma-Regression-Project","owner":"tinaland101","description":"The goal of this project is to analyze and visualize the results of a clinical study involving the treatment of squamous cell carcinoma (SCC) in mice. As a senior data analyst, you are tasked with preparing a technical report for Pymaceuticals, Inc.","archived":false,"fork":false,"pushed_at":"2025-01-09T03:23:54.000Z","size":411,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-09T04:31:25.229Z","etag":null,"topics":["linear-regression","mathplotlib","numpy","pandas","pyhton"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinaland101.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-14T21:38:48.000Z","updated_at":"2025-01-09T03:23:57.000Z","dependencies_parsed_at":"2024-12-15T02:20:06.861Z","dependency_job_id":"d291437a-fcf0-4e10-91d5-7e0edb292676","html_url":"https://github.com/tinaland101/Carcinoma-Regression-Project","commit_stats":null,"previous_names":["tinaland101/mathplotlib_challenge","tinaland101/carcinoma-regression-project"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinaland101%2FCarcinoma-Regression-Project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinaland101%2FCarcinoma-Regression-Project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinaland101%2FCarcinoma-Regression-Project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinaland101%2FCarcinoma-Regression-Project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinaland101","download_url":"https://codeload.github.com/tinaland101/Carcinoma-Regression-Project/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241715018,"owners_count":20007914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["linear-regression","mathplotlib","numpy","pandas","pyhton"],"created_at":"2025-03-03T18:13:54.478Z","updated_at":"2026-05-08T01:38:00.897Z","avatar_url":"https://github.com/tinaland101.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Carcinoma Regression project\n\n# create variable for reading cvs from computer\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport scipy.stats as st\n\n# Paths to your data files\nmouse_metadata_path = \"/Users/christinaland/Downloads/Starter_Code-9/Pymaceuticals/data/Mouse_metadata.csv\"\nstudy_results_path = \"/Users/christinaland/Downloads/Starter_Code-9/Pymaceuticals/data/Study_results.csv\"\n\n# Read the CSV files into DataFrames\nmouse_metadata = pd.read_csv(mouse_metadata_path)\nstudy_results = pd.read_csv(study_results_path)\n\n# Merge the data on 'Mouse ID'\nmerged_data = pd.merge(mouse_metadata, study_results, on=\"Mouse ID\")\n\n# Specify the desired column order\ndesired_column_order = [\n    'Mouse ID', 'Timepoint', 'Tumor Volume (mm3)', 'Metastatic Sites',\n    'Drug Regimen', 'Sex', 'Age_months', 'Weight (g)'\n]\n\n# Reorganize the columns\ndata_merged_col = merged_data[desired_column_order]\n\n# Sort by 'Timepoint' in ascending order\ndata_merged_col_sorted = data_merged_col.sort_values(by=\"Timepoint\")\n\n# Display the sorted data\nprint(data_merged_col_sorted.head())\n\n\n# number of mice\nmouse_sum = data_merged_col[\"Mouse ID\"].nunique()\nprint(mouse_sum)\n\nhould be uniquely identified by Mouse ID and Timepoint\n# Get the duplicate mice by ID number that shows up for Mouse ID and Timepoint\nduplicate_mice = data_merged_col[data_merged_col.duplicated(subset=[\"Mouse ID\", \"Timepoint\"], keep=False)]\n\nduplicate_mice_ids = duplicate_mice[\"Mouse ID\"].unique()\n\n\nprint(duplicate_mice_ids, duplicate_mice_ids.dtype)\nduplicates_df = data_merged_col[data_merged_cleaned.duplicated(subset=['Mouse ID', 'Timepoint'])]\nprint(duplicates)\n\ndata_merged = pd.merge(mouse_metadata, study_results, on=\"Mouse ID\")\n\n\nduplicates = data_merged[data_merged.duplicated(subset=[\"Mouse ID\", \"Timepoint\"], keep=\"first\")]\n\n\n\ndata_cleaned = data_merged.drop_duplicates(subset=\"Mouse ID\", keep=\"first\")\n\n\n\n\n\nprint(\"\\nCleaned DataFrame:\")\nprint(data_cleaned.head())\n\n\nunique_mice_count = data_cleaned['Mouse ID'].nunique()\nprint(unique_mice_count)\n\n# Group the merged data by 'Drug Regimen'\ngrouped_data = data_merged.groupby('Drug Regimen')['Tumor Volume (mm3)']\n\n# Calculate summary statistics\nmean_tumor_volume = grouped_data.mean()\nmedian_tumor_volume = grouped_data.median()\nvariance_tumor_volume = grouped_data.var()\nstd_dev_tumor_volume = grouped_data.std()\nsem_tumor_volume = grouped_data.sem()\n\n# Create a summary DataFrame by combining all the calculated statistics\nsummary_stats = pd.DataFrame({\n    'Mean Tumor Volume': mean_tumor_volume,\n    'Median Tumor Volume': median_tumor_volume,\n    'Tumor Volume Variance': variance_tumor_volume,\n    'Tumor Volume Std. Dev.': std_dev_tumor_volume,\n    'Tumor Volume Std. Err.': sem_tumor_volume\n})\n\n# Display the summary statistics table\nprint(summary_stats)\n\nimport pandas as pd\n# Count the number of rows (Mouse ID/Timepoints) for each drug regimen\nrows_per_drug_regimen = data_merged.groupby('Drug Regimen').size()\n\n# Sort the values in descending order\nrows_per_drug_regimen = rows_per_drug_regimen.sort_values(ascending=False)\n\n# Create the bar plot using Pandas plot function\nrows_per_drug_regimen.plot(kind='bar', figsize=(10, 6), color='skyblue')\n\n# Adding labels and title\nplt.title('Total Number of Rows (Mouse ID/Timepoints) per Drug Regimen')\nplt.xlabel('Drug Regimen')\nplt.ylabel('Number of Rows (Mouse ID/Timepoints)')\n\n# Rotate the x-axis labels for better readability\nplt.xticks(rotation=45)\n\n# Show the plot\nplt.tight_layout()  # Ensure the labels fit in the plot\nplt.show()\nimport matplotlib.pyplot as plt\n# Count the number of rows (Mouse ID/Timepoints) for each drug regimen\nrows_per_drug_regimen = data_merged.groupby('Drug Regimen').size()\n\n# Sort the values in descending order\nrows_per_drug_regimen = rows_per_drug_regimen.sort_values(ascending=False)\n\n# Generate the bar plot using Pandas\nrows_per_drug_regimen.plot(kind='bar', color='blue', figsize=(10, 6))\n\n\n\nplt.ylabel('# of Observed Mouse Timepoints')\nplt.xlabel('Drug Regimen')\nplt.xticks(rotation=45)\nplt.tight_layout()  # Ensure the labels fit in the plot\nplt.show()\nimport pandas as pd\n \n #Get the unique mice and their gender\nunique_mice_gender = data_merged.drop_duplicates(subset='Mouse ID')['Sex']\n\n# Count the number of unique female and male mice\ngender_counts = unique_mice_gender.value_counts()\n\n# Create a pie chart using Pandas\ngender_counts.plot(kind='pie', autopct='%1.1f%%', figsize=(7, 7), startangle=90, colors=['lightblue', 'pink'])\n\n\n\n# Show the plot\nplt.ylabel('')  # Hide the y-label (it is redundant for a pie chart)\nplt.tight_layout()  # Ensure the labels fit within the plot space\nplt.show()\n\nimport matplotlib.pyplot as plt\n\n# Assuming 'data_merged' is already created and merged from the previous steps\n\n# Count the number of female and male mice in the study\ngender_count = data_merged['Sex'].value_counts()\n\n# Create the pie chart using Matplotlib's pyplot methods\nplt.figure(figsize=(8, 8))  # Set the figure size\nplt.pie(gender_count, labels=gender_count.index, autopct='%1.1f%%', startangle=90, colors=['lightblue', 'salmon'])\n\n# Show the plot\nplt.show()\nimport pandas as pd\n\n# Assuming 'data_merged' is already loaded and merged with all columns.\n\n# Group by Drug Regimen and get the final tumor volume for each mouse\nlast_timepoints = data_merged.groupby('Mouse ID')['Timepoint'].max()\nlast_timepoints_df = pd.merge(last_timepoints, data_merged, on=['Mouse ID', 'Timepoint'], how='left')\n\n# Filter for the treatment regimens of interest\ntreatment_regimens = ['Capomulin', 'Ramicane', 'Infubinol', 'Ceftamin']\nfiltered_data = last_timepoints_df[last_timepoints_df['Drug Regimen'].isin(treatment_regimens)]\n\n# Create a dictionary to hold potential outliers for each treatment regimen\noutliers = {}\n\n# Loop through each treatment regimen to find outliers\nfor regimen in treatment_regimens:\n    # Filter the data for the current regimen\n    regimen_data = filtered_data[filtered_data['Drug Regimen'] == regimen]['Tumor Volume (mm3)']\n    \n    # Calculate the quartiles and IQR\n    Q1 = regimen_data.quantile(0.25)\n    Q3 = regimen_data.quantile(0.75)\n    IQR = Q3 - Q1\n    \n    # Calculate the lower and upper bounds for outliers\n    lower_bound = Q1 - 1.5 * IQR\n    upper_bound = Q3 + 1.5 * IQR\n    \n    # Identify potential outliers\n    potential_outliers = regimen_data[(regimen_data \u003c lower_bound) | (regimen_data \u003e upper_bound)]\n    \n    # Store the outliers for this regimen\n    outliers[regimen] = potential_outliers\n\n# Display the potential outliers for each regimen\nfor regimen, outlier_data in outliers.items():\n    print(f\"{regimen}'s potential outliers: {outlier_data}\\n\")\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\n# Assuming 'data_merged' is already loaded and merged with all columns.\n\n# Group by Drug Regimen and get the final tumor volume for each mouse\nlast_timepoints = data_merged.groupby('Mouse ID')['Timepoint'].max()\nlast_timepoints_df = pd.merge(last_timepoints, data_merged, on=['Mouse ID', 'Timepoint'], how='left')\n\n# Filter for the treatment regimens of interest\ntreatment_regimens = ['Capomulin', 'Ramicane', 'Infubinol', 'Ceftamin']\nfiltered_data = last_timepoints_df[last_timepoints_df['Drug Regimen'].isin(treatment_regimens)]\n\n# Create a dictionary to hold potential outliers for each treatment regimen\noutliers = {}\n\n# Create a list to hold tumor volume data for each regimen (for the box plot)\ntumor_volumes = []\n\n# Loop through each treatment regimen to find outliers and prepare data for the box plot\nfor regimen in treatment_regimens:\n    # Filter the data for the current regimen\n    regimen_data = filtered_data[filtered_data['Drug Regimen'] == regimen]['Tumor Volume (mm3)']\n    \n    # Calculate the quartiles and IQR\n    Q1 = regimen_data.quantile(0.25)\n    Q3 = regimen_data.quantile(0.75)\n    IQR = Q3 - Q1\n    \n    # Calculate the lower and upper bounds for outliers\n    lower_bound = Q1 - 1.5 * IQR\n    upper_bound = Q3 + 1.5 * IQR\n    \n    # Identify potential outliers\n    potential_outliers = regimen_data[(regimen_data \u003c lower_bound) | (regimen_data \u003e upper_bound)]\n    \n    # Store the outliers for this regimen\n    outliers[regimen] = potential_outliers\n    \n    # Append tumor volume data for box plot\n    tumor_volumes.append(regimen_data)\n\n# Display the potential outliers for each regimen\nfor regimen, outlier_data in outliers.items():\n    print(f\"{regimen}'s potential outliers: {outlier_data}\\n\")\n\n# Create the box plot\nplt.figure(figsize=(10, 6))\nplt.boxplot(tumor_volumes, labels=treatment_regimens, patch_artist=True)\n\n# Adding labels and title\nplt.title('Distribution of Tumor Volumes for Each Treatment Group')\nplt.xlabel('Drug Regimen')\nplt.ylabel('Tumor Volume (mm3)')\n\n# Show the plot\nplt.tight_layout()\nplt.show()\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\n# Assuming 'data_merged' is already loaded and merged with all columns.\n\n# Filter the data for a single mouse treated with Capomulin\nmouse_id = 'l509'  # Example Mouse ID for a mouse treated with Capomulin\ncapomulin_data = data_merged[(data_merged['Drug Regimen'] == 'Capomulin') \u0026 (data_merged['Mouse ID'] == mouse_id)]\n\n# Create the plot of Tumor Volume vs. Timepoint (line plot without grid lines and points)\nplt.figure(figsize=(8, 6))\n\n# Plot with a solid line, but no points (no markers)\nplt.plot(capomulin_data['Timepoint'], capomulin_data['Tumor Volume (mm3)'], color='b', linestyle='-', marker='', linewidth=2)\n\n# Add titles and labels\nplt.title(f'Tumor Volume vs. Timepoint for Mouse {mouse_id} (Capomulin Treatment)', fontsize=14)\nplt.xlabel('Timepoint (Days)', fontsize=12)\nplt.ylabel('Tumor Volume (mm3)', fontsize=12)\n\n# Remove the grid\nplt.grid(False)\n\n# Display the plot\nplt.tight_layout()\nplt.show()\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\n# Assuming 'data_merged' is already loaded and merged with all columns.\n\n# Filter the data for the Capomulin regimen\ncapomulin_data = data_merged[data_merged['Drug Regimen'] == 'Capomulin']\n\n# Group by 'Mouse ID' and calculate the average tumor volume for each mouse\naverage_tumor_volume = capomulin_data.groupby('Mouse ID')['Tumor Volume (mm3)'].mean()\n\n# Merge the average tumor volume with the mouse weights (using 'Mouse ID')\nmouse_weights = capomulin_data[['Mouse ID', 'Weight (g)']].drop_duplicates()\nmerged_data = pd.merge(average_tumor_volume, mouse_weights, on='Mouse ID')\n\n# Create a scatter plot of mouse weight vs. average tumor volume\nplt.figure(figsize=(8, 6))\nplt.scatter(merged_data['Weight (g)'], merged_data['Tumor Volume (mm3)'], color='b', edgecolor='black', alpha=0.7)\n\n# Add titles and labels\nplt.title('Mouse Weight vs. Average Tumor Volume for Capomulin Regimen', fontsize=14)\nplt.xlabel('Weight (g)', fontsize=12)\nplt.ylabel('Average Tumor Volume (mm3)', fontsize=12)\n\n# Display the plot\nplt.tight_layout()\nplt.show()\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom scipy import stats\n\n# Assuming 'data_merged' is already loaded and merged with all columns.\n\n# Filter the data for the Capomulin regimen\ncapomulin_data = data_merged[data_merged['Drug Regimen'] == 'Capomulin']\n\n# Group by 'Mouse ID' and calculate the average tumor volume for each mouse\naverage_tumor_volume = capomulin_data.groupby('Mouse ID')['Tumor Volume (mm3)'].mean()\n\n# Merge the average tumor volume with the mouse weights (using 'Mouse ID')\nmouse_weights = capomulin_data[['Mouse ID', 'Weight (g)']].drop_duplicates()\nmerged_data = pd.merge(average_tumor_volume, mouse_weights, on='Mouse ID')\n\n# Calculate the Pearson correlation coefficient\ncorrelation = merged_data['Weight (g)'].corr(merged_data['Tumor Volume (mm3)'])\nprint(f\"Pearson correlation coefficient: {correlation}\")\n\n# Perform linear regression to get the slope and intercept\nslope, intercept, r_value, p_value, std_err = stats.linregress(merged_data['Weight (g)'], merged_data['Tumor Volume (mm3)'])\n\n# Create the regression line\nregression_line = slope * merged_data['Weight (g)'] + intercept\n\n# Create the scatter plot\nplt.figure(figsize=(8, 6))\nplt.scatter(merged_data['Weight (g)'], merged_data['Tumor Volume (mm3)'], color='b', edgecolor='black', alpha=0.7)\n\n# Plot the regression line\nplt.plot(merged_data['Weight (g)'], regression_line, color='r', linewidth=2)\n\n# Add titles and labels\nplt.title('Mouse Weight vs. Average Tumor Volume for Capomulin Regimen', fontsize=14)\nplt.xlabel('Weight (g)', fontsize=12)\nplt.ylabel('Average Tumor Volume (mm3)', fontsize=12)\n\n# Display the plot\nplt.tight_layout()\nplt.show()\n\n# Print the linear regression results\nprint(f\"Linear Regression Model: y = {slope:.2f}x + {intercept:.2f}\")\nprint(f\"R-squared: {r_value**2:.2f}\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinaland101%2Fcarcinoma-regression-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinaland101%2Fcarcinoma-regression-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinaland101%2Fcarcinoma-regression-project/lists"}