---
title: "R Notebook"
output: html_notebook
---

This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code. 

Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*. 

```{r}
plot(cars)
```

Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Ctrl+Alt+I*.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the *Preview* button or press *Ctrl+Shift+K* to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike *Knit*, *Preview* does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.


Importing file

```{r}

DEG.IL1B.CD4.IL1B.Downregulated <- read.csv("DEG_IL1B_CD4_IL1B_Downregulated.csv", sep=",")


DEG.IL1B.CD4.IL1B.Upregulated <- read.csv("DEG_IL1B_CD4_IL1B_Upregulated.csv", sep=",")

```



Upregulated Set

```{r}

row.names(DEG.IL1B.CD4.IL1B.Upregulated) <- DEG.IL1B.CD4.IL1B.Upregulated$Genes
DEG.IL1B.CD4.IL1B.Upregulated.All <- DEG.IL1B.CD4.IL1B.Upregulated[,2:7]


```



Downregulated Set

```{r}

row.names(DEG.IL1B.CD4.IL1B.Downregulated) <- DEG.IL1B.CD4.IL1B.Downregulated$Genes
DEG.IL1B.CD4.IL1B.Downregulated.All <- DEG.IL1B.CD4.IL1B.Downregulated[,2:7]


```


Creating Matrices

```{r}

DEG.IL1B.CD4.IL1B.Downregulated.All.Matrix <- data.matrix(DEG.IL1B.CD4.IL1B.Downregulated.All)

DEG.IL1B.CD4.IL1B.Upregulated.All.Matrix <- data.matrix(DEG.IL1B.CD4.IL1B.Upregulated.All)

```


Creating heatmaps

## Downregulated
```{r}


colorpalette <- colorRampPalette(c("blue", "white", "red")) (n=599)



tiff(file="01.19.2021.DEG.IL1B.CD4.IL1B.Downregulated.All.Heatmap.tiff")
DEG.IL1B.CD4.IL1B.Downregulated.All.Heatmap <- heatmap.2(DEG.IL1B.CD4.IL1B.Downregulated.All.Matrix, Colv = FALSE,  Rowv = FALSE, col= colorpalette, margins = c(2,8), density.info = "none", trace = "none")



```

## Upregulated
```{r}

tiff(file="01.19.2021.DEG.IL1B.CD4.IL1B.Upregulated.All.Heatmap.tiff")
DEG.IL1B.CD4.IL1B.Upregulated.All.Heatmap <- heatmap.2(DEG.IL1B.CD4.IL1B.Upregulated.All.Matrix, Colv = FALSE,  Rowv = FALSE, col= colorpalette, margins = c(2,8), density.info = "none", trace = "none")


```


## Creating average heatmap


```{r}


DEG.IL1B.CD4.IL1B.Downregulated.AVG <- DEG.IL1B.CD4.IL1B.Downregulated[,8:9]

DEG.IL1B.CD4.IL1B.Upregulated.AVG <- DEG.IL1B.CD4.IL1B.Upregulated[,8:9]


DEG.IL1B.CD4.IL1B.Downregulated.AVG.Matrix <- data.matrix(DEG.IL1B.CD4.IL1B.Downregulated.AVG)

DEG.IL1B.CD4.IL1B.Upregulated.AVG.Matrix <- data.matrix(DEG.IL1B.CD4.IL1B.Upregulated.AVG)





```


# Heatmaps
## Downregulated
```{r}


tiff(file="01.19.2021.DEG.IL1B.CD4.IL1B.Downregulated.AVG.Heatmap.tiff")
DEG.IL1B.CD4.IL1B.Downregulated.AVG.Heatmap <- heatmap.2(DEG.IL1B.CD4.IL1B.Downregulated.AVG.Matrix, Colv = FALSE,  Rowv = FALSE, col= colorpalette, margins = c(2,8), density.info = "none", trace = "none")


      
```


## Upregulated
```{r}

tiff(file="01.19.2021.DEG.IL1B.CD4.IL1B.Upregulated.AVG.Heatmap.tiff")
DEG.IL1B.CD4.IL1B.Upregulated.AVG.Heatmap <- heatmap.2(DEG.IL1B.CD4.IL1B.Upregulated.AVG.Matrix, Colv = FALSE,  Rowv = FALSE, col= colorpalette, margins = c(2,8), density.info = "none", trace = "none")


```


Cleaned up Version Heatmpas

These heatmaps only contain data that have all 3 entries for CD4+ and 0 for all thre entries for CD4-


#Importing file

```{r}

DEG.IL1B.CD4.IL1B.Downregulated.Cleaned <- read.csv("DEG_IL1B_CD4_IL1B_Downregulated_Cleaned.csv", sep=",")


```



Downregulated Set

```{r}

row.names(DEG.IL1B.CD4.IL1B.Downregulated.Cleaned) <- DEG.IL1B.CD4.IL1B.Downregulated.Cleaned$Genes
DEG.IL1B.CD4.IL1B.Downregulated.Cleaned <- DEG.IL1B.CD4.IL1B.Downregulated.Cleaned[,2:7]


```


Creating Matrices

