R/ReadBeta.R

Defines functions ReadBeta

Documented in ReadBeta

#' Read gene beta scores
#'
#' Read gene beta scores from file or data frame
#'
#' @docType methods
#' @name ReadBeta
#' @rdname ReadBeta
#' @aliases readbeta
#'
#' @param gene_summary A data frame or a file path to gene summary file generated by MAGeCK-MLE.
#'
#' @return A data frame, whose first column is Gene and other columns are comparisons.
#'
#' @author Wubing Zhang
#'
#' @examples
#' file3 = file.path(system.file("extdata", package = "MAGeCKFlute"),
#' "testdata/mle.gene_summary.txt")
#' dd = ReadBeta(file3)
#' head(dd)
#'
#' @export
ReadBeta <- function(gene_summary){
  if(is.null(dim(gene_summary))){
    gene_summary = read.table(file = gene_summary, sep = "\t", header = TRUE, quote = "",
                              comment.char = "", check.names = FALSE, stringsAsFactors = FALSE)
  }
  dd = gene_summary
  if(sum(grepl("beta$", colnames(dd)))>0){
    dd = dd[, c(1, which(grepl("beta$", colnames(dd))))]
    names(dd) = gsub(".beta", "", names(dd))
  }
  return(dd)
}

Try the MAGeCKFlute package in your browser

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

MAGeCKFlute documentation built on Nov. 8, 2020, 5:40 p.m.