In R, Biostrings::PWM
can convert the Position Frequency Matrix to Position Weight Matrix (pfm to pwm). but the colsums of pwm is not 1. However, in seqLogo::makePWM
request a pwm with colsum is 1. What's the reason or wrong? Is there any other way to convert the pfm to pwm since seqLogo::makePWM
is of necessity for me. Thank you.
Update: Code as below.
library(Biostrings)
data(HNF4alpha)
pfm <- consensusMatrix(HNF4alpha)
#JASPAR_CORE/MA0002.2.pfm
pfm1 <- c(1387 , 2141,727,1517,56,0,0,62,346,3738,460,0,116
,1630,1060,1506,519,1199,5098,4762,1736,2729,236,0,0,1443
,851,792,884,985,3712,0,0,85,1715,920,4638,5098,3455
,1230,1105,1981,2077,131,0,336,3215,308,204,0,0,84)
pfm1 <- as.integer(pfm1)
pfm1 <- matrix(pfm1, nrow=4, ncol=13, byrow = TRUE)
rownames(pfm1) <- c("A", "C", "G", "T")
pfm[rownames(pfm1),] <- pfm1
pwm <- PWM(pfm)
colSums(pwm)
## 0.24534982 0.24245488 0.24187243 0.23899403 0.17464467 -0.15326904 -0.03531437 0.17292782 0.21962851 0.20141431 -0.03056159 -0.15326904 0.18119170
Hi, thanks for this. Did you find an answer to the issue above? Also, could you recommend the best way to obtain PWMs from the Jaspar collection of pfms?