#' Read FACETS CNV Segments
#'
#' Reads the output by the FACETS `emcncf` function and exports the `cncf`
#' CNV segment coordinates.
#'
#' @param facets Path to FACETS `emcncf` text file.
#' @return A dataframe (`tibble`) with the following columns:
#' * chrom: chromosome
#' * start: start coordinate
#' * end: end coordinate
#' * tot_cn: total copy number estimate
#'
#' @examples
#' cn <- system.file("extdata", "HCC2218_facets_cncf.tsv", package = "pebbles")
#' prep_facets_seg(cn)
#'
#' @export
prep_facets_seg <- function(facets) {
stopifnot(file.exists(facets))
cnv <- readr::read_tsv(facets, col_types = "cddddddddiiddd") %>%
dplyr::select(.data$chrom, .data$start, .data$end, .data$tcn.em) %>%
dplyr::rename(tot_cn = .data$tcn.em) %>%
dplyr::filter(.data$chrom != "MT") %>%
dplyr::mutate(chrom = dplyr::case_when(
.data$chrom == "23" ~ "X",
TRUE ~ .data$chrom))
structure(list(cnv = cnv), class = "cnv")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.