diff --git a/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/scripts/pdf_report.py b/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/scripts/pdf_report.py index 056a0ea7f07cffb999a7a89aecb4e97ef4b49c94..5206e98cf6ceb6896e1d2668f30b34e02b812036 100755 --- a/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/scripts/pdf_report.py +++ b/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/scripts/pdf_report.py @@ -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) diff --git a/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/templates/pdf/lib_mapping.tex b/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/templates/pdf/lib_mapping.tex index 8026fed7bd9dc08bcccecbe44a87ec2c0b50cb5b..0d862bc9b649157cef7fe5640fbc1948681968fe 100644 --- a/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/templates/pdf/lib_mapping.tex +++ b/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/templates/pdf/lib_mapping.tex @@ -1,18 +1,15 @@ \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 *)) diff --git a/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/templates/pdf/sample.tex b/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/templates/pdf/sample.tex index 947049d2eea57196665a1f63212e7e121d47fd9c..39709550273ada4a8b0fd73d69b5e4982c883f57 100644 --- a/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/templates/pdf/sample.tex +++ b/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/templates/pdf/sample.tex @@ -1,7 +1,7 @@ \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" *)) diff --git a/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/templates/pdf/sample_mapping.tex b/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/templates/pdf/sample_mapping.tex new file mode 100644 index 0000000000000000000000000000000000000000..5e3ab9da745896723197f78ca8ba0d9d428f3667 --- /dev/null +++ b/public/gentrap/src/main/resources/nl/lumc/sasc/biopet/pipelines/gentrap/templates/pdf/sample_mapping.tex @@ -0,0 +1,41 @@ +\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}