correlationPlot: Generate heatmap of correlations

View source: R/plot.R

correlationPlotR Documentation

Generate heatmap of correlations

Description

Visualize the correlations between topics stored in a matrix, typically one returned via getCorrMtx(). This function uses ggplot2::geom_tile.

Usage

correlationPlot(
  mat,
  colLabs = NA,
  rowLabs = NA,
  title = NA,
  annotation = FALSE
)

Arguments

mat

matrix with correlation values from -1 to 1

colLabs

x-axis label for plot. These are the columns of the matrix, or specifically m2 from getCorrMtx. (default: NULL)

rowLabs

y-axis label for plot. These are the rows of the matrix, or specifically m1 from getCorrMtx. (default: NULL)

title

title of the plot. (default: NULL)

annotation

Boolean to show the correlation values in the squares of the heatmap (default; FALSE)

Value

a heatmap of the values in the input mat

Examples

data(mOB)
pos <- mOB$pos
cd <- mOB$counts
counts <- cleanCounts(cd, min.lib.size = 100)
corpus <- restrictCorpus(counts, removeAbove=1.0, removeBelow = 0.05)
ldas <- fitLDA(t(as.matrix(corpus)), Ks = 3)
optLDA <- optimalModel(models = ldas, opt = 3)
results <- getBetaTheta(optLDA, perc.filt = 0.05, betaScale = 1000)
deconProp <- results$theta
corMtx <- getCorrMtx(m1 = as.matrix(deconProp), m2 = as.matrix(deconProp), type = "t")
rownames(corMtx) <- paste0("X", seq(nrow(corMtx)))
colnames(corMtx) <- paste0("X", seq(ncol(corMtx)))
correlationPlot(mat = corMtx, title = "Proportional correlation", annotation = TRUE) +
    ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90, vjust = 0))


JEFworks-Lab/STdeconvolve documentation built on July 17, 2024, 7:11 a.m.