##' plotspwheatmap
##' @title Plot heat map of the metabolic subpathway activity matrix
##' @description According to the threshold of the set P value, The `plotspwheatmap()` function plots a heat map of the significant metabolic subpathways.
##' @param DF_result A list of result data generated by function `CalculateDF()`.
##' @param PValue_threshold Threshold for screening significant metabolic subpathways.
##' @param main an overall title for the heatmap.
##' @param show.rownames Boolean specifying if row names are be shown.
##' @param show.colnames Boolean specifying if column names are be shown.
##' @param fontsize Base fontsize for the plot (default: 10).
##' @param fontsize.row Fontsize for rownames (default: 10).
##' @param fontsize.col Fontsize for colnames (default: 10).
##' @param cluster_rows boolean values determining if rows should be clustered or hclust object.
##' @param cluster_cols boolean values determining if columns should be clustered or hclust object.
##' @param scale Character indicating if the values should be centered
##' @return A heat map.
##' ##' @examples
##' require(pheatmap)
##' DFspw<-get("DFspw")
##' plotspwheatmap(DFspw,cluster_rows = TRUE,show.colnames = FALSE)
##' @importFrom pheatmap pheatmap
##' @importFrom grDevices rainbow
##' @export
plotspwheatmap<-function(DF_result,PValue_threshold=0.01,main="",show.rownames = TRUE,show.colnames = TRUE,
fontsize = 10,fontsize.row = 10,fontsize.col = 10,cluster_rows=FALSE,cluster_cols=FALSE,scale = "none"){
havepheatmap <- isPackageLoaded("pheatmap")
if(havepheatmap==FALSE){
stop("The 'pheatmap' library, should be loaded first")
}
phen<-names(table(colnames(DF_result$SubpathwayMatrix)))
phen_length<-table(colnames(DF_result$SubpathwayMatrix))
colork<-rainbow(length(phen))
names(colork)<-phen
colann<-data.frame(Phenotype=factor(colnames(DF_result$SubpathwayMatrix)))
row.names(colann)<-paste(colnames(DF_result$SubpathwayMatrix),c(1:ncol(DF_result$SubpathwayMatrix)),sep = "")
colnames(DF_result$SubpathwayMatrix)<-paste(colnames(DF_result$SubpathwayMatrix),c(1:ncol(DF_result$SubpathwayMatrix)),sep = "")
ann_colors<-list(Phenotype=colork)
dfspw<-row.names(DFspw[["Difference_analysis"]])[which(DFspw[["Difference_analysis"]]$P.Value<=PValue_threshold)]
pp<-match(dfspw,row.names(DF_result$SubpathwayMatrix))
rt_matrix<-DF_result$SubpathwayMatrix[pp,]
pheatmap(rt_matrix,cluster_rows=cluster_rows,cluster_cols=cluster_cols,annotation_col =colann,
show_rownames=show.rownames, show_colnames=show.colnames,fontsize=fontsize, fontsize_row=fontsize.row,
fontsize_col=fontsize.col,annotation_colors = ann_colors,main=main,
gaps_col=phen_length[1],scale=scale)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.