R/get_human_chromosomes.R

Defines functions get_human_chromosomes

Documented in get_human_chromosomes

#' @title Get human chromosome data
#'
#' @description This is a simple function that produces the human chromosome information used in the Gadget into a desired format.
#'
#' @param ret
#' Bool, if T it returns the data to R
#' @param write
#' Bool, if T then returns the data to a file in the current wd (as .txt).
#' @param write_as
#' Name with .txt that specifies the file name if write == T.
#'
#' @import dplyr
#' @export
#'
#' @return A .txt file or a data.frame or both
#' @examples
#' \dontrun{
#' get_human_chromosomes()
#' }

#### Chromosomes

## Set up human chromosome base
get_human_chromosomes <- function(ret = F, write = T, write_as = "chromosomes.txt") {

  centromere_position <- c(125.0, 93.3, 91.0, 50.4,
                        48.4, 61.0, 59.9, 45.6,
                        49.0, 40.2, 53.7, 35.8,
                        17.9, 17.6, 19.0, 36.6,
                        24.0, 17.2, 26.5, 27.5,
                        13.2, 14.7, 60.6, 12.5)

  chromosome_length <- c(247.2, 242.8, 199.4, 191.3,
                       180.8, 170.9, 158.8, 146.3,
                       140.4, 135.4, 134.5, 132.3,
                       114.1, 106.3, 100.3, 88.8,
                       78.7, 76.1, 63.8, 62.4,
                       46.9, 49.5, 154.9, 57.5)

  chromosome_name <- c(as.character(1:22), "X", "Y")

  human_chromosomes <- dplyr::tibble(chromosome_name, chromosome_start = rep(1, 24),
                            chromosome_end = chromosome_length*1000000, centromere_position*1000000)

  if (write) {
    ## Save table for future use into current wd
    write.table(human_chromosomes, file = write_as, sep = "\t", quote = F,
            col.names = F, row.names = F)
  }

  if (ret) {

    return(human_chromosomes)

  }

}
lharris421/gdexpl documentation built on Dec. 23, 2019, 6:38 p.m.