Load the packages

library(readxl)
library(pheatmap)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tibble)
library(RColorBrewer)

palette and annotations

# Generate a color palette
n_colors <- 100  # Number of colors needed
my_palette <- colorRampPalette(brewer.pal(n_colors, "YlOrRd"))
## Warning in brewer.pal(n_colors, "YlOrRd"): n too large, allowed maximum for palette YlOrRd is 9
## Returning the palette you asked for with that many colors
colors_yellow_to_red <- my_palette(n_colors)
# Read the annotation file
Annotation = read_excel("/Users/victor/Documents/PhD/Data analysis/Gene expression/qPCR organoids Vera/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("/Users/victor/Documents/PhD/Data analysis/Gene expression/qPCR organoids Vera/qPCR organoids Vera.xlsx", sheet = "Claudin1" )
## New names:
## • `` -> `...1`
CLDN1<- CLDN1 %>% 
    tibble::column_to_rownames("...1") 
CLDN1=as.matrix(CLDN1)
pheatmap(CLDN1, color = colors_yellow_to_red, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="CLDN1", treeheight_row = 20, treeheight_col = 20  )

#Create a heatmap for each gene
CCL20 = read_excel("/Users/victor/Documents/PhD/Data analysis/Gene expression/qPCR organoids Vera/qPCR organoids Vera.xlsx", sheet = "CCL20" )
## New names:
## • `` -> `...1`
CCL20 <- CCL20  %>% 
    tibble::column_to_rownames("...1") 
CCL20 =as.matrix(CCL20)
pheatmap(CCL20, color = colors_yellow_to_red, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="CCL20", treeheight_row = 20, treeheight_col = 20  )

#Create a heatmap for each gene
CLDN2 = read_excel("/Users/victor/Documents/PhD/Data analysis/Gene expression/qPCR organoids Vera/qPCR organoids Vera.xlsx", sheet = "Claudin2" )
## New names:
## • `` -> `...1`
CLDN2 <- CLDN2  %>% 
    tibble::column_to_rownames("...1") 
CLDN2 =as.matrix(CLDN2)
pheatmap(CLDN2, color = colors_yellow_to_red, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="CLDN2", treeheight_row = 20, treeheight_col = 20  )

CLDN3 = read_excel("/Users/victor/Documents/PhD/Data analysis/Gene expression/qPCR organoids Vera/qPCR organoids Vera.xlsx", sheet = "Claudin3" )
## New names:
## • `` -> `...1`
CLDN3 <- CLDN3  %>% 
    tibble::column_to_rownames("...1") 
CLDN3 =as.matrix(CLDN3)
pheatmap(CLDN3, color = colors_yellow_to_red, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="CLDN3", treeheight_row = 20, treeheight_col = 20  )

CDH1 = read_excel("/Users/victor/Documents/PhD/Data analysis/Gene expression/qPCR organoids Vera/qPCR organoids Vera.xlsx", sheet = "CDH1" )
## New names:
## • `` -> `...1`
CDH1 <- CDH1  %>% 
    tibble::column_to_rownames("...1") 
CDH1 =as.matrix(CDH1)
pheatmap(CDH1, color = colors_yellow_to_red, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="CDH1", treeheight_row = 20, treeheight_col = 20  )

TJP1 = read_excel("/Users/victor/Documents/PhD/Data analysis/Gene expression/qPCR organoids Vera/qPCR organoids Vera.xlsx", sheet = "TJP1" )
## New names:
## • `` -> `...1`
TJP1 <- TJP1  %>% 
    tibble::column_to_rownames("...1") 
TJP1 =as.matrix(TJP1)
pheatmap(TJP1, color = colors_yellow_to_red, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="TJP1", treeheight_row = 20, treeheight_col = 20  )

CXCL8= read_excel("/Users/victor/Documents/PhD/Data analysis/Gene expression/qPCR organoids Vera/qPCR organoids Vera.xlsx", sheet = "CXCL8" )
## New names:
## • `` -> `...1`
CXCL8 <- CXCL8  %>% 
    tibble::column_to_rownames("...1") 
CXCL8 =as.matrix(CXCL8)
pheatmap(CXCL8, color = colors_yellow_to_red, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="CXCL8", treeheight_row = 20, treeheight_col = 20  )

TGFB= read_excel("/Users/victor/Documents/PhD/Data analysis/Gene expression/qPCR organoids Vera/qPCR organoids Vera.xlsx", sheet = "TGFB" )
## New names:
## • `` -> `...1`
TGFB <- TGFB  %>% 
    tibble::column_to_rownames("...1") 
TGFB =as.matrix(TGFB)
pheatmap(TGFB, color = colors_yellow_to_red, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="TGFB", treeheight_row = 20, treeheight_col = 20  )

CD274 = read_excel("/Users/victor/Documents/PhD/Data analysis/Gene expression/qPCR organoids Vera/qPCR organoids Vera.xlsx", sheet = "CD274" )
## New names:
## • `` -> `...1`
CD274 <- CD274  %>% 
    tibble::column_to_rownames("...1") 
CD274 =as.matrix(CD274)
pheatmap(CD274, color = colors_yellow_to_red, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="CD274", treeheight_row = 20, treeheight_col = 20  )

HLADR = read_excel("/Users/victor/Documents/PhD/Data analysis/Gene expression/qPCR organoids Vera/qPCR organoids Vera.xlsx", sheet = "HLA-DR" )
## New names:
## • `` -> `...1`
HLADR <- HLADR  %>% 
    tibble::column_to_rownames("...1") 
HLADR =as.matrix(HLADR)
pheatmap(HLADR, color = colors_yellow_to_red, annotation_col = Annotation, cellwidth = 20, cellheight = 15, main="HLADR", treeheight_row = 20, treeheight_col = 20  )

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.