% Template for PLoS
% Version 3.5 March 2018
%
% % % % % % % % % % % % % % % % % % % % % %
%
% -- IMPORTANT NOTE
%
% This template contains comments intended 
% to minimize problems and delays during our production 
% process. Please follow the template instructions
% whenever possible.
%
% % % % % % % % % % % % % % % % % % % % % % % 
%
% Once your paper is accepted for publication, 
% PLEASE REMOVE ALL TRACKED CHANGES in this file 
% and leave only the final text of your manuscript. 
% PLOS recommends the use of latexdiff to track changes during review, as this will help to maintain a clean tex file.
% Visit https://www.ctan.org/pkg/latexdiff?lang=en for info or contact us at latex@plos.org.
%
%
% There are no restrictions on package use within the LaTeX files except that 
% no packages listed in the template may be deleted.
%
% Please do not include colors or graphics in the text.
%
% The manuscript LaTeX source should be contained within a single file (do not use \input, \externaldocument, or similar commands).
%
% % % % % % % % % % % % % % % % % % % % % % %
%
% -- FIGURES AND TABLES
%
% Please include tables/figure captions directly after the paragraph where they are first cited in the text.
%
% DO NOT INCLUDE GRAPHICS IN YOUR MANUSCRIPT
% - Figures should be uploaded separately from your manuscript file. 
% - Figures generated using LaTeX should be extracted and removed from the PDF before submission. 
% - Figures containing multiple panels/subfigures must be combined into one image file before submission.
% For figure citations, please use "Fig" instead of "Figure".
% See http://journals.plos.org/plosone/s/figures for PLOS figure guidelines.
%
% Tables should be cell-based and may not contain:
% - spacing/line breaks within cells to alter layout or alignment
% - do not nest tabular environments (no tabular environments within tabular environments)
% - no graphics or colored text (cell background color/shading OK)
% See http://journals.plos.org/plosone/s/tables for table guidelines.
%
% For tables that exceed the width of the text column, use the adjustwidth environment as illustrated in the example table in text below.
%
% % % % % % % % % % % % % % % % % % % % % % % %
%
% -- EQUATIONS, MATH SYMBOLS, SUBSCRIPTS, AND SUPERSCRIPTS
%
% IMPORTANT
% Below are a few tips to help format your equations and other special characters according to our specifications. For more tips to help reduce the possibility of formatting errors during conversion, please see our LaTeX guidelines at http://journals.plos.org/plosone/s/latex
%
% For inline equations, please be sure to include all portions of an equation in the math environment.  For example, x$^2$ is incorrect; this should be formatted as $x^2$ (or $\mathrm{x}^2$ if the romanized font is desired).
%
% Do not include text that is not math in the math environment. For example, CO2 should be written as CO\textsubscript{2} instead of CO$_2$.
%
% Please add line breaks to long display equations when possible in order to fit size of the column. 
%
% For inline equations, please do not include punctuation (commas, etc) within the math environment unless this is part of the equation.
%
% When adding superscript or subscripts outside of brackets/braces, please group using {}.  For example, change "[U(D,E,\gamma)]^2" to "{[U(D,E,\gamma)]}^2". 
%
% Do not use \cal for caligraphic font.  Instead, use \mathcal{}
%
% % % % % % % % % % % % % % % % % % % % % % % % 
%
% Please contact latex@plos.org with any questions.
%
% % % % % % % % % % % % % % % % % % % % % % % %

\documentclass[10pt,letterpaper]{article}
\usepackage[top=0.85in,left=1.5in, footskip=0.75in]{geometry}
\usepackage{bm}
% amsmath and amssymb packages, useful for mathematical formulas and symbols
\usepackage{amsmath,amssymb}

% Use adjustwidth environment to exceed column width (see example table in text)
\usepackage{changepage}
\usepackage{cite}
\usepackage{ragged2e}
% Use Unicode characters when possible
\usepackage[utf8x]{inputenc}

% textcomp package and marvosym package for additional characters
\usepackage{textcomp,marvosym}

