<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.columns(-1).order('desc').draw();
    });
</script>

<div class="abc" style="float: left; margin-left: 15%; margin-right:15%; width: 70%" >
    <h2>Analysis   <i class="fa fa-question-circle" onClick="toggle1(this)" style="cursor:pointer;"></i></h2>
    <div class="box">
        <div class="description" style="display: none;">
            <p><b>Variants Table</b></p>
            <p> CHROM : chromosome name.</p>
            <p> POS : the 1-based position of the variation on the given sequence..</p>
            <p> GENE : gene symbol.</p>
            <p> ALLELES : REF(reference base or bases in the case of an indel) - ALT(alternative alleles).</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> DP : depth.</p>
            <p> GT : genotype.</p>
            <p> INDEX : match cell index.</p>
            <p> CLUSTER : match cell cluster.</p>
            <p> NCELL : number of match cell.</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}},
                    "colorscale": "Jet", 
                    "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>{{variant_table['title'] | safe}}</h3>
        <div style=" margin-left: 3%; margin-right:3%;">
            {{variant_table['table'] | safe}}
        </div>
        


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