Commit bd63192b authored by Penom Nom's avatar Penom Nom
Browse files

web interface

improvement on pindel
bugfixes
redone merge --> sv_group removed
parent bf68b702
$(document).on("click", ".length-view-btn", function() {
if ($(":checked[id^=chk_sample_]").size() > 0) {
$("#modal-label-tmpl").html("NG6 <small> " + $("#analyse_name").val() + "</small>");
$("#modal-body-tmpl").html('<div id="highcharts_container"></div>');
$("#modal-foot-tmpl").html('<button class="btn btn-default" data-dismiss="modal" aria-hidden="true"><i class="glyphicon glyphicon-remove"></i> Close</button>');
$("#highcharts_container").css('width', '845px');
var all_boxplot = [];
var all_outliers = [];
var all_sample_id = [];
$(":checked[id^=chk_sample_]").each(function(){
var index = $(this).attr("id").split("_")[2];
var val_boxplot = $("#boxplot_"+index).val().split(";");
var val_outliers = $("#outliers_"+index).val().split(";");
var val_soft = $("#soft_"+index).val();
all_sample_id.push(val_soft);
if(val_outliers[0] != '' ){
$.each(val_outliers, function(position, value){
all_outliers.push([parseInt(index),parseInt(value)]);
});
}
val_boxplot = val_boxplot.map(function (x) {
return parseInt(x, 10); //cast to int
});
all_boxplot.push(val_boxplot);
});
var chart = new Highcharts.Chart({
chart: {
renderTo: 'highcharts_container',
type: 'boxplot'
},
title: {
text: 'SV length Box-Plot'
},
legend: {
enabled: false
},
xAxis: {
categories: all_sample_id,
title: {
text: 'Software'
}
},
function powerset(ary) {
var ps = [[]];
for (var i=0; i < ary.length; i++) {
for (var j = 0, len = ps.length; j < len; j++) {
ps.push(ps[j].concat(ary[i]));
}
}
return ps;
}
yAxis: {
title: {
text: 'Sizes'
}
},
$(document).ready(function(){
$(document).on("click", ".length-view-btn", function() {
if ($(":checked[id^=chk_sample_]").size() > 0) {
$("#modal-label-tmpl").html("NG6 <small> " + $("#analyse_name").val() + "</small>");
$("#modal-body-tmpl").html('<div id="highcharts_container"></div>');
$("#modal-foot-tmpl").html('<button class="btn btn-default" data-dismiss="modal" aria-hidden="true"><i class="glyphicon glyphicon-remove"></i> Close</button>');
$("#highcharts_container").css('width', '845px');
series: [{
name: 'Sizes',
data: all_boxplot,
tooltip: {
headerFormat: '<em>Software {point.key}</em><br/>'
}
}, {
name: 'Outliers',
color: Highcharts.getOptions().colors[0],
type: 'scatter',
data: all_outliers,
marker: {
fillColor: 'white',
lineWidth: 1,
lineColor: Highcharts.getOptions().colors[0]
},
tooltip: {
pointFormat: 'Observation: {point.y}'
var all_boxplot = [];
var all_outliers = [];
var all_sample_id = [];
$(":checked[id^=chk_sample_]").each(function(){
var index = $(this).attr("id").split("_")[2];
var index2 = $(this).attr("id").split("_")[3];
var val_boxplot = $("#boxplot_"+index+"_"+index2).val().split(";");
console.log(val_boxplot)
var val_outliers = $("#outliers_"+index+"_"+index2).val().split(";");
var val_soft = $("#soft_"+index+"_"+index2).val();
all_sample_id.push(val_soft);
if(val_outliers[0] != '' ){
$.each(val_outliers, function(position, value){
all_outliers.push([parseInt(index),parseInt(value)]);
});
}
}]
});
resize_center_btmodal('#ng6modal', chart.chartWidth + 50);
//Display
$("#ng6modal").modal();
}
});
////////////////////////////////////////////////////////////////////////////////////////////////////
$(document).on("click", ".compo-view-btn", function() {
if ($(":checked[id^=chk_sample_]").size() > 0) {
$("#modal-label-tmpl").html("NG6 <small> " + $("#analyse_name").val() + "</small>");
$("#modal-body-tmpl").html('<div id="highcharts_container"></div>');
$("#modal-foot-tmpl").html('<button class="btn btn-default" data-dismiss="modal" aria-hidden="true"><i class="glyphicon glyphicon-remove"></i> Close</button>');
$("#highcharts_container").css('width', '845px');
var tags = $("#ntag_0").val().split(";")
var all_count = [];
$(":checked[id^=chk_sample_]").each(function(){
var index = $(this).attr("id").split("_")[2];
var val_count = $("#ncount_"+index).val().split(";");
var soft = $("#soft_"+index).val();
val_count = val_count.map(function (x) {
return parseInt(x, 10); //cast to int
val_boxplot = val_boxplot.map(function (x) {
return parseInt(x, 10); //cast to int
});
all_boxplot.push(val_boxplot);
});
var chart = new Highcharts.Chart({
chart: {
renderTo: 'highcharts_container',
type: 'boxplot',
zoomType: 'xy'
},
title: {
text: 'SV length Box-Plot'
},
legend: {
enabled: false
},
xAxis: {
categories: all_sample_id,
title: {
text: 'Software'
}
},
yAxis: {
title: {
text: 'Sizes'
}
},
series: [{
name: 'Sizes',
data: all_boxplot,
tooltip: {
headerFormat: '<em>Software: {point.key}</em><br/>'
}
}]
});
resize_center_btmodal('#ng6modal', chart.chartWidth + 50);
//Display
$("#ng6modal").modal();
}
});
////////////////////////////////////////////////////////////////////////////////////////////////////
$(document).on("click", ".compo-view-btn", function() {
if ($(":checked[id^=chk_sample_]").size() > 0) {
$("#modal-label-tmpl").html("NG6 <small> " + $("#analyse_name").val() + "</small>");
$("#modal-body-tmpl").html('<div id="highcharts_container"></div>');
$("#modal-foot-tmpl").html('<button class="btn btn-default" data-dismiss="modal" aria-hidden="true"><i class="glyphicon glyphicon-remove"></i> Close</button>');
$("#highcharts_container").css('width', '845px');
var tags = $("#ntag_0_0").val().split(";")
var all_count = [];
$(":checked[id^=chk_sample_]").each(function(){
var index = $(this).attr("id").split("_")[2];
var index2 = $(this).attr("id").split("_")[3];
var val_count = $("#ncount_"+index+"_"+index2).val().split(";");
var soft = $("#soft_"+index+"_"+index2).val();
val_count = val_count.map(function (x) {
return parseInt(x, 10); //cast to int
});
all_count.push({name:soft, data:val_count});
});
var chart = new Highcharts.Chart({
chart: {
renderTo: 'highcharts_container',
zoomType: 'xy',
type: 'line'
},
title: {
text: 'SVR found in at least N individuals'
},
xAxis: {
categories: tags,
title: {
text: 'At least N individuals',
},
labels: {
overflow: 'justify'
}
},
yAxis: {
min: 0,
title: {
text: 'Count',
},
labels: {
overflow: 'justify'
}
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
floating: true,
borderWidth: 1,
backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
shadow: true,
title: {
text: 'Software<br/><span style="font-size: 9px; color: #666; font-weight: normal">(Click to hide)</span>',
style: {
fontStyle: 'italic'
}
},
x: -100
},
credits: {
enabled: false
},
series: all_count
});
resize_center_btmodal('#ng6modal', chart.chartWidth + 50);
//Display
$("#ng6modal").modal();
}
});
////////////////////////////////////////////////////////////////////////////////////////////////////
$.getScript("http://bioinfo.genotoul.fr/jvenn/src/jvenn.min.js", function(){
$(document).on("click", ".jvenn-btn", function() {
//modal
$("#modal-label-tmpl").html("NG6 <small> " + $("#analyse_name").val() + "</small>");
$("#modal-body-tmpl").html('<div id="jvenn_container"></div>');
$("#modal-foot-tmpl").html('<button class="btn btn-default" data-dismiss="modal" aria-hidden="true"><i class="glyphicon glyphicon-remove"></i> Close</button>');
$("#jvenn_container").css('width', '845px');
if ($(":checked[id^=chk_sample_]").size() > 0) {
//venn_count
var venn_count = [];
var tmp = $("#venn_count").val().split(",");
$.each(tmp, function(index, item){
var pair = item.split(":");
venn_count[pair[0]] = pair[1];
});
//combinations
var selection = [];
$(":checked[id^=chk_sample_0_]").each(function(){ // ALL only
var soft = $(this).val();
selection.push(soft);
});
var combinations = powerset(selection);
var keys = powerset(['A','B','C','D']);
var my_values = {};
var my_names = {};
//here
$.each(combinations, function(index, item){
if (keys[index] != '')
my_values[keys[index].join("")] = venn_count[item.join(";")];
if (keys[index].length == 1){
my_names[keys[index]] = item.join(";");
}
});
console.log(my_names);
console.log(my_values);
}
//jvenn
$('#jvenn_container').jvenn({
series: [{
name: my_names,
values: my_values
}],
disableClick: true
});
all_count.push({name:soft, data:val_count});
});
var chart = new Highcharts.Chart({
chart: {
renderTo: 'highcharts_container',
type: 'bar'
},
title: {
text: 'SVR found in at least N individuals'
},
xAxis: {
categories: tags,
title: {
text: 'At least N individuals',
align: 'high'
},
labels: {
overflow: 'justify'
}
},
yAxis: {
min: 0,
title: {
text: 'Count',
align: 'high'
},
labels: {
overflow: 'justify'
}
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -40,
y: 80,
floating: true,
borderWidth: 1,
backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
shadow: true
},
credits: {
enabled: false
},
series: all_count
});
resize_center_btmodal('#ng6modal', chart.chartWidth + 50);
//Display
$("#ng6modal").modal();
}
});
//launch modal
resize_center_btmodal('#ng6modal');
$("#ng6modal").modal();
});
});
});
\ No newline at end of file
{extends file='AnalysisTemplate.tpl'}
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="http://bioinfo.genotoul.fr/jvenn/src/jvenn.min.js" type="text/javascript"></script>
{block name=description_update}
<br/>
<div style="float:right;">
{if $is_project_admin }
<button id="add_file" type="button" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-plus"></i> add files</button>
{/if}
</div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<div style="float:right;">
{if $is_project_admin }
<button id="add_file" type="button" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-plus"></i> add files</button>
{/if}
</div>
<br/> Lorem ipsum dolor sit amet.
{/block}
{block name=results_title}Structural variations stats{/block}
{block name=results}
<div id="user_information_dialog" title="">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<br/>
</div>
<table class="table table-striped table-bordered dataTable analysis-result-table">
<thead>
<tr>
<th><center><input type="checkbox" id="chk_all_sample"></center></th>
<th class="string-sort" >Sample(by software)</th>
<th class="numeric-sort">Median size</th>
<th class="numeric-sort">Mean size</th>
<th class="numeric-sort">Min size</th>
<th class="numeric-sort">Max size</th>
<th class="numeric-sort">Standard deviation</th>
<th class="numeric-sort">Number of SV</th>
</tr>
</thead>
<tbody>
{assign var="i" value=0}
{foreach from=$analyse_results key=sample item=sample_results}
{block name=results}
{assign var=my_types value=['ALL', 'DEL', 'DUP', 'INV', 'INS']}
{assign var="j" value=0}
<input type="hidden" id="venn_count" value="{$analyse_results["software_merge"]["default"].venn_count}"/>
<button type="button" class="btn btn-default multiple-selection-btn jvenn-btn"> Venn Diagram </button>
{foreach from=$my_types item=t}
<div id="user_information_dialog" title=""><br/><br/>{$t}<br/><br/><br/></div>
<table class="table table-striped table-bordered dataTable analysis-result-table">
<thead>
<tr>
<td>
<center>
<input type="checkbox" id="chk_sample_{$i}" value="sample"/>
<input type="hidden" id="boxplot_{$i}" value="{$sample_results["default"].boxplot}"/>
<input type="hidden" id="outliers_{$i}" value="{$sample_results["default"].outliers}"/>
<input type="hidden" id="soft_{$i}" value="{$sample_results["default"].soft}"/>
<input type="hidden" id="ntag_{$i}" value="{$sample_results["default"].n_tag}"/>
<input type="hidden" id="ncount_{$i}" value="{$sample_results["default"].n_count}"/>
</center>
</td>
<td>{$sample_results["default"].soft}</td>
<td>{$sample_results["default"].median}</td>
<td>{$sample_results["default"].mean}</td>
<td>{$sample_results["default"].min}</td>
<td>{$sample_results["default"].max}</td>
<td>{$sample_results["default"].sd}</td>
<td>{$sample_results["default"].number}</td>
<th><center><input type="checkbox" id="chk_all_sample_{$j}"></center></th>
<th class="string-sort" >Type</th>
<th class="numeric-sort">Number of SV</th>
<th class="numeric-sort">Median size</th>
<th class="numeric-sort">Mean size</th>
<th class="numeric-sort">Min size</th>
<th class="numeric-sort">Max size</th>
<th class="numeric-sort">Standard deviation</th>
<th class="numeric-sort">Outliers(boxplot)</th>
</tr>
{$i = $i +1}
</thead>
{assign var="i" value=0}
{foreach from=$analyse_results key=software item=software_results}
{foreach from=$software_results key=type item=infos_list}
{if $type == $t}
<tbody>
<tr>
<td>
<center>
<input type="checkbox" id="chk_sample_{$j}_{$i}" name="chk_soft" value="{$infos_list.soft}"/>
<input type="hidden" id="boxplot_{$j}_{$i}" value="{$infos_list.boxplot}"/>
<input type="hidden" id="outliers_{$j}_{$i}" value="{$infos_list.outliers}"/>
<input type="hidden" id="soft_{$j}_{$i}" value="{$infos_list.soft}"/>
<input type="hidden" id="ntag_{$j}_{$i}" value="{$infos_list.n_tag}"/>
<input type="hidden" id="ncount_{$j}_{$i}" value="{$infos_list.n_count}"/>
</center>
</td>
<td>{$infos_list.soft}</td>
<td>{$infos_list.number}</td>
<td>{$infos_list.median}</td>
<td>{$infos_list.mean}</td>
<td>{$infos_list.min}</td>
<td>{$infos_list.max}</td>
<td>{$infos_list.sd}</td>
<td>{$infos_list.outliers}</td>
</tr>
</tbody>
{$i = $i +1}
{/if}
{/foreach}
{/foreach}
</tbody>
<tfoot>
<tr>
<th align="left" colspan="{if $has_several_samples && ($nb_processed_samples >=1)}10{else}9{/if}">
With selection :
<button type="button" class="btn btn-default multiple-selection-btn length-view-btn" id="boxplot_button"> boxplot with outlier </button>
<button type="button" class="btn btn-default multiple-selection-btn compo-view-btn" id="barplot_button"> barplot </button>
</th>
</tr>
</tfoot>
</table>
<tfoot>
<tr>
<th align="left" colspan="{if $has_several_samples && ($nb_processed_samples >=1)}10{else}9{/if}">
With selection :
<button type="button" class="btn btn-default multiple-selection-btn length-view-btn"> Boxplots* </button>
<button type="button" class="btn btn-default multiple-selection-btn compo-view-btn"> Accumulation Curves </button>
</th>
</tr>
</tfoot>
</table>
{$j = $j +1}
{/foreach}
{/block}
\ No newline at end of file
......@@ -29,7 +29,6 @@ class SVDetection (NG6Workflow):
def get_description(self):
return "This pipeline aims to detect structural variations in whole genomes."
def define_parameters(self, function="process"):
self.add_input_file("reference_genome", "On which genome should the reads being aligned on", required=True) # , file_format="fasta"
self.add_parameter("chrom", "Studied chromosome (do not forget the chr prefix if there is one)", default="", type=str)
......@@ -39,35 +38,35 @@ class SVDetection (NG6Workflow):
self.add_parameter("min_len", "Minimum length of a variant (50)", type=int, default=50)
self.add_parameter("max_len", "Maximum length of a variant (8 500 000)", type=int, default=8500000) #TODO: max calculed % chr size
self.add_parameter("min_mapq", "min. paired-end mapping quality", type=int, default=30)
self.add_parameter("overlap_percent", "Minimum threshold of overlap percent between 2 SV", type=float, default=0.7)
self.add_parameter("li_range", "Range of localisation interval around breakpoints", type=int, default=1000)
#TODO: infuture minmapq -> juste apres lalignement
def process(self):
input_bam = [spl.reads1[0] for spl in self.samples]
indiv_list = [spl.name for spl in self.samples]
results = []
delly = self.add_component("Delly", [input_bam, self.reference_genome])
# delly = self.add_component("Delly", [input_bam, self.reference_genome])
# breakdancer = self.add_component("Breakdancer", [input_bam, self.reference_genome, self.chrom, self.min_sup, self.min_mapq, self.max_len])
pindel = self.add_component("Pindel", kwargs={"input_bam":input_bam,"reference_genome": self.reference_genome,
"output_file":"pindel.concat.out", "chrom":self.chrom, "mean_insert":self.mean_insert,
"min_sup":self.min_sup, "indiv_list":indiv_list})
# cnvnator = self.add_component("CnvNator", [input_bam, self.reference_genome, self.chrom, self.bin_size])
#=====TEST PURPOSE=====
# #=====TEST PURPOSE=====
input_f = ["/home/yguarr/DataTest/example_cnvnator_raw.txt","/home/yguarr/DataTest/example2_cnvnator_raw.txt","/home/yguarr/DataTest/example3_cnvnator_raw.txt"]
input_name = ["SAMPLE1","SAMPLE2","SAMPLE3"]
#=====TEST PURPOSE=====
delly = self.add_component("Standardisation", [delly.output_file, "delly", "delly.bed", self.min_len, self.max_len, indiv_list])
# indiv_list = ["SAMPLE1","SAMPLE2","SAMPLE3"]
# #=====TEST PURPOSE=====
# delly = self.add_component("Standardisation", [delly.output_file, "delly", "delly.bed", self.min_len, self.max_len, indiv_list])
pindel = self.add_component("Standardisation", [pindel.output_file, "pindel", "pindel.bed", self.min_len, self.max_len, indiv_list])
# breakdancer = self.add_component("Standardisation", [breakdancer.output_file, "breakdancer", "breakdancer.bed", self.min_len, self.max_len, indiv_list, input_bam])
cnvnator = self.add_component("Standardisation", [input_f, "cnvnator", "cnvnator.bed", self.min_len, self.max_len, indiv_list])
results=[delly.output_file, pindel.output_file, cnvnator.output_file]#, breakdancer.output_file]#, pindel.output_file]
self.add_component(component_name="Analyzebed", addto="project", args=[results])
# results=[delly.output_file, pindel.output_file, cnvnator.output_file, breakdancer.output_file]
# results=[delly.output_file, pindel.output_file, breakdancer.output_file]
results=[pindel.output_file,cnvnator.output_file]
# results = ["/home/yguarr/delly.bed", "/home/yguarr/breakdancer.bed", "/home/yguarr/cnvnator.bed", "/home/yguarr/pindel.bed"]
# results = [cnvnator.output_file, pindel.output_file]
arg_list = [results, self.bin_size, self.min_sup, self.min_len, self.max_len, self.overlap_percent, self.li_range, ["pindel", "cnvnator"]]
self.add_component(component_name="Analyzebed", addto="project", args=arg_list)
def post_process(self):
pass