code: def freqs_to_heights( matrix ):
      
      # Columns are sequence positions, rows are symbol counts/frequencies
      f = matrix.values.transpose()
      n, m = f.shape
      # Ensure normalized
      f = f / sum( f, axis=0 )
      # Shannon entropy (the where replaces 0 with 1 so that '0 log 0 == 0')
      H = - sum( f * log2( where( f, f, 1 ) ), axis=0 )
      # Height
      return transpose( f * ( log2( n ) - H ) )
docs: Calculate logo height using the method of:
      
      Schneider TD, Stephens RM. "Sequence logos: a new way to display consensus 
      sequences." Nucleic Acids Res. 1990 Oct 25;18(20):6097-100.