<p>What you are missing is the accuracy of the prediction, this is the next step and must be &gt;80%, preferably &gt;85% and &gt;90% is good in biological systems. If its lower than 80% you'll need to adjust the training. Following this there are issues with false positives and false negatives.</p>
<p>The method of using seems fine for mapping sequence motifs to transcription factors, which is my interpretation of your question. There must have been vectorisation of the sequence data and this is not trivial.</p>
<p>To answer your question, which you might be asking, you cannot produce an automated heatmap of sequence motif in relation to the transcriptor factor binding. You simply input a sequence and the associated transcription factors are revealed. Unless you vectorised your transcription factors somehow and associated this with a sequence motif.</p>
<p>To produce a heatmap, which again is what I suspect you are requesting, you do this via iteration. So you need a bit of coding. Thus you take all relevant sequence motifs - particularly those that have not been trained - and input them into deep learning algorithm and map which motifs associate with which binding factors and assign a numerical score to given groups of sequence motifs. Any graphics program can then be used to convert this to a heat map. Deciding 'taxonomic groups' for the sequence motifs is subject to your discretion. If you've given the transcription factors and trained this onto the sequence motifs, then classification of transcription factors I suspect would be much easier.</p>
<p>Heatmaps are produced in other machine learning approaches, i.e. which exclude deep learning, but your next step is percentage accuracy regardless of approach.</p>

CC BY-SA 4.0
2022-01-22T22:46:23.220Z
2022-02-22T11:24:04.883Z
2022-02-22T11:24:04.883Z
M__
<p>I created a basic CNN architecture using Tensorflow to classify transcription factor binding sites. My aim is to somehow extract and visualize sequence logos from the convolutional kernels. The model looks like this:</p>
<pre class="lang-py prettyprint-override"><code>model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Conv2D(128, (1, 24), padding='same', input_shape=(1, 101, 4), activation='relu'))
model.add(tf.keras.layers.GlobalMaxPool2D())
# ...
</code></pre>
<p>I am using the supplement <a href="http://cnn.csail.mit.edu/motif_discovery/" rel="nofollow noreferrer">dataset</a> from <a href="https://www.researchgate.net/publication/304002757_Convolutional_neural_network_architectures_for_predicting_DNA-protein_binding" rel="nofollow noreferrer">this publication</a></p>
<p>What I tried so far is that I have trained the model and created a new model out of it which has only an input layer and an output layer that contains the weights of the original convolution kernels:</p>
<pre class="lang-py prettyprint-override"><code>test_model = tf.keras.models.Model(inputs=model.inputs, outputs=model.layers[0].output)
feature_maps = test_model.predict(x)
</code></pre>
<p>I have ran a prediction on a sequence and plotted out a convolution kernel:
<a href="https://i.sstatic.net/j7CKEl.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/j7CKEl.png" alt="Convolution kernel plot" /></a></p>
<p>At this point I got a bit stuck as I am not sure how can I move forward with this in the direction of visualizing the sequence logos.</p>

<python><machine-learning><tensorflow>
How to extract and visualize sequence logos from CNN kernels?
# How to extract and visualize sequence logos from CNN kernels?

(Asked by: username_0 on 2022-01-22)

I created a basic CNN architecture using Tensorflow to classify transcription factor binding sites. My aim is to somehow extract and visualize sequence logos from the convolutional kernels. The model looks like this:
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Conv2D(128, (1, 24), padding='same', input_shape=(1, 101, 4), activation='relu'))
model.add(tf.keras.layers.GlobalMaxPool2D())
# ...

I am using the supplement dataset from this publication
What I tried so far is that I have trained the model and created a new model out of it which has only an input layer and an output layer that contains the weights of the original convolution kernels:
test_model = tf.keras.models.Model(inputs=model.inputs, outputs=model.layers[0].output)
feature_maps = test_model.predict(x)

I have ran a prediction on a sequence and plotted out a convolution kernel:

At this point I got a bit stuck as I am not sure how can I move forward with this in the direction of visualizing the sequence logos.

**Tags:** python, machine-learning, tensorflow

---

## 1 answers

### Answer by username_1 on 2022-01-22. Score: 0

What you are missing is the accuracy of the prediction, this is the next step and must be >80%, preferably >85% and >90% is good in biological systems. If its lower than 80% you'll need to adjust the training. Following this there are issues with false positives and false negatives.

The method of using seems fine for mapping sequence motifs to transcription factors, which is my interpretation of your question. There must have been vectorisation of the sequence data and this is not trivial.

To answer your question, which you might be asking, you cannot produce an automated heatmap of sequence motif in relation to the transcriptor factor binding. You simply input a sequence and the associated transcription factors are revealed. Unless you vectorised your transcription factors somehow and associated this with a sequence motif.

To produce a heatmap, which again is what I suspect you are requesting, you do this via iteration. So you need a bit of coding. Thus you take all relevant sequence motifs - particularly those that have not been trained - and input them into deep learning algorithm and map which motifs associate with which binding factors and assign a numerical score to given groups of sequence motifs. Any graphics program can then be used to convert this to a heat map. Deciding 'taxonomic groups' for the sequence motifs is subject to your discretion. If you've given the transcription factors and trained this onto the sequence motifs, then classification of transcription factors I suspect would be much easier.

Heatmaps are produced in other machine learning approaches, i.e. which exclude deep learning, but your next step is percentage accuracy regardless of approach.


---

