R/define-class.R

#' Survival Cliques Class
#' 
#' Class to describe and represent survival analysis on modules
#' 
#' For internal use only
#' 
#' @slot alphas Object of class \code{"numeric"}. It contains pvalues of the cliques/modules
#' @slot zlist Object of class \code{"list"}. For each cliques, the list of pvalues for all the covariates
#' @slot cliques Object of class \code{"list"}. The list of the genes in the cliques
#' @slot coxObjs Object of class \code{"list"}. For each cliques, the object used for Coxph analysis
#' @slot cliquesLoadings Object of class \code{"list"}. For each cliques, the loadings as calculated by the PCA
#' @slot cliquesExpr Object of class \code{"list"}. For each cliques, the cliques expression
#' 
#' @rdname survClasses
#' @examples 
#' showClass("survCliques")
#' 
survCliques <- setClass("survCliques", package = "survClip",
                    slots = c(alphas  = "numeric",
                              zlist   = "list", 
                              cliques = "list",
                              coxObjs = "list",
                              cliquesLoadings = "list",
                              cliquesExpr = "list"))

setMethod("show",
          signature = "survCliques",
          definition = function(object) {
            sthis <- seq_len(min(length(object@alphas), 3))
            sthis <- order(object@alphas)[sthis]
            
            sigCliquesIdx = which(object@alphas <= 0.05)
            
            for (i in sthis) {
              cat(paste0("Cliques ",i, ": pvalue ", object@alphas[i], "\n"))
              cat("Clique is composed by the followings:\n")
              cat(paste(object@cliques[[i]], collapse=", "))
              cat("\n-+-\n")
            }
            
            if (length(sthis) < length(sigCliquesIdx)) {
              cat(paste0("There are other ", length(sigCliquesIdx)-length(sthis), " cliques with pvalue <= 0.05"))
            }
              
            invisible(NULL)
          })


#' Survival Cliques Class
#' 
#' Class to describe and represent survival analysis on modules
#' 
#' For internal use only
#' 
#' @slot pvalue Object of class \code{"numeric"}. It contains the pvalue of the whole model generated by the analysis
#' @slot zlist Object of class \code{"numeric"}. vector of pvalues for all the covariates
#' @slot coxObj Object of class \code{"data.frame"}. The object used for Coxph analysis
#' @slot loadings Object of class \code{"matrix"}. The loadings as calculated by the PCA
#' @slot method Object of class \code{"character"}. Type of method used
#' 
#' @rdname survClasses
#' @examples 
#' showClass("survPath")
#' 
survPath <- setClass("survPath", package = "survClip",
                     slots = c(pvalue = "numeric",
                               zlist = "numeric",
                               coxObj = "data.frame",
                               loadings = "matrix",
                               method  = "character"))

setMethod("show",
          signature = "survPath",
          definition = function(object) {
            cat(paste0("Pathway processed with ", object@method, " method\n   pvalue: ", object@pvalue, "\n"))
            invisible(NULL)
          })
cavei/survClip documentation built on June 19, 2019, 8:46 p.m.