#Import file of Upregulated Genes

Comparison_of_DEG_by_Significance_Up <- read_excel("Comparison of DEG by Significance Up.xlsx", col_types = c("text", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric"))
                                                   
print(Comparison_of_DEG_by_Significance_Up)    
## # A tibble: 58 × 7
##    Upregulated_Genes Overall Original_Author Colon Author_HCE Blood_Vessel
##    <chr>               <dbl>           <dbl> <dbl>      <dbl>        <dbl>
##  1 BIRC3                   0              20    19         17            0
##  2 C11orf96                0               0     0          0            0
##  3 CCL2                   20              19     9         11           16
##  4 CCL20                   7              18     0          0            0
##  5 CEBPD                   6               0     0          0            0
##  6 CSF1                   13               0    10          0            0
##  7 CSF2                    1              17     0          0            0
##  8 CSF3                    0              16     0          0            0
##  9 CXCL1                  19              15     4          0           19
## 10 CXCL10                  0              14     0          0            0
## # ℹ 48 more rows
## # ℹ 1 more variable: Author_HCAE <dbl>
## Melt table into long version

comparison_up_long <- pivot_longer(data = Comparison_of_DEG_by_Significance_Up, cols = -c(Upregulated_Genes), names_to = "Study", values_to = "Significance")
comparison_up_long
## # A tibble: 348 × 3
##    Upregulated_Genes Study           Significance
##    <chr>             <chr>                  <dbl>
##  1 BIRC3             Overall                    0
##  2 BIRC3             Original_Author           20
##  3 BIRC3             Colon                     19
##  4 BIRC3             Author_HCE                17
##  5 BIRC3             Blood_Vessel               0
##  6 BIRC3             Author_HCAE                0
##  7 C11orf96          Overall                    0
##  8 C11orf96          Original_Author            0
##  9 C11orf96          Colon                      0
## 10 C11orf96          Author_HCE                 0
## # ℹ 338 more rows

## Import Downregulated Genes

Comparison_of_DEG_by_Significance_Down <- read_excel("Comparison of DEG by Significance Down.xlsx", col_types = c("text", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric"))

print(Comparison_of_DEG_by_Significance_Down)
## # A tibble: 76 × 7
##    Downregulated_Genes Overall Original_Author Colon Author_HCE Blood_Vessel
##    <chr>                 <dbl>           <dbl> <dbl>      <dbl>        <dbl>
##  1 ABCA8                     0               0     0          0           19
##  2 AP5S1                     0              20     0          0            0
##  3 ARID5B                    0               0    13          0            0
##  4 ARFGAP2                   0              19     0          0            0
##  5 ASCL2                     8               0    18         16            0
##  6 ASNS                      0              18     0          0            0
##  7 BMI1                      0              17     0          0            0
##  8 BOC                       0               0     2          0            0
##  9 BRCA2                     0               0     0          0            0
## 10 BRD8                      0               0     0          0            9
## # ℹ 66 more rows
## # ℹ 1 more variable: Author_HCAE <dbl>
## Melt table into long version

comparison_down_long <- pivot_longer(data = Comparison_of_DEG_by_Significance_Down, cols = -c(Downregulated_Genes), names_to = "Studies", values_to = "Significance_Down")
comparison_down_long
## # A tibble: 456 × 3
##    Downregulated_Genes Studies         Significance_Down
##    <chr>               <chr>                       <dbl>
##  1 ABCA8               Overall                         0
##  2 ABCA8               Original_Author                 0
##  3 ABCA8               Colon                           0
##  4 ABCA8               Author_HCE                      0
##  5 ABCA8               Blood_Vessel                   19
##  6 ABCA8               Author_HCAE                     0
##  7 AP5S1               Overall                         0
##  8 AP5S1               Original_Author                20
##  9 AP5S1               Colon                           0
## 10 AP5S1               Author_HCE                      0
## # ℹ 446 more rows
## Plot Compiled Downregulated Data

downregulated_heatmap <- ggplot (data = comparison_down_long, mapping = aes(x = Downregulated_Genes, y = Studies, fill = Significance_Down)) + geom_tile() + xlab(label = "Genes")

downregulated_heatmap + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) + scale_fill_gradient(low = "#e5ebf0", 
                      high = "darkred",
                      limits = c(0, 20))

DEG_Across_Cell_Types <- read_excel("DEG Across Cell Types.xlsx")
DEG_Across_Cell_Types
## # A tibble: 30 × 4
##    Cell_Type    Gene_Name Fold_Change_HCE Fold_Change_HCAE
##    <chr>        <chr>               <dbl>            <dbl>
##  1 Colon        C9orf152            -2.03             0   
##  2 Colon        TNFRSF19            -1.77             0   
##  3 Colon        PATZ1               -1.46             0   
##  4 Blood_Vessel DOP1A                0               -2.03
##  5 Blood_Vessel ABCA8                0               -2.06
##  6 Blood_Vessel PPFIBP2              0               -1.61
##  7 Blood_Vessel CNTRL                0               -2.45
##  8 Blood_Vessel KLF2                 0               -1.45
##  9 Colon        KCNE3               -1.57             0   
## 10 Colon        ARID5B              -1.42             0   
## # ℹ 20 more rows
require("ggrepel")
## Loading required package: ggrepel
ggplot(DEG_Across_Cell_Types) +
    geom_point(aes(x = Fold_Change_HCE, 
                   y = Fold_Change_HCAE, 
                   color = Cell_Type)) + 
    geom_text_repel(aes(x = Fold_Change_HCE,
                  y = Fold_Change_HCAE,
                  label = Gene_Name))