R/addClusterCols.R

Defines functions markClusterCol

Documented in markClusterCol

#' @include utilities.R
#'
NULL



#' markClusterCol
#' 
#' A function to mark the columns containing cluster information in the metadata
#' or colData of a Seurat or SCE object. Columns are marked with "cluster_" 
#' prefix.
#' @param object Either a Seurat or SCE object containing clustering information
#' @param pattern pattern indicating which columns contain cluster information
#' @return A Seurat or SCE object
#' @examples 
#' SeuratObj <- readRDS(file.path(system.file(package = "Spaniel"), 
#'                                 "extdata/SeuratData.rds"))
#' SeuratObj <- markClusterCol(SeuratObj, "res")
#' @export
markClusterCol <- function(object, pattern) {
    metaData <- getMetadata(object)
    whichCols <- grep(pattern, colnames(metaData))
    colnames(metaData)[whichCols] <- paste0("cluster_",
                                            colnames(metaData)[whichCols])
    object <- updateMetadata(metaData, object)
    return(object)
}

Try the Spaniel package in your browser

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

Spaniel documentation built on Nov. 8, 2020, 5:54 p.m.