Plotting protein position weighted matrices in seqLogo and DiffLogo
3
0
Entering edit mode
jeffb • 0
@jeffb-11108
Last seen 7.8 years ago
University of Massachusetts Amherst

Hi,

I am trying to plot protein position weighted matrices in seqLogo and DiffLogo and seem to be have a similar problem in which the correct letter for the amino acid is not displayed properly in the plot.  It works fine for DNA sequences, but not proteins. 

Cheers, Jeff

library(Biostrings)
library(seqLogo)

#Logo of DNA alignment
sequences <- c("ATCCG","TACCG","AACGC")
pwm1 <- consensusMatrix(sequences, as.prob = TRUE)
pwm1
seqLogo(pwm = pwm1)

#Logo of protein alignment
sequences <- c("SCPCA", "PCPTQ", "ECPCQ")
pwm2 <- consensusMatrix(sequences, as.prob = TRUE)
pwm2
seqLogo(pwm=pwm2, alphabet=ASN)

 

 

 

seqlogo DiffLogo • 1.5k views
ADD COMMENT
0
Entering edit mode

Values for all 20 amino acids need to be in the matrix to plot correctly.

ADD REPLY
0
Entering edit mode
Ou, Jianhong ★ 1.3k
@ou-jianhong-4539
Last seen 8 hours ago
United States

Hi,

Package motifStack can plot for proteins. I am sorry for annoying you when I mention motifStack here.

Please have a try:

library(Biostrings)
library(seqLogo)
library(motifStack)
#Logo of DNA alignment
sequences <- c("ATCCG","TACCG","AACGC")
pwm1 <- consensusMatrix(sequences, as.prob = TRUE)
pwm1
seqLogo(pwm = pwm1)

#Logo of protein alignment
sequences <- c("SCPCA", "PCPTQ", "ECPCQ")
pwm2 <- consensusMatrix(sequences, as.prob = TRUE)
pwm2
#seqLogo(pwm=pwm2, alphabet=ASN)
pfm2 <- new("pfm", mat=pwm2, name="pwm2", alphabet="AA")
plot(pfm2)
ADD COMMENT
0
Entering edit mode
jeffb • 0
@jeffb-11108
Last seen 7.8 years ago
University of Massachusetts Amherst

Thanks!  This above works fine for plotting using motifStack instead of seqLogo.  I love the different plots in the motifStack Vignette.  

Our immediate need is to compare 2 pwms which DiffLogo is designed to do.  We can do this if all 20 AA's are present in the alignment as in the below example, but if the matrix contains less than 20 AA then it will not plot correctly.  Can stackMotif do something similar?

Thanks, Jeff

library(Biostrings)
library(seqLogo)
library(DiffLogo)

alignment1 <- c("ACDEEFGHIKLMNPQRSTVWY", "ACDEEFGHIKLMNPQRSTVWY", "ACDEEFGHIKLMNPQRSTVWY")
pwm1 <- consensusMatrix(alignment1, as.prob = TRUE)
seqLogo(pwm = pwm1, alphabet = ASN)

alignment2 <- c("ACDDEFGHIKLMNPQRSTVWY", "ACDDEFGHIKLMNPQRSTVWY", "ACDCEFGHIKLMNPQRSTVWY")
pwm2 <- consensusMatrix(alignment2, as.prob = TRUE)
seqLogo(pwm = pwm2, alphabet = ASN)

diffLogoFromPwm(pwm1 = pwm1, pwm2 = pwm2, alphabet = ASN)

ADD COMMENT
0
Entering edit mode

Hey Jeff,

I tried to reproduce the bug, but I miss the function consensusMatrix. Could it be that the problem lies there? How does consensusMatrix know which alphabet to use?

I tried it with the DiffLogo internal method getPwmFromAlignment(alignment1, ASN, 0) and it worked fine.

 

Best regards

 

Martin 

ADD REPLY
0
Entering edit mode
mgledi • 0
@mgledi-11295
Last seen 7.7 years ago

Hey Jeff,

I tried to reproduce the bug, but I miss the function consensusMatrix. Could it be that the problem lies there? How does consensusMatrix know which alphabet to use?

I tried it with the DiffLogos internal method getPwmFromAlignment(alignment1, ASN, 0) and it worked fine.

 

Best regards

 

Martin 

ADD COMMENT

Login before adding your answer.

Traffic: 662 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6