<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/sequential-fitting-strategies-for-models-of-short-rna-sequencing-data/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://statmd.wordpress.com/2017/06/18/sequential-fitting-strategies-for-models-of-short-rna-sequencing-data/"> R – Statistical Reflections of a Medical Doctor</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>After a (really long!) hiatus I am reactivating my statistical blog. The first article  concerns the clarification of a point made in the manual of our recently published <a rel="nofollow" href="https://academic.oup.com/nar/article-lookup/doi/10.1093/nar/gkx199" target="_blank">statistical model </a>for short RNA sequencing data.<br>
The background for this post, in case one wants to skip reading the manuscript (please do read it !), centers around the limitations of existing methods for the analysis of data for this very promising class of biomarkers. To overcome these limitations our group comprised from investigators from <a rel="nofollow" href="http://medicine.unm.edu/academic-divisions/nephrology/index.html" target="_blank">Division of Nephrology</a>, University of New Mexico and the <a rel="nofollow" href="https://www.pnri.org/research-programs/galas-lab/" target="_blank">Galas Lab </a>at Pacific Northwest Research Institute introduced a novel method for the analysis of short RNA sequencing (sRNAseq) data. This method (RNAseqGAMLSS), which was derived from first principles modeling of the short RNAseq process, was shown to have a number of desirable properties in an analysis of nearly 200 public and <a rel="nofollow" href="https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE93399" target="_blank">internal datasets</a>:</p>
<ol>
<li>It can <strong>quantify</strong> the intrinsic, <strong>sequencing specific bias</strong> of sRNAseq from calibration, synthetic equimolar mixes of the target short RNAs (e.g. microRNAs)</li>
<li> It can use such estimates to <strong><em>correct </em>for the bias present in experimental samples</strong> of different composition and input than the calibration runs. This in turns opens the way for the use of short RNAseq measurements in personalized medicine applications (as explained <a rel="nofollow" href="https://academic.oup.com/nar/article-lookup/doi/10.1093/nar/gkx199#64202128" target="_blank">here</a>)</li>
<li>Adapted to the problem of differential expression analysis, our method exhibited  <strong>greater</strong> <strong>accuracy</strong>, <strong>higher sensitivity and specificity</strong> <strong>than</strong> six <strong>existing algorithms</strong> (<a rel="nofollow" href="http://www.ncbi.nlm.nih.gov/pubmed/25516281" target="_blank"><em>DESeq2</em></a>, <a rel="nofollow" href="http://www.ncbi.nlm.nih.gov/pubmed/19910308" target="_blank"><em>edgeR</em></a>, <a rel="nofollow" href="http://www.ncbi.nlm.nih.gov/pubmed/23428641" target="_blank"><em>EBSeq</em></a>, <a rel="nofollow" href="http://www.ncbi.nlm.nih.gov/pubmed/25605792" target="_blank">limma</a>, <a rel="nofollow" href="http://www.ncbi.nlm.nih.gov/pubmed/23001152" target="_blank"><em>DSS</em></a>, <a rel="nofollow" href="http://www.ncbi.nlm.nih.gov/pubmed/24485249" target="_blank"><em>voom</em></a>) for the analysis of short RNA-seq data.</li>
<li><strong>In contrast to these popular methods which force the expression profiles to have a certain form of symmetry</strong> (equal number and magnitude of over-expressed and under-expressed sequences), <strong>our method can be used to discover global, directional changes in expression profiles</strong> which are missed by the aforementioned methods. Accounting for such a possibility may be appropriate in certain instances, in which the disease process leads to loss or gain in the number of cells of origin of the affected organ/tissue.</li>
</ol>
<p>The proposed methodology which is based on <em>Generalized Additive Models for Location, Scale and Shape </em>(<a rel="nofollow" href="http://www.gamlss.org/" target="_blank">GAMLSS</a>) involves the fitting of simultaneous regression models for the location (mean) and the scale (dispersion) of sequence counts using either the Negative Binomial or a particular parameterization of the Normal distribution. However <span>there is price to pay for the advantages of RNASeqGAMLSS</span> over alternatives: this comes in the form of a small (but not infinitesimal) probability<span><a rel="nofollow" href="https://statmd.wordpress.com/2017/06/18/sequential-fitting-strategies-for-models-of-short-rna-sequencing-data/#f1" target="_blank">[1]</a></span> that the fitting algorithm will execute successfully. In the manual of our <a rel="nofollow" href="https://bitbucket.org/chrisarg/rnaseqgamlss/raw/a2eed60a2b81f76b7bff67d62b5dcd21371c0c93/BaseCode/RNASeqGAMLSS%20Manual.docx" target="_blank">method </a>(Section 6.4) we explain that a numerically more stable way of fitting these complex models exists and should be adapted if one encounters numerical optimization errors with the default approach used in the <a rel="nofollow" href="https://academic.oup.com/nar/article-lookup/doi/10.1093/nar/gkx199" target="_blank"><em>Nucleic Acids Research</em> (NAR) manuscript</a>. The three steps of this <em>sequential fitting strategy</em> are as follows:</p>
<ol>
<li>One fits a <em>Poisson </em>count mixed model to the RNAseq data, to obtain estimates of the relative mean expression for the different short RNA species in the expression profile</li>
<li>These estimates are used <span>to fix the values</span> of the mean parameter model of the RNASeqGAMLSS model while estimating the values of the dispersion parameters.</li>
<li>Finally, one uses the values of the mean (Step 1) and dispersion (Step 2) parameters to fit the general RNASeqGAMLSS model</li>
</ol>
<p>In essence one ignores the overdispersion (additional variability) of the short RNAseq data (Step 1) to guide the algorithm into estimates of the dispersion parameters (Step 2). Finally one uses the separate estimates of the mean (Step 1) and dispersion (Step 2) parameters as an initial point for the simultaneous estimation of both (Step 3). The reason that this approach works is because the dispersion parameters do not affect the mean parameters, so that the Poisson distribution of Step 1 has the same mean as the RNASeqGAMLSS model. Hence the estimates produced by this Step are identical (to the limit of numerical precision) to those that would have been produced by a successful execution of the RNASeqGAMLSS optimization algorithms. Fixing these values when fitting the RNASeqGAMLSS model in Step 2 facilitates estimation of the dispersion parameters. Having very good initial guesses for these parameters virtually guarantees convergence of the 3rd Step (which is the only step in the <a rel="nofollow" href="https://academic.oup.com/nar/article-lookup/doi/10.1093/nar/gkx199" target="_blank"><em>NAR</em> </a>paper).</p>
<p>A fully worked out example is shown below (note that the data used in the <em>NAR </em>paper, source code, manual that includes instructions to compile the source code of the RNASeqGAMLSS and Win64 DLL libraries are all available in the <a rel="nofollow" href="https://bitbucket.org/chrisarg/rnaseqgamlss/src/a2eed60a2b81f76b7bff67d62b5dcd21371c0c93/BaseCode/?at=master" target="_blank">BitBucket repository</a> for this project)</p>
<p><b>First, </b>we load the data, the C++ libraries and extract the data to the two groups we would like to compare :</p>
<pre>
library(TMB) ## the TMB framework for optimizati
library(lme4)
## load the DE C++ libraries
dyn.load(dynlib(&quot;LQNO_DE&quot;))
## Note about the form of data storage for use with this software
##================================================================================
## the long format should be employed when storing microRNA data for
## GAMLSS type of analyses: in this format, the data are arranged in columns:
## - column miRNA : yields the name of the miRNA
## - column reads : reads of the miRNA from a *single sample*
## - column SampleID: the sample the reads were recorded at
## this is called long format, because data from experiments are stored in
## different rows (rather than appearing as consecutive columns)
##================================================================================
## lads the data from the 286 series
load(&quot;286.RData&quot;)
## Obtain data for GAMLSS - we will compare the two ratiometric series
datRat&lt;-subset(dat286.long,(Series==&quot;RatioB&quot; | Series ==&quot;RatioA&quot;) &amp; Amount==&quot;100 fmoles&quot;)
datRat$SampleID&lt;-factor(datRat$SampleID)
datRat$Series&lt;-factor(datRat$Series)

