draw.funcEnrich.bar: Bar Plot for Gene Set Enrichment Analysis Result

View source: R/pipeline_functions.R

draw.funcEnrich.barR Documentation

Bar Plot for Gene Set Enrichment Analysis Result

Description

draw.funcEnrich.bar draws a horizontal bar plot to visualize the gene set enrichment analysis. Users can choose to display P-values and the top intersected genes from each gene set.

Usage

draw.funcEnrich.bar(
  funcEnrich_res = NULL,
  top_number = 30,
  Pv_col = "Ori_P",
  item_col = "Intersected_items",
  Pv_thre = 0.1,
  display_genes = FALSE,
  name_col = "#Name",
  gs_cex = 0.5,
  gene_cex = 0.5,
  main = "",
  bar_col = brewer.pal(8, "RdBu")[7],
  eg_num = 5,
  pdf_file = NULL
)

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".

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.

display_genes

logical, if TRUE, the intersected genes will be displayed. Default is FALSE.

name_col

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

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.5.

main

character, an overall title for the plot.

bar_col

character, the color code used to plot the bars. Default is brewer.pal(8,'RdBu')[7].

eg_num

numeric, the number of intersected gene symbols to display on the right side of the bar. Default is 5.

pdf_file

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

Value

Return a logical value. If TRUE, the plot has been created successfully.

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.bar(funcEnrich_res=res1,top_number=5,
                   main='Function Enrichment for Top drivers',
                   gs_cex=0.4,gene_cex=0.5)
draw.funcEnrich.bar(funcEnrich_res=res1,top_number=3,
                   main='Function Enrichment for Top drivers',
                   display_genes = TRUE,eg_num=3,
                   gs_cex=0.3,gene_cex=0.3)
## 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.bar(funcEnrich_res=res1,top_number=30,
                    main='Function Enrichment for Top drivers',
                    pdf_file=sprintf('%s/funcEnrich_bar_nogene.pdf',
                    analysis.par$out.dir.PLOT))
draw.funcEnrich.bar(funcEnrich_res=res1,top_number=30,
                    main='Function Enrichment for Top drivers',
                    display_genes = TRUE,gs_cex=0.6,
                    pdf_file=sprintf('%s/funcEnrich_bar_withgene.pdf',
                    analysis.par$out.dir.PLOT))

## End(Not run)

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