R/get_samples.R

Defines functions get_samples

Documented in get_samples

#' Title get_samples
#'
#' Used to get samples ID by searching interested gene from CNV annotation list.
#'
#' @param annotated_cnvlist CNV-gene annotated list, default format was generated by call_gene function.
#' @param gene_name Official gene name in text format.Standard parameter should set as gene_name = "GPB4".
#'
#' @import dplyr
#'
#' @return A datatable contain sample ID and CNV information
#' @export get_samples
#'
get_samples <- function(annotated_cnvlist, gene_name){

  if(typeof(annotated_cnvlist) == "character"){
    cnv_list <- read.table(file = annotated_cnvlist, header = T, sep = "\t")
  } else {
    cnv_list = annotated_cnvlist
  }

  gene_sample <- cnv_list %>%
                 filter(name2 == gene_name) %>%
                 select(Sample_ID, Chr, CNV_Start, CNV_End, Length, CNV_Value,name2)
  return(gene_sample)
}
JH-Zhou/HandyCNV documentation built on Dec. 18, 2021, 12:25 a.m.