R/ctgGEMset-class.R

Defines functions ctgGEMset

Documented in ctgGEMset

#' The ctgGEMset class
#'
#' The main class used by the \pkg{cellTreeGenerator} package to hold single
#' cell gene expression data and generated tree results.  ctgGEMset extends the
#' [SummarizedExperiment::SummarizedExperiment-class] class.
#'
#' This class is initialized from a matrix of gene expression values and
#' associated metadata.  Methods that operate on ctgGEMset objects
#' comprise the ctgGEM workflow.
#'
#'
#' @field monocleInfo A character vector of parameters used by
#'     \code{generate_tree(treeType = "monocle")} in the
#'     \pkg{cellTreeGenerator} workflow
#' @field TSCANinfo A character vector of the row name of a single gene in
#'     \code{exprsData()} to use for a single gene vs. pseudotime plot for
#'     \code{generate_tree(treeType = "TSCAN")} in the
#'     \pkg{cellTreeGenerator} workflow
#' @field sincellInfo A list containing named parameters used by
#'     \code{generate_tree(treeType = "sincell")} in the
#'     \pkg{cellTreeGenerator} workflow
#' @field treeList A list containing the simplified igraph representation of
#'     the trees generated by the \pkg{ctgGEM} workflow
#' @field originalTrees A list containing the trees generated by the
#'     \pkg{ctgGEM} workflow in their original formats for re-plotting
#' @name ctgGEMset
#' @rdname ctgGEMset
#' @aliases ctgGEMset-class
#' @exportClass ctgGEMset
#' @import SummarizedExperiment
#' @examples
#' # load HSMMSingleCell package
#' library(HSMMSingleCell)
#'
#' # load the data
#' data(HSMM_expr_matrix)
#' data(HSMM_sample_sheet)
#' data(HSMM_gene_annotation)
#'
#' # construct a ctgGEMset
#' dataSet <- ctgGEMset(exprsData = HSMM_expr_matrix,
#'                         phenoData = HSMM_sample_sheet,
#'                         featureData = HSMM_gene_annotation)

.ctgGEMset <- setClass(
    "ctgGEMset",
    contains="SummarizedExperiment",
    slots = representation(
        monocleInfo = "list",
        TSCANinfo = "character",
        sincellInfo = "list",
        treeList = "list",
        originalTrees = "list"
    )
)

#' Creates a new ctgGEMset object.
#'
#' @param exprsData expression data matrix for an experiment
#' @param phenoData a data frame containing attributes of individual samples
#' @param featureData a data frame containing attributes of features (genes)
#' @return a new ctgGEMset object
#' @import SummarizedExperiment
#' @export
#' @examples
#' # load HSMMSingleCell package
#' library(HSMMSingleCell)
#'
#' # load the data
#' data(HSMM_expr_matrix)
#' data(HSMM_sample_sheet)
#' data(HSMM_gene_annotation)
#'
#'
#' # construct a ctgGEMset
#' dataSet <- ctgGEMset(exprsData = HSMM_expr_matrix,
#'                         phenoData = HSMM_sample_sheet,
#'                         featureData = HSMM_gene_annotation)
ctgGEMset <- function(exprsData, phenoData=NULL, featureData=NULL)
{
    if (!is(exprsData, "matrix")) {
        stop("argument exprsData must be a matrix")
    }
    se <- SummarizedExperiment(assays = list(exprsData),
                                rowData = featureData,
                                colData = phenoData)
    .ctgGEMset(se)
}
bicbioeng/ctgGEM documentation built on Sept. 5, 2021, 8:42 p.m.