Project 1

Introduction

In this analysis, I delved into a data set provided by the Centers for Disease Control and Prevention (CDC). This data set investigates the physiological responses of male rats exposed to fumes from 3D printing. In order to further focus this investigation, I chose three variables that affect neurotransmitters and hormones within the body:

CGRP (Calcitonin Gene-Related Peptide) - A neuropeptide involved with various physiological functions. These include but are not limited to: pain modulation, inflammation, and vasodilation (the expansion or narrowing of blood vessels).

POMC (Pro-opiomelanocortin) - A precursor protein that is processed by the body to produce more hormones that regulate pain and the adrenal cortex.

GNRH (Gonadotropin-Releasing Hormone) - A hormone that regulates reproductive functions.

By examining these variables, I aim to gain some insights into the biological responses of rats exposed to 3D printing emissions. This could contribute to a better understanding of the health implications associated with producing 3D printed parts.

Loading Libraries

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dplyr)
library(ggfortify)
library(viridisLite)

In this chunk, I am loading the necessary libraries required for the investigation. Tidyverse, dplyr, and ggfortify provide a wide array of functions that assist with data manipulation and enhance some of the plots created below. ViridisLite is specifically loaded for the heatmap located at the bottom of the investigation.

Setting a Pathway

setwd("/Users/Mathew/Downloads/Data Sets - Data 110")
orig_hypothal <- read_csv("hypothalamus_pcr_analysis.csv")
Rows: 60 Columns: 15
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (1): condition
dbl (14): animal, day, 18S, fold cgrp, fold fos, foldcreb, fold sod, fold vi...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

In this chunk, Rstudio is loading the data set from the set location within my computer.

Cleaning the Data

NeuroHoro<-orig_hypothal|>
  select(animal, day, condition, `fold cgrp`, `fold gnrh`, `fold pomc`)

In this chunk, I am narrowing down the data to exclude data that isn’t relevant to the investigation. Aside from the designated neurotransmitters, I have chosen to keep the number assigned to each rat, the number of days each rat spent exposed to fumes, and whether the rat was exposed to air or to 3D printing fumes.

DPNeuro <- NeuroHoro |>
  filter( condition %in% c("3DP"))
  DPNeuro
# A tibble: 30 × 6
   animal   day condition `fold cgrp` `fold gnrh` `fold pomc`
    <dbl> <dbl> <chr>           <dbl>       <dbl>       <dbl>
 1      7     1 3DP              0.91        3.26        0.01
 2      8     1 3DP              0.98        0.08        0.35
 3      9     1 3DP              1.95        1.03        3.19
 4     10     1 3DP              1.26        3.11        1.16
 5     11     1 3DP              1.35        0.63        1.18
 6     12     1 3DP              2.68        0.07        0.01
 7     19     4 3DP              0.62       43.4         1.56
 8     20     4 3DP              1.19        0.44        0.07
 9     21     4 3DP              0.59        0.26        0.03
10     22     4 3DP              1.11        0.33        0.23
# ℹ 20 more rows

In this chunk, I removed all the data involving rats that were only exposed to air. Now, the only data remaining involves rats exposed to 3D printing fumes.

Checking for Correlation

In this section of code, I aim to create a linear regression plot to check for a correlation between the neurotransmitter levels of the rat and the number of days they spent exposed to 3D printing fumes.

p1 <- ggplot(DPNeuro, aes(x = day, y = `fold cgrp`+ `fold gnrh` +`fold pomc`)) +
 labs(title = "Neurotransmitter Levels After 3D Fume Exposure",
 caption = "Source: Centers for Disease Control and Prevention") +
 xlab("Days") +
 ylab ("Neurotransmitter Levels") +
 theme_minimal(base_size = 12)
p1 + geom_point()

In this chunk, I have created a scatter plot to visualize the narrowed down data. This allows for the identification of outliers, which can negatively influence the relationships between the two variables.

DPNeuro <- DPNeuro[DPNeuro$animal != 44,]
p2 <- ggplot(DPNeuro, aes(x = day, y = `fold cgrp`+ `fold gnrh` + `fold pomc`)) +
 labs(title = "Neurotransmitter Levels After 3D Fume Exposure",
 caption = "Source: Centers for Disease Control and Prevention") +
 xlab("Days") +
 ylab ("Neurotransmitter Levels") +
 theme_minimal(base_size = 12)
p2 + geom_point()

In this chunk, I removed all data involving the rat labeled 44. This removes the outlier within the data set. This will allow for a more accurate assessment of the relationship between the variables.

p3 <- p2 + geom_point() + geom_smooth(method='lm',formula=y~x)
p3

In this chunk, I have added a linear regression line to show the relationship between the variables. It has determined that the levels of the selected neurotransmitters increase the longer a rat is exposed to 3D printing fumes.

Creating a Heatmap

I have chosen to create a heatmap for this data visualization to better identify the relationship found in the earlier linear regression model.

DPMprep<-DPNeuro|>
  select(`fold cgrp`, `fold gnrh`, `fold pomc`)

In this chunk, I have removed all variables that are not the relevant neurotransmitters. This allows the heatmap to solely focus on comparing the neurotransmitters and prevents the generation of additional irrelevant data.

DPMatrix <- data.matrix(DPMprep)

In this chunk, I am converting the data into a matrix form. This is to make the data compatible with the heatmap command.

heatmap(DPMatrix, 
        Rowv = NA, Colv = NA, 
        col= viridis(25),
        s=0.6, v=1, scale="column", 
        margins=c(5,5), 
        main = "Neurotransmitter Levels After 3D Fume Exposure", 
        xlab = "Neurotransmitters", 
        ylab ="Neurotransmitter Levels",
        labCol = c("crgp", "gnrh", "pomc"),
        cexCol=1, cexRow =1,)
layout: widths =  0.05 4 , heights =  0.25 4 ; lmat=
     [,1] [,2]
[1,]    0    3
[2,]    2    1
legend("topright",
       legend = seq(min(DPMatrix), max(DPMatrix), length.out = 5),
       fill = viridis(25),
       title = "Intensity",
       cex = 0.8,
       box.lwd = 1,
       title.adj = 0.5)

In this chunk, I have finished the heatmap to complete the data visualization. I have added a legend to clarify the intensity for the heatmap to allow for an easier understanding of the data.

Closing Essay

When cleaning my data, I chose to take certain steps that appear unnecessary at first glance. Specifically, when using the initial ‘select’ command, I opted to keep the ‘animals’ column within my data set. While this data was irrelevant, it allowed me to remove specific outliers in the later stages of the project. Additionally, I used the ‘filter’ command to exclude specific data within the ‘condition’ column. This allowed me to focus my analysis on the data related to rats exposed to 3D printing fumes.

The visualization I generated illustrates the relationship between the duration of exposure to 3D printing fumes and neurotransmitter levels in male rats. Both the linear regression plot and heat map display a relationship between the variables. However, I originally expected the data to show a much more significant impact on neurotransmitter levels. This suggests that the impact on the fumes might not be as severe as I anticipated.

I personally wish that I could have created a better heat map. Despite my best efforts and research, I continued to encounter the same issues. My legend constantly appeared over my key aspects of my visualization. The title could only grow larger in font size, even after I put in the relevant command. Every attempt at adding a caption was met with constant errors. The largest difficulty was losing the entirety of my project a few hours before the deadline. Thankfully, I was able to recover some of the data, but typing everything back out takes time.