#' Generate position weight matrix
#'
#' @docType methods
#' @name getPWM
#' @rdname getPWM
#'
#' @param sequences A vector of sequences.
#'
#' @return PWM (position weight matrix).
#'
#' @author Wubing Zhang
#'
#' @export
getPWM <- function(sequences){
tmp = matrix(unlist(strsplit(sequences, "")), ncol = nchar(sequences)[1], byrow = TRUE)
AAs = unique(as.character(tmp))
pwm = apply(tmp, 2, function(x) table(x)[AAs])
rownames(pwm) = AAs
colnames(pwm) = 1:nchar(sequences)[1]
pwm[is.na(pwm)] = 0
pwm = pwm / colSums(pwm)
return(pwm)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.