<script> {% include "./js/jquery.dataTables.min.js" %} </script>
<script> {% include "./js/dataTables.jqueryui.min.js" %} </script>

<script> {% include "./js/jszip.min.js" %} </script>
<script> {% include "./js/dataTables.buttons.min.js" %} </script>
<script> {% include "./js/buttons.flash.min.js" %} </script>
<script> {% include "./js/buttons.html5.min.js" %} </script>
<script> {% include "./js/buttons.print.min.js" %} </script>

<style> {% include "./css/jquery-ui.css" %}</style>
<style> {% include "./css/dataTables.jqueryui.min.css" %}</style>
<style> {% include "./css/buttons.dataTables.min.css" %}</style>

<script>
    $(document).ready(function () {
            var table = $('#variant_table').DataTable({
                "scrollX": true,
                dom: 'Bfrtip',
                buttons: ['excel']
            });
            table.draw();
    });
</script>

<div class="abc" style="float: left; margin-left: 15%; margin-right:15%; width: 70%" >
    <h2>Analysis   <i class="icon-help-circled" onClick="toggle1(this)" style="cursor:pointer;"></i></h2>
    <div class="box">
        <div class="description" style="display: none;">
            <p><b>Variants Table</b></p>
            <p> VID : variant ID.</p>
            <p> Chrom : chromosome name.</p>
            <p> Pos : the 1-based position of the variation on the given sequence..</p>
            <p> Alleles : REF(reference base or bases in the case of an indel) - ALT(alternative alleles).</p>
            <p> Gene : gene symbol.</p>
            <p> ncell_cover :number of cells with read count at this position.</p>
            <p> ncell_alt: number of cells with variant read count only.</p>
            <p> ncell_ref: number of cells with reference read count only. </p>
            <p> ncell_ref_and_alt: number of cells with both variant and reference read count.</p>
            <p> mRNA :  A standard nomenclature is used in specifying the sequence changes.</p>
            <p> Protein :  A standard nomenclature is used in specifying the sequence changes.</p>
            <p> COSMIC : COSMIC annotation.</p>
        </div>
      <div id="cluster_tsne" style="float: left; margin-left: 3%; margin-top: 1%;margin-right:0%; width: 47%">
        <script>
            var data = []
            {% for cluster_item in cluster_tsne %}
                var x_coord = {{cluster_item["tSNE_1"]}};
                var y_coord = {{cluster_item["tSNE_2"]}};
                var trace = {
                    x: x_coord,
                    y: y_coord,
                    name: '{{cluster_item["name"]}}',
                    mode: 'markers',
                    marker: {"opacity": 0.9, "size": 4},
                }
                data.push(trace);
            {% endfor %}

            var layout = {

                hovermode:"closest", 
                title: 't-SNE plot Colored by Clusters', 
                xaxis: {
                    zeroline: true,
                    showline: false,
                    type: "linear",
                    title: "t-SNE1"
                },
                yaxis: {
                    zeroline: true,
                    showline: false,
                    type: "linear",
                    title: "t-SNE2"
                },
            }

            var config = { 
                "displayModeBar": true, 
                "staticPlot": false, 
                "showAxisDragHandles": false, 
                "modeBarButtons": [["toImage", "resetScale2d"]], 
                "scrollZoom": false,
                "displaylogo": false, 
            }
            Plotly.newPlot('cluster_tsne', data, layout, config);
        </script>       
      </div>

      <div id="count_tsne" style="float: left; margin-left: 3%; margin-top: 1%;margin-right:0%; width: 47%">
        <script>
            var data = []
            var x_coord = {{count_tsne["tSNE_1"]|safe}};
            var y_coord = {{count_tsne["tSNE_2"]|safe}};
            var trace = {
                x: x_coord,
                y: y_coord,
                text: {{count_tsne["text"]|safe}},
                mode: 'markers',
                marker: { 
                    "opacity": 0.9, 
                    "size": 4,
                    "color":{{count_tsne["value"]|safe}},
                    "colorbar": {"title": "Cell Variant Counts"},
                },
            }
            data.push(trace);

            var layout = {

                hovermode:"closest", 
                title: '{{count_tsne["title"]}}', 
                xaxis: {
                    zeroline: true,
                    showline: false,
                    type: "linear",
                    title: "t-SNE1"
                },
                yaxis: {
                    zeroline: true,
                    showline: false,
                    type: "linear",
                    title: "t-SNE2"
                },
            }

            var config = { 
                "displayModeBar": true, 
                "staticPlot": false, 
                "showAxisDragHandles": false, 
                "modeBarButtons": [["toImage", "resetScale2d"]], 
                "scrollZoom": false,
                "displaylogo": false, 
            }
            Plotly.newPlot('count_tsne', data, layout, config);
        </script>       
      </div>
      
      <hr />

        <h3>{{table_dict['title'] | safe}}</h3>
        <div style=" margin-left: 3%; margin-right:3%;">
            {{table_dict['table'] | safe}}
        </div>
        


      <div class="clear" ></div>
    </div>
  </div>