R/getEmapInput_many.R

Defines functions getEMapInput_many

Documented in getEMapInput_many

#' Wrapper to generate multiple EnrichmentMaps (perhaps one per class)
#'
#' @param featScores (list) keys are classes, and values are data.frames of
#' network scores across cross-validation (output of getFeatScores()).
#' @param namedSets_valid (list) Grouped unit variables limited to the
#' units contained in the dataset. e.g. keys are pathways and values are
#' the genes measured in this dataset.
#' e.g.:
#' $`MISSPLICED_GSK3BETA_MUTANTS_STABILIZE_BETA-CATENIN`
#' [1] 'PPP2R5E' 'PPP2CB'  'APC'     'AXIN1'   'PPP2R1B' 'PPP2R1A' 'CSNK1A1'
#' [8] 'PPP2R5D' 'PPP2R5C' 'PPP2R5B' 'PPP2R5A' 'PPP2CA'  'GSK3B'
#' @param netTypes (data.frame) 'inputNets.txt' file
#' generated by NetDx. Dataframe has two columns, network type and
#' network  name. I.E:
#'  clinical                                          clinical
#'       rna GUANOSINE_NUCLEOTIDES__I_DE_NOVO__I__BIOSYNTHESIS
#'       rna                              RETINOL_BIOSYNTHESIS
#' @param outDir (char) path to output directory
#' @param ... parameters for getEMapInput()
#' @examples
#' data(featScores)
#' 
#' pathwayList <- readPathways(fetchPathwayDefinitions("October",2020))
#' pathwayList <- pathwayList[seq_len(5)]
#' 
#' netInfoFile <- system.file("extdata","example_output/inputNets.txt",package="netDx")
#' netTypes <- read.delim(netInfoFile,sep='\t',h=FALSE,as.is=TRUE)
#' outDir <- paste(tempdir(),'plots',sep='/')
#' if (!file.exists(outDir)) dir.create(outDir)
#' EMap_input <- getEMapInput_many(featScores,pathwayList,
#'      netTypes,outDir=outDir)
#' @return (list) of length g, where g is the number of groups in featScores.
#' Values are lists, corresponding to the output of getEmapInput.R
#' @export
getEMapInput_many <- function(featScores, namedSets_valid, netTypes, 
		outDir, ...) {
    
    out <- list()
    for (gp in names(featScores)) {
        cur_out_files <- getEMapInput(featScores[[gp]], namedSets_valid, 
					netTypes,  ...)
        out[[gp]] <- cur_out_files
        
    }
    return(out)
}
BaderLab/netDx documentation built on Sept. 26, 2021, 9:13 a.m.