R/magma_read_sets_out.R

Defines functions magma_read_sets_out

Documented in magma_read_sets_out

#' MAGMA: read sets.out 
#' 
#' Read a sets.out file generated by MAGMA enrichment tests.
#' 
#' @param out_prefix Out file path prefix.
#' @inheritParams calculate_celltype_associations
#' 
#' @keywords internal
magma_read_sets_out <- function(out_prefix,
                                verbose = TRUE){  
    sets.out <- sprintf("%s.sets.out",out_prefix)
    sets.out <- get_actual_path(sets.out)
    if(file.exists(sets.out)){
        messager("Reading sets out info from .set.out file.",
                 v=verbose) 
        res <- utils::read.table(file = fix_path(sets.out),
                                  header = TRUE,
                                  stringsAsFactors = FALSE) 
    } else {
        messager("Reading sets out info from .gsa.out file.",
                 v=verbose)
        #### Not totally sure if this is right
        path <- sprintf("%s.gsa.out", out_prefix)
        path <- get_actual_path(path)
        res <- utils::read.table(file = fix_path(path),
                                  header = TRUE,
                                  stringsAsFactors = FALSE)
        res <- res[(res$TYPE == "SET") & (res$MODEL == 1), ]
    }
    return(res)
}
neurogenomics/MAGMA_Celltyping documentation built on Oct. 12, 2024, 12:36 a.m.