In todays session we will work with some of the RNAseq data of adult mouse tissues from Bing Ren’s lab, Liver and Heart.
Preprocessed counts for Tissue data for this practical session can be found in the data directory. data/tissueCounts.RData
Load in the DESeq2 object for Tissues experiment, produce an rlog transformation and plot the PCA for these genes.
library(DESeq2)
library(ggplot2)
load("data/gC_TissueFull.RData")
<- DESeqDataSet(geneCounts, design = ~Tissue)
dds <- DESeq(dds)
dds
<- rlog(dds)
rlogTissue <- DESeq2::plotPCA(rlogTissue, intgroup = "Tissue")
myPlot +theme_bw() myPlot
Filter to genes significant (padj < 0..01) from our LRT test between all groups and produce a heatmap.
<- DESeq(dds,test="LRT",reduced = ~1)
dds2 <- results(dds2)
AllChanges <- assay(rlogTissue)
rlogMatrix <- rownames(AllChanges)[AllChanges$padj < 0.01 & !is.na(AllChanges$padj)]
sigChanges <- rlogMatrix[rownames(rlogMatrix) %in% sigChanges,]
sigMat <- as.data.frame(colData(rlogTissue)[,1,drop=FALSE])
annoDF library(pheatmap)
pheatmap(sigMat,
scale="row",
show_rownames = FALSE,
annotation_col = annoDF)
Extract the influence of genes to PC2 and produce a heatmap as above but now ranked by PC2 rotation/loadings.
<- prcomp(t(rlogMatrix))
pcRes <- sort(pcRes$rotation[,2],decreasing = TRUE)
PC2_rnk <- sigMat[match(names(PC2_rnk),rownames(sigMat),nomatch = 0),]
PC2_mat pheatmap(PC2_mat,
scale="row",
cluster_rows=FALSE,
show_rownames = FALSE,annotation_col = annoDF
)
Produce a PCA plot of the GO “heart development” genes (“GO:0007507”). You will need to extract all genes within this group from the org.Mm.eg.db package.
library(org.Mm.eg.db)
<- AnnotationDbi::select(org.Mm.eg.db, keytype = "GOALL",
HeartDevelopment keys = "GO:0007507", columns = "ENTREZID")
<- unique(HeartDevelopment$ENTREZID)
HeartDevelopment_Entrez ::plotPCA(rlogTissue[rownames(rlogTissue) %in% HeartDevelopment_Entrez],intgroup = "Tissue") + theme_bw() DESeq2
Create a Heatmap of all genes and include row annotation showing members of heart development, liver development and kidney development GO set.
library(org.Mm.eg.db)
<- AnnotationDbi::select(org.Mm.eg.db,keytype = "GOALL",
HeartDevelopment keys = "GO:0007507",columns = "ENTREZID")
<- unique(HeartDevelopment$ENTREZID)
HeartDevelopment_Entrez library(org.Mm.eg.db)
<- AnnotationDbi::select(org.Mm.eg.db,keytype = "GOALL",
LiverDevelopment keys = "GO:0001889",columns = "ENTREZID")
<- unique(LiverDevelopment$ENTREZID)
LiverDevelopment_Entrez library(org.Mm.eg.db)
<- AnnotationDbi::select(org.Mm.eg.db,keytype = "GOALL",
KidneyDevelopment keys = "GO:0001822",columns = "ENTREZID")
<- unique(KidneyDevelopment$ENTREZID)
KidneyDevelopment_Entrez <- data.frame(HeartDev=factor(rownames(sigMat) %in% HeartDevelopment_Entrez),
annoRow LiverDev=factor(rownames(sigMat) %in% LiverDevelopment_Entrez),
KidneyDev=factor(rownames(sigMat) %in% KidneyDevelopment_Entrez))
rownames(annoRow) <- rownames(sigMat)
= list(
ann_colors HeartDev = c("FALSE"="white","TRUE"="green"),
LiverDev = c("FALSE"="white","TRUE"="red"),
KidneyDev = c("FALSE"="white","TRUE"="blue")
)
pheatmap(sigMat,
scale="row",
show_rownames = FALSE,
annotation_col = annoDF,
annotation_row = annoRow,
annotation_colors = ann_colors)
Take the LRT filtered rlog counts and cluster using pheatmap into 3 clusters,
set.seed(153)
<- pheatmap(sigMat,
k scale="row",kmeans_k = 3)
names(k$kmeans)
## [1] "cluster" "centers" "totss" "withinss" "tot.withinss"
## [6] "betweenss" "size" "iter" "ifault"
<- as.data.frame(factor(k$kmeans$cluster))
clusterDF colnames(clusterDF) <- "Cluster"
1:10,,drop=FALSE] clusterDF[
## Cluster
## 20671 1
## 27395 1
## 18777 2
## 21399 3
## 108664 2
## 319263 3
## 76187 2
## 70675 3
## 73824 3
## 100039596 2
<- sigMat[order(clusterDF$Cluster),]
OrderByCluster
pheatmap(OrderByCluster,
scale="row",annotation_row = clusterDF,
show_rownames = FALSE,cluster_rows = FALSE)