```{r}

DEG.IL1B.CD4.IL1B.Downregulated.Cleaned.Matrix <- data.matrix(DEG.IL1B.CD4.IL1B.Downregulated.Cleaned)


```


Creating heatmaps

## Downregulated
```{r}


colorpalette <- colorRampPalette(c("blue", "white", "red")) (n=599)



tiff(file="01.19.2021.DEG.IL1B.CD4.IL1B.Downregulated.Cleaned.Heatmap.tiff")
DEG.IL1B.CD4.IL1B.Downregulated.Cleaned.Heatmap <- heatmap.2(DEG.IL1B.CD4.IL1B.Downregulated.Cleaned.Matrix, Colv = FALSE,  Rowv = FALSE, col= colorpalette, margins = c(2,8), density.info = "none", trace = "none")



```




#####IL1B CD4- vs Veh CD4-

#Importing file

```{r}

DEG.IL1B.VEH.Downregulated.Cleaned <- read.csv("DEG_IL1B_VEH_Downregulated_Cleaned.csv", sep=",")


```



Downregulated Set

```{r}

row.names(DEG.IL1B.VEH.Downregulated.Cleaned) <- DEG.IL1B.VEH.Downregulated.Cleaned$Genes
DEG.IL1B.VEH.Downregulated.Cleaned <- DEG.IL1B.VEH.Downregulated.Cleaned[,2:7]


```


Creating Matrices

```{r}

DEG.IL1B.VEH.Downregulated.Cleaned.Matrix <- data.matrix(DEG.IL1B.VEH.Downregulated.Cleaned)


```


Creating heatmaps

## Downregulated
```{r}


colorpalette <- colorRampPalette(c("blue", "white", "red")) (n=599)



tiff(file="01.19.2021.DEG.IL1B.VEH.Downregulated.Cleaned.Heatmap.tiff")
DEG.IL1B.VEH.Downregulated.Cleaned.Heatmap <- heatmap.2(DEG.IL1B.VEH.Downregulated.Cleaned.Matrix, Colv = FALSE,  Rowv = FALSE, col= colorpalette, margins = c(2,8), density.info = "none", trace = "none")



```



#####Veh CD4+ vs Veh CD4-

#Importing file

```{r}

DEG.VEH.CD4.VEH.Downregulated.Cleaned <- read.csv("DEG_VEH_CD4_VEH_Downregulated_Cleaned.csv", sep=",")


```



Downregulated Set

```{r}

row.names(DEG.VEH.CD4.VEH.Downregulated.Cleaned) <- DEG.VEH.CD4.VEH.Downregulated.Cleaned$Genes
DEG.VEH.CD4.VEH.Downregulated.Cleaned <- DEG.VEH.CD4.VEH.Downregulated.Cleaned[,2:7]


```


Creating Matrices

```{r}

DEG.VEH.CD4.VEH.Downregulated.Cleaned.Matrix <- data.matrix(DEG.VEH.CD4.VEH.Downregulated.Cleaned)


```


Creating heatmaps

## Downregulated
```{r}


colorpalette <- colorRampPalette(c("blue", "white", "red")) (n=599)



tiff(file="01.19.2021.DEG.VEH.CD4.VEH.Downregulated.Cleaned.Heatmap.tiff")
DEG.VEH.CD4.VEH.Downregulated.Cleaned.Heatmap <- heatmap.2(DEG.VEH.CD4.VEH.Downregulated.Cleaned.Matrix, Colv = FALSE,  Rowv = FALSE, col= colorpalette, margins = c(2,8), density.info = "none", trace = "none")



```




#####IL1B CD4+ vs Veh CD4+

#Importing file

```{r}

DEG.IL1B.CD4.VEH.CD4.Downregulated.Cleaned <- read.csv("DEG_IL1B_CD4_VEH_CD4_Downregulated_Cleaned.csv", sep=",")


```



Downregulated Set

```{r}

row.names(DEG.IL1B.CD4.VEH.CD4.Downregulated.Cleaned) <- DEG.IL1B.CD4.VEH.CD4.Downregulated.Cleaned$Genes
DEG.IL1B.CD4.VEH.CD4.Downregulated.Cleaned <- DEG.IL1B.CD4.VEH.CD4.Downregulated.Cleaned[,2:7]


```


Creating Matrices

```{r}

DEG.IL1B.CD4.VEH.CD4.Downregulated.Cleaned.Matrix <- data.matrix(DEG.IL1B.CD4.VEH.CD4.Downregulated.Cleaned)


```


Creating heatmaps

## Downregulated
```{r}


colorpalette <- colorRampPalette(c("blue", "white", "red")) (n=599)



tiff(file="01.19.2021.DEG.IL1B.CD4.VEH.CD4.Downregulated.Cleaned.Heatmap.tiff")
DEG.IL1B.CD4.VEH.CD4.Downregulated.Cleaned.Heatmap <- heatmap.2(DEG.IL1B.CD4.VEH.CD4.Downregulated.Cleaned.Matrix, Colv = FALSE,  Rowv = FALSE, col= colorpalette, margins = c(2,8), density.info = "none", trace = "none")



```



