Heatmap with GO Terms
The development version can be installed from GitHub using:
devtools::install_github("ilwookkim/GOheatmap")
library(GOheatmap)
Load example data selected STAD-TCGA RNAseq data (50 patients from TP53 wildtype and 50 from mutation; 275 genes selected by top significant DEGs) mat: RSEM countdata of RNAseq, samples_df: samples annotation data frame
mat.file <- system.file("extdata", "mat.Rdata", package="GOheatmap")
load(mat.file)
ls()
[1] "mat" "mat.file" "samples_df"
Pre-treatment
Remove NA, if necessary.
mat <- data.frame(na.omit(mat))
knitr::kable(head(mat[, 1:4], 3), "simple")
# column: samples, row: genes (HGNC symbol)
TCGA.CD.8536.01 TCGA.BR.8077.01 TCGA.HU.A4G3.01 TCGA.HU.A4H4.01
------ ---------------- ---------------- ---------------- ----------------
ACTC1 31 104 349 37
ACTG2 4385 2080 6012 1236
ACTN2 1 6 0 1
Run goheatmap
goheatmap function needs the following parameters. RNAseq countdata (column: samples ID, row: HGNC gene symbol), anno (samples annotation data frame, Default to NULL) ,Parameters k (number of clustering, Default to 3), n_go (number of terms to display, Default to 3), sources details here, cor (TRUE for spearman's correlation coefficient, FALSE for vst scaled matrix, Default to TRUE), title (Title of heatmap, Default to GOheatmap)
# For the spearman's correlation coefficient matrix
goheatmap(mat, k = 3, n_go = 3, sources = "GO:BP", cor.s = TRUE, title = "GOheatmap")
goheatmap(mat, k = 3, n_go = 3, sources = "KEGG", cor.s = TRUE, title = "GOheatmap")
When sources = "", goheatmap function uses all possible sources ("GO:MF","GO:CC","GO:BP","KEGG","REAC","WP","TF","MIRNA","HPA","CORUM","HP")
goheatmap(mat, k = 3, n_go = 3, sources = "", cor.s = TRUE, title = "GOheatmap")
When cor.s = FALSE, then countdata needs to be normalized for visualization.
# For the normalized count matrix by DESeq2
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("DESeq2")
library(DESeq2)
dds <- DESeqDataSetFromMatrix(countData = mat,
colData = samples_df,
design = ~ condition)
dds <- DESeq(dds)
mat <- as.data.frame(counts(dds, normalized=T))
If a sample annotation data frame exists, provide it into anno parameter. Default to NULL
knitr::kable(head(samples_df[, 1:2], 3), "simple")
samples condition
---------------- ----------
TCGA.CD.8536.01 TP53wt
TCGA.BR.8077.01 TP53mut
TCGA.HU.A4G3.01 TP53wt
goheatmap(mat, anno = samples_df, k = 3, n_go = 3, sources = "GO:BP", cor.s = FALSE, title = "GOheatmap")