jbkinney / logomaker

Software for the visualization of sequence-function relationships
MIT License
179 stars 34 forks source link

KeyError: '1' #15

Closed ZeeshanAbbas92 closed 3 years ago

ZeeshanAbbas92 commented 3 years ago

This is my code below:

import pandas as pd import numpy as np import seqlogo import logomaker

m46 = np.matrix('1.000000 0.000000 0.000000 0.000000;\ 0.000000 1.000000 0.000000 0.000000;\ 1.000000 0.000000 0.000000 0.000000;\ 0.318996 0.275710 0.237386 0.167907;\ 0.398952 0.263579 0.173146 0.164323;\ 0.327819 0.293631 0.181141 0.197408;\ 0.342707 0.290047 0.191067 0.176179')

crp_df = pd.DataFrame(m46) logomaker.Logo(df=crp_df, font_name='Arial Rounded MT Bold', fade_below=0.5, shade_below=0.5, figsize=(10,3))

It returns the error: KeyError: '1' at line 1112 of /logomaker/src/Logo.py

Would you please guide me if I am doing something wrong?

atareen commented 3 years ago

Hi Zeeshan,

Your dataframe elements, as you've written them, appear to have str (string) as their datatype. Logomaker requires its input pandas dataframe (to the Logo constructor) to have numbers as its elements, e.g., float, or int. I've initialized your numpy array as numbers and assumed (based on the shape of your matrix) that you were trying to plot a DNA logo of sequence length 7. This gives the output the picture below. However this isn't a logomaker issue so I am closing this.

Screen Shot 2021-05-12 at 9 53 11 AM