% cite package, to clean up citations in the main text. Do not remove.
\usepackage{cite}
\usepackage{makecell}
% Use nameref to cite supporting information files (see Supporting Information section for more info)
\usepackage{nameref,hyperref}

% line numbers
\usepackage[right]{lineno}
\usepackage{comment}
% ligatures disabled
\usepackage{microtype}
\DisableLigatures[f]{encoding = *, family = * }

% color can be used to apply background shading to table cells only
\usepackage[table]{xcolor}
\usepackage[justification=centering]{caption}
% array package and thick rules for tables
\usepackage{array}
\usepackage{diagbox}
% create "+" rule type for thick vertical lines
\newcolumntype{+}{!{\vrule width 2pt}}
\newcommand{\indep}{\perp \!\!\! \perp}
% create \thickcline for thick horizontal lines of variable length
\newlength\savedwidth
\newcommand\thickcline[1]{%
  \noalign{\global\savedwidth\arrayrulewidth\global\arrayrulewidth 2pt}%
  \cline{#1}%
  \noalign{\vskip\arrayrulewidth}%
  \noalign{\global\arrayrulewidth\savedwidth}%
}

% \thickhline command for thick horizontal lines that span the table
\newcommand\thickhline{\noalign{\global\savedwidth\arrayrulewidth\global\arrayrulewidth 2pt}%
\hline
\noalign{\global\arrayrulewidth\savedwidth}}


% Remove comment for double spacing
%\usepackage{setspace} 
%\doublespacing

% Text layout
\raggedright
\setlength{\parindent}{0.5cm}
\textwidth 5.25in 
\textheight 8.75in

% Bold the 'Figure #' in the caption and separate it from the title/caption with a period
% Captions will be left justified
\usepackage[aboveskip=1pt,labelfont=bf,labelsep=period,justification=raggedright,singlelinecheck=off]{caption}
\renewcommand{\figurename}{Fig}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
% Use the PLoS provided BiBTeX style
\bibliographystyle{plos2015}

% Remove brackets from numbering in List of References
\makeatletter
\renewcommand{\@biblabel}[1]{\quad#1.}
\makeatother

\usepackage{dirtytalk}

% Header and Footer with logo
\usepackage{lastpage,fancyhdr,graphicx}
\usepackage{epstopdf}
%\pagestyle{myheadings}
\pagestyle{fancy}
\fancyhf{}
%\setlength{\headheight}{27.023pt}
%\lhead{\includegraphics[width=2.0in]{PLOS-submission.eps}}
\rfoot{\thepage/\pageref{LastPage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrule}{\hrule height 2pt \vspace{2mm}}
\fancyheadoffset[L]{2.25in}
\fancyfootoffset[L]{2.25in}
\lfoot{\today}

%% Include all macros below
\newtheorem{definition}{Definition}
\newtheorem{assumption}{Assumption}
\newtheorem{proposition}{Proposition}
\newtheorem{remark}{Remark}
\newcommand{\lorem}{{\bf LOREM}}
\newcommand{\ipsum}{{\bf IPSUM}}

%% END MACROS SECTION


\begin{document}
\vspace*{0.2in}

% Title must be 250 characters or less.
%\begin{flushleft}
{\Large
\textbf\newline{Utilizing Machine Learning with Knockoff Filtering to Extract Significant Metabolites in Crohn’s Disease with a Publicly Available Untargeted Metabolomics Dataset: Supplementary Notes} % Please use "sentence case" for title and headings (capitalize only the first word in a title (or heading), the first word in a subtitle (or subheading), and any proper nouns).
}
\newline
% Insert author names, affiliations and corresponding author email (do not include titles, positions, or degrees).
\\
Shoaib Bin Masud\textsuperscript{1\P},
Conor Jenkins\textsuperscript{3\P},
Erika Hussey\textsuperscript{2},
Seth Elkin-Frankston\textsuperscript{2},
Phillip Mach\textsuperscript{3},
Elizabeth Dhummakupt\textsuperscript{3*\&},
Shuchin Aeron\textsuperscript{1*\&},
\\
\bigskip
\textbf{1} Dept. of Electrical and Computer Engineering, Tufts University, Medford, MA, USA
\\
\textbf{2} DEVCOM Soldier Center, Natick, MA 01760, USA
\\
\textbf{3} DEVCOM Chemical Biological Center, Aberdeen Proving Ground, MD 21010, USA
\\
\bigskip

% Insert additional author notes using the symbols described below. Insert symbol callouts after author names as necessary.
% 
% Remove or comment out the author notes below if they aren't used.
%
% Primary Equal Contribution Note
\Yinyang These authors contributed equally to this work.

% Additional Equal Contribution Note
% Also use this double-dagger symbol for special authorship notes, such as senior authorship.
\ddag These authors also contributed equally to this work.

% Current address notes
%\textcurrency Current Address: Dept/Program/Center, Institution Name, City, State, Country % change symbol to "\textcurrency a" if more than one current address note
% \textcurrency b Insert second current address 
% \textcurrency c Insert third current address

% Deceased author note
%\dag Deceased

% Group/Consortium Author Note
%\textpilcrow Membership list can be found in the Acknowledgments section.

% Use the asterisk to denote corresponding authorship and provide email address in note below.
* elizabeth.s.dhummakupt.civ@mail.mil, shuchin@ece.tufts.edu 

%\end{flushleft}
% Please keep the abstract below 300 words

\section{Overview of the knockoff filtering method}
\subsection{Problem setting}
Given $n$ i.i.d. pairs of
covariates and response variable, each of the form $(X, Y)$, where $X = ({X}_1, \dots, {X}_p)\in \mathbb R^p$  has $p$ covariates with a joint distribution $\mathsf {P_X}$, that is typically known and $Y \in \mathbb R$. However, the conditional distribution $\mathsf{P}_{\mathsf Y|\mathsf X}$ is unknown. $Y$ can depend on any of the $p$ covariates in either a parametric or non-parametric way. Discovering important covariates can be modeled as the following multiple hypothesis testing problem:

$$H_0^j: Y \indep X_j|X_{-j} \hspace{2mm}\text{versus} \hspace{2mm} H_A^j : Y \not \indep X_j| X_{-j} \hspace{2mm}\forall j = 1, \dots, p. $$ 


where, $X_{-j} = (X_1, \dots, X_{j-1}, X_{j+1}, \dots, X_p )$. By applying any variable selection method, we seek to find the Markov Blanket i.e. the smallest subset of covariates $S \subseteq \{1, \dots, p\}$ so that the response $Y$ is conditionally independent of  other covariates:
$$Y \indep \{X_j\}_{j\not \in S} | \{X_j\}_{j \in S},$$
The set of covariates $ \mathcal H_0 = \{j: j\not \in S\}$ is denoted as the true set of null or unimportant vaiables. For any set of selected covariates $\hat S\subset \{1, \dots, p\}$, false discovery rate (FDR) is defined as the expected proportion of null covariates in it:

$$\text {FDR} = \mathbb E\left[  \frac{|\hat{\mathcal S} \cap \mathcal H_0|} {\text{max}(1, \;\;  |\hat{\mathcal S}|)}  \right]$$

The goal of knockoff filtering is to select as many important variables as possible while bounding the expected false discovery proportion known as FDR below a predefined level $q\in(0, 1)$. Barber and Candes in \cite{candes2016panning} proposed a variable selection procedure called as (Model-X)MX- knockoff that controls the false discovery rate.

\begin{definition}\cite{candes2016panning}
Given a family of random variables $ X = (X_1, \dots, X_p)$, MX-knockoff proposed to create a new family of random variables $\tilde{ X} = (\tilde X_1, \dots, \tilde X_p)$ satisfying following two properties: 
\end{definition}
\begin{enumerate}
    \item Exchangeability property: For any subset $S \in\{1, \dots, p\}$
    \begin{equation}\label{exchangeability}
        ( X, \tilde{ X})_{\text{swap}(S)} \overset{d}{=} ( X, \tilde { X})
    \end{equation}
    where,  $( X, \tilde { X})_{\text{swap}(S)}$ denotes the swapping the position between $X_j$ with $\tilde X_j$ for $j\in S$ and $\overset{d}{=}$ is defined as the equality in distribution. 
    \item $Y \indep \tilde{ X} \;|\;  X$. This property is achieved by generating knockoff $\tilde{ X}$ without observing $Y$. 
\end{enumerate}

Pairwise exchangeability condition in \ref{exchangeability} simply infers that knockoff variables preserve some of the structure of original variables. Knockoff covariates are null, and they have the same power to explain response variable as the original null covariates. The number of knockoff covariates selected by any selection procedure will thus be a good estimate for the number of null covariates that have been selected from the original covariates \cite{candes2016panning}. 


\subsection{Generation of Knockoff variables}
Exchangeability defined in equation \ref{exchangeability} is hard to achieve as it requires the exact knowledge of $\mathsf{P}_{\mathsf{X}}$. Assuming $X$ is sampled from a multivariate normal distribution $\mathcal N(0, \mathbf{\Sigma})$, one way to achieve exchangeability is by sampling $(X, \tilde {X})\sim \mathcal N(0, \mathbf{G})$ where $\mathbf G$ is positive semidefinite,
$$ \mathbf G =\begin{bmatrix}
         \mathbf \Sigma &  \mathbf \Sigma- \text{diag}\left\{ s\right \}\\
         \mathbf \Sigma- \text{diag}\left\{ s\right \} & \mathbf \Sigma 
        \end{bmatrix};$$
        
$X_j$ and $\tilde X_j$ for $j = 1, \dots, p$ has to be decorrelated as much as possible to increase the power of a variable selection method which is ensured by taking $\{s_j\}_{i = 1}^p \approx 1$. To create approximate knockoff we can sample $\tilde X$ from the following conditional distribution:
$${\tilde X}| X\sim \mathcal N(\mu, \mathbf V),$$
$\mu$ and $V$ can be achieved using following regression formula:
\begin{align}\label{k_generation}
     \mu =  X -  X \mathbf \Sigma^{-1} \text{diag}\{s\},\\
   \mathbf  V = 2 \text{diag}\{s\} -\text{diag}\{s\} \mathbf \Sigma^{-1}\text{diag}\{s\}.
\end{align}
The above equations provide the second-order knockoff by approximating mean and covariance assuming the distribution in Gaussian. However, recent development in knockoff filtering takes the advantage of deep generative models and can generate higher order knockoffs \cite{romano2020deep, liu2018auto, lu2018deeppink}. Going forward, we denote $\mathbf X \in \mathbb R^{n\times p}$ as the data matrix, $\tilde {\mathbf X} \in \mathbb R^{n\times p}$ as the knockoff matrix  and $\mathbf y \in \mathbb R^n$ as the response vector. 



\subsection{Feature Statistics}
In order to find the true set of non-null covariates, consider any machine learning method that can provide feature importance e.g. Lasso regression \cite{tibshirani2011regression}, Random forest \cite{trainor2017evaluation}. Training the variable selection method $t(\cdot)$ on the augmented $[\mathbf X, \mathbf {\tilde X}] \in \mathbb R^{n\times 2p}$ to predict $\mathbf y$, will generate feature importance for $j = 1, 2, \dots, p, p+1, \dots, 2p$ variables, where $Z_j$ represents the importance of the  original covariates ($1, \dots, p$)  and $\tilde Z_j$ represents the importance of the knockoff covariates ($p+1, \dots, 2p$).

\begin{figure}[ht]
 \begin{adjustwidth}{-.5in}{0in}
    \centering
    \includegraphics[width = 14cm, height = 6cm]{Variables.png}
    \caption{Feature importance statistics for $1000$ original variables and corresponding knockoff variables. Black dot represents the null features. Red and blue dot refers to feature statistics of non-null features for original variables and corresponding knockoff variables respectively.}
    \label{feature_statistics}
    \end{adjustwidth}
\end{figure}

$$( Z, \tilde { Z})=(Z_1, \dots, Z_p, \tilde Z_1, \dots, \tilde Z_p) = t([\mathbf X, \mathbf {\tilde X}], \mathbf y).$$ 
For any set $S\subset \{1, \dots, p\}$, swapping the position of any covariate with its knockoff will change the position of the statistics in the same manner,
\begin{equation}
    ( Z, \tilde { Z})_{\text{swap}(S)} = t([\mathbf X, \mathbf {\tilde X}]_{\text{swap}(S)}, \mathbf y).
\end{equation} 

By the definition of  null variables, feature importance statistics of all null covariates $Z_j$ should be close to zero, although this may not be the case in practice (Figure \ref{feature_statistics}). In addition to this, for knockoff variables to serve as negative controls, the feature importance of a true variable has to be larger than that of its knockoff counterpart. In order to find the important covariates, Candes \cite{barber2015controlling} defined a new statistics called as adjusted knockoff score $W_j$.

\begin{definition}\cite{candes2016panning}\label{Knockoff score}
Knockoff statistics $ W_j$ for each $j \in \{1, \dots, p\}$ representing feature importance obey two following properties:
\end{definition}
\begin{enumerate}
    \item It depends on original, knockoff and response variables
    $$W_j =f \circ t([\mathbf X, \tilde {\mathbf X}], \mathbf y) = w_j([\mathbf X, \tilde {\mathbf X}], \mathbf y).$$
    where function $f(\cdot)$ works on the feature importance obtained from variable selection method $t(\cdot)$.
    \item $w_j$ has to obey the flip-sign property e.g. swapping $X_j$ with $\tilde X_j$ will flip  the sign of $W_j$ for any $S\subset \{1, \cdots, p\}$
    \begin{align}
        w_j([\mathbf X, \tilde {\mathbf X}]_{\text{swap}(S)}, \mathbf y) = \begin{cases}
        w_j([\mathbf X, \tilde {\mathbf X}], \mathbf y), &  j\notin S\\
        -w_j([\mathbf X, \tilde {\mathbf X}], \mathbf y), & j \in S
        \end{cases}
        \end{align}
\end{enumerate}
Based on the properties of $W_j$, Candes in \cite{barber2015controlling} proposed the following remark:
\begin{remark}\cite{candes2016panning}\label{remark}
Conditional on $(|W_1|, \dots, |W_p|)$, the signs of the null $W_j$'s, $j\in \mathcal H_0$, are i.i.d. coin flips.
\end{remark}



There are several functions with flip-sign property to provide the desired statistics. Considering the lasso regression problem on the augmented matrix consists of original and knockoff variables $[\mathbf X, \tilde {\mathbf X}]\in \mathbb R^{n\times 2p}$, the feature importance can be obtained by:
 \begin{equation}
     \bm{\hat \beta} = \argmin_{\bm \beta \in \mathbb R^{2p}} \frac{1}{2} \|\mathbf y - [\mathbf X, \mathbf{\tilde X}]\bm \beta \|_2^2 + \lambda \|\bm \beta \|_1,
 \end{equation}
 where $\lambda$ is a regularization parameter that controls the sparsity of the coefficients. The lasso coefficient difference provides the necessary knockoff statistics with the required properties:
 \begin{equation}
     W_j =  Z_j - \tilde { Z_j} = |\bm{\hat \beta_j}| - |\bm{\hat\beta}_{j + p}|,\;\;\;\; \forall j\in \{1,\dots, p\},
 \end{equation}
 A large positive $W_j$ provides evidence that original $X_j$ is more important than it's knockoff counterpart  $\tilde X_j$, thus belongs to the model. In the main text,  we  used Random forest classifier \cite{trainor2017evaluation} as the variable selection method and considered OOB(Out of Bag) score  as feature importance $Z_j$.


\subsection{FDR control in MX-knockoff}
Exploiting the underlying property of the knockoff statistics in remark \ref{remark}, a data dependent threshold that controls the FDR under a given significant level $q \in (0, 1)$ is calculated according to the following equation as defined in \cite{benjamini1995controlling},
\begin{gather}
    \tau_{+} = \text{min}\big\{t>0: \frac{\text{offset} + \# \{j: W_j \leq -t\}}{j: \#\{W_j \geq t\}} \leq q\} 
\end{gather}
where the \say{offset} is either $0$ or $1$, and determines the conservativeness of the FDR control procedure ($0$ being less conservative). After calculating the threshold, the set of selected variables is denoted by:
\begin{equation}
    \hat S = \{j \in \{1, \dots, p\}: W_j \leq \tau_{+}\} . 
\end{equation}
One of the major drawbacks of selecting the variables using the above \say{Model-X} method is it's instability since the generation of knockoff variables follows a random approach. Different draws of knockoff data matrix $\tilde { \mathbf X}$ yield different solutions hence inferences become irreproducible. To counter this problem, Nguyen \cite{nguyen2020aggregation} proposed Aggregate Knockoff, a quantile aggregation technique performed on knockoff scores obtained from multiple knockoffs to develop a robust inference. In the following subsection we discuss this version of knockoff filtering.

\subsection{Aggregation of Multiple Knockoffs}
This procedure follows the same techniques as described in \cite{candes2016panning} to generate $B$ independent copies of knockoff data $\{\tilde{\mathbf X}_b\}_{b=1}^B$ and knockoff statistics $W$ according to Definition \ref{Knockoff score}. However, instead of calculating a data dependent threshold from $W$, it introduces an intermediate $p$-value.
\begin{definition}\cite{nguyen2020aggregation}
Intermediate $p-$ value for $j\in \{1, \dots, p\}$ is defined as
    \begin{gather}\label{inter_p}
        \pi_j = \begin{cases}
        \frac{1 +\;\; \#\; \{k:\;\; W_k\;\; \leq -W_j\;\}}{p}\;\; \text{if}\;\; W_j > 0,\\
        1 \;\;\text{if}\;\; W_j \leq 0.
        \end{cases}
    \end{gather}
\end{definition}
Intermediate $p$-values are calculated for each variable $j\in\{1, \dots p\}$ for $B$ draws of knockoff variables using equation \ref{inter_p}. Then quantile aggregation \cite{meinshausen2009p} is performed for each variable in parallel according to the following equation:
\begin{gather}
    \bar \pi_j = \text{min} \Big\{1, \frac{q_\gamma(\{\pi_j^{(b)}: b \in \{1, \dots, B\}\})}{\gamma}\Big\}.
\end{gather}
where, $q_\gamma(\cdot)$ is the $\gamma-$ quantile function.

Finally, Benjamini-Hocherberg step up procedure \cite{benjamini1995controlling} is used to find threshold on the ordered p-values $\bar\pi_{(1)} \leq \bar\pi_{(2)}\leq \cdots\leq \bar\pi_{(p)}$ using the following equation under the assumption of independence or positive  dependence between p-values.

\begin{equation}
     \hat K_{BH} = \text{max} \{k: \bar\pi_{(k)} \leq \frac{kq}{p}\},
\end{equation}

where $q\in (0, 1)$ is the FDR control level. Then, the set of selected variables will be:
$$\hat S = \{j\in \{1, \dots, p\}: \; \bar\pi_{(j)} \leq \bar \pi_{\hat K_{BH}}\}.$$
\begin{proposition}\cite{nguyen2020aggregation}
For $B= 1$ and $\gamma = 1$, aggregated knockoff will be equivalent of MX-knockoff \cite{candes2016panning}.
\end{proposition} 

%\begin{thebibliography}{10}
%\singlespacing
\bibliography{ref.bib}

%\end{thebibliography}



\end{document}

