\subsection{Automatically sorting pulling curves}% -  -  -  -  -  -  -  -  -  -
\label{sec.auto_sort}

%In order to appreciate the mechanisma behind the various recorded curves, let us more closely consider the physical situation.
We attempt to unfold a protein by retracting the AFM tip from the surface (Sec.~\ref{sec.unfold_procedure}).
However, most data does not look like that in Figure~\ref{fig.force_curve_example}.
There are several possible outcomes when the AFM tip is pulled away from the surface.
They are (roughly in order of their probability): 
\begin{packed_enum}
 \item The tip does not stick to anything, and retreats without much deflection. \label{item.free_pull}
 \item The tip sticks to a protein that's tangled in the mat of other proteins covering the surface.\label{item.mat}
 \item The tip sticks to a protein very close to the end bound to the surface.\label{item.short}
 \item The tip sticks to a single protein close to the free end, and gives a clean unfolding force curve.\label{item.good}
 \item The tip sticks to several proteins, and unfolds them all in parallel.\label{item.multi}
 \item Unidentified long range forces skew the measured force.\label{item.lrf}
\end{packed_enum}
Example curves illustrating the unwanted behaviors are given in Figure~\ref{fig.curve_types}.
\begin{figure}[btp]
 \centering
% \subfloat[Tip does not stick.]{\includegraphics[width=0.45\textwidth]{}}\\
 \subfloat[Tip sticks in mat.]{\includegraphics[width=0.45\textwidth]{curve_mat}}
 \quad
 \subfloat[Tip close to bound end.]{\includegraphics[width=0.45\textwidth]{curve_short}}\\ 
 \subfloat[Long range forces.]{\includegraphics[width=0.45\textwidth]{curve_lrf}}
 \quad
 \subfloat[Tip sticks to several proteins.]{\includegraphics[width=0.45\textwidth]{curve_pair}}\\
 \caption{Classes of unfolding force curves.
    Note that each plot is scaled differently to highlight its distinguishing features.}
 \label{fig.curve_types}
\end{figure}

The current procedure is to manually go through the data and pick out the `good' curves by eye.
We would like this process to be at least partially replaced by automatic sorting, which would
clarify sorting criteria, ease sorting of large data sets, and allow automatic tuning of experiment parameters to maximize yield.
My current algorithm for sorting pulling curves is discussed in Appendix~\ref{sec.sorting_criteria}.

After training the automatic sorter to mostly agree with our intuitive sorting on one data set, we tested the sorter by comparing it's results to our manual selection on another dataset.
Our results are given in Table~\ref{tab.sort_comparison}.
\begin{table}[btp]
% \setlength{captionskip}{5pt}
 \hspace{\stretch{1}}
 \subfloat[Training set.]{\label{tab.sort_train}% 050307
  \begin{tabular}{c|rr}
    \% \Bstrut & Good & Bad \\
    \hline
    $+$ \Tstrut & 1.9 & 23 \\
    $-$ & 0.3 & 75 \\
  \end{tabular}}
 \hspace{\stretch{1}}
 \subfloat[Test set.]{\label{tab.sort_test}    % 051507
  \begin{tabular}{c|rr}
    \% & Good & Bad \\
    \hline
    $+$ & 2.2 & 3.9 \\
    $-$ & 2.2 & 91.5 \\
   \end{tabular}}
 \hspace{\stretch{1}}
 \caption{Comparison of manual and automatic sorting.
   (a) The training set of 620 AFM tip retractions.
   (b) The test set of 712 retractions.
   The rows represent the algorithms choices, and the columns represent manual choices.
   The parameters for each experiment were nominally identical, so the large variation between the two datasets is disturbing, but the algorithm is at least correlated with manual decisions.}
 \label{tab.sort_comparison}
\end{table}

After a manual examination of the results, the automatic program did a good job of removing curves with long range forces or no unfolding forces, but had trouble separating the curves with clean protein unfolding sawtooth from curves with more complicated features.
This difficulty is understandable, because the current algorithm only looks for steep drops in force with roughly the proper spacing, but does not fit the region between drops to the WLC model.
Adding a WLC fitting step should be much more accurate, and will hopefully supplant manual sorting completely.

We do not yet understand the reasons behind the large difference between Tables~\ref{tab.sort_train} and~\ref{tab.sort_test}.
There may be some variables we are not controlling, or it may simply be spatial irregularity in the manner the protein is distributed over the sample.
Once the automatic sorter becomes more reliable, we hope to clarify the reasons behind this variation.
