Skip to content

Commit 92e8462

Browse files
chore(manuscript): update v2 diff file
1 parent 538c255 commit 92e8462

File tree

1 file changed

+153
-4
lines changed
  • reproducibility/manuscript

1 file changed

+153
-4
lines changed

reproducibility/manuscript/v2.tex

Lines changed: 153 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@
252252

253253
% abstract
254254

255-
\abstract{Single-cell RNA Velocity has dramatically advanced our ability
255+
\abstract{Single-cell RNA velocity has dramatically advanced our ability
256256
to model cellular differentiation and cell fate decisions. However,
257257
current preprocessing choices and model assumptions often lead to errors
258258
in assigning developmental trajectories. Here, we develop,
@@ -284,7 +284,7 @@
284284
\section*{Main text}\label{sec-main}
285285
\addcontentsline{toc}{section}{Main text}
286286

287-
RNA Velocity is a powerful computational framework to estimate the time
287+
RNA velocity is a powerful computational framework to estimate the time
288288
derivative of gene expression
289289
\citep{La_Manno2018-lj, Svensson2018-vk, Qiu2022-dj, Bergen2020-pj}. The
290290
framework has been used to study developmental cell lineage trajectories
@@ -664,11 +664,160 @@ \subsection{Model formulation}\label{sec-methods-model}
664664
level from the differential equations proposed in velocyto
665665
\citep{La_Manno2018-lj} and scVelo \citep{Bergen2020-pj} \begin{align}
666666
\frac{d u\left(\tau^{\left(k_{cg}\right)}\right)}{d \tau^{\left(k_{cg}\right)}}
667-
&= \alpha^{\left(k_{cg}\right)}-\beta_g u\left(\tau^{\left(k_{cg}\right)}\right), \label{eq-dudt}\\
667+
&= \alpha^{\left(k_{cg}\right)}-\beta_g u\left(\tau^{\left(k_{cg}\right)}\right),
668+
\label{eq-dudt}\\
668669
\frac{d s\left(\tau^{\left(k_{cg}\right)}\right)}{d \tau^{\left(k_{cg}\right)}}
669-
&= \beta_g u\left(\tau^{\left(k_{cg}\right)}\right)-\gamma_g s\left(\tau^{\left(k_{cg}\right)}\right). \label{eq-dsdt}
670+
&= \beta_g u\left(\tau^{\left(k_{cg}\right)}\right)
671+
-\gamma_g s\left(\tau^{\left(k_{cg}\right)}\right). \label{eq-dsdt}
672+
\end{align} In the equation, the subscript \(c\) is the cell dimension,
673+
\(g\) is the gene dimension,
674+
\(\left( u\left( \tau^{(k_{cg})} \right), s\left( \tau^{(k_{cg})} \right) \right)\)
675+
are the unspliced and spliced expression functions given the change of
676+
time per cell and gene. \(\tau_{cg}\) represents the displacement of
677+
time per cell and gene with \begin{align}
678+
\tau^{(k_{cg})} &= \operatorname{softplus} \left( t_{c} - {t_{0}^{(k_{cg})}}_g \right) \\
679+
& = \log( 1 + \exp (t_c - {t_{0}^{(k_{cg})}}_g)),
680+
\end{align} in which \(t_c\) is the shared time per cell,
681+
\({t_{0}^{(kcg)}}_g\) is the gene-specific switching time. Each cell and
682+
gene combination has its transcriptional state
683+
\(k_{cg} \in \{ 0, 1 \}\), where \(0\) indicates the activation state
684+
and \(1\) indicates the expression state. Each gene has two switching
685+
times for representing activation and repression: \({t_{0}^{(0)}}_g\) is
686+
the first switching time corresponding to when the gene expression
687+
starts to be activated, \({t_0^{(1)}}_g\) is the second switching time
688+
corresponding to when the gene expression starts to be repressed. We
689+
note that \(\alpha^{(1)}\) is shared for all the genes, while
690+
\({\alpha^{(0)}}_g\) is learned independently for each gene.
691+
692+
The analytic solution of the differential equations to predict spliced
693+
and unspliced gene expression given their parameters is derived by the
694+
authors of scVelo and a theoretical RNA velocity study
695+
\citep{Bergen2020-pj, Li2021-qa} and given in Eqs.
696+
\ref{eq-solution-u}-\ref{eq-solution-s2}. \begin{align}
697+
u\left(\tau^{\left(k_{c g}\right)}\right)
698+
&= u_0^{\left(k_{c g}\right)}{ }_g e^{-\beta_g \tau^{\left(k_{c g}\right)}}
699+
\nonumber \\
700+
&\hskip -24pt + \frac{\alpha^{\left(k_{c g}\right)}}
701+
{\beta_g}\left(1-e^{-\beta_g \tau^{\left(k_{c g}\right)}}\right)
702+
\label{eq-solution-u}\\
703+
s\left(\tau^{\left(k_{c g}\right)}\right)
704+
&= s_0^{\left(k_{c g}\right)} e^{-\gamma_g \tau^{\left(k_{c g}\right)}}
705+
\nonumber \\
706+
&\hskip -24pt + \frac{\alpha^{\left(k_{c g}\right)}}{\gamma_g}
707+
\left(1-e^{-\gamma_g \tau^{\left(k_{c g}\right)}}\right)
708+
\nonumber\\
709+
&\hskip -24pt + \frac{\alpha^{\left(k_{c g}\right)}-\beta_g u_0^{\left(k_{c g}\right)}}
710+
{\gamma_g-\beta_g}\left(e^{-\gamma_g \tau^{\left(k_{c g}\right)}}
711+
-e^{-\beta_g \tau^{\left(k_{c g}\right)}}\right),
712+
\nonumber \\
713+
&\qquad \beta \neq \gamma \label{eq-solution-s} \\
714+
s\left(\tau^{\left(k_{c g}\right)}\right)
715+
&= {s_0^{\left(k_{c g}\right)}}_g e^{-\beta_g \tau^{\left(k_{c g}\right)}} \nonumber \\
716+
&\hskip -24pt +\frac{\alpha^{\left(k_{c g}\right)}}{\beta_g}
717+
\left(1-e^{-\beta_g \tau^{(k c g)}}\right)
718+
\nonumber \\
719+
&\hskip -24pt -\left(\alpha^{\left(k_{c g}\right)}
720+
-\beta_g u_0^{\left(k_{c g}\right)}{ }_g\right) \tau^{\left(k_{c g}\right)}
721+
e^{-\beta_g \tau^{\left(k_{c g}\right)}}, \nonumber \\
722+
&\qquad \beta = \gamma \label{eq-solution-s2}
670723
\end{align}
671724
725+
To simplify these equations, consider the case when \(k_{cg} = 0\) and
726+
\(\beta_g \neq \gamma_g\). Then, \begin{align}
727+
u\left(\tau^{(0)}\right) &= {u_0^{(0)}}_g e^{-\beta_g \tau^{(0)}} \nonumber \\
728+
& \hskip -24pt + \frac{{\alpha^{(0)}}_g}{\beta_g}\left(1-e^{-\beta_g \tau^{(0)}}\right),
729+
\label{eq-sol-usimp} \\
730+
s\left(\tau^{(0)}\right) &= s_0^{(0)}{ }_g e^{-\gamma_g \tau^{(0)}} \nonumber \\
731+
& \hskip -24pt +\frac{{\alpha^{(0)}}_g}{\gamma_g}\left(1-e^{-\gamma_g \tau^{(0)}}\right)
732+
\nonumber\\
733+
& \hskip -24pt +\frac{{\alpha^{(0)}}_g-\beta_g {u_0^{(0)}}_g}{\gamma_g-\beta_g}
734+
\left(e^{-\gamma_g \tau^{(0)}}-e^{-\beta_g \tau^{(0)}}\right). \label{eq-sol-ssimp}
735+
\end{align} When \(k_{cg} = 0\) and \(\beta_g = \gamma_g\), then
736+
\(u\left(\tau^{(0)}\right)\) has the same solution, and
737+
\(s\left(\tau^{(0)}\right)\) becomes \begin{align}
738+
s\left(\tau^{(0)}\right) &= s_0^{(0)}{ }_g e^{-\gamma_g \tau^{(0)}} \nonumber \\
739+
& \hskip -24pt +\frac{{\alpha^{(0)}}_g}{\gamma_g}
740+
\left(1-e^{-\gamma_g \tau^{(0)}}\right) \nonumber\\
741+
& \hskip -24pt - \left( {\alpha^{(0)}}_g-\beta_g {u_0^{(0)}}_g \right)
742+
\tau^{(0)} e^{-\beta_g \tau^{(0)}}. \label{eq-sol-ssimp2}
743+
\end{align} When \(k_{cg} = 1\) and \(\beta_g \neq \gamma_g\), then
744+
\begin{align}
745+
u\left(\tau^{(1)}\right) &=u_0^{(1)} g^{e^{-\beta_g \tau^{(1)}}}, \\
746+
s\left(\tau^{(1)}\right) &=s_0^{(1)} e^{-\gamma_g \tau^{(1)}} \nonumber \\
747+
& \hskip -24pt +\frac{-\beta_g u_0^{(1)}}{\gamma_g-\beta_g}
748+
\left(e^{-\gamma_g \tau^{(1)}}-e^{-\beta_g \tau^{(1)}}\right).
749+
\end{align} When \(k_{cg} = 1\) and \(\beta_g = \gamma_g\), then
750+
\(u\left(\tau^{(1)}\right)\) has the same solution, and
751+
\(s\left(\tau^{(1)}\right)\) becomes \begin{align}
752+
s\left(\tau^{(1)}\right)=s_0^{(1)}{ }_g e^{-\gamma_g \tau^{(1)}}
753+
+\beta_g u_0^{(1)}{ }_g \tau^{(1)} e^{-\beta_g \tau^{(1)}}.
754+
\end{align}
755+
756+
\subsection{Variational inference}\label{sec-methods-inference}
757+
758+
Given observations
759+
\(\tilde{X}_{cg} = \left( u_{cg}^{obs}, s_{cg}^{obs} \right)\), we would
760+
like to compute the posterior distribution over the random variables
761+
\begin{align}
762+
\theta &= \left( t_{c}, \eta_{c}^{(u)}, \eta_{c}^{(s)} \right), \\
763+
\phi &= \left( {t_{0}^{(0)}}_g, \Delta \text{switching}_{g}, {\alpha^{(0)}}_{g}, \beta_{g}, \gamma_{g} \right),
764+
\end{align} but exact Bayesian inference is intractable in this model.
765+
We use Pyro to automatically integrate out the local discrete latent
766+
variables \(k\), which is defined as the cell and gene transcriptional
767+
state (see above), and approximate the posterior over the remaining
768+
latent variables using variational inference
769+
\citep{Bingham2018-id, Kucukelbir2016-bk}, which converts intractable
770+
integrals into optimization problems that can be solved with
771+
off-the-shelf tools. In variational inference, we maximize a tractable
772+
bound (the evidence lower bound (ELBO)) on the Kullback-Leibler (KL)
773+
divergence
774+
\[\text{KL}\left( q_{\phi}(\theta, \psi) \mathrel{\Vert} p(\theta, \psi \vert \tilde{X}_{cg}) \right)\]
775+
between a parametric family of tractable probability distributions q and
776+
the intractable true posterior \begin{align}
777+
\varphi^* &= \operatorname{argmax}_{\varphi} \text{ELBO} \nonumber \\
778+
&= \operatorname{argmax}_{\varphi} \bigg\{ E_{q_{\varphi}} \bigg[ \log \left(p\left(\tilde{X}_{c g}, \theta, \psi \right) \right) \nonumber\\
779+
&\qquad\qquad\qquad\qquad -\log \left(q_{\varphi}(\theta, \psi)\right) \bigg] \bigg\}
780+
\end{align} We approximate our model's posterior distribution
781+
\(p( \theta, \psi \vert
782+
\tilde{X})\) with a tractable family of probability distributions
783+
\(q_{\psi}(\theta, \phi) = q_{\phi_1}(\theta) q_{\phi_2}(\psi)\), where
784+
\(q_{\phi_1}(\theta)\) is a product of independent univariate Gaussian
785+
distributions with learnable location and scale parameters and
786+
\(q_{\phi_2}(\psi)\) is a multivariate Gaussian distribution with a
787+
learnable location parameter and a learnable low-rank covariance matrix.
788+
We solve the resulting stochastic optimization problem using a version
789+
of Automatic Differentiation Variational Inference (ADVI)
790+
\citep{Kucukelbir2016-bk}: we obtain gradient estimates by
791+
differentiating a Monte Carlo estimate of the ELBO and update the
792+
variational parameters using stochastic gradient ascent. Our
793+
implementation and experiments use generic variational families and
794+
Monte Carlo ELBO and gradient estimators provided by Pyro
795+
\citep{Bingham2018-id}, an open source library for probabilistic machine
796+
learning, and a version built into Pyro of the adaptive stochastic
797+
gradient ascent algorithm Adam augmented with gradient clipping to
798+
enhance numerical stability during training.
799+
800+
\subsection{Model training}\label{sec-methods-training}
801+
802+
For the pancreas, PBMC, and uni-fate and bi-fate LARRY single-cell data,
803+
since the data dimension is relatively small, we run Model 1 and Model 2
804+
with a minimum of 100 epochs and a maximum of 4000 epochs. For each
805+
epoch, we input spliced and unspliced read counts from all the cells and
806+
determine the convergence condition with an early stopping strategy in
807+
which the patience is set to 45 and consumes one patience if the minimal
808+
ELBO improvement of training data per epoch is lower than \(10^{-4}\) of
809+
previous loss. The learning rate is set to be \(10^{-2}\) with a decay
810+
rate of \(0.11/4000\) per epoch. For the multi-fate LARRY dataset, since
811+
this is a large dataset with over \(4 \times
812+
10^4\) cells, we use mini batches of cells to train Model 1 and Model 2
813+
with a minimum of 100 epochs and a maximum of 1000 epochs. Specifically,
814+
the batch size was set to 4000 cells for both models with an early
815+
stopping patience 45 and consume one patience if the minimal ELBO
816+
improvement of training data per epoch lower than \(10^{-3}\) of
817+
previous loss. The learning rate is set to be \(10^{-2}\) with a decay
818+
rate of \(0.11/1000\) per epoch. All models were trained on a machine
819+
with an NVIDIA A100 GPU and the CentOS 7 operating system.
820+
672821
\subsection{Posterior
673822
prediction}\label{sec-methods-posterior-prediction}
674823

0 commit comments

Comments
 (0)