draw.funcEnrich.cluster: Cluster Plot for Gene Set Enrichment Analysis Result

View source: R/pipeline_functions.R

draw.funcEnrich.clusterR Documentation

Cluster Plot for Gene Set Enrichment Analysis Result

Description

draw.funcEnrich.cluster draws a cluster plot based on binary matrix, to visualize the existence of genes in the enriched gene sets. The P-value of enrichment is also displayed in the plot.

Usage

draw.funcEnrich.cluster(
  funcEnrich_res = NULL,
  top_number = 30,
  Pv_col = "Ori_P",
  name_col = "#Name",
  item_col = "Intersected_items",
  Pv_thre = 0.1,
  gs_cex = 0.7,
  gene_cex = 0.8,
  pv_cex = 0.7,
  main = "",
  h = 0.95,
  inner_color = brewer.pal(9, "Reds")[3],
  cluster_gs = TRUE,
  cluster_gene = TRUE,
  pdf_file = NULL,
  use_genes = NULL,
  return_mat = FALSE
)

Arguments

funcEnrich_res

data.frame, containing the result of functional enrichment analysis. It is highly suggested to use funcEnrich.Fisher to create this data frame. If users decided to prepare the data.frame on their own, please make sure the column names match the following parameters.

top_number

numeric, the number of top enriched gene sets to be displayed. Default is 30.

Pv_col

character, the name of the column in funcEnrich_res which contains P-value. Default is "Ori_P".

name_col

character, the name of the column in funcEnrich_res which contains gene set name. Default is "#Name".

item_col

character, the name of the column in funcEnrich_res which contains intersected genes collapsed with ";". Default is "Intersected_items".

Pv_thre

numeric, threshold of P-values. Genes or drivers with P-values lower than the threshold will be kept. Default is 0.1.

gs_cex

numeric, giving the amount by which the text of gene sets names should be magnified relative to the default. Default is 0.5.

gene_cex

numeric, giving the amount by which the text of gene symbols should be magnified relative to the default. Default is 0.8.

pv_cex

numeric, giving the amount by which the text of P-values should be magnified relative to the default. Default is 0.7.

main

character, an overall title for the plot.

h

numeric, the height where the cluster tree should be cut. The same parameter as cutree. Default is 0.95.

inner_color

character, the color code for the indexing box inside the main plot region. Could be one character or a character vector. If want to set the color by gene, could input the color code character with names set as genes. If want to set the color by Z-score, could use 'z2col' to generate the color code. Default is brewer.pal(9,'Reds')[3].

cluster_gs

logical, if TRUE, gene sets will be clustered. Default is TRUE.

cluster_gene

logical, if TRUE, genes will be clustered. Default is TRUE.

pdf_file

character, the file path to save as PDF file. If NULL, no PDF file will be saved. Default is NULL.

use_genes

a vector of characters, a vector of gene symbols to display. If NULL, all the genes in the top enriched gene sets will be displayed. Default is NULL.

return_mat

logical, if TRUE, return a binary matrix. Rows are gene sets, columns are genes. Default if FALSE.

Value

If return_mat==FALSE, return a logical value. If TRUE, plot has been created successfully. If return_mat == TRUE, return a binary matrix of the cluster. Rows are gene sets, columns are genes.

Examples

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
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)
gs.preload(use_spe='Homo sapiens',update=FALSE)
res1 <- funcEnrich.Fisher(input_list=ms_tab[rownames(sig_driver),'geneSymbol'],
                          bg_list=ms_tab[,'geneSymbol'],
                          use_gs=c('H','C5'),Pv_thre=0.1,Pv_adj = 'none')
draw.funcEnrich.cluster(funcEnrich_res=res1,top_number=30,gs_cex = 0.5,
                       gene_cex=0.9,pv_cex=0.8)
DA_Z <- z2col(ms_tab[rownames(sig_driver),'Z.G4.Vs.others_DA'],
        blue_col=brewer.pal(9,'Blues')[3],
        red_col=brewer.pal(9,'Reds')[3],col_max_thre=6)
names(DA_Z) <- ms_tab[rownames(sig_driver),'geneSymbol']
draw.funcEnrich.cluster(funcEnrich_res=res1,top_number=30,gs_cex = 0.5,
                       gene_cex=0.9,pv_cex=0.8,inner_color=DA_Z)
draw.funcEnrich.cluster(funcEnrich_res=res1,top_number=10,gs_cex = 0.6,
                       gene_cex=1,pv_cex=1,
                       cluster_gs=TRUE,cluster_gene = TRUE)
draw.funcEnrich.cluster(funcEnrich_res=res1,top_number=15,gs_cex = 0.8,
                       gene_cex=0.9,pv_cex=0.8,
                       cluster_gs=TRUE,cluster_gene = FALSE)
draw.funcEnrich.cluster(funcEnrich_res=res1,top_number=20,gs_cex = 0.8,
                        gene_cex=0.9,pv_cex=0.8,
                        cluster_gs=FALSE,cluster_gene = TRUE)
draw.funcEnrich.cluster(funcEnrich_res=res1,top_number=20,gs_cex = 1,
                        gene_cex=1,pv_cex=0.8,
                        cluster_gs=FALSE,cluster_gene = FALSE)
## 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
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)
gs.preload(use_spe='Homo sapiens',update=FALSE)
res1 <- funcEnrich.Fisher(input_list=ms_tab[rownames(sig_driver),'geneSymbol'],
                          bg_list=ms_tab[,'geneSymbol'],
                          use_gs=c('H','C5'),Pv_thre=0.1,Pv_adj = 'none')
analysis.par$out.dir.PLOT <- getwd() ## directory for saving the pdf files
draw.funcEnrich.cluster(funcEnrich_res=res1,top_number=30,gs_cex = 0.8,
                        gene_cex=0.9,pv_cex=0.8,
                        pdf_file = sprintf('%s/funcEnrich_cluster.pdf',
                        analysis.par$out.dir.PLOT))
draw.funcEnrich.cluster(funcEnrich_res=res1,top_number=30,gs_cex = 1.4,
                        gene_cex=1.5,pv_cex=1.2,
                        pdf_file = sprintf('%s/funcEnrich_clusterBOTH.pdf',
                        analysis.par$out.dir.PLOT),
                        cluster_gs=TRUE,cluster_gene = TRUE)
draw.funcEnrich.cluster(funcEnrich_res=res1,top_number=30,gs_cex = 0.8,
                        gene_cex=0.9,pv_cex=0.8,
                        pdf_file = sprintf('%s/funcEnrich_clusterGS.pdf',
                        analysis.par$out.dir.PLOT),
                        cluster_gs=TRUE,cluster_gene = FALSE)
draw.funcEnrich.cluster(funcEnrich_res=res1,top_number=30,gs_cex = 0.8,
                        gene_cex=0.9,pv_cex=0.8,
                        pdf_file = sprintf('%s/funcEnrich_clusterGENE.pdf',
                        analysis.par$out.dir.PLOT),
                        cluster_gs=FALSE,cluster_gene = TRUE)
draw.funcEnrich.cluster(funcEnrich_res=res1,top_number=30,gs_cex = 1.5,
                        gene_cex=1.4,pv_cex=1.2,
                        pdf_file = sprintf('%s/funcEnrich_clusterNO.pdf',
                        analysis.par$out.dir.PLOT),
                        cluster_gs=FALSE,cluster_gene = FALSE)

## End(Not run)

jyyulab/NetBID documentation built on Dec. 23, 2024, 6:34 a.m.