%% brew depends: ac, l2
%% weave depends: l2

<% apid_vals <- l2[acid == ac, unique(apid)] %>
<% for (i in seq_along(apid_vals)) { -%>
<% mylabel <- paste0("acid", ac, "plate", i) %>

\hfill \par
\setkeys{Gin}{width=1\linewidth}
\begin{figure}[H]
<<<%= mylabel %>,fig=true,strip.white=true,echo=false,height=8,width=12>>=
gtoxPlotPlate(dat = l2, apid = "<%= apid_vals[i]%>", id = <%= ac %>)
@
\end{figure}
\par

<% 
up_aeid <- aes[acid == ac & analysis_direction == "up", aeid]
pc_spid <- pcdat[acid == ac & apid == apid_vals[i], spid]
pcids <- l5[spid %in% pc_spid & aeid == up_aeid, m4id]
%>

<% if (length(pcids) > 0) { -%>
<% for (pcid in pcids) { -%>
<% mylabel <- paste0("m4id", pcid) %>

\hfill \par
\setkeys{Gin}{width=0.9\linewidth}
\begin{figure}[H]
<<<%= mylabel %>,fig=true,strip.white=true,echo=false,height=7,width=12>>=
gtoxPlotM4ID(m4id = <%= pcid %>, lvl = 6, bline = "coff")
@
\end{figure}
\par

<% } %> %% END M4ID POSITIVE CONTROL FOR-LOOP
\clearpage
<% } %> %% END POSITIVE CONTROL IF-STATEMENT

<% } %> %% END PLATE LOOP
