# PWM (4xM matrices) to Sequence Logo Visualizations in MATLAB or Python

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.

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')

And here is MATLAB Port:

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