Commit 8811baae authored by bow's avatar bow
Browse files

Initial mapping subsection in report

parent de316ff7
......@@ -324,13 +324,28 @@ class LongTable(object):
def nice_int(num, default="None"):
if num is None:
return default
return locale.format("%i", int(num), grouping=True)
try:
return locale.format("%i", int(num), grouping=True)
except:
return default
def nice_flt(num, default="None"):
if num is None:
return default
return locale.format("%.2f", float(num), grouping=True)
try:
return locale.format("%.2f", float(num), grouping=True)
except:
return default
def float2nice_pct(num, default="None"):
if num is None:
return default
try:
return locale.format("%.2f", float(num) * 100.0, grouping=True)
except:
return default
# and some handy functions
......@@ -363,6 +378,7 @@ def write_template(run, template_file, logo_file):
# put in out filter functions
env.filters["nice_int"] = nice_int
env.filters["nice_flt"] = nice_flt
env.filters["float2nice_pct"] = float2nice_pct
# write tex template for pdflatex
jinja_template = env.get_template(path.basename(template_file))
......@@ -384,6 +400,7 @@ class GentrapLib(object):
self.sample = sample
self.name = name
self._raw = summary
# flexiprep settings
self.flexiprep = summary.get("flexiprep", {})
self.clipping = not self.flexiprep["settings"]["skip_clip"]
self.trimming = not self.flexiprep["settings"]["skip_trim"]
......@@ -400,6 +417,8 @@ class GentrapLib(object):
if "fastqc_R2_qc" in self.flexiprep["files"]:
self.fastqc_r2_qc_files = self.flexiprep["files"]["fastqc_R2_qc"]
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", {})
def __repr__(self):
return "{0}(sample=\"{1}\", lib=\"{2}\")".format(
......
......@@ -2,3 +2,5 @@
\label{lib:(((lib.name)))}
((* include "lib_seqeval.tex" *))
\clearpage
((* include "lib_mapping.tex" *))
\subsection{Mapping}
\label{sec:map}
\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 ))))}
\setlength{\tabcolsep}{11pt}
((* if lib.is_paired_end *))
\begin{tabular}{ l r r r }
\hline
\multirow{2}{*}{Parameter} & \multicolumn{1}{c}{All Pairs} & \multicolumn{1}{c}{First in Pairs} & \multicolumn{1}{c}{Second in Pairs} \\
& Value & Value & Value \\
\hline \hline
Total reads & ((( lib.aln_metrics.PAIR.total_reads|nice_int ))) & ((( lib.aln_metrics.FIRST_OF_PAIR.total_reads|nice_int ))) & ((( lib.aln_metrics.SECOND_OF_PAIR.total_reads|nice_int ))) \\
Mean read length & ((( lib.aln_metrics.PAIR.mean_read_length|nice_flt ))) & ((( lib.aln_metrics.FIRST_OF_PAIR.mean_read_length|nice_flt ))) & ((( lib.aln_metrics.SECOND_OF_PAIR.mean_read_length|nice_flt ))) \\
Strand balance & ((( lib.aln_metrics.PAIR.strand_balance|nice_flt ))) & ((( lib.aln_metrics.FIRST_OF_PAIR.strand_balance|nice_flt ))) & ((( lib.aln_metrics.SECOND_OF_PAIR.strand_balance|nice_flt ))) \\
\% Mapped to reference & ((( lib.aln_metrics.PAIR.pct_pf_reads_aligned|float2nice_pct )))\% & ((( lib.aln_metrics.FIRST_OF_PAIR.pct_pf_reads_aligned|float2nice_pct )))\% & ((( lib.aln_metrics.SECOND_OF_PAIR.pct_pf_reads_aligned|float2nice_pct )))\% \\
\% Mapped to reference (MAPQ >= 20) & ((( lib.aln_metrics.PAIR.pct_pf_reads_aligned|float2nice_pct )))\% & ((( lib.aln_metrics.FIRST_OF_PAIR.pct_pf_reads_aligned|float2nice_pct )))\% & ((( lib.aln_metrics.SECOND_OF_PAIR.pct_pf_reads_aligned|float2nice_pct )))\% \\
Mismatch rate & ((( lib.aln_metrics.PAIR.pf_mismatch_rate|float2nice_pct )))\% & ((( lib.aln_metrics.FIRST_OF_PAIR.pf_mismatch_rate|float2nice_pct )))\% & ((( lib.aln_metrics.SECOND_OF_PAIR.pf_mismatch_rate|float2nice_pct )))\% \\
Indel rate & ((( lib.aln_metrics.PAIR.pf_indel_rate|float2nice_pct )))\% & ((( lib.aln_metrics.FIRST_OF_PAIR.pf_indel_rate|float2nice_pct )))\% & ((( lib.aln_metrics.SECOND_OF_PAIR.pf_indel_rate|float2nice_pct )))\% \\
Chimeras & ((( lib.aln_metrics.PAIR.pct_chimeras|float2nice_pct )))\% & ((( lib.aln_metrics.FIRST_OF_PAIR.pct_chimeras|float2nice_pct )))\% & ((( lib.aln_metrics.SECOND_OF_PAIR.pct_chimeras|float2nice_pct )))\% \\
\hline
((* else *))
\begin{tabular}{ l r }
\hline
\multirow{1}{*}{Parameter} & \multicolumn{1}{c}{Value} \\
\hline \hline
Total reads & ((( lib.aln_metrics.UNPAIRED.total_reads|nice_int ))) \\
Mean read length & ((( lib.aln_metrics.UNPAIRED.mean_read_length|nice_flt ))) \\
Strand balance & ((( lib.aln_metrics.UNPAIRED.strand_balance|nice_flt ))) \\
\% Mapped to reference & ((( lib.aln_metrics.UNPAIRED.pct_pf_reads_aligned|float2nice_pct )))\% \\
\% Mapped to reference (MAPQ >= 20) & ((( lib.aln_metrics.UNPAIRED.pct_pf_reads_aligned|float2nice_pct )))\% \\
Mismatch rate & ((( lib.aln_metrics.UNPAIRED.pf_mismatch_rate|float2nice_pct )))\% \\
Indel rate & ((( lib.aln_metrics.UNPAIRED.pf_indel_rate|float2nice_pct )))\% \\
\hline
((* endif *))
\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}
%}
%{
% \IfFileExists{((( vars['OUT_DIR'] )))/((( vars['SAMPLE'] ))).f.insertsizes.png}
% {
% \begin{figure}[h!]
% \centering
% \includegraphics[width=0.7\textwidth]{((( vars['OUT_DIR'] )))/((( vars['SAMPLE'] ))).f.insertsizes.png}
% \caption{Distribution of insert size length of paired-end reads whose first read maps to the minus strand.}
% \end{figure}
% }{}
% \IfFileExists{((( vars['OUT_DIR'] )))/((( vars['SAMPLE'] ))).r.insertsizes.png}
% {
% \begin{figure}[h!]
% \centering
% \includegraphics[width=0.7\textwidth]{((( vars['OUT_DIR'] )))/((( vars['SAMPLE'] ))).r.insertsizes.png}
% \caption{Distribution of insert size length of paired-end reads whose first read maps to the plus strand.}
% \end{figure}
% }{}
%}
%((* endif *))
=))
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