R/cli-interface.R

Defines functions plink plink2 snptest gtool gcta

Documented in gcta gtool plink plink2 snptest

#' @title Genomic CLI Tools
#'
#' @description Simple wrappers to several common genomic tools.
#'
#' @param ... One or several expressions passed to the command-line tool.
#'
#' @details You may write the arguments as one string, or, if preferred, you may break the arguments in seperate strings which will be combined before the call to the CLI tool.
#'
#' Use \code{\link{setup_tools}} for help setting up your .Rprofile \code{options} to direct these functions to the location of the executables on your machine.
#'
#' \itemize{
#'   \item \strong{PLINK 1.9} - Click \href{http://www.cog-genomics.org/plink2/}{here} for more details.
#'   \item \strong{PLINK 2.0} - Click \href{http://www.cog-genomics.org/plink/2.0/}{here} for more details.
#'   \item \strong{SNPTEST} - Click \href{https://mathgen.stats.ox.ac.uk/genetics_software/snptest/snptest}{here} for more details.
#'   \item \strong{GTOOL} - Click \href{https://www.well.ox.ac.uk/~cfreeman/software/gwas/gtool.html}{here} for more details.
#'   \item \strong{GCTA} - Click \href{hhttp://cnsgenomics.com/software/gcta/#Overview}{here} for more details.
#' }
#'
#' @name cli
#' @export

#' @rdname cli
#' @export
plink <- function(...){
  plink <- getOption('plink.path', default = Sys.which('plink'))
  args <- paste(rlang::exprs(...), collapse = ' ')
  command <- glue::glue('{plink} {args}')
  cat(command)
  system(command)
}

#' @rdname cli
#' @export
plink2 <- function(...){
  plink2 <- getOption('plink2.path', default = Sys.which('plink2'))
  args <- paste(rlang::exprs(...), collapse = ' ')
  command <- glue::glue('{plink2} {args}')
  cat(command)
  system(command)
}

#' @rdname cli
#' @export
snptest <- function(...) {
  snptest <- getOption('snptest.path', default = Sys.which('snptest'))
  args <- paste(rlang::exprs(...), collapse = ' ')
  command <- glue::glue('{snptest} {args}')
  cat(command)
  system(command)
}

#' @rdname cli
#' @export
gtool <- function(...){
  gtool <- getOption('gtool.path', default = Sys.which('gtool'))
  args <- paste(rlang::exprs(...), collapse = ' ')
  command <- glue::glue('{gtool} {args}')
  cat(command)
  system(command)
}

#' @rdname cli
#' @export
gcta <- function(...){
  plink <- getOption('gcta.path', default = Sys.which('gcta'))
  args <- paste(rlang::exprs(...), collapse = ' ')
  command <- glue::glue('{gcta} {args}')
  cat(command)
  system(command)
}
mattwarkentin/genetools documentation built on Nov. 4, 2019, 6:19 p.m.