## STEP 0: PREPARE THE DATA FOR THE RNASeqGAMLSS FIT
u_X&lt;-as.numeric(factor(datRat$miRNA)) ## maps readings to the identity of the miRNA
u_G&lt;-as.numeric(factor(datRat$Series)) ## maps counts to group
y=datRat$reads ## extract the actual counts
X&lt;-model.matrix(~Series,data=datRat) ## design matrix (ANOVA) for group comparisons
</pre>
<p><strong>Secondly</strong>, we fit the Poisson model (Step 1), using the facilities of the lme4 R package:</p>
<pre>
## STEP 1: USE A POISSON MODEL TO OBTAIN ESTIMATES FOR THE MU SUBMODEL
##==========================================================================================
## fit the parameters for the mu submodel using the poisson GLM
gl&lt;-glmer(reads~Series+(0+Series|miRNA),data=datRat,family=&quot;poisson&quot;)
</pre>
<p><strong>Then </strong>we extract the values of these parameters and used them to fix the values of the mean submodel (Step 2):</p>
<pre>
## STEP 2: USE THE MU MODEL ESTIMATES TO FIT THE PHI SUBMODEL
##==========================================================================================
## initializes standard deviation of RE for the mu submodel
sigmu=sqrt(diag((summary(gl)[[&quot;varcor&quot;]])[[1]]))
sigsig=rep(1,max(u_G)) ## initializes standard deviation of RE for the phi submodel
b=fixef(gl) ## initial values for the overall group means (mean submodel)
## initial values for the variation of miRNAs around their group mean (mean submodel)
u_m=as.matrix(ranef(gl)$miRNA)
## Very rough initial values for the phi submodel parameters
s_b=rep(0,ncol(X)) ## initial values for the overall group means (phi submodel)
## initial values for the variation of miRNAs around their group mean (phi submodel)
u_s= matrix(0,max(u_X),max(u_G))
## MAP list that allow us to fix some parameters to their values
MAP&lt;-NULL
MAP[[&quot;b&quot;]]&lt;-factor(rep(NA,length(b)))
MAP[[&quot;u_m&quot;]]&lt;-factor(rep(NA,length(c(u_m))))
MAP[[&quot;sigmu&quot;]]&lt;-factor(rep(NA,length(sigmu)))
## construct the AD object - note that we fix the mu at their values while estimating the
## phi submodel
obj.TMB&lt;-MakeADFun(data=list(y=y,X=X,u_X=u_X,u_G=u_G),
parameters=list(b=b,s_b=s_b,u_m=u_m,u_s=u_s,
sigmu=sigmu,sigsig=sigsig),
DLL=&quot;LQNO_DE&quot;,random=c(&quot;u_s&quot;),hessian=FALSE,silent=TRUE,
method=&quot;BFGS&quot;,random.start=expression(last.par.best[random]),
ADReport=TRUE,map=MAP)
## parameter estimation - note errors may be generated during some iterations
f.TMB&lt;-nlminb(obj.TMB$par,obj.TMB$fn,obj.TMB$gr,
control=list(eval.max=10000,iter.max=10000),lower=-30,upper=30)
## obtain the report on the parameters to extract the fitted values of the gamlss model
rep&lt;-sdreport(obj.TMB)
u_s = matrix(summary(rep,&quot;random&quot;,p.value=FALSE)[,1],ncol=max(u_G))
dummy&lt;-summary(rep,&quot;fixed&quot;,p.value=FALSE)[,1] ## parameter estimates
s_b=dummy[1:max(u_G)]
sigsig=dummy[-(1:max(u_G))]
</pre>
<p><strong>Finally, </strong> we refit the model letting all parameters vary:</p>
<pre>

