Skip to content

Commit

Permalink
combineSeqs
Browse files Browse the repository at this point in the history
  • Loading branch information
noriakis committed Jun 20, 2024
1 parent 8b41dcf commit 615e880
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
16 changes: 14 additions & 2 deletions R/combineSeqs.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,28 @@
#' @param species species ID
#' @param argList args to passed to consensusSeq
#' @param output_seq output just the sequence
#' @param minor_align minor allele alignment
#' @export
#' @return new stana object
combineSeqs <- function(stana_list, species, argList=list(), output_seq=FALSE) {
combineSeqs <- function(stana_list, species, argList=list(), output_seq=FALSE,
minor_align=FALSE) {
if (!is.list(stana_list)) {stop("Please provide list of stana object")}
each_ID <- lapply(stana_list, function(x) x@snpsInfo[[species]] |> row.names())
each_ID <- lapply(stana_list, function(x) {
if (minor_align) {
ids <- paste0(row.names(x@snpsInfo[[species]]), ":minor", x@snpsInfo[[species]]$minor_allele)
} else {
ids <- x@snpsInfo[[species]] |> row.names()
}
return(ids)
})
intersected <- Reduce(intersect, each_ID)
if (length(intersected)==0) {stop("No common SNVs")}

qqcat("Common SNVs: @{length(intersected)}\n")
argList[["return_mat"]] <- TRUE
if (minor_align) {
intersected <- strsplit(intersected, ":minor") %>% lapply("[", 1) %>% unlist()
}
argList[["site_list"]] <- intersected

passList <- list()
Expand Down
10 changes: 9 additions & 1 deletion man/combineSeqs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 615e880

Please sign in to comment.