\n");
html.push_str("
Summary
\n");
- // --- Reads alignment ---
- html.push_str("
\n
\n");
- html.push_str("
Reads alignment
\n");
- html.push_str("
\n");
-
+ // --- Reads alignment (RNASeqQCAnalysis.prepareHtmlSummary) ---
+ let mut alignment: Vec<(&str, String)> = Vec::new();
if data.paired {
- // Qualimap uses a SINGLE row: "Number of mapped reads (left/right):" / "N / M"
- table_row(
- html,
+ alignment.push((
"Number of mapped reads (left/right):",
- &format!(
+ format!(
"{} / {}",
- format_with_commas(data.left_proper),
- format_with_commas(data.right_proper)
+ format_long(data.left_proper),
+ format_long(data.right_proper)
),
- );
- table_row(
- html,
+ ));
+ alignment.push((
"Number of aligned pairs (without duplicates):",
- &format_with_commas(data.both_proper / 2),
- );
+ format_long(data.both_proper / 2),
+ ));
+ } else {
+ alignment.push((
+ "Number of mapped reads:",
+ format_long(data.primary_alignments),
+ ));
}
-
- table_row(
- html,
- "Total number of alignments:",
- &format_with_commas(data.primary_alignments + data.secondary_alignments),
- );
- table_row(
- html,
- "Number of secondary alignments:",
- &format_with_commas(data.secondary_alignments),
- );
- table_row(
- html,
- "Number of non-unique alignments:",
- &format_with_commas(data.alignment_not_unique),
- );
- table_row(
- html,
- "Aligned to genes:",
- &format_with_commas(data.exonic_reads),
- );
- table_row(
- html,
- "Ambiguous alignments:",
- &format_with_commas(data.ambiguous_reads),
- );
- table_row(
- html,
- "No feature assigned:",
- &format_with_commas(data.no_feature),
- );
- table_row(html, "Not aligned:", &format_with_commas(data.not_aligned));
-
- // SSP estimation (if unstranded)
+ alignment.extend([
+ (
+ "Total number of alignments:",
+ format_long(data.primary_alignments + data.secondary_alignments),
+ ),
+ (
+ "Number of secondary alignments:",
+ format_long(data.secondary_alignments),
+ ),
+ (
+ "Number of non-unique alignments:",
+ format_long(data.alignment_not_unique),
+ ),
+ ("Aligned to genes:", format_long(data.exonic_reads)),
+ ("Ambiguous alignments:", format_long(data.ambiguous_reads)),
+ ("No feature assigned:", format_long(data.no_feature)),
+ ]);
+ if data.seq_not_found > 0 {
+ alignment.push((
+ "Missing chromosome in annotation: ",
+ format_long(data.seq_not_found),
+ ));
+ }
+ alignment.push(("Not aligned:", format_long(data.not_aligned)));
if data.stranded == Strandedness::Unstranded {
- let total_ssp = data.ssp_fwd + data.ssp_rev;
- if total_ssp > 0 {
- let fwd_pct = data.ssp_fwd as f64 / total_ssp as f64 * 100.0;
- let rev_pct = data.ssp_rev as f64 / total_ssp as f64 * 100.0;
- table_row(
- html,
- "Strand specificity estimation (fwd/rev):",
- &format!("{:.2}% / {:.2}%", fwd_pct, rev_pct),
- );
- }
+ let (fwd, rev) = super::strand_estimation(data.ssp_fwd, data.ssp_rev);
+ alignment.push((
+ "Strand specificity estimation (fwd/rev):",
+ format!("{} / {}", format_decimal(fwd), format_decimal(rev)),
+ ));
}
-
- html.push_str("
\n
\n
\n");
+ summary_table(html, "Reads alignment", &alignment);
// --- Reads genomic origin ---
- html.push_str("
\n
\n");
- html.push_str("
Reads genomic origin
\n");
- html.push_str("
\n");
-
- let total_classified = data.exonic_reads + data.intronic_reads + data.intergenic_reads;
- let exonic_pct = if total_classified > 0 {
- data.exonic_reads as f64 / total_classified as f64 * 100.0
- } else {
- 0.0
+ // Percentages of exonic + "no feature" reads, as in the text report.
+ let total_reads = data.exonic_reads + data.no_feature;
+ let origin_row = |count: u64| {
+ format!(
+ "{} / {}",
+ format_long(count),
+ format_percentage(percentage_of(count, total_reads))
+ )
};
- let intronic_pct = if total_classified > 0 {
- data.intronic_reads as f64 / total_classified as f64 * 100.0
- } else {
- 0.0
- };
- let intergenic_pct = if total_classified > 0 {
- data.intergenic_reads as f64 / total_classified as f64 * 100.0
- } else {
- 0.0
- };
-
- // Qualimap format: "Exonic: " / "126,404,800 / 76.4%" (slash separator, variable decimals)
- table_row(
+ summary_table(
html,
- "Exonic: ",
- &format!(
- "{} / {:.2}%",
- format_with_commas(data.exonic_reads),
- exonic_pct
- ),
- );
- table_row(
- html,
- "Intronic: ",
- &format!(
- "{} / {:.2}%",
- format_with_commas(data.intronic_reads),
- intronic_pct
- ),
- );
- table_row(
- html,
- "Intergenic: ",
- &format!(
- "{} / {:.2}%",
- format_with_commas(data.intergenic_reads),
- intergenic_pct
- ),
+ "Reads genomic origin",
+ &[
+ ("Exonic: ", origin_row(data.exonic_reads)),
+ ("Intronic: ", origin_row(data.intronic_reads)),
+ ("Intergenic: ", origin_row(data.intergenic_reads)),
+ (
+ "Intronic/intergenic overlapping exon: ",
+ origin_row(data.overlapping_exon_reads),
+ ),
+ ],
);
- let overlapping_pct = if total_classified > 0 {
- data.overlapping_exon_reads as f64 / total_classified as f64 * 100.0
- } else {
- 0.0
- };
- table_row(
+ // --- Transcript coverage profile ---
+ summary_table(
html,
- "Intronic/intergenic overlapping exon: ",
- &format!(
- "{} / {:.2}%",
- format_with_commas(data.overlapping_exon_reads),
- overlapping_pct
- ),
+ "Transcript coverage profile",
+ &[
+ ("5' bias:", format_decimal(data.five_bias)),
+ ("3' bias:", format_decimal(data.three_bias)),
+ ("5'-3' bias:", format_decimal(data.five_three_bias)),
+ ],
);
- html.push_str("
\n
\n
\n");
-
- // --- Transcript coverage profile ---
- html.push_str("
\n
\n");
- html.push_str("
Transcript coverage profile
\n");
- html.push_str("
\n");
-
- table_row(html, "5' bias:", &format_bias(data.five_bias));
- table_row(html, "3' bias:", &format_bias(data.three_bias));
- table_row(html, "5'-3' bias:", &format_bias(data.five_three_bias));
+ // --- Junction analysis ---
+ let mut junctions: Vec<(&str, String)> =
+ vec![("Reads at junctions:", format_long(data.reads_at_junctions))];
+ for (motif, pct) in super::junction_motif_rows(data.junction_motifs, data.reads_at_junctions) {
+ junctions.push((motif, format_percentage(pct)));
+ }
+ summary_table(html, "Junction analysis", &junctions);
- html.push_str("
\n
\n
\n");
+ html.push_str("
\n");
+}
- // --- Junction analysis ---
+/// One `