R/internals.R

Defines functions delete_gap_cols as_character_matrix

as_character_matrix <- function(x){
  res <- stringr::str_split(x, "")
  do.call(rbind, res)
}


# Delete columns with at least one gap
# Return character vector
delete_gap_cols <- function(x) {
  x_mat <- as_character_matrix(x)
  sel <- apply(x_mat, 2, function(x) any(x == "-"))
  res <- x_mat[, !sel]
  res <- apply(res, 1, paste, collapse = "")
  return(res)
}

Try the bioseq package in your browser

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

bioseq documentation built on Sept. 6, 2022, 5:07 p.m.