R/removeSequences.R

Defines functions removeSequences

Documented in removeSequences

#' @title Remove Sequences
#' @description Remove sequences not used by samples.
#'   
#' @param g a \linkS4class{gtypes} object.
#' 
#' @return a new \linkS4class{gtypes} object with unused sequences removed.
#' 
#' @author Eric Archer \email{eric.archer@@noaa.gov}
#' 
#' @export
#' 
removeSequences <- function(g) {
  if(is.null(getSequences(g))) return(g)
  haps <- getAlleleNames(g)
  g@sequences <- g %>% 
    getLociNames() %>% 
    purrr::map(function(x) getSequences(g)[[x]][haps[[x]]]) %>% 
    stats::setNames(names(haps)) %>% 
    as.multidna()
  g
}
  
  

Try the strataG package in your browser

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

strataG documentation built on Feb. 28, 2020, 9:07 a.m.