R/getBiomarker.R

Defines functions getBiomarker

Documented in getBiomarker

#' Given a list of genes and a SCtkExperiment object, return
#' the binary or continuous expression of the genes.
#'
#' @param gene gene list
#' @param binary "Binary" for binary expression or "Continuous" for a gradient.
#' Default: "Binary"
#' @param inSCE Input SCtkExperiment object. Required
#' @param useAssay Indicate which assay to use. The default is "counts".
#'
#' @return getBiomarker(): A data.frame of expression values
#' @export
#' @examples
#' getBiomarker(mouseBrainSubsetSCE, gene="C1qa")
#'
getBiomarker <- function(inSCE, gene, binary="Binary", useAssay="counts"){
  # Get sample names
  sample <- colnames(inSCE)
  # Get counts for gene in sample
  c <- SummarizedExperiment::assay(inSCE, useAssay)[c(gene), ]
  # If color scale is "yes"/"no"
  if (binary == "Binary"){
    expression <- c > 0
  } else if (binary == "Continuous"){
    expression <- c
  }
  # Make data frame with sample, counts
  bio <- data.frame(sample, expression)
  colnames(bio) <- c("sample", gene)
  return(bio)
}
mmkhan19/singleCellTK documentation built on March 22, 2022, 7:43 a.m.