View source: R/mplnVisualize.R
mplnVisualizeHeatmap | R Documentation |
A function to produce heatmaps of data with clustering results.
mplnVisualizeHeatmap(
dataset,
clusterMembershipVector = NA,
fileName = paste0("Plot_", date()),
printPlot = TRUE,
format = "pdf"
)
dataset |
A dataset of class matrix and type integer such that rows correspond to observations (N) and columns (C) correspond to variables. |
clusterMembershipVector |
A numeric vector of length nrow(dataset) containing the cluster membership of each observation as generated by mpln(). Default is NA. |
fileName |
Unique character string indicating the name for the plot being generated. Default is Plot_date, where date is obtained from date(). |
printPlot |
Logical indicating if plot(s) should be saved in local directory. Default TRUE. Options TRUE or FALSE. |
format |
Character string indicating the format of the image to be produced. Default 'pdf'. Options 'pdf' or 'png'. |
A heatmap of data with cluster memberships.
Anjali Silva, anjali@alumni.uoguelph.ca
# Example 1
# Setting the parameters
trueMu1 <- c(6.5, 6, 6, 6, 6, 6)
trueMu2 <- c(2, 2.5, 2, 2, 2, 2)
trueSigma1 <- diag(6) * 2
trueSigma2 <- diag(6)
# Generating simulated data
simulatedCounts <- MPLNClust::mplnDataGenerator(nObservations = 100,
dimensionality = 6,
mixingProportions = c(0.79, 0.21),
mu = rbind(trueMu1, trueMu2),
sigma = rbind(trueSigma1, trueSigma2),
produceImage = "No")
# Clustering data
MPLNClustResults <- MPLNClust::mplnVariational(
dataset = as.matrix(simulatedCounts$dataset),
membership = "none",
gmin = 1,
gmax = 3,
initMethod = "kmeans",
nInitIterations = 1,
normalize = "Yes")
# Visualize data via a Heatmap for G = 2
MPLNHeatmap2 <- MPLNClust::mplnVisualizeHeatmap(dataset = simulatedCounts$dataset,
clusterMembershipVector =
MPLNClustResults$allResults$`G=2`$clusterlabels,
fileName = 'TwoClusterModel',
printPlot = FALSE,
format = 'png')
# Visualize data via a Heatmap for G = 3
MPLNHeatmap3 <- MPLNClust::mplnVisualizeHeatmap(dataset = simulatedCounts$dataset,
clusterMembershipVector =
MPLNClustResults$allResults$`G=3`$clusterlabels,
fileName = 'ThreeClusterModel',
printPlot = FALSE,
format = 'png')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.