Commit 1de28c56 authored by bow's avatar bow
Browse files

Add library-level and sample-level RNA metrics to report

parent bbaa6236
......@@ -419,6 +419,31 @@ class GentrapLib(object):
self.fastqc_r2_qc = FastQC(self.fastqc_r2_qc_files["fastqc_data"]["path"])
# mapping metrics settings
self.aln_metrics = summary.get("bammetrics", {}).get("stats", {}).get("alignment_metrics", {})
# insert size metrics files
self.inserts_metrics_files = summary.get("bammetrics", {}).get("files", {}).get("insert_size_metrics", {})
# rna metrics files and stats
_rmetrics = summary.get("gentrap", {}).get("stats", {}).get("rna_metrics", {})
if _rmetrics:
self.rna_metrics_files = summary.get("gentrap", {}).get("files", {}).get("rna_metrics", {})
self.rna_metrics = {k: v for k, v in _rmetrics.items() }
pf_bases = float(_rmetrics["pf_bases"])
exonic_bases = int(_rmetrics.get("coding_bases", 0)) + int(_rmetrics.get("utr_bases", 0))
# picard uses pct_ but it's actually ratio ~ we follow their convention
pct_exonic_bases_all = exonic_bases / float(_rmetrics["pf_bases"])
pct_exonic_bases = exonic_bases / float(_rmetrics.get("pf_aligned_bases", 0))
self.rna_metrics.update({
"exonic_bases": exonic_bases,
"pct_exonic_bases_all": pct_exonic_bases_all,
"pct_exonic_bases": pct_exonic_bases,
"pct_aligned_bases": 1.0,
"pct_aligned_bases_all": float(_rmetrics.get("pf_aligned_bases", 0.0)) / pf_bases,
"pct_coding_bases_all": float(_rmetrics.get("coding_bases", 0.0)) / pf_bases,
"pct_utr_bases_all": float(_rmetrics.get("utr_bases", 0.0)) / pf_bases,
"pct_intronic_bases_all": float(_rmetrics.get("intronic_bases", 0.0)) / pf_bases,
"pct_intergenic_bases_all": float(_rmetrics.get("intergenic_bases", 0.0)) / pf_bases,
})
if _rmetrics.get("ribosomal_bases", "") != "":
self.rna_metrics["pct_ribosomal_bases_all"] = float(_rmetrics.get("pf_ribosomal_bases", 0.0)) / pf_bases
def __repr__(self):
return "{0}(sample=\"{1}\", lib=\"{2}\")".format(
......@@ -436,6 +461,30 @@ class GentrapSample(object):
self.libs = \
{l: GentrapLib(self.run, self, l, summary["libraries"][l]) \
for l in self.lib_names}
# rna metrics files and stats
_rmetrics = summary.get("gentrap", {}).get("stats", {}).get("rna_metrics", {})
if _rmetrics:
self.rna_metrics_files = summary.get("gentrap", {}).get("files", {}).get("rna_metrics", {})
self.rna_metrics = {k: v for k, v in _rmetrics.items() }
pf_bases = float(_rmetrics["pf_bases"])
exonic_bases = int(_rmetrics.get("coding_bases", 0)) + int(_rmetrics.get("utr_bases", 0))
# picard uses pct_ but it's actually ratio ~ we follow their convention
pct_exonic_bases_all = exonic_bases / float(_rmetrics["pf_bases"])
pct_exonic_bases = exonic_bases / float(_rmetrics.get("pf_aligned_bases", 0))
self.rna_metrics.update({
"exonic_bases": exonic_bases,
"pct_exonic_bases_all": pct_exonic_bases_all,
"pct_exonic_bases": pct_exonic_bases,
"pct_aligned_bases": 1.0,
"pct_aligned_bases_all": float(_rmetrics.get("pf_aligned_bases", 0.0)) / pf_bases,
"pct_coding_bases_all": float(_rmetrics.get("coding_bases", 0.0)) / pf_bases,
"pct_utr_bases_all": float(_rmetrics.get("utr_bases", 0.0)) / pf_bases,
"pct_intronic_bases_all": float(_rmetrics.get("intronic_bases", 0.0)) / pf_bases,
"pct_intergenic_bases_all": float(_rmetrics.get("intergenic_bases", 0.0)) / pf_bases,
})
if _rmetrics.get("ribosomal_bases", "") != "":
self.rna_metrics["pct_ribosomal_bases_all"] = float(_rmetrics.get("pf_ribosomal_bases", 0.0)) / pf_bases
def __repr__(self):
return "{0}(\"{1}\")".format(self.__class__.__name__, self.name)
......
\subsection{Mapping}
\label{sec:map}
\label{sec:map-((( lib.sample.name )))-((( lib.name )))}
\subsubsection{Mapping statistics}
Table~\ref{tab:bamstat-((( lib.sample.name )))-((( lib.name ))))} shows the overview statistics of the
generated alignment file.
\indent
% number + percentage of reads mapped to genome
% number + percentage of properly paired reads
\begin{center}
\captionof{table}{Mapping Overview}
\label{tab:bamstat-((( lib.sample.name )))-((( lib.name ))))}
\label{tab:bamstat-((( lib.sample.name )))-((( lib.name )))}
\setlength{\tabcolsep}{11pt}
((* if lib.is_paired_end *))
\begin{tabular}{ l r r r }
......@@ -46,34 +43,19 @@ generated alignment file.
\end{tabular}
\end{center}
((=
%((* if run.is_paired_end *))
%% inferred insert size distribution
%\subsection{Insert size distribution}
%
%This section contains a quick overview of the insert size distribution
%of the mapped reads.
%
%\indent
%
%There are three possible types of inserts the graph may denote:
%\begin{description}
% \item[\textit{inward}] \hfill \\
% Each read pair maps to opposite strands and point towards each other.
% \item[\textit{outward}] \hfill \\
% Each read pair maps to opposite strands and point away from each other.
% \item[\textit{same directions}] \hfill \\
% Both read pair map to the same strand.
%\end{description}
%
%\IfFileExists{((( vars['OUT_DIR'] )))/((( vars['SAMPLE'] ))).insertsizes.png}
%{
% \begin{figure}[h!]
% \centering
% \includegraphics[width=0.7\textwidth]{((( vars['OUT_DIR'] )))/((( vars['SAMPLE'] ))).insertsizes.png}
% \caption{Distribution of insert size length of paired-end reads mapped to opposite strands.}
% \end{figure}
%}
((* if lib.is_paired_end *))
% inferred insert size distribution
\subsubsection{Insert size distribution}
\IfFileExists{((( lib.inserts_metrics_files.output_histogram.path )))}
{
\begin{figure}[h!]
\centering
\includegraphics[width=0.7\textwidth]{((( lib.inserts_metrics_files.output_histogram.path )))}
\caption{Distribution of insert size length of paired-end reads mapped to opposite strands.}
\end{figure}
}
((= TODO: strand-specific stats
%{
% \IfFileExists{((( vars['OUT_DIR'] )))/((( vars['SAMPLE'] ))).f.insertsizes.png}
% {
......@@ -92,5 +74,42 @@ generated alignment file.
% \end{figure}
% }{}
%}
%((* endif *))
=))
((* endif *))
((* if lib.sample.libs|length > 1 *))
\subsubsection{RNA-specific metrics}
\IfFileExists{((( lib.rna_metrics_files.output_chart.path )))}
{
\begin{figure}[h!]
\centering
\includegraphics[width=0.7\textwidth]{((( lib.rna_metrics_files.output_chart.path )))}
\caption{Normalized coverage bias plot.}
\end{figure}
}
\begin{center}
\captionof{table}{Functional annotation metrics}
\label{tab:fannot-((( lib.sample.name )))-((( lib.name ))))}
\setlength{\tabcolsep}{11pt}
\begin{tabular}{ l r r r }
\hline
\multirow{2}{*}{Parameter} & \multicolumn{3}{c}{Value} \\
& Count & \% of all & \% of aligned \\
\hline \hline
Total bases & ((( lib.rna_metrics.pf_bases|nice_int ))) & 100\% & - \\
Aligned bases & ((( lib.rna_metrics.pf_aligned_bases|nice_int ))) & ((( lib.rna_metrics.pct_aligned_bases_all|float2nice_pct )))\% & ((( lib.rna_metrics.pct_aligned_bases|float2nice_pct )))\% \\
Exonic bases & ((( lib.rna_metrics.exonic_bases|nice_int ))) & ((( lib.rna_metrics.pct_exonic_bases_all|float2nice_pct )))\% & ((( lib.rna_metrics.pct_exonic_bases|float2nice_pct )))\% \\
\hspace*{4mm}Coding bases & ((( lib.rna_metrics.coding_bases|nice_int ))) & ((( lib.rna_metrics.pct_coding_bases_all|float2nice_pct )))\% & ((( lib.rna_metrics.pct_coding_bases|float2nice_pct )))\% \\
\hspace*{4mm}UTR bases & ((( lib.rna_metrics.utr_bases|nice_int ))) & ((( lib.rna_metrics.pct_utr_bases_all|float2nice_pct )))\% & ((( lib.rna_metrics.pct_utr_bases|float2nice_pct )))\% \\
Intronic bases & ((( lib.rna_metrics.intronic_bases|nice_int ))) & ((( lib.rna_metrics.pct_intronic_bases_all|float2nice_pct )))\% & ((( lib.rna_metrics.pct_intronic_bases|float2nice_pct )))\% \\
Intergenic bases & ((( lib.rna_metrics.intergenic_bases|nice_int ))) & ((( lib.rna_metrics.pct_intergenic_bases_all|float2nice_pct )))\% & ((( lib.rna_metrics.pct_intergenic_bases|float2nice_pct )))\% \\
((* if lib.rna_metrics.ribosomal_bases != "" *))
Ribosomal bases & ((( lib.rna_metrics.ribosomal_bases|nice_int ))) & ((( lib.rna_metrics.pct_ribosomal_bases_all|float2nice_pct )))\% & ((( lib.rna_metrics.pct_ribosomal_bases|float2nice_pct )))\% \\
((* endif *))
\hline
\end{tabular}
\end{center}
((* endif *))
\part{Sample "((( sample.name )))" Results}
\label{sample:(((sample.name)))}
Hello from module ((( sample ))) \\
((* include "sample_mapping.tex" *))
((* for lib in sample.libs.values() *))
((* include "lib.tex" *))
......
\section{Mapping}
\label{sec:map-((( sample.name )))}
\subsection{Mapping statistics}
\indent
\subsection{RNA-specific metrics}
\IfFileExists{((( sample.rna_metrics_files.output_chart.path )))}
{
\begin{figure}[h!]
\centering
\includegraphics[width=0.7\textwidth]{((( sample.rna_metrics_files.output_chart.path )))}
\caption{Normalized coverage bias plot.}
\end{figure}
}
\begin{center}
\captionof{table}{Functional annotation metrics}
\label{tab:fannot-((( sample.name )))}
\setlength{\tabcolsep}{11pt}
\begin{tabular}{ l r r r }
\hline
\multirow{2}{*}{Parameter} & \multicolumn{3}{c}{Value} \\
& Count & \% of all & \% of aligned \\
\hline \hline
Total bases & ((( sample.rna_metrics.pf_bases|nice_int ))) & 100\% & - \\
Aligned bases & ((( sample.rna_metrics.pf_aligned_bases|nice_int ))) & ((( sample.rna_metrics.pct_aligned_bases_all|float2nice_pct )))\% & ((( sample.rna_metrics.pct_aligned_bases|float2nice_pct )))\% \\
Exonic bases & ((( sample.rna_metrics.exonic_bases|nice_int ))) & ((( sample.rna_metrics.pct_exonic_bases_all|float2nice_pct )))\% & ((( sample.rna_metrics.pct_exonic_bases|float2nice_pct )))\% \\
\hspace*{4mm}Coding bases & ((( sample.rna_metrics.coding_bases|nice_int ))) & ((( sample.rna_metrics.pct_coding_bases_all|float2nice_pct )))\% & ((( sample.rna_metrics.pct_coding_bases|float2nice_pct )))\% \\
\hspace*{4mm}UTR bases & ((( sample.rna_metrics.utr_bases|nice_int ))) & ((( sample.rna_metrics.pct_utr_bases_all|float2nice_pct )))\% & ((( sample.rna_metrics.pct_utr_bases|float2nice_pct )))\% \\
Intronic bases & ((( sample.rna_metrics.intronic_bases|nice_int ))) & ((( sample.rna_metrics.pct_intronic_bases_all|float2nice_pct )))\% & ((( sample.rna_metrics.pct_intronic_bases|float2nice_pct )))\% \\
Intergenic bases & ((( sample.rna_metrics.intergenic_bases|nice_int ))) & ((( sample.rna_metrics.pct_intergenic_bases_all|float2nice_pct )))\% & ((( sample.rna_metrics.pct_intergenic_bases|float2nice_pct )))\% \\
((* if sample.rna_metrics.ribosomal_bases != "" *))
Ribosomal bases & ((( sample.rna_metrics.ribosomal_bases|nice_int ))) & ((( sample.rna_metrics.pct_ribosomal_bases_all|float2nice_pct )))\% & ((( sample.rna_metrics.pct_ribosomal_bases|float2nice_pct )))\% \\
((* endif *))
\hline
\end{tabular}
\end{center}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment