draw.categoryValue: Scatter Box Plot of Driver's Expression Values and Activity...

View source: R/pipeline_functions.R

draw.categoryValueR Documentation

Scatter Box Plot of Driver's Expression Values and Activity Values across Subgroup of Samples

Description

draw.categoryValue draws a scatter box plot to visualize one selected driver's expression value and activity value across different phenotype subgroups of samples. Two side-by-side scatter box plots will be created. The left plot shows driver's activity values in different phenotype subgroups, each point is a sample. The right plot shows driver's expression value in different phenotype subgroups, each point is a sample.

Usage

draw.categoryValue(
  ac_val = NULL,
  exp_val = NULL,
  use_obs_class = NULL,
  category_color = NULL,
  stripchart_color = get_transparent("black", 0.7),
  strip_cex = 1,
  class_order = NULL,
  class_srt = 90,
  class_cex = 1,
  pdf_file = NULL,
  main_ac = "",
  main_exp = "",
  main_cex = 1,
  use_color = NULL,
  pre_define = NULL
)

Arguments

ac_val

a vector of numerics, the activity values of the selected driver across all samples.

exp_val

a vector of numerics, the expression values of the selected driver across all samples.

use_obs_class

a vector of characters, the category of sample. The order of samples here must match the order in ac_val and exp_val. Users can call get_obs_label to create this vector.

category_color

a vector of characters, a vector of color codes for each category in class_order. If NULL, will call get.class.color to create the vector. Default is NULL.

stripchart_color

character, the color of the scatter of points. Default is "black" with transparency alpha equals 0.7.

strip_cex

numeric, giving the amount by which the size of scattered points should be magnified relative to the default. Default is 1.

class_order

a vector of characters, the order of catefory (subgroup). If NULL, will use the alphabetical order of the category (subgroup). Default is NULL.

class_srt

numeric, rotation angle of the column labels (subgroup labels) at the bottom of the box plot. Default is 90.

class_cex

numeric, giving the amount by which the text of category (subgroup) labels should be magnified relative to the default. Default is 1.

pdf_file

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

main_ac

character, the main title of the plot to show activity values. Default is "".

main_exp

character, the main title of the plot to show expression values. Default is "".

main_cex

numeric, giving the amount by which the text of the main title should be magnified relative to the default. Default is 1.

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.

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)
driver_list <- rownames(sig_driver)
use_driver <- driver_list[3]
exp_mat <- Biobase::exprs(analysis.par$cal.eset)
## expression,the rownames could match originalID
ac_mat  <- Biobase::exprs(analysis.par$merge.ac.eset)
## activity,the rownames could match originalID_label
phe_info <- Biobase::pData(analysis.par$cal.eset)
use_obs_class <- get_obs_label(phe_info = phe_info,'subgroup')
draw.categoryValue(ac_val=ac_mat[use_driver,],
                   exp_val=exp_mat[ms_tab[use_driver,'originalID'],],
                   use_obs_class=use_obs_class,
                   class_order=c('WNT','SHH','G4'),
                   class_srt=30,
                   main_ac = ms_tab[use_driver,'gene_label'],
                   main_exp=ms_tab[use_driver,'geneSymbol'],
                   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
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)
driver_list <- rownames(sig_driver)
use_driver <- driver_list[3]
exp_mat <- Biobase::exprs(analysis.par$cal.eset)
## rownames could match originalID
ac_mat  <- Biobase::exprs(analysis.par$merge.ac.eset)
## rownames could match originalID_label
phe_info <- Biobase::pData(analysis.par$cal.eset)
use_obs_class <- get_obs_label(phe_info = phe_info,'subgroup')
analysis.par$out.dir.PLOT <- getwd() ## directory for saving the pdf files
draw.categoryValue(ac_val=ac_mat[use_driver,],
                   exp_val=exp_mat[ms_tab[use_driver,'originalID'],],
                   use_obs_class=use_obs_class,
                   class_order=c('WNT','SHH','G4'),
                   class_srt=30,
                   main_ac = ms_tab[use_driver,'gene_label'],
                   main_exp=ms_tab[use_driver,'geneSymbol'],
                   pdf_file=sprintf('%s/categoryValue_demo1.pdf',
                   analysis.par$out.dir.PLOT))

## End(Not run)

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