-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd70d17
commit 94fefb9
Showing
7 changed files
with
267 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
/temp | ||
|
||
.DS_Store | ||
.idea | ||
|
||
# testing files | ||
/tests/samples/local | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use crate::duplicates; | ||
use anyhow::{Context, Result}; | ||
use serde_json::json; | ||
use std::collections::HashMap; | ||
|
||
// include the template HTML file at compile time as a string literal | ||
const TEMPLATE_HTML: &str = include_str!("summary_template.html"); | ||
|
||
pub fn summarize(index: &str, output: &str) -> Result<()> { | ||
info!("Summarising index at {index}"); | ||
let (_, statistics, info) = duplicates::get_duplicates(index)?; | ||
|
||
let mut data = serde_json::to_value(info).context("Could not serialize info")?; | ||
|
||
println!("{}", serde_json::to_string(&statistics)?); | ||
data["stats"] = serde_json::Value::String(serde_json::to_string(&statistics)?); | ||
|
||
println!( | ||
"{}", | ||
serde_json::to_string_pretty(&data).context("Should be serialisable")? | ||
); | ||
|
||
let file = std::fs::File::create(output)?; | ||
let mut reg = handlebars::Handlebars::new(); | ||
reg.render_template_to_write(TEMPLATE_HTML, &data, file); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta content="width=device-width, initial-scale=1.0" name="viewport"> | ||
<title>Bar Chart from JSON</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
padding: 20px; | ||
margin: auto; | ||
max-width: 800px; | ||
min-height: 100%; | ||
background-color: white; | ||
} | ||
|
||
html { | ||
background-color: #beabc2; | ||
} | ||
|
||
td { | ||
vertical-align: top; | ||
} | ||
|
||
td:nth-child(1) { | ||
/* your stuff here */ | ||
min-width: 150px; | ||
} | ||
|
||
td:nth-child(2) { | ||
font-family: monospace; | ||
padding-left: 10px; | ||
font-size: 1.1em; | ||
} | ||
|
||
canvas { | ||
margin-top: 20px; | ||
} | ||
</style> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.3.0/chart.umd.min.js"></script> | ||
<script> | ||
let stats = {{{ stats }}}; | ||
let data = stats.distribution; | ||
</script> | ||
</head> | ||
<body> | ||
<h1>💅 nailpolish summary report</h1> | ||
<h2>Summary table</h2> | ||
<table> | ||
<tr> | ||
<td> | ||
nailpolish version | ||
</td> | ||
<td> | ||
{{ nailpolish_version }} | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td> | ||
file path | ||
</td> | ||
<td> | ||
{{ file_path }} | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
dataset size | ||
</td> | ||
<td> | ||
{{ gb }} | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
index date | ||
</td> | ||
<td> | ||
{{ index_date }} | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td> | ||
total read count | ||
</td> | ||
<td> | ||
{{ read_count }} | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
matched reads | ||
</td> | ||
<td> | ||
{{ matched_read_count }} | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
unmatched reads | ||
</td> | ||
<td> | ||
{{ unmatched_read_count }} | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td> | ||
average quality | ||
</td> | ||
<td> | ||
{{ avg_qual }} | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
average length | ||
</td> | ||
<td> | ||
{{ avg_len }} | ||
</td> | ||
</tr> | ||
</table> | ||
<h2> | ||
By UMI group | ||
</h2> | ||
|
||
A 'UMI group' is a group of reads which all share the same barcode and UMI. | ||
|
||
<canvas id="byUmi"></canvas> | ||
|
||
<h2> | ||
By read | ||
</h2> | ||
|
||
Each read is classified by the number of reads in its corresponding UMI group. | ||
|
||
<canvas id="byRead"></canvas> | ||
|
||
<script> | ||
const umi_dup_data = { | ||
"labels": Object.keys(data), | ||
"datasets": [{ | ||
label: "", | ||
// "label": "duplicate count", | ||
// "backgroundcolor": "rgba(75, 192, 192, 0.2)", | ||
// "bordercolor": "rgba(75, 192, 192, 1)", | ||
"data": Object.values(data) | ||
}] | ||
}; | ||
|
||
const ctxUmi = document.getElementById('byUmi').getContext('2d'); | ||
new Chart(ctxUmi, { | ||
type: 'bar', | ||
data: umi_dup_data, | ||
options: { | ||
plugins: { | ||
legend: { | ||
display: false | ||
}, | ||
}, | ||
responsive: true, | ||
scales: { | ||
y: { | ||
beginAtZero: true | ||
}, | ||
x: { | ||
title: "Duplicate count" | ||
} | ||
} | ||
} | ||
}); | ||
|
||
let read_data = Object.fromEntries(Object.entries(data).map(([k, v]) => ([k, v*k]))); | ||
|
||
const read_dup_data = { | ||
"labels": Object.keys(read_data), | ||
"datasets": [{ | ||
label: "", | ||
// "label": "duplicate count", | ||
// "backgroundcolor": "rgba(75, 192, 192, 0.2)", | ||
// "bordercolor": "rgba(75, 192, 192, 1)", | ||
"data": Object.values(read_data) | ||
}] | ||
}; | ||
|
||
const ctxRead = document.getElementById('byRead').getContext('2d'); | ||
new Chart(ctxRead, { | ||
type: 'bar', | ||
data: read_dup_data, | ||
options: { | ||
plugins: { | ||
legend: { | ||
display: false | ||
}, | ||
}, | ||
responsive: true, | ||
scales: { | ||
y: { | ||
beginAtZero: true | ||
}, | ||
x: { | ||
title: "duplicate count" | ||
} | ||
} | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |