out2excel: Save the Master Table into Excel File

View source: R/pipeline_functions.R

out2excelR Documentation

Save the Master Table into Excel File

Description

out2excel is a function can save data frame as Excel File. This is mainly for the output of master table generated by generate.masterTable.

Usage

out2excel(
  all_ms_tab,
  out.xlsx,
  mark_gene = NULL,
  mark_col = NULL,
  mark_strategy = "color",
  workbook_name = "ms_tab",
  only_z_sheet = FALSE,
  z_column = NULL,
  sig_thre = 1.64
)

Arguments

all_ms_tab

list or data.frame, if data.frame, it is generated by generate.masterTable. If list, each list element is data.frame/master table. The name of the list element will be the sheet name in the excel file.

out.xlsx

character, path and file name of the output Excel file.

mark_gene

list, list of marker genes. The name of the list element is the marked group name. Each element is a vector of marker genes. This is optional, just to add additional information to the file.

mark_col

character, the color to mark the marker genes. If NULL, will use get.class.color to get the colors.

mark_strategy

character, users can choose between "color" and "add_column". "Color" means the mark_gene will be marked by filling its background color; "add_column" means the mark_gene will be displayed in a separate column with TRUE/FALSE, indicating whether the gene belongs to a mark group or not.

workbook_name

character, name of the workbook for the output Excel. Default is "ms_tab".

only_z_sheet

logical, if TRUE, will create a separate sheet only contains Z-statistics related columns from DA/DE analysis. Default is FALSE.

z_column

character, name of the columns contain Z-statistics. If NULL, find column names start with "Z.". Default is NULL.

sig_thre

numeric, threshold for the Z-statistics. Z values passed the threshold will be colored. The color scale is defined by z2col. Default is 1.64.

Value

Return a logical value. If TRUE, the Excel file has been generated successfully.

Examples

## 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 ## this is master table generated before
mark_gene <- list(WNT=c('WIF1','TNC','GAD1','DKK2','EMX2'),
                 SHH=c('PDLIM3','EYA1','HHIP','ATOH1','SFRP1'),
                 Group3=c('IMPG2','GABRA5','EGFL11','NRL','MAB21L2','NPR3','MYC'),
                 Group4=c('KCNA1','EOMES','KHDRBS2','RBM24','UNC5D'))
mark_col <- get.class.color(names(mark_gene),
            pre_define=c('WNT'='blue','SHH'='red',
            'Group3'='yellow','Group4'='green'))
outfile <- 'test_out.xlsx'
out2excel(ms_tab,out.xlsx = outfile,mark_gene,mark_col)

## End(Not run)

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