Hello,
I'm trying to go from Bio.motif elements into logos and the available resources haven't solved my particular problem.
The motif.weblogo() function doesn't seem to be working. There's a previous issue asking about it, and I have the same problem, but none of the answers work for me. I updated biopython to 1.81 and it still doesn't work even though the problem was supposed to be solved by 1.80.
I also checked Logomaker, which is a great tool but I need a dataframe object for the motif, and I don't know how to go from a Bio.motif element to that format. I only have access to a position counts matrix, not a list of sequences, so I can't just output the sequences and use that as a dataframe.
Is there any more direct method to solve this issue?
Thanks in advance
1 answer
This is an old (and solved) issue. I'll add an answer to mark it as solved.
I downloaded a set of counts matrixes from HOCOMOCO (e.g. NKX2-5), opened them in Python with
m_list = motifs.parse(open(file.pcm), 'pfm-four-columns')
m = m_list[0]
and tried to get from that counts matrix to a LOGO visualization.
I ended up putting it into a Pandas (pd) data frame with
m_df = pd.DataFrame(m.counts)
and parsing that with Logomaker (lm) using
lm_info = lm.transform_matrix(m_df, from_type='counts', to_type='information')
Using lm.Logo(lm_info) seemed to work fine to visualize a LOGO.
Apparently, my problem was not using data frames and trying to make it work with Python lists.
Log in to answer this question.
do you have a reproducible example to work with?
Hi! This is an old problem I ended up solving, but I don't remember the things I had tried that failed.
I downloaded a set of counts matrixes from HOCOMOCO (e.g. NKX2-5), opened them in Python with
and tried to get from that counts matrix to a LOGO visualization.
I ended up putting it into a Pandas (pd) data frame with
and parsing that with Logomaker (lm) using
That seemed to work fine. I think my problem was not using data frames and trying to make it work with Python lists.