jbkinney/logomaker

Custom Xlabels

Closed this issue · 4 comments

Hi. I'm doing a protein logo with mutations, and I need to make the Xlabel show the wildtype and number, instead of only the number.

This is my 'logo' dataframe

         W     F     Y     M     I     D     E     Q     R     V     L     N     S     T
R358  0.77  0.00  0.68  0.00  0.00  0.66  0.68  0.00  0.00  0.00  0.00  0.00  0.00  0.00
H359  0.84  0.00  0.83  0.00  0.00  0.00  0.00  0.71  0.00  0.00  0.00  0.70  0.00  0.70
N360  0.95  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.93  0.00  0.00  0.00  0.00  0.00
F362  0.65  0.00  0.70  0.69  0.67  0.00  0.00  0.00  0.00  0.68  0.68  0.00  0.00  0.00
S363  0.76  0.74  0.76  0.75  0.73  0.00  0.00  0.00  0.00  0.00  0.71  0.00  0.00  0.00
A366  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.21  0.00  0.00  0.00  0.23  0.00  0.22
K367  0.23  0.00  0.23  0.00  0.00  0.00  0.00  0.00  0.23  0.00  0.00  0.00  0.00  0.00
K370  0.18  0.00  0.18  0.00  0.00  0.00  0.00  0.17  0.00  0.00  0.00  0.18  0.18  0.00
E373  0.00  0.00  0.00  0.19  0.21  0.00  0.00  0.00  0.00  0.20  0.20  0.00  0.00  0.00
L375  1.00  0.95  0.94  0.88  0.85  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00
A377  0.84  0.00  0.00  0.85  0.80  0.00  0.00  0.00  0.00  0.00  0.80  0.00  0.00  0.00
N382  0.89  0.00  0.00  0.00  0.00  0.78  0.78  0.80  0.00  0.00  0.00  0.00  0.00  0.00

When doing the figure, it complains:

fig = logomaker.Logo(logo)

logomaker.src.error_handling.LogomakerError: could not convert df.index to type int. Check that all positions have integer numerical values.

Thanks in advance
Pedro

Can you provide a minimal working code snippet for me to reproduce your issue?

Thank you @atareen
I believe the first column of the dataframe is expected to be an integer, instead of a string. Weblogos usually just display the position number, but in this case scenario the desired Xlabel of the logo would be the notation "Residue+Position".

This is the code I'm using to try it:

import pandas as pd
import logomaker

 #logodict is the dictionary to create the dataframe on top
logo = pd.DataFrame(logdict)
fig    = logomaker.Logo(logo)

If you provide the data in a file, I'll plot the logo for you and share the code.

I've plotted a logo from the data you've provided along with your custom xlabels from the first column of data. I am attaching a screenshot of a very minimal example showing this, but please note this is not a logomaker issue, so I am closing this.

Screenshot 2023-08-29 at 10 07 21 AM