Difference between revisions of "Team:Heidelberg/Sandbox1025"

(Blanked the page)
 
Line 1: Line 1:
{{Heidelberg/navbar}}
 
{{Heidelberg/header}}
 
{{Heidelberg/text/introduction_notebook}}
 
  
 
{{Heidelberg/boxopen|Week 34|{{#tag:html|<h2>Optopace</h2>
 
No entry for this subproject this week.<h2>Software</h2>
 
KW34
 
=====
 
Word2Vec Embeddings on Proteinsequences
 
---------------------
 
We rewrote a word2vec implementation from tensorflows tutorials that implements Efficient Estimation of Word Representations in Vector Space, ICLR 2013 (Mikolov, et. al.). The model is a skipgram model with negative sample that uses custom ops written in C. The code was adapted to our needs, mainly by changing datatypes in the C kernels and writing a different evaluation function based on predicting the nearest words to the most frequent words instead of using analogies. Two new datasets were generated based on both swissprot and uniprot. Training of 4mer embeddings in 50, 100 and 200 dimensions were started but have not been calculated yet.
 
Visualisation of the first checkpoints is possible via tensorboard [Visualisation of an example embedding via tensorboard](170820ai-vistestemb).
 
 
IMPLEMENTATION OF SQUEEZENET Architecture
 
---------------------------------
 
With implamentation of a new architecture based on Sequeeze-net (Forrest N. Iandola, 2017), relying on 1x1 convolutions we were able to grasp the 299 as well as the 637 classes dataset. The new model architecture looks the following:
 
 
- InputLayer  model_valid/input_layer_valid: (64, 20, 1000, 1)
 
- PadLayer  model_valid/block1/pad_layer_valid: paddings:[[0, 0], [0, 0], [3, 3], [0, 0]] mode:CONSTANT
 
- Conv2dLayer model_valid/block1/cnn_layer_valid: shape:[20, 7, 1, 128] strides:[1, 5, 1, 1] pad:VALID act:prelu
 
- Conv1dLayer model_valid/block2/cnn_layer_valid: shape:[6, 128, 128] stride:1 pad:SAME act:prelu
 
- Conv1dLayer model_valid/1x1_I/1x1_valid: shape:[1, 128, 64] stride:1 pad:SAME act:prelu
 
- BatchNormLayer model_valid/1x1_I/batchnorm_layer_valid: decay:0.900000 epsilon:0.000010 act:identity is_train:False
 
- Conv1dLayer model_valid/block3/cnn_layer_valid: shape:[5, 64, 256] stride:1 pad:SAME act:prelu
 
- PoolLayer  model_valid/block3/pool_layer_valid: ksize:[2] strides:[2] padding:VALID pool:pool
 
- BatchNormLayer model_valid/block3/batchnorm_layer_valid: decay:0.900000 epsilon:0.000010 act:identity is_train:False
 
- Conv1dLayer model_valid/block4/cnn_layer_valid: shape:[5, 256, 256] stride:1 pad:SAME act:prelu
 
- PoolLayer  model_valid/block4/pool_layer_valid: ksize:[2] strides:[2] padding:VALID pool:pool
 
- BatchNormLayer model_valid/block4/batchnorm_layer_valid: decay:0.900000 epsilon:0.000010 act:identity is_train:False
 
- Conv1dLayer model_valid/1x1_II/1x1_valid: shape:[1, 256, 128] stride:1 pad:SAME act:prelu
 
- BatchNormLayer model_valid/1x1_II/batchnorm_layer_valid: decay:0.900000 epsilon:0.000010 act:identity is_train:False
 
- Conv1dLayer model_valid/block5/cnn_layer_valid: shape:[5, 128, 256] stride:1 pad:SAME act:prelu
 
- PoolLayer  model_valid/block5/pool_layer_valid: ksize:[2] strides:[2] padding:VALID pool:pool
 
- BatchNormLayer model_valid/block5/batchnorm_layer_valid: decay:0.900000 epsilon:0.000010 act:identity is_train:False
 
- Conv1dLayer model_valid/block6/cnn_layer_valid: shape:[5, 256, 512] stride:1 pad:SAME act:prelu
 
- PoolLayer  model_valid/block6/pool_layer_valid: ksize:[2] strides:[2] padding:VALID pool:pool
 
- BatchNormLayer model_valid/block6/batchnorm_layer_valid: decay:0.900000 epsilon:0.000010 act:identity is_train:False
 
- Conv1dLayer model_valid/1x1_III/1x1_valid: shape:[1, 512, 256] stride:1 pad:SAME act:prelu
 
- BatchNormLayer model_valid/1x1_III/batchnorm_layer_valid: decay:0.900000 epsilon:0.000010 act:identity is_train:False
 
- Conv1dLayer model_valid/block7/cnn_layer_valid: shape:[5, 256, 516] stride:1 pad:SAME act:prelu
 
- PoolLayer  model_valid/block7/pool_layer_valid: ksize:[2] strides:[2] padding:VALID pool:pool
 
- BatchNormLayer model_valid/block7/batchnorm_layer_valid: decay:0.900000 epsilon:0.000010 act:identity is_train:False
 
- Conv1dLayer model_valid/block8/cnn_layer_valid: shape:[5, 516, 1024] stride:1 pad:SAME act:prelu
 
- PoolLayer  model_valid/block8/pool_layer_valid: ksize:[2] strides:[2] padding:VALID pool:pool
 
- BatchNormLayer model_valid/block8/batchnorm_layer_valid: decay:0.900000 epsilon:0.000010 act:identity is_train:False
 
- Conv1dLayer model_valid/1x1_IV/cnn_layer_valid: shape:[1, 1024, 512] stride:1 pad:SAME act:prelu
 
- BatchNormLayer model_valid/1x1_IV/batchnorm_layer_valid: decay:0.900000 epsilon:0.000010 act:identity is_train:False
 
- Conv1dLayer model_valid/block9/cnn_layer_valid: shape:[5, 512, 1024] stride:1 pad:SAME act:prelu
 
- PoolLayer  model_valid/block9/pool_layer_valid: ksize:[2] strides:[2] padding:VALID pool:pool
 
- BatchNormLayer model_valid/block9/batchnorm_layer_valid: decay:0.900000 epsilon:0.000010 act:identity is_train:False
 
- Conv1dLayer model_valid/outlayer/cnn_layer_valid: shape:[1, 1024, 637] stride:1 pad:SAME act:prelu
 
- BatchNormLayer model_valid/outlayer/batchnorm_layer_valid: decay:0.900000 epsilon:0.000010 act:identity is_train:False
 
- MeanPool1d global_avg_pool: filter_size:[7] strides:1 padding:valid
 
 
The architecture is fully convolutional, ending in an average pooling layer as outlayer, with the channels dimension corresponding to the number of classes. All inputs were 1-hot encoded and zero padded to a boxsize of 1000 positions.
 
 
| Model |  lr | classes | Comment | restored | maxstep | boxsize | ACC          |
 
|-------|------|---------|---------|----------|---------|---------|--------------|
 
|      | 0.01 |    299 |        | NO      |  220000 |    1000 | 0.8 (valid)  |
 
|      | 0.01 |    637 |        | NO      |  180000 |    1000 | 0.55 (valid) |
 
|      | 0.01 |    637 |        | YES      |  35000 |    1000 | 0.75 (valid) |
 
 
 
References:
 
-----
 
1. Iandola, F. N., Han, S., Moskewicz, M. W., Ashraf, K., Dally, W. J., & Keutzer, K. (2016). SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and< 0.5 MB model size. arXiv preprint arXiv:1602.07360.
 
2. Mikolov, T., Sutskever, I., Chen, K., Corrado, G. S., & Dean, J. (2013). Distributed representations of words and phrases and their compositionality. In Advances in neural information processing systems (pp. 3111-3119).
 
 
<h2>Modeling</h2>
 
A first numeric model of PredCel works without oscillations. Graphs look reasonable so far. Modelling was performed on three levels: On the lowest level one Step of Predcel monitoring Phage concentration as well as uninfected, infected and phage producing E. coli concentration [Graph of level 1 Predcel model](170820mod-lvl1.png). One level above all the concentrations were tracked over 100 iterations of Predcel [Graph of level 2 Predcel model](170820mod-lvl2.png). And on the third level different sets of values for starting fitness, starting phage concentration and starting E. coli concentration were tested. In this case we only monitored how long the phage titer at the end of each iteration of Predcel stayed above 1 pfu/mL and below 1e8 pfu/mL.[Graph of level 3 Predcel model](170820mod-lvl3.png)
 
At least the two higher levels probably only work in python, but maybe an interactive version of what happens during one iteration is possible. A final more comfortable version of the script was started.
 
}}|34}}{{Heidelberg/boxopen|Week 35|{{#tag:html|<h2>Optopace</h2>
 
No entry for this subproject this week.<h2>Software</h2>
 
KW35
 
======
 
 
Performance of the Squeezenet Architecture - singlelabel 599
 
-------
 
The model was run successfully on the old 599 classes dataset.
 
Parameters: lr = E-2, batchsize=64, epsilon=0.1
 
[ROC](DeeProtein_TFRECORDS_PURECONV_1x1tuned_750k_restored750kfull_sce_adam_1dconv637_1000_one_hot_padded_64_0.001_0.1.roc_16.svg)
 
[Precision](DeeProtein_TFRECORDS_PURECONV_1x1tuned_750k_restored750kfull_sce_adam_1dconv637_1000_one_hot_padded_64_0.001_0.1.precision_16.svg)
 
 
Performance of the Squeezenet Architecture - singlelabel 679
 
-------
 
The model was run successfully on the 679 classes dataset.
 
Parameters: lr = E-5, batchsize=64, epsilon=0.1
 
[ROC](DeeProtein_TFRECORDS_PURECONV_1x1tuned_restored679_sce_adam_1dconv_EC_679_1000_one_hot_padded_64_0.001_0.1.roc_9.svg)
 
[Precision](DeeProtein_TFRECORDS_PURECONV_1x1tuned_restored679_sce_adam_1dconv_EC_679_1000_one_hot_padded_64_0.001_0.1.precision_9.svg)
 
 
Performance of the Squeezenet Architecture - Multilabel 1084
 
-------
 
The model was run successfully on the 1084 GO-classes dataset.
 
Parameters: lr = E-3, batchsize=64, epsilon=0.1
 
[ROC](DeeProtein_TFRECORDS_PURECONV_1x1LARGE_MULTI_restored1084_sce_adam_1dconv_EC_1084_1000_one_hot_padded_64_0.0001_0.1.roc_39.svg)
 
[Precision](DeeProtein_TFRECORDS_PURECONV_1x1LARGE_MULTI_restored1084_sce_adam_1dconv_EC_1084_1000_one_hot_padded_64_0.0001_0.1.precision_39.svg)
 
 
Corrected datasets for missing classes, reworte ```eval()``` to enclude the whole validation set
 
------------------------
 
- Dataset 637, was missing 138 classes due to the min. length requirement in the ```DatasetGenerator``` class. The requirement was lowered to 175AA. Further the ```DatasetGenerator``` class was rewritten, to ensure to contain 5 samples from every class in the validation set.
 
- the ```eval()``` function of ```DeeProtein``` was rewritten to perform the validaion on the _whole_ validation set at given steps.
 
 
Performance on 679 classes with minlength 175:
 
lr=0.01, e=0.1, batchsize=64
 
[ROC](DeeProtein_TFRECORDS_PURECONV_1x1tuned_restored637750kfull_sce_adam_1dconv679_1000_one_hot_padded_64_0.01_0.1.roc_32.svg)
 
[Precision](DeeProtein_TFRECORDS_PURECONV_1x1tuned_restored637750kfull_sce_adam_1dconv679_1000_one_hot_padded_64_0.01_0.1.precision_32.svg)
 
 
lr=0.001, e=0.1, batchsize=64
 
[ROC](DeeProtein_TFRECORDS_PURECONV_1x1tuned_restored637750kfull_sce_adam_1dconv679_1000_one_hot_padded_64_0.01_0.1.roc_32.svg)
 
[Precision](DeeProtein_TFRECORDS_PURECONV_1x1tuned_restored637750kfull_sce_adam_1dconv679_1000_one_hot_padded_64_0.01_0.1.precision_32.svg)
 
 
Reinitialization with pretrained parameters and lower learning rate allowed finetuning of the classifier. Especially as the validation set is uniformally distributed (in contrast to the training set) the classifier can be considered as trained.
 
 
ROC/ACC/AUC-metrics
 
--------
 
ROC and AUC was added to be calculated on the fly (after validation on the whole validation set.).
 
 
Training models on the embedded sequences
 
------------------
 
We generated batches from the word embeddings (dim=100, kmer-length=3) for the 679(EC) and the 1084 mulilabel network. However training proceeds much more slowly as the parametersize is 5 times the size of the one-hot network.
 
 
Multilabel-classification
 
--------
 
In order to be able to perform multilabel classification, we rewrite the input pipeline (```DatasetGenerator, BatchGenerator, TFrecordsgenerator```) and generated two datasets with 339 and 1084 classes respectively. The considered labels were chosen solely based on their polulation. As the GO-term hierarchy follows a directed acyclic graph (DAG) we looked up all parent nodes for each leaf nodes and included the total set of annotations for each sequence.
 
 
First models were run after extending the network for 2 convolutional and 2 1x1 layers on the 1084 classes dataset. Results were disenchanting.
 
 
Comparison of datasets
 
----------------
 
Total seqs after filtering (EC): 220488
 
Total seqs after filtering (GO): 235767
 
 
| Datatype | Dataset | Samples | % of filtered sequences considered | % of total sequences considered |
 
|----------|---------|---------|------------------------------------|---------------------------------|
 
| EC      |    679 |  165658 |                              75.13 |                          63.18 |
 
| GO      |    1084 |  233386 |                              98.99 |                          89.00 |
 
 
Word2Vec
 
------
 
The new word2vec adaption we implemented last week was optimized by a few minor changes. Metadata of the embeddings can now be used to analyse the embeddings with tensorboard. Search for a single k-mer, finding the nearest neighbours, annotating frequencies or other properties to the points and search for groups of k-mers defined by regular expressions work. Embeddings of 3-mers and 4-mers in 50, 100 and 200 dimensions were calculated on whole swissprot and whole uniprot. Principle Component Analysis (PCA) was performed on a 100-dimensional embedding of 3-mers from swissprot and showed interesting properties. However, reduction of 100 dimensions to two or three may account for at least some of these.
 
![Frequencies of 3-mers](170827mod-freqs.png)
 
Here the 3-mers marked darker are more frequent, those seem to cluster together.
 
![All 3-mers containing a specific amino acid](170827mod-aas.gif)
 
For each amino acid all 3-mers containing it are marked in read. Some of those selection cluster together, others do not. This may also be due to the dimension reduction.
 
![All 3-mers containing cysteine](170827mod-c.png)
 
All 3-mers containing cysteine are marked in red.
 
![All 3-mers containing lysine](170827mod-k.png)
 
All 3-mers containing lysine are marked in red.
 
![All 3-mers containing proline](170827mod-p.png)
 
All 3-mers containing proline are marked in red.
 
![All 3-mers containing valine](170827mod-v.png)
 
All 3-mers containing valine are marked in red.
 
Especially cysteine, proline and lysine containing 3-mers cluster together, while the ones containing valine appear to be more equally distributed.
 
Clustering of k-mers based on amino acid content is a first hint, embeddings can be useful for input of neural networks. However their performance can probably only be measured indirectly by comparing the performance of a single architecture on different inputs.
 
<h2>Modeling</h2>
 
Calculations of medium consumption for iGEM goes green were performed and made interactive. A heatmap visualizes medium consumption, calculation of ideal turbidostat and lagoon sizes are possible. The user can annotate own experiments and compare them to others.
 
[Heatmap with default values](170827mod-heatmap.png)
 
Experimentation with elements of a Predcel model based on distributions instead of scalars were started. The idea is that a population of phages does not have one fitness between 0 and 1 but rather has individuals that have different fitness values. In this more complex model the concentrations have to be calculated for each phage fitness value, depending on the amount of phages that have that fitness value. The fitness distribution is changed by mutation and by selection. The first naive approach for mutation was programmed. It simply substracts a given percentage of the difference between the amount of a fitness value and the mean amount from the amount of a fitness value. Obviously this is oversimplified and will therefore be replaced by a model based on the idea that every sequence that mutates gets better or worse with normally distributed changes.
 
}}|35}}
 
 
{{Heidelberg/footer}}
 

Latest revision as of 17:48, 14 December 2017