R/activeModScoreHTML.R

Defines functions activeModScoreHTML

Documented in activeModScoreHTML

## Function to save HTML with scores from functional classification of gene
## groups
##
## Parameters: mod      -> object of class maigesActMod
##             dir      -> string giving the folder where to save the table
##             fileSave -> name of the file to be saved (without extension)
##
## Gustavo H. Esteves
## 27/05/07
##
##


activeModScoreHTML <- function(mod=NULL, dir="./", fileSave="scores") {


    ## Making some basic initial tests...
    if(is.null(data))
        stop("You MUST specify an object generated by activeMod function.")

    ## Adjusting the dir parameter
    tmp <- strsplit(dir, NULL)
    if (tmp[[1]][length(tmp[[1]])] != "/")
        dir <- paste(dir, "/", sep="")

    
    ##geting the information needed
    score <- mod@globalScore
    modules <- names(score)
    
    
    ## Saving HTML table
    idx <- which(apply(mod@modByCond != 0, 2, sum, na.rm=TRUE) != 0)
    if(length(idx) < 2)
        stop("Less than 2 elements present significant results!")
    
    target <- R2HTML::HTMLInitFile(outdir=dir, filename=fileSave)
    for (i in idx) {
        R2HTML::HTML(paste("<center><br><b>", modules[i], "</b></center>",
        sep=""), file=target)
        
        idxTmp <- sort(score[[i]][, 2], index.return=TRUE)$ix
        tmp <- score[[i]][idxTmp, ]
        R2HTML::HTML(tmp, digits=4, file=target)
        
    }
    
    R2HTML::HTMLEndFile()
    
}

Try the maigesPack package in your browser

Any scripts or data that you put into this service are public.

maigesPack documentation built on Nov. 8, 2020, 6:23 p.m.