%\VignetteIndexEntry{How to iFlow}
%\VignettePackage{iFlow}

\documentclass[12pt,letterpaper]{article}
\usepackage{amscd,amsmath,amssymb,verbatim}
\usepackage{hyperref}
\usepackage{times}
\usepackage[square,numbers]{natbib}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{Sweave}
\usepackage{subfigure}


\textwidth=6.2in
\textheight=8.5in
\oddsidemargin=.1in
\evensidemargin=.1in
\headheight=-.3in


\newcommand{\scscst}{\scriptscriptstyle}
\newcommand{\scst}{\scriptstyle}
\newcommand{\Rfunction}[1]{{\texttt{#1}}}
\newcommand{\Rcode}[1]{{\texttt{#1}}}
\newcommand{\Robject}[1]{{\texttt{#1}}}
\newcommand{\Rpackage}[1]{{\textsf{#1}}}
\newcommand{\Rclass}[1]{{\textit{#1}}}
\newcommand{\Rfunarg}[1]{{\texttt{#1}}}
\newcommand{\code}[1]{{\texttt{#1}}}


\begin{document}

\title{How to iFlow }

\author{Kyongryun Lee, Nishant Gopalakrishnan, and Chao-Jen Wong}

\maketitle

\section{Introduction}

The \Rpackage{iFlow} package~\cite{iflowpaper} is implemented using the Gtk2
toolkit~\citep{rgtk2, gtk2}, and sits on top of R and Bioconductor.  It allows
convenient management, visualization, and analysis of flow cytometry (FCM)
data.  

Integrated with several FCM related packages\footnote{These include the
  \Rpackage{flowCore}, \Rpackage{flowStats}, \Rpackage{flowViz} packages so
  far. In the future, we hope to include novel analytic methods implemented
in other Bioconductor packages such as \Rpackage{flowClust},
\Rpackage{flowMerge} and etc.} in Bioconductor, \Rpackage{iFlow}  provides an
interactive graphical  user interface (GUI) allowing users to facilitate the analysis
and visualization of complex FCM data. The user can find the major tools on
main application window (see Figure~\ref{mainapp}): the Data menu 
allows manipulation of the loaded data; the Graphic menu provides a range of
visualization methods; and the Gate MENU supports a number of automated gating
algorithms as well as manual gating. 

This vignette provides a step-by-step demonstration of a typical
work flow for FCM analysis and guidelines for all the
tools and methods available in \Rpackage{iFlow}. We start by loading a sample
data, GvHD, in the \Rpackage{flowCore} package and showing how to view the
corresponding parameters and annotation data.  We proceed to transform the
dataset with the \Rfunction{arcsinh} transformation, followed by per-channel
basis normalization on some of the 
flow channels. A couple of visualization functions are then demonstrated for
the currently active dataset. Finally, we illustrate how to create gating
objects by manual or auto-gating methods and show how to apply these objects
to the active dataset.  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%     Table 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{table}
\centering
\begin{tabular}{|l|l|}
\hline
  \bfseries Menu  & \bfseries Description  \\  \hline
  \hline
   File &    \\  \hline
     - Open & Loads FCS or rda (rdata) files.             \\ \hline
   - Save As & Saves statistics for data.                \\ \hline
   - Load & Loads FCS or rda (rdata) files internally.  \\ \hline
   - Quit & Closes \Rpackage{iFlow}.          \\ \hline
   \hline
    Data &   \\ \hline
     - Transformation & Transforms data in \Rfunction{linear}, \Rfunction{ln},
                        \Rfunction{log}, \Rfunction{biexponential}, \\ 
                      & \Rfunction{logicle}, \Rfunction{arcsinh}, and
                        \Rfunction{quadratic} functions.\\ \hline  
   - Subset  &        \\
     - - Filters &  Makes a subset with a selected gate object.  \\
     - - pData   &  Makes a subset with selected sample covariates.  \\  \hline
   - Compensation & Compensates data by applying  a provided \\
                  &  spillover matrix (limited currently). \\ \hline
   - Normalization & Normalizes data through provided three functions : \\
                   & \Rfunction{warpSet}, \Rfunction{gpaSet},
   \Rfunction{gaussNorm}. \\ \hline 
   - Summary & Summaries data through basic statistics :   \\
                   & \Rfunction{median}, \Rfunction{mean}, \Rfunction{max},
   \Rfunction{min}, or user-defined function. \\ \hline 
   \hline
   Graphics &      \\ \hline
     - Plots & Provides various plots for \Robject{flowSet} and
     \Robject{flowFrame}. \\ 
            & Displays data in the form of, \Rfunction{Contour},
     \Rfunction{ECDF}, \Rfunction{Dot}, \Rfunction{Histogram}, \\ 
            &  \Rfunction{Parallel Coordinate}, \Rfunction{Q-Q},
     \Rfunction{Scatter Plot Matrix}, \Rfunction{Smooth Scatter}, \\ 
            & \Rfunction{Stack Density}, \Rfunction{Timeline} and
     \Rfunction{Workflow}. \\ \hline 
   \hline            
   Gate &                              \\ \hline
     - Create &   Creates an object by provided gating methods : \\
              & \Rfunction{Rectangle}, \Rfunction{Quadrant},
     \Rfunction{Lymphcyte}, \Rfunction{Kmeans}, \Rfunction{Norm2}, \\
     & \Rfunction{Curv1}, \Rfunction{Curv2}, and \Rfunction{manual gating}. \\
     \hline  
    
    - Combine & Runs boolean operations to combine objects: \Rfunction{\&},
    \Rfunction{|} and  \Rfunction{!}. \\ \hline 
   \hline
    - Backgating & Shows the effect of the gate on each level in a gating hierarchy. \\ 
   \hline
   ProBin &                   \\ \hline
     - ProBin & Visualizes the differences between the binned control and data. \\ \hline
   \hline
    Help &  Supports documentation and command history for users. \\ \hline
 \end{tabular}
  \caption{The main application menus.}
  \label{table1}
\end{table}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{figure*}[tb]
  \centering
  \includegraphics[width=0.7\textwidth]{Figures/iflow}
  \caption{iFlow's main application window.}
  \label{mainapp}
\end{figure*}

%% FIXME: try not to use this figure as it is has appeared on the published
%% paper 
\begin{figure}[t]
\centering
\includegraphics[width=4.0in,trim=0 50 0 0,clip]{Figures/sdp}
  \caption{An iFlow graphics window displaying data of three FCM
    channels in the form of stacked density plots for ten different
    samples.}
\label{viz}
\end{figure}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Installation}
The \Rpackage{iFlow} package can be installed by typing in the following lines
into an R console.  
%
\begin{Schunk}
\begin{Sinput}
> source("http://bioconductor.org/biocLite.R")
> biocLite("iFlow")
\end{Sinput}
\end{Schunk}
%
\Rpackage{iFlow} can be started using  \Rfunction{library(iFlow)}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Main Application}
Upon calling up the \Rpackage{iFlow} package, the \Rfunction{iFlow} main
application window
will appear on the screen, as depicted in Figure~\ref{mainapp}. The application
window consists of a control and a main panel.
The control panel lists all the loaded datasets and defined gates, and allows
the user to select one of interest.  All operations 
are performed on the currently selected dataset.  
The main panel consists of a notebook with three types of tabs:
\begin{description}
  \item[Information] Provides details about the currently selected dataset.
    It also displays information about previously defined gates and
    transformations, which can be reused in other tasks. 
  \item[Annotation] Provides phenotypic information about the individual
    samples in the current dataset.
  \item[Summary] Provides various summaries of the currently selected dataset.
\end{description}

The application consists of File, Data, Graphics, Gate,  ProBin and Help
menu sections with each providing detailed sub menu items. The functionality
provided by each menu is described in detail in the following sections.  

\subsection{File Menu}
The File menu provides options to import and export data from into the
\Rpackage{iFlow} program. The File menu has four sub menus Open, Load, Save As
and Quit. The Open option can be used to import data available as FCS or LMD
files while the  Load option allows the user to conveniently load flow
cytometry data already available in the R global workspace.

The GvHD data available in the \Rpackage{flowCore} package can be imported into 
\Rpackage{iFlow} by first reading it into the R workspace using the following
lines of code and subsequently using the Load menu to select the GvHD3 and
GvHD5 \Rclass{flowSets} that were created, as demonstrated in
Figure~\ref{fig:load}. 

\begin{Schunk}
\begin{Sinput}
> data(GvHD)
> GvHD3 <- GvHD[1:3]
> GvHD5 <- GvHD[5:10]
\end{Sinput}
\end{Schunk}


\begin{figure}[tb]
 \centering
 \includegraphics[width = 1.8in, totalheight=1.5in]{Figures/load}
 \caption{A pop-up GUI for selecting the imported datasets.}
 \label{fig:load}
\end{figure}

The data panel displays the GvHD3 and GvHD5 \Rclass{flowSets} that have been 
loaded in the \Rpackage{iFlow} program. More details regarding the datasets
GvHD3 and GvHD5 can be obtained by 
first selecting a \Rclass{flowSet} and then accessing the Information and 
Annotation panels. The Information panel provides details regarding the 
fluorescence stains that were used (Figure~\ref{fig:dataview}) while the
Annotation panel provides a  
tabular view of the sample covariates (PatientID, Visit number etc.)
(Figure~\ref{fig:pheno}) 

\begin{figure}[tb]
\centering
\includegraphics[width=0.7\textwidth]{Figures/dataview}
\caption{Information tab showing the details of the currently selected
  dataset, GvHD3.} 
\label{fig:dataview}
\end{figure}


\begin{figure}[tb]
\centering
\includegraphics[width=0.7\textwidth]{Figures/pheno}
\caption{Annotation tab showing phenotypic information of the GvHD3
  dataset. } 
\label{fig:pheno}
\end{figure}

%% FIXME %%
% What exactly does the save menu option do ?? 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\subsection{Data Menu}

The Data menu provides options to transform, subset, compensate or normalize
data that is currently selected in the  data panel.

\subsubsection{Transformation}
%
\begin{figure}[bt]
  \centering                                                                
  \includegraphics[width=3.5in, height=3in]{Figures/transform}
  \caption{The \Rfunction{arcsinh} transformation GUI.}
  \label{fig:transform}
\end{figure}
%
The dataset selected by the user can be transformed for better visualization
of the data using the Transformation option available in the Data menu. The
\Rpackage{iFlow} package provides  \Rfunction{linear}, \Rfunction{log},
\Rfunction{ln}, \Rfunction{logicle}, \Rfunction{arcsinh}, 
\Rfunction{biexponential} scale and \Rfunction{quadratic} transformations. The
user is also provided the option of applying the transformation of choice to
selected fluorescence channels in the dataset. 

Continuing with our example, we proceed to transform the GvHD3 dataset with
the \Rfunction{arcsinh} transformation. The results is shown in
Figure~\ref{fig:transform}. The GvHD3 object after transformation can be
observed in the Data panel as GvHD3\_trans, as depicted in
Figure~\ref{fig:trans-info}  

\begin{figure}[tb]
  \centering
  \includegraphics[width=0.7\textwidth]{Figures/transinfo}
  \caption{Information of the transformed dataset, GvHD3\_trans.}
  \label{fig:trans-info}
\end{figure}
                                                    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Subset}

The subset option allows the user to subset the selected dataset in the Data
panel using either a gate  or by making use of sample covariates that are
displayed under the Annotation tab.  

We proceed to subset the transformed data by the sample covariate name to
include two samples s5a02 and s5a03, as illustrated in Figure~\ref{fig:subset}

\begin{figure}[tb]
\centering
\includegraphics[width=0.7\textwidth]{Figures/subset}
\caption{Subset data.}
\label{fig:subset}
\end{figure}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Compensation}

The compensation menu can be used to compensate fluorescence intensities to
reduce the effects of spillover fluorescence of a particular dye from the
other fluorescence channels. The compensation options in \Rpackage{iFlow} is
limited to the use of the spillover matrix available from the FCS file. 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Normalization}

The normalization menu provides access to \Rfunction{warpSet},
\Rfunction{gaussNorm} and \Rfunction{gpaSet} normalization methods.  The 
\Rfunction{warpSet} and \Rfunction{gaussNorm} are per-channel normalization
methods~\citep{1Dnorm} that identify landmarks in the selected fluorescence
channels and then transform the data such that the landmarks are aligned
across samples in a \Rclass{flowSet}. The \Rfunction{gpaSet} option applies a
multidimensional normalization method using the generalized Procrustes
analysis (GPA) method. 

%% FIXME: per-channel normalization usually only apply to fluorescence
%% channels. It would be more reasonable to do the lymphocyte filtering first,
%% then apply 1D normalization using warpSet.
As shown in Figure~\ref{fig:userfunc}, the "FSC-H" and "SSC-H"
channels of the subset data GvHD3\_trans\_sub \Rclass{flowSet} is
normalized using the \Rfunction{warpSet} function.

\begin{figure}[tb]
\centering
\includegraphics[width=0.7\textwidth]{Figures/userfunc}
\caption{Summary tab for the GvHD3\_trans\_sub\_normalized dataset.}
\label{fig:userfunc}
\end{figure}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Summary}

The summary menu provides basic summary statistics (mean, median etc.) of flow
parameters for each sample. A new summary tab with the calculated 
summary measures is then displayed next to the Annotation tab. Shown in
Figure~\ref{fig:userfunc} is the summary tab for the
GvHD3\_trans\_sub\_normalized dataset.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\subsection{Graphics Menu}

\begin{figure}[tbph]
\centering
\includegraphics[width=3.0in, height=3.0in]{Figures/gmenu}
\caption{Stack Density Plot GUI}
\label{fig:gmenu}
\end{figure}    

The Graphics menu provides several methods to visualize flow cytometry
data. The choices are:

\begin{description}
  \item[Contour Plot] Opens a new GUI which allows the user to select one or
    more data samples and flow channels for X- and Y-axis. Clicking
    on OK will create contour plots for the currently selected samples.

  \item[ECDF Plot] Opens a new GUI which allows the user to select one or more
    samples and a flow channel for X-axis. Clicking on OK will
    create empirical CDF plots for the selected samples with selected
    channels. 

  \item[Dot Plot] Opens a new GUI which allows the user to select
    one or more samples and flow channels for X- and Y-axis.  Clicking
    on will create non-smooth scatter plots.
  
  \item[Histogram Plot]  Opens a new GUI which allows the user to select a
    sample and a flow channel. Clicking on OK will create a frequency
    plot.  

  \item[Parallel Coordinates Plot] Opens a new GUI which allows the user to
    select a sample and a couple or more channels. Clicking on OK
    will create a parallel coordinate plots.
    
  \item[Q-Q Plot] Opens a new GUI which allows the user to select one or more
    samples and a flow channel. Clicking on OK will creates
    a quantile plot.


  \item[Scatter Plot Matrix] Opens a new GUI which allows the  user to select
    one sample and one ore more flow channels.  Clicking on OK will
    create Trellis scatter plots matrices (\Rfunction{splom}) from 
    selected samples.

  \item[Smooth Scatter Plot] Opens a new GUI which allows the user to select one
    or more samples and flow channels for X- and Y-axis. Clicking on
    OK will create Trellis scatter plots for  selected samples. 

  \item[Stack Density] Opens a new GUI which allows the user to select one ore
    more samples and flow channels. Clicking on OK will creates
    horizontal stack plots of density estimates for selected samples. 
           
  \item[Timeline] Opens a new GUI which allows the user to select one or more
    \Rclass{flowFrame}(s) and one channel. Clicking on OK will  plot values
    for the selected samples against a time domain in the
    dataset. It helps to identify problems related to instrument
    setting when the measurement runs.  

  \item[workflow] Creates a flow chart of the current workflow.
  
\end{description}

\begin{figure}[tbhp]
  \centering
  \includegraphics[width=0.6\textwidth]{Figures/stack}
  \caption{Stack Density Plots.}
  \label{fig:densityplots}
\end{figure}

Continuing the example, we activate "GvHD3\_trans\_sub\_normalization" by
clicking the 
data on Data tab in the control panel. Then, select Graphics|Stack Density
Plots.  We select  all the samples and three channels such as
"FSC-H", "SSC-H", and "FL1-H" in the currently activated dataset. The new GUI
calling up by Stack Density Plot selection is shown  in Figure~\ref{fig:gmenu}. 
Depicted in Figure~\ref{fig:densityplots} is the resulting density
plot. Note that any created plots can be saved in the form of 'png' file.



\begin{figure}[tbhp]
  \centering
  \includegraphics[width=0.98\textwidth]{Figures/workflow}
  \caption{Workflow plot.}
  \label{fig:workflow}
\end{figure}
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
\clearpage
\subsection{Gate Menu}

\begin{figure}[tb]
  \centering
  \includegraphics[width=0.7\textwidth]{Figures/gateview}
  \caption{Description of a selected object on Gate View}
  \label{fig:gateview}
\end{figure}

The Gate menu contains two options: Create and Combine. The Create option
allows the user to create gate objects either by manual gating or by the
provided auto-gating methods. The Combine option allows to
combine gate objects. 

\subsubsection{Create Gates}
The Create option provides five selections of auto-geometric gates: 

\begin{description}

\item[Rectangle Gate] Opens new GUIs which allow the user to select two channels
  for X- and Y-axis and to specify the boundary of the rectangle gate. It than
  creates a \Robject{RectangleGate} object.
            
\item[Quadrant Gate] Opens a new GUI which allows the user to select 
  channels for X- and Y-Axis.  It then creates a \Robject{QuadrantGate}
  object and tries to find the most likely separation of the two-dimensional
  data in four quadrant.
                          
\item[Lymphocyte Gate] Opens a new GUI which allows the user to select two
  channels for X- and Y-axis and specify one or more rough preselection
  channels. It then creates a \Robject{LymphFilter} object to identify 
  cell population of roughly elliptical shape.
                     
\item[Kmeans] Opens a new GUI which allows the user to select one channel.  It
  creates a \Rfunction{KmeansFilter} object to identify cell population
  based on one-dimensional k-means clustering operation.
                      
\item[Norm2 Gate] Opens a new GUI which allows the user to select two channels
  for X- and Y-axis.  It creates a \Robject{Norm2Filter} object to find a
  region to mostly resemble a bivariate Normal distribution.
  
\item[Curv1 Gate]  Opens a new GUI which allows the user to select one
  channel. It creates a \Rfunction{Curv1Filter} object to select
  one-dimensional high-density regions.  
  
\item[Curv2 Gate]  Opens a new GUI which allows the user to select two channels
  for X- and Y-axis. It creates a \Rfunction{Curv2Filter} object to select
  two-dimensional high-density regions.    
                          
\end{description}

For the example, we first create three gate objects.  The list of gate
objects will be shown on the Gate List tab on the control panel. 
Additionally, Gate List tab supports summary and a scatter plot of an object in the activated data
by right mouse click on the panel. The summary tab on the object is generated 
on the information panel. Gate View tab provides description of a selected
object. See Figure~\ref{fig:gateview}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsubsection{Applying Gate Objects}

After the Gate objects are created, \Rpackage{iFlow} allows the user to
apply gate objects to the datasets in the following two ways:

\begin{figure}[htbp]
  \centering
  \includegraphics[width=2.5in, height=2.8in]{Figures/subset_gate}
  \caption{A pup-up GUI for selecting a gate for a subset.}
  \label{fig:subset_gate}
\end{figure}

\begin{description}
  \item[Data|Subset By|Gate] Select Data menu and sequentially select Subset
    By and then Gate items. A new GUI will be created, as shown in
    Figure~\ref{fig:subset_gate}, allowing the user to select the Gate objects
    to be applied to the activated dataset.
    
  \item[Drag and Drop] Drag a gate object on the Gate List panel and drop it
    onto the dataset on the Data panel.
\end{description}

As illustrated in Figure~\ref{fig:filter_rst}, the "GvHD3\_trans\_sub" data is
filtered by using with \Robject{Norm2Filter}. Consequently, the filtered
datasets,
"GvHD3\_trans\_sub\_gatedefaultNormFilter+" and
"GvHD3\_trans\_sub\_gatedefaultNormFilter-", are included in the Data tab 
as child nodes of activated dataset.  Figure~\ref{fig:gfilter}
displays a dot plot for the 
"GvHD3\_trans\_sub\_gatedefaultNormFilter+" data object.




\begin{figure}[tbhp]
  \centering
  \includegraphics[width=0.7\textwidth]{Figures/filter_rst}
  \caption{Filtered data.}
  \label{fig:filter_rst}
\end{figure}

\begin{figure}[tbhp]
  \centering
  \includegraphics[width=0.6\textwidth]{Figures/gfilter+}
  \caption{Dot plot for the filtered data.}
  \label{fig:gfilter}
\end{figure}





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Manual Gate}
\Rpackage{iFlow} also supports manual gating to identify cell populations on
one or two dimensional plots.  The user can follow the following two simple
steps to create a gate object:

\begin{enumerate}

  \item Select Gate|Create|Manual Gate menu item. A new GUI will appear on the
    screen allowing the user to choose a sample and flow
    parameters of interest. A smooth scatter plot will then be created.

  \item Draw an enclosed area on the plot by clicking a mouse button on the
    region of interest, as illustrated in Figure~\ref{fig:mgate}. When
    finished, double-click the right mouse button outside of the plot in the
    graphics window.  

\end{enumerate}

\begin{figure}[tbhp]
\centering
\includegraphics[width=0.7\textwidth]{Figures/mgate}
\caption{Drawing an interesting region to create a gate object.}
\label{fig:mgate}
\end{figure}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Combine Gates}

The Combine Gates option allows the user to combine created gates through one
or more boolean operations such as \Rfunction{\&}, \Rfunction{|} and
\Rfunction{!}. Upon selecting this option, a new GUI will appear on the
screen, as depicted in Figure~\ref{fig:cgates}, allowing the user to select the
existing gates and the boolean operation.  The combined gate object will be
created and listed on the Gate List panel as a new gate object.

%% FIXME: explain more clearly about the the negation operation.
%%Note that for the negation, \Rfunction{!}, operation, it needs to select a
%%gate ID on right hand which is [Operation, Filter name] - [! FilterID 6]. 

\begin{figure}
\centering
\includegraphics[width=2.8in, height=3.2in]{Figures/cgates}
\caption{Combine gates}
\label{fig:cgates}
\end{figure}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Backgating}

Backgating analysis provides visualization with the gated polulation at each level in 
a gating hierarchy. So it is able to validate gating positions through the display.
The right-most plot on the graphic window shows final gated polulation of events overlaid 
in a gating hierachy. The summary of the gated population at each level is provided by 
generating summary tab on information panel in the order.


To perform backgating analysis, choose Gate|Backgating menu item, and 
select gate objects in order for shown gate objects on gate list panel by clicking on Add. 
It is also able to delete the selected gates on hierarchy panel (of a selected gate list) 
by clicking on Remove. 

For the example, we apply Norm2Filter object to the active data set, then apply Norm2Filter1
object to the gated population through Norm2Filter1. To validate the position of gates, we are 
able to use backgating function on menu. Figure~\ref{fig:backgating} shows the
GUI of Gate|Backgating menu item, users are able to specify the order of gates they want to
apply gate objects to the data. So Figure~\ref{fig:bg_rst} shows the final gated polulation
overlaid at each level. Therefore, we can easily see whether of not one of selected gates is 
correctly applied.


\begin{figure}                                                              
\centering
\includegraphics[width=3.4in, height=2.7in]{Figures/backgating}
\caption{GUI for backgating analysis}
\label{fig:backgating}
\end{figure}

\begin{figure}                                                              
\centering
\includegraphics[width=3.4in, height=2.7in]{Figures/bg_rst}
\caption{backgating display for the gated population of events overlaid in a gating hierarchy.}
\label{fig:bg_rst}
\end{figure}
 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Help Menu}
The Help menu has two options: Manual and iflow.history. The Manual option
provides a basic user's guide for using \Rpackage{iFlow}. The iFlow.history
option is meant to show the history of actions (R commands) of the current
workflow. Still under development, it now only works for graphics commands.
See Figure~\ref{fig:history} for an example. 


\begin{figure}                                                              
\centering
\includegraphics[width=3.4in, height=2.7in]{Figures/history}
\caption{The history of graphics commands for the current workflow.}
\label{fig:history}
\end{figure}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Conclusion}

The \Rpackage{iFlow} package contains all the code necessary to create and run
the GUI, but it does not contain any code for the analysis of FCS
data. Rather, it relies on functionality implemented in other R
packages such as \Rpackage{flowCore}, \Rpackage{flowStats}, and
\Rpackage{flowViz}. 
It currently provides access to data visualization, manual and
automated gating, transformations and basic data manipulations.  This
is sufficient for initial exploratory data inspection, as well as for
prototyping large analysis projects.

Some of the capabilities exposed by the \Rpackage{iFlow}, such as automated
gating, already go beyond what is available in standard FCM GUI software.
However, the primary long-term advantage of our software is its open
and extensible nature.  Additional functionality may easily be added
in response to user feedback, or once common use cases have emerged.


\clearpage
\newpage

\bibliographystyle{abbrvnat}
%\bibliographystyle{plain}
\bibliography{iflow}

\end{document}