Load the packages

library(readxl)
library(pheatmap)
library(dplyr)
## 
## Attache Paket: 'dplyr'
## Die folgenden Objekte sind maskiert von 'package:stats':
## 
##     filter, lag
## Die folgenden Objekte sind maskiert von 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tibble)
library(RColorBrewer)

palette and annotations

# Create the color palette
num_colors <- 100
light_blue_to_red_palette <- colorRampPalette(c("lightblue","white", "red"))(num_colors)
# Read the annotation file
Annotation = read_excel("Annotation.xlsx")
## New names:
## • `` -> `...1`
Annotation <- Annotation  %>% 
    tibble::column_to_rownames("...1") # First column as row names

Create a heatmap for each gene

CLDN1 = read_excel("qPCR organoids Vera.xlsx", sheet = "Claudin1" )
## New names:
## • `` -> `...1`
CLDN1<- CLDN1 %>% 
    tibble::column_to_rownames("...1") 
CLDN1=as.matrix(CLDN1)
# Find the minimum and maximum values of the heatmap_data matrix
min_value <- min(CLDN1)
max_value <- max(CLDN1)
breakpoints <- c(seq(min_value, 1, length.out = num_colors/2), seq(1+1e-10, max_value, length.out = num_colors/2))
# Create the heatmap using pheatmap with custom color palette and color scale
pheatmap(CLDN1, color = light_blue_to_red_palette, annotation_col = Annotation, cellwidth = 20,breaks = breakpoints, cellheight = 15, main="CLDN1", treeheight_row = 20, treeheight_col = 20  )

CCL20 = read_excel("qPCR organoids Vera.xlsx", sheet = "CCL20" )
## New names:
## • `` -> `...1`
CCL20 <- CCL20  %>% 
    tibble::column_to_rownames("...1") 
CCL20 =as.matrix(CCL20)
min_value <- min(CCL20)
max_value <- max(CCL20)
breakpoints <- c(seq(min_value, 1, length.out = num_colors/2), seq(1+1e-10, max_value, length.out = num_colors/2))
pheatmap(CCL20, color = light_blue_to_red_palette,breaks = breakpoints, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="CCL20", treeheight_row = 20, treeheight_col = 20  )

#Create a heatmap for each gene
CLDN2 = read_excel("qPCR organoids Vera.xlsx", sheet = "Claudin2" )
## New names:
## • `` -> `...1`
CLDN2 <- CLDN2  %>% 
    tibble::column_to_rownames("...1") 
CLDN2 =as.matrix(CLDN2)
min_value <- min(CLDN2)
max_value <- max(CLDN2)
breakpoints <- c(seq(min_value, 1, length.out = num_colors/2), seq(1+1e-10, max_value, length.out = num_colors/2))
pheatmap(CLDN2, color = light_blue_to_red_palette,breaks = breakpoints, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="CLDN2", treeheight_row = 20, treeheight_col = 20  )

CLDN3 = read_excel("qPCR organoids Vera.xlsx", sheet = "Claudin3" )
## New names:
## • `` -> `...1`
CLDN3 <- CLDN3  %>% 
    tibble::column_to_rownames("...1") 
CLDN3 =as.matrix(CLDN3)
min_value <- min(CLDN3)
max_value <- max(CLDN3)
breakpoints <- c(seq(min_value, 1, length.out = num_colors/2), seq(1+1e-10, max_value, length.out = num_colors/2))
pheatmap(CLDN3, color = light_blue_to_red_palette,breaks = breakpoints, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="CLDN3", treeheight_row = 20, treeheight_col = 20  )

CDH1 = read_excel("qPCR organoids Vera.xlsx", sheet = "CDH1" )
## New names:
## • `` -> `...1`
CDH1 <- CDH1  %>% 
    tibble::column_to_rownames("...1") 
CDH1 =as.matrix(CDH1)
min_value <- min(CDH1)
max_value <- max(CDH1)
breakpoints <- c(seq(min_value, 1, length.out = num_colors/2), seq(1+1e-10, max_value, length.out = num_colors/2))
pheatmap(CDH1, color = light_blue_to_red_palette,breaks = breakpoints, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="CDH1", treeheight_row = 20, treeheight_col = 20  )

TJP1 = read_excel("qPCR organoids Vera.xlsx", sheet = "TJP1" )
## New names:
## • `` -> `...1`
TJP1 <- TJP1  %>% 
    tibble::column_to_rownames("...1") 
TJP1 =as.matrix(TJP1)
min_value <- min(TJP1)
max_value <- max(TJP1)
breakpoints <- c(seq(min_value, 1, length.out = num_colors/2), seq(1+1e-10, max_value, length.out = num_colors/2))
pheatmap(TJP1, color = light_blue_to_red_palette,breaks = breakpoints, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="TJP1", treeheight_row = 20, treeheight_col = 20  )

CXCL8= read_excel("qPCR organoids Vera.xlsx", sheet = "CXCL8" )
## New names:
## • `` -> `...1`
CXCL8 <- CXCL8  %>% 
    tibble::column_to_rownames("...1") 
CXCL8 =as.matrix(CXCL8)
min_value <- min(CXCL8)
max_value <- max(CXCL8)
breakpoints <- c(seq(min_value, 1, length.out = num_colors/2), seq(1+1e-10, max_value, length.out = num_colors/2))
pheatmap(CXCL8, color = light_blue_to_red_palette,breaks = breakpoints, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="CXCL8", treeheight_row = 20, treeheight_col = 20  )

TGFB= read_excel("qPCR organoids Vera.xlsx", sheet = "TGFB" )
## New names:
## • `` -> `...1`
TGFB <- TGFB  %>% 
    tibble::column_to_rownames("...1") 
TGFB =as.matrix(TGFB)
min_value <- min(TGFB)
max_value <- max(TGFB)
breakpoints <- c(seq(min_value, 1, length.out = num_colors/2), seq(1+1e-10, max_value, length.out = num_colors/2))
pheatmap(TGFB, color = light_blue_to_red_palette,breaks = breakpoints, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="TGFB", treeheight_row = 20, treeheight_col = 20  )

CD274 = read_excel("qPCR organoids Vera.xlsx", sheet = "CD274" )
## New names:
## • `` -> `...1`
CD274 <- CD274  %>% 
    tibble::column_to_rownames("...1") 
CD274 =as.matrix(CD274)
min_value <- min(CD274)
max_value <- max(CD274)
breakpoints <- c(seq(min_value, 1, length.out = num_colors/2), seq(1+1e-10, max_value, length.out = num_colors/2))
pheatmap(CD274, color = light_blue_to_red_palette,breaks = breakpoints, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="CD274", treeheight_row = 20, treeheight_col = 20  )

HLADR = read_excel("qPCR organoids Vera.xlsx", sheet = "HLA-DR" )
## New names:
## • `` -> `...1`
HLADR <- HLADR  %>% 
    tibble::column_to_rownames("...1") 
HLADR =as.matrix(HLADR)
min_value <- min(HLADR)
max_value <- max(HLADR)
breakpoints <- c(seq(min_value, 1, length.out = num_colors/2), seq(1+1e-10, max_value, length.out = num_colors/2))
pheatmap(HLADR, color = light_blue_to_red_palette,breaks = breakpoints, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="HLADR", treeheight_row = 20, treeheight_col = 20  )