#' Table creation for sequences
#'
#' Build a contingency table of the counts at each position of sequences.
#'
#' @docType methods
#' @name tableSeqs
#' @rdname tableSeqs
#'
#' @param sequences A character vector with the same length of sequences.
#' @param len Integer, specifying the read length.
#' @return A data frame.
#' @author Wubing Zhang
#' @export
#'
tableSeqs <- function(sequences, len = nchar(sequences[1])){
sequences = sequences[nchar(sequences)==len]
tmp = matrix(unlist(strsplit(sequences, "")), ncol = len, byrow = TRUE)
items = unique(c(tmp))
gg = t(apply(tmp, 2, function(x) table(x)[items]))
colnames(gg) = items
gg[is.na(gg)] = 0
gg = as.data.frame(gg)
return(gg)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.