Nothing
### Copyright 2016-04 Ghislain DURIF
###
### This file is part of the `hClustering' library for R and related languages.
### It is made available under the terms of the GNU General Public
### License, version 2, or at your option, any later version,
### incorporated herein by reference.
###
### This program is distributed in the hope that it will be
### useful, but WITHOUT ANY WARRANTY; without even the implied
### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
### PURPOSE. See the GNU General Public License for more
### details.
###
### You should have received a copy of the GNU General Public
### License along with this program; if not, write to the Free
### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
### MA 02111-1307, USA
#' @title Heatmap of Hierarchical Clustering based on log-likelihood ratio
#'
#' @description
#' \code{plot_heatmap} draws the heatmap after the clustering from \code{\link{hClust_llr}}
#'
#' @details
#' Plot the result from \code{\link{hClust_llr}}
#'
#'@author
#'Ghislain Durif, \email{ghislain.durif@univ-lyon1.fr}
#'
#'@seealso \code{\link{hClust_llr}}
#'
#'@importFrom RColorBrewer brewer.pal
#'@importFrom gplots heatmap.2
#'
#'@param diss_matrix dissimilarity matrix between individuals (n x n) used for clustering
#'@param clustering an object of type hclust, generated by \code{\link{hClust_llr}}
#'@param rSideCol a vector of color to add on the row side of the heatmap (default is NULL)
#'@param cSideCol a vector of color to add on the column side of the heatmap (default is NULL)
#'@param title a title (default is NULL)
#'
#### heatmap with color on the side
#' @export
plot_heatmap <- function(diss_matrix, clustering, rSideCol=NULL, cSideCol=NULL, title=NULL) {
my_palette <- colorRampPalette(brewer.pal(n = 7,name = "RdYlBu"))(100)
if(!is.null(rSideCol) & is.null(cSideCol)) {
heatmap.2(as.matrix(diss_matrix),
notecol="white",
key=TRUE,
density.info="density",
trace="none",
col=my_palette,
dendrogram="both",
Colv=as.dendrogram(clustering),
Rowv=as.dendrogram(clustering),
RowSideColors=rSideCol,
main=title)
} else if(is.null(rSideCol) & !is.null(cSideCol)) {
heatmap.2(as.matrix(diss_matrix),
notecol="white",
key=TRUE,
density.info="density",
trace="none",
col=my_palette,
dendrogram="both",
Colv=as.dendrogram(clustering),
Rowv=as.dendrogram(clustering),
ColSideColors=cSideCol,
main=title)
} else if(!is.null(rSideCol) & !is.null(cSideCol)) {
heatmap.2(as.matrix(diss_matrix),
notecol="white",
key=TRUE,
density.info="density",
trace="none",
col=my_palette,
dendrogram="both",
Colv=as.dendrogram(clustering),
Rowv=as.dendrogram(clustering),
RowSideColors=rSideCol,
ColSideColors=cSideCol,
main=title)
} else if(is.null(rSideCol) & is.null(cSideCol)) {
heatmap.2(as.matrix(diss_matrix),
notecol="white",
key=TRUE,
density.info="density",
trace="none",
col=my_palette,
dendrogram="both",
Colv=as.dendrogram(clustering),
Rowv=as.dendrogram(clustering),
main=title)
}
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.