## STEP 3: REFIT THE MODEL WITHOUT FIXING ANY PARAMETERS
##==========================================================================================
obj.TMB&lt;-MakeADFun(data=list(y=y,X=X,u_X=u_X,u_G=u_G),
parameters=list(b=b,s_b=s_b,u_m=u_m,u_s=u_s,
sigmu=sigmu,sigsig=sigsig),
DLL=&quot;LQNO_DE&quot;,random=c(&quot;u_m&quot;,&quot;u_s&quot;),hessian=TRUE,silent=TRUE,
method=&quot;BFGS&quot;,random.start=expression(last.par.best[random]),
ADReport=TRUE)
## scale objective by the magnitude of the deviance of the fitted Poisson model
f.TMB&lt;-nlminb(obj.TMB$par,obj.TMB$fn,obj.TMB$gr,
control=list(eval.max=10000,iter.max=10000,scale=deviance(gl)),lower=-30,upper=30)
## obtain the report on the parameters
rep&lt;-sdreport(obj.TMB)
## differential expression ratios, standard errors z and p-values
gamlssAD&lt;-summary(rep,&quot;report&quot;,p.value=TRUE)[1:nlevels(datRat$miRNA),]
rownames(gamlssAD)&lt;-levels(datRat$miRNA)
## rownames are the miRNAs; columns are estimates, standard error, z value and pvalue

## the final estimates with their standard errors
head(gamlssAD)

</pre>
<p>These steps (and the RNASeqGAMLSS code) is going to be incorporated in an upcoming <em>Bioconductor </em>package for the analysis of short RNA sequencing data by Dr <a rel="nofollow" href="https://www.researchgate.net/profile/Lorena_Pantano" target="_blank">Lorena Pantano </a>PhD. Until this package becomes available, the aforementioned code snippets may adapted very easily to one’s application by suitable adaptations of the code (i.e. the names of the columns corresponding to the RNA species, sample identifiers and experimental groups).</p>
<p><span><a name="f1"></a>1. </span>This is particularly likely when the underlying <a rel="nofollow" href="https://bitbucket.org/chrisarg/rnaseqgamlss" target="_blank">software implementations</a> are <span>not</span> compiled against the<a rel="nofollow" href="https://software.intel.com/en-us/mkl" target="_blank"> Intel®Math Kernel Libraries</a>.</p>
<p> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/statmd.wordpress.com/856/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/comments/statmd.wordpress.com/856/"></a> <img border="0" alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" data-recalc-dims="1"></p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://statmd.wordpress.com/2017/06/18/sequential-fitting-strategies-for-models-of-short-rna-sequencing-data/"> R – Statistical Reflections of a Medical Doctor</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/1kYC0ZMV_0M" height="1"></a></div>