R/summarize-tag.r

Defines functions summarize_tag

Documented in summarize_tag

#' Summarize the features in a gencode-derived tibble.
#'
#' summarize_tag returns a tibble containing the number of features included
#' in a tibble produced by genetable::import_gencode() (or similar) that are
#' annotated with the tag provided in the argument. Legal tags are listed at
#' https://www.gencodegenes.org/gencode_tags.html
#'
#'  
#' @param gtf A tibble containing gene definitions in the formate made by
#'   genetable::import_gencode()
#' @param tag The tag to summarize features by - a string.
#' @return A table containing the cross tabulation of features by tag.
#' @examples
#' \dontrun{
#' summarize_tag(gtf = gtf, tag = "basic")
#' }
#' @export

summarize_tag <- function(gtf, tag = "basic"){
  # check arguments
  if (missing(gtf)) stop("gtf not defined")
  if (!(tag %in% unique(gtf$tag))) stop ("tag not in gtf tibble")
  return(table(gtf$feature, gtf$tag == tag))
}
UW-GAC/genetable documentation built on May 5, 2019, 11:08 p.m.