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


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:

enter image description here

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


2 Answers 2


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



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

And here is MATLAB Port:


enter image description here


answer from @M__, converted from comments:

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


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.

  • $\begingroup$ 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 :(. $\endgroup$
    – Zebra Fish
    Jul 24, 2022 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.