text: user132: Imagine I have a dataset of highly periodic gene expression, taken at densely spaced timepoints. I know that the expression is periodic, but different genes have different offsets.
  It is trivial to convert my timestamps into a cosine (cos_time = cos(offset + time*pi*2/PERIOD)), so that this new variable is linear with the genes' expressions -- but only with the ones that have a peak at offset.
  What if I could have multiple cos_times (let's call them phases) and then ask DESeq2: "OK, which gene's behavior is most linear with which phase?" Barring comparing p-values of each LRT test, is there a better way?
  Disclaimer: I know about cosinor, Lomb-Scargle periodograms, ARS, JTK etc, and I know they are likely more applicable in this particular case. I'm interested in whether it is in general possible to ask such a question from DESeq2, even if the variables in question are not periodic. Phase just seemed like the simplest concept to demonstrate this on.
  
  user73: If I were to do this, my first guess would be to add in the phases as a separate factor in the statistical model, something like:
  ~ Condition + sex + phase1 + phase2 + phase3 + ...
  
  
  user77: If you have densely spaced time points the using non-linear regression to directly fit the signal to a cosine or sine curve, which would directly produce the offset, would be much simpler. DESeq2 wouldn't be the appropriate tool then, you'd use base R and the nls() function.
  
original_text: 132: <p>Imagine I have a dataset of highly periodic gene expression, taken at densely spaced timepoints. I know that the expression is periodic, but different genes have different offsets.</p>
  
  <p>It is trivial to convert my timestamps into a cosine (<code>cos_time = cos(offset + time*pi*2/PERIOD)</code>), so that this new variable is linear with the genes' expressions -- but only with the ones that have a peak at <code>offset</code>.</p>
  
  <p>What if I could have multiple <code>cos_time</code>s (let's call them <code>phases</code>) and then ask DESeq2: "OK, which gene's behavior is most linear with which phase?" Barring comparing p-values of each LRT test, is there a better way?</p>
  
  <p>Disclaimer: <em>I know about cosinor, Lomb-Scargle periodograms, ARS, JTK etc, and I know they are likely more applicable in this particular case. I'm interested in whether it is in general possible to ask such a question from DESeq2, even if the variables in question are not periodic. Phase just seemed like the simplest concept to demonstrate this on.</em></p>
   73: <p>If I were to do this, my first guess would be to add in the phases as a separate factor in the statistical model, something like:</p>
  
  <pre><code>~ Condition + sex + phase1 + phase2 + phase3 + ...
  </code></pre>
   77: <p>If you have densely spaced time points the using non-linear regression to directly fit the signal to a cosine or sine curve, which would directly produce the offset, would be much simpler. DESeq2 wouldn't be the appropriate tool then, you'd use base R and the <code>nls()</code> function.</p>
  