draw.GSEA.NetBID.GS: Draw GSEA (gene set enrichment analysis) Plot with NetBID...

View source: R/pipeline_functions.R

draw.GSEA.NetBID.GSR Documentation

Draw GSEA (gene set enrichment analysis) Plot with NetBID Analysis of Gene Sets

Description

draw.GSEA.NetBID.GS creates a GSEA plot for gene sets with more NetBID analysis information. Such as, number of genes in each gene set, marking the rank of annotated genes in the differential expression profile and differential activity (DA) values.

Usage

draw.GSEA.NetBID.GS(
  DE = NULL,
  name_col = NULL,
  profile_col = NULL,
  profile_trend = "pos2neg",
  sig_gs_list = NULL,
  gs_DA_Z = NULL,
  use_gs2gene = NULL,
  top_gs_number = 30,
  target_col = "RdBu",
  left_annotation = "",
  right_annotation = "",
  main = "",
  profile_sig_thre = 0,
  Z_sig_thre = 1.64,
  pdf_file = NULL
)

Arguments

DE

data.frame, a data.frame created either by function getDE.limma.2G or getDE.BID.2G. Row names are gene names, columns must include the calculated differencial values (e.g. "ID", "logFC", "AveExpr", "P.Value" etc.).

name_col

character, the name of the column in DE contains gene names. If NULL, will use the row names of DE. Default is NULL.

profile_col

character, the name of the column in DE contains calculated differencial value (e.g. "logFC" or "P.Value"). If DE is created by getDE.limma.2G or getDE.BID.2G, this parameter should be set to "logFC" or "t".

profile_trend

character, users can choose between "pos2neg" and "neg2pos". "pos2neg" means high profile_col in target group will be shown on the left. "neg2pos" means high profile_col in control group will be shown on the left. Default is "pos2neg".

sig_gs_list

a vector of characters, the names of top gene sets.

gs_DA_Z

a vector of numerics, the Z-statistics of differentail activity (DA) values for the sig_gs_list. It is highly suggested to assign name to the vector, otherwise will use name of sig_gs_list.

use_gs2gene

list, contains elements of gene sets. Element name is gene set name, each element contains a vector of genes belong to that gene set. This list can be created by calling one element from all_gs2gene, or merge several gene sets into one by using merge_gs.

top_gs_number

integer, the number of top significant gene sets to be displayed. Default is 30.

target_col

character, name of the color palette used for display marker line in the panel. Users can choose between "black" and "RdBu". If "black", the marker line in the panel is black. If "RdBu", the marker line in the panel is Red to Blue. The color shade of the marker line is decided by each gene's significance of differentiation. High in red, low in blue. Default is "RdBu".

left_annotation

character, annotation on the left of profile curve, indicating high in control group or target group. Default is "".

right_annotation

character, annotation on the right of profile curve, indicating high in the opposite group of left_annotation. Default is "".

main

character, an overall title for the plot. Default is "".

profile_sig_thre

numeric, threshold value for target genes. This parameter works only when target_col_type is set as "DE" and target_col is set as "RdBu". Non-significant target genes will be colored grey. Default is 0.

Z_sig_thre

numeric, threshold value of Z-statistics from driver_DA_Z and driver_DE_Z. Significant values will have background color. Default is 1.64.

pdf_file

character, the file path to save figure 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

## Not run: 
db.preload(use_level='transcript',use_spe='human',update=FALSE)

## get all_gs2gene

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
comp <- 'G4.Vs.others'
DE <- analysis.par$DE[[comp]]
analysis.par$out.dir.PLOT <- getwd()

## directory for saving the pdf files
exp_mat_gene <- Biobase::exprs(analysis.par$cal.eset)

## calculate activity for all genesets
use_gs2gene <- merge_gs(all_gs2gene=all_gs2gene,
                       use_gs=c('H','CP:BIOCARTA','CP:REACTOME','CP:KEGG','C5'))
ac_gs <- cal.Activity.GS(use_gs2gene = use_gs2gene,cal_mat = exp_mat_gene)

## get DA for the gene set
phe_info <- Biobase::pData(analysis.par$cal.eset)
G0  <- rownames(phe_info)[which(phe_info$`subgroup`!='G4')]
# get sample list for G0
G1  <- rownames(phe_info)[which(phe_info$`subgroup`=='G4')]
# get sample list for G1
DA_gs <- getDE.limma.2G(eset=generate.eset(ac_gs),G1=G1,G0=G0,
                        G1_name='G4',G0_name='others')
## or use: DA_gs <- getDE.BID.2G(eset=generate.eset(ac_gs),G1=G1,G0=G0,
                        G1_name='G4',G0_name='others')
## draw vocalno plot for top sig-GS
sig_gs <- draw.volcanoPlot(dat=DA_gs,
                           label_col='ID',
                           logFC_col='logFC',
                           Pv_col='P.Value',
                           logFC_thre=0.25,
                           Pv_thre=1e-4,
                           main='Volcano Plot for gene sets',
                           show_label=TRUE,
                           label_type = 'distribute',
                           label_cex = 0.5,
                           pdf_file=sprintf('%s/vocalno_GS_DA.pdf',
                           analysis.par$out.dir.PLOT))
## GSEA plot for the significant gene sets
draw.GSEA.NetBID.GS(DE=DE,name_col='ID',
                    profile_col='t',profile_trend='pos2neg',
                    sig_gs_list = sig_gs$ID,
                    gs_DA_Z=DA_gs[sig_gs$ID,'Z-statistics'],
                    use_gs2gene = use_gs2gene,
                    top_gs_number=5,target_col='RdBu',
                    left_annotation = 'test_left',
                    right_annotation = 'test_right',
                    main='test',Z_sig_thre=1.64,profile_sig_thre = 0,
                    pdf_file=sprintf('%s/NetBID_GSEA_GS_demo1.pdf',
                    analysis.par$out.dir.PLOT))

## End(Not run)

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