View source: R/pipeline_functions.R
draw.heatmap | R Documentation |
draw.heatmap
plots the heatmap to see the expression level or activity level of genes and drivers across selected samples.
draw.heatmap(
mat = NULL,
use_genes = rownames(mat),
use_gene_label = use_genes,
use_samples = colnames(mat),
use_sample_label = use_samples,
phenotype_info = NULL,
use_phe = NULL,
main = "",
scale = "none",
pdf_file = NULL,
cluster_rows = TRUE,
cluster_columns = TRUE,
show_row_names = TRUE,
show_column_names = TRUE,
clustering_distance_rows = "pearson",
clustering_distance_columns = "pearson",
use_color = NULL,
pre_define = NULL,
...
)
mat |
numeric matrix, the expression/activity matrix. Rows are genes or drivers, columns are selected samples. |
use_genes |
a vector of characters, selected genes (e.g. "originID"). Default is row names of |
use_gene_label |
a vector of characters, a vector of labels for |
use_samples |
a vector of characters, selected samples. Default is column names of |
use_sample_label |
a vector of characters, a vector of labels for |
phenotype_info |
data.frame, phenotype of samples. Users can call |
use_phe |
a list of characters, selected phenotype of samples. A subset of columns from |
main |
character, an overall title for the plot. Default is "". |
scale |
character, users can choose from "row", "column" and "none". Indicating if the values should be centered and scaled in either the row direction or the column direction, or none. Default is "none". |
pdf_file |
character, the file path to save plot as PDF file. If NULL, no PDF file will be saved. Default is NULL. |
cluster_rows , cluster_columns |
logical, the same parameters in |
show_row_names , show_column_names |
logical, the same parameters used in |
clustering_distance_rows , clustering_distance_columns |
character, the same parameters used in |
use_color |
a vector of color codes, colors to be assigned to each member of display label. Default is brewer.pal(9, 'Set1'). |
pre_define |
a vector of characters, pre-defined color codes for a certain input (e.g. c("blue", "red") with names c("A", "B")). Default is NULL. |
... |
for more options, please check |
Return a logical value. If TRUE, the plot has been created successfully.
analysis.par <- list()
analysis.par$out.dir.DATA <- system.file('demo1/driver/DATA/',package = "NetBID2")
NetBID.loadRData(analysis.par=analysis.par,step='ms-tab')
ms_tab <- analysis.par$final_ms_tab
exp_mat <- Biobase::exprs(analysis.par$cal.eset) ## rownames matches originalID
ac_mat <- Biobase::exprs(analysis.par$merge.ac.eset) ## rownames matches originalID_label
phe_info <- Biobase::pData(analysis.par$cal.eset) ## phenotype information
sig_driver <- draw.volcanoPlot(dat=ms_tab,label_col='gene_label',
logFC_col='logFC.G4.Vs.others_DA',
Pv_col='P.Value.G4.Vs.others_DA',
logFC_thre=0.4,
Pv_thre=1e-7,
main='Volcano Plot for G4.Vs.others_DA',
show_label=FALSE,
label_type = 'origin',
label_cex = 0.5)
sig_driver <- sig_driver[1:10,]
draw.heatmap(mat=exp_mat,use_genes=ms_tab[rownames(sig_driver),'originalID'],
use_gene_label=ms_tab[rownames(sig_driver),'gene_label'],
use_samples=colnames(exp_mat),
use_sample_label=phe_info[colnames(exp_mat),'geo_accession'],
phenotype_info=phe_info,use_phe=c('gender','pathology','subgroup'),
main='Expression for Top drivers',scale='row',
cluster_rows=TRUE,cluster_columns=TRUE,
clustering_distance_rows='pearson',
clustering_distance_columns='pearson',
row_names_gp = gpar(fontsize = 12),
pre_define=c('WNT'='blue','SHH'='red','G4'='green'))
draw.heatmap(mat=ac_mat,use_genes=ms_tab[rownames(sig_driver),'originalID_label'],
use_gene_label=ms_tab[rownames(sig_driver),'gene_label'],
use_samples=colnames(ac_mat),
use_sample_label=phe_info[colnames(ac_mat),'geo_accession'],
phenotype_info=phe_info,use_phe=c('gender','pathology','subgroup'),
main='Activity for Top drivers',scale='row',
cluster_rows=TRUE,cluster_columns=TRUE,
clustering_distance_rows='pearson',
clustering_distance_columns='pearson',
row_names_gp = gpar(fontsize = 6),
pre_define=c('WNT'='blue','SHH'='red','G4'='green'))
## Not run:
analysis.par <- list()
analysis.par$out.dir.DATA <- system.file('demo1/driver/DATA/',package = "NetBID2")
NetBID.loadRData(analysis.par=analysis.par,step='ms-tab')
ms_tab <- analysis.par$final_ms_tab
exp_mat <- Biobase::exprs(analysis.par$cal.eset) ## rownames matches originalID
ac_mat <- Biobase::exprs(analysis.par$merge.ac.eset) ## rownames matches originalID_label
phe_info <- Biobase::pData(analysis.par$cal.eset) ## phenotype information
analysis.par$out.dir.PLOT <- getwd() ## directory for saving the pdf files
sig_driver <- draw.volcanoPlot(dat=ms_tab,label_col='gene_label',
logFC_col='logFC.G4.Vs.others_DA',
Pv_col='P.Value.G4.Vs.others_DA',
logFC_thre=0.4,
Pv_thre=1e-7,
main='Volcano Plot for G4.Vs.others_DA',
show_label=FALSE,
label_type = 'origin',
label_cex = 0.5)
draw.heatmap(mat=exp_mat,use_genes=ms_tab[rownames(sig_driver),'originalID'],
use_gene_label=ms_tab[rownames(sig_driver),'gene_label'],
use_samples=colnames(exp_mat),
use_sample_label=phe_info[colnames(exp_mat),'geo_accession'],
phenotype_info=phe_info,
use_phe=c('gender','pathology','subgroup'),
main='Expression for Top drivers',scale='row',
cluster_rows=TRUE,cluster_columns=TRUE,
clustering_distance_rows='pearson',
clustering_distance_columns='pearson',
row_names_gp = gpar(fontsize = 12),
pdf_file=sprintf('%s/heatmap_demo1.pdf',
analysis.par$out.dir.PLOT),
pre_define=c('WNT'='blue','SHH'='red','G4'='green'))
draw.heatmap(mat=ac_mat,use_genes=ms_tab[rownames(sig_driver),'originalID_label'],
use_gene_label=ms_tab[rownames(sig_driver),'gene_label'],
use_samples=colnames(ac_mat),
use_sample_label=phe_info[colnames(ac_mat),'geo_accession'],
phenotype_info=phe_info,
use_phe=c('gender','pathology','subgroup'),
main='Activity for Top drivers',scale='row',
cluster_rows=TRUE,cluster_columns=TRUE,
clustering_distance_rows='pearson',
clustering_distance_columns='pearson',
row_names_gp = gpar(fontsize = 6),
pdf_file=sprintf('%s/heatmap_demo2.pdf',
analysis.par$out.dir.PLOT),
pre_define=c('WNT'='blue','SHH'='red','G4'='green'))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.