<p><em>answer from @M__, converted from <a href="https://bioinformatics.stackexchange.com/help/privileges/comment">comments</a>:</em></p>
<p>This has been answered on stackoverflow using matplotlib for seq logo plot:</p>
<p><a href="https://stackoverflow.com/questions/42615527/sequence-logos-in-matplotlib-aligning-xticks">https://stackoverflow.com/questions/42615527/sequence-logos-in-matplotlib-aligning-xticks</a></p>
<p>IMO its only useful for presentation, pretty pictures, thus there's no need for someone to write a library (which is what you're asking). If I'm using a mutation matrix (which I do), I want the raw numbers and significance values I don't want pretty graphs getting in the way.</p>
<p>Conceptually you would move from 2D to 1D, without subplots (which is doable), i.e. its a matrix. My view on code availability is not universal. I've had requests for separate CLIs (useful for someone clearly) ... which just never happened.</p>

CC BY-SA 4.0
2022-07-24T19:25:14.660Z
The solution proposed in the link is focused primarily on a tool that is captured as the pyseqlogo packet at the end. I have spent a good part of the day trying install the packet and get it to work, but to no avail it's failed with too many errors and complications to list :(.
Zebra Fish
CC BY-SA 4.0
2022-07-24T07:11:50.990Z
2022-07-24T23:21:58.127Z
2022-07-24T23:21:58.127Z
gringer
<p>After much searching and trial and error, located possibly the optimal tool for my question:</p>
<p><strong>seqlogo</strong></p>
<p><a href="https://github.com/betteridiot/seqlogo" rel="nofollow noreferrer">https://github.com/betteridiot/seqlogo</a></p>
<p>Surprisingly not only seqlogo is an elegant and minimal solution in Python (and R) I have discovered it has a relative implementation in MATLAB! It installed and worked the first try - beautiful output with all the output options I needed - rock solid.</p>
<p><strong>Python</strong> one liner (not counting the example pwm input generation)</p>
<p>random_ppm = np.random.dirichlet(np.ones(4), size=16)</p>
<p>ppm = seqlogo.Ppm(random_ppm)</p>
<p><strong>seqlogo.seqlogo(ppm  ,format='png',filename='out.png')</strong></p>
<p>Produces the following ('out.png')</p>
<p><a href="https://i.sstatic.net/hrIZJ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/hrIZJ.png" alt="enter image description here" /></a></p>
<p>And here is <strong>MATLAB</strong> Port:</p>
<p><a href="https://www.mathworks.com/help/bioinfo/ref/seqlogo.html" rel="nofollow noreferrer">https://www.mathworks.com/help/bioinfo/ref/seqlogo.html</a></p>
<p><a href="https://i.sstatic.net/Weeh9.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Weeh9.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2022-07-24T22:17:23.680Z
2022-07-24T23:10:17.103Z
2022-07-24T23:10:17.103Z
Zebra Fish
<p>Is there a MATLAB, or else Python (not R) tool for visualizing sequence Logos from probability weight matrices (PWMs)?</p>
<p>This seems like a basic and simple tool to implement, yet just above the threshold in the space of tedious to write my own from scratch - I was surprised I couldn't find a basic function like a</p>
<pre><code>visualizePWM(pwm_matrix) 
</code></pre>
<p>that would take a pwm_matrix that is a (4 by m) matrix and spit out the visualization of an m-length sequence motif/logo like:</p>
<p><a href="https://i.sstatic.net/Uf9QO.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Uf9QO.png" alt="enter image description here" /></a></p>
<p>I see all kinds of over-complicated bloated tools that I thought I ask in case I am missing something.</p>

<rna-seq><python><visualization><motifs><matlab>
PWM (4xM matrices) to Sequence Logo Visualizations in MATLAB or Python
# PWM (4xM matrices) to Sequence Logo Visualizations in MATLAB or Python

(Asked by: username_0 on 2022-07-22)

Is there a MATLAB, or else Python (not R) tool for visualizing sequence Logos from probability weight matrices (PWMs)?
This seems like a basic and simple tool to implement, yet just above the threshold in the space of tedious to write my own from scratch - I was surprised I couldn't find a basic function like a
visualizePWM(pwm_matrix) 

that would take a pwm_matrix that is a (4 by m) matrix and spit out the visualization of an m-length sequence motif/logo like:

I see all kinds of over-complicated bloated tools that I thought I ask in case I am missing something.

**Tags:** rna-seq, python, visualization, motifs, matlab

---

## 2 answers

### Answer by username_1 on 2022-07-24. Score: 1

*answer from @M\_\_, converted from [comments](https://bioinformatics.stackexchange.com/help/privileges/comment):*

This has been answered on stackoverflow using matplotlib for seq logo plot:

<https://stackoverflow.com/questions/42615527/sequence-logos-in-matplotlib-aligning-xticks>

IMO its only useful for presentation, pretty pictures, thus there's no need for someone to write a library (which is what you're asking). If I'm using a mutation matrix (which I do), I want the raw numbers and significance values I don't want pretty graphs getting in the way.

Conceptually you would move from 2D to 1D, without subplots (which is doable), i.e. its a matrix. My view on code availability is not universal. I've had requests for separate CLIs (useful for someone clearly) ... which just never happened.

> **Comments:**
> **username_0**: The solution proposed in the link is focused primarily on a tool that is captured as the pyseqlogo packet at the end. I have spent a good part of the day trying install the packet and get it to work, but to no avail it's failed with too many errors and complications to list :(.  

---

### Answer by username_0 on 2022-07-24. Score: 1

After much searching and trial and error, located possibly the optimal tool for my question:

**seqlogo**

<https://github.com/betteridiot/seqlogo>

Surprisingly not only seqlogo is an elegant and minimal solution in Python (and R) I have discovered it has a relative implementation in MATLAB! It installed and worked the first try - beautiful output with all the output options I needed - rock solid.

**Python** one liner (not counting the example pwm input generation)

random\_ppm = np.random.dirichlet(np.ones(4), size=16)

ppm = seqlogo.Ppm(random\_ppm)

**seqlogo.seqlogo(ppm ,format='png',filename='out.png')**

Produces the following ('out.png')

[![enter image description here](https://i.sstatic.net/hrIZJ.png)](https://i.sstatic.net/hrIZJ.png)

And here is **MATLAB** Port:

<https://www.mathworks.com/help/bioinfo/ref/seqlogo.html>

[![enter image description here](https://i.sstatic.net/Weeh9.png)](https://i.sstatic.net/Weeh9.png)


---

