Answers.Body: <p><a href="https://www.nature.com/articles/s41586-018-0393-7" rel="nofollow noreferrer">This publication</a> used a negative binomial regression model of the counts of cells at each time-point.</p>
  
  <p>From the methods section: <em>"For each cell type, we model the number of lineage-labelled cells detected in each analysed mouse as a random count variable using a negative binomial distribution. The frequency of detection is modelled by using the natural log of the total number of cells of that type profiled in a given mouse as an offset. The time point of each mouse (0, 30 or 60 days post tamoxifen) is provided as a covariate. The negative binomial model was fit using the R command ‘glm.nb’ from the ‘MASS’ package. The P value for the significance of the change in labelled fraction size between time-points was assessed using a likelihood-ratio test, computing using the R function ‘anova’."</em></p>
  
  <p>The method is available <a href="https://github.com/adamh-broad/single_cell_airway/blob/d7741835738ed58a9f93f2febb4dd302d9a9455b/PulseSeq.md#compute-the-p-values-for-increasing-labeled-fraction-using-negative-binomial-regression" rel="nofollow noreferrer">here</a> as an R script.</p>
  
  <p>The input <code>x</code> is a dataframe with the following columns:</p>
  
  <pre><code>x<span class="math-container">$variable # celltype
  x$</span>value # cell count
  x<span class="math-container">$batch # condition+donor
  x$</span>timepoint # condition (e.g. adult, fetal)
  </code></pre>
  
  <p>Montoro, D.T., Haber, A.L., Biton, M. et al. A revised airway epithelial hierarchy includes CFTR-expressing ionocytes. Nature 560, 319–324 (2018) doi:10.1038/s41586-018-0393-7</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-20T18:15:51.140Z
Answers.LastActivityDate: 2019-11-20T18:15:51.140Z
Answers.UserDisplayName: Peter
Body: <p>I want to test for significance between differences in cell count between conditions.</p>
  
  <p>I have 2 conditions (N, T), 3 donors (samples) each, and four cell types (A-D) as shown in the example below.</p>
  
  <p>I believe this problem is analogous to the differential expression test performed with edgeR or DEseq.</p>
  
  <p>Example data:</p>
  
  <pre><code>Count   Sample  Celltype    Condition
  555 P1  D   T
  3829    P1  C   T
  945 P1  A   T
  222 P1  B   T
  795 P2  D   T
  5464    P2  C   T
  839 P2  A   T
  438 P2  B   T
  629 P3  D   T
  6426    P3  C   T
  647 P3  A   T
  457 P3  B   T
  8   P1  D   N
  5122    P1  C   N
  3204    P1  A   N
  1   P1  B   N
  20  P2  D   N
  6111    P2  C   N
  2524    P2  A   N
  26  P2  B   N
  66  P3  D   N
  7490    P3  C   N
  5272    P3  A   N
  3   P3  B   N
  </code></pre>
  
Tags: <scrnaseq><single-cell>
Title: Calculating celltype proportion changes between conditions in single-cell data
ThreadText: # Calculating celltype proportion changes between conditions in single-cell data
  
  (Asked by: username_0 on 2019-11-20)
  
  I want to test for significance between differences in cell count between conditions.
  
  I have 2 conditions (N, T), 3 donors (samples) each, and four cell types (A-D) as shown in the example below.
  
  I believe this problem is analogous to the differential expression test performed with edgeR or DEseq.
  
  Example data:
  
  ```
  Count   Sample  Celltype    Condition
  555 P1  D   T
  3829    P1  C   T
  945 P1  A   T
  222 P1  B   T
  795 P2  D   T
  5464    P2  C   T
  839 P2  A   T
  438 P2  B   T
  629 P3  D   T
  6426    P3  C   T
  647 P3  A   T
  457 P3  B   T
  8   P1  D   N
  5122    P1  C   N
  3204    P1  A   N
  1   P1  B   N
  20  P2  D   N
  6111    P2  C   N
  2524    P2  A   N
  26  P2  B   N
  66  P3  D   N
  7490    P3  C   N
  5272    P3  A   N
  3   P3  B   N
  
  ```
  
  **Tags:** scrnaseq, single-cell
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-11-20. Score: 1
  
  [This publication](https://www.nature.com/articles/s41586-018-0393-7) used a negative binomial regression model of the counts of cells at each time-point.
  
  From the methods section: *"For each cell type, we model the number of lineage-labelled cells detected in each analysed mouse as a random count variable using a negative binomial distribution. The frequency of detection is modelled by using the natural log of the total number of cells of that type profiled in a given mouse as an offset. The time point of each mouse (0, 30 or 60 days post tamoxifen) is provided as a covariate. The negative binomial model was fit using the R command ‘glm.nb’ from the ‘MASS’ package. The P value for the significance of the change in labelled fraction size between time-points was assessed using a likelihood-ratio test, computing using the R function ‘anova’."*
  
  The method is available [here](https://github.com/adamh-broad/single_cell_airway/blob/d7741835738ed58a9f93f2febb4dd302d9a9455b/PulseSeq.md#compute-the-p-values-for-increasing-labeled-fraction-using-negative-binomial-regression) as an R script.
  
  The input `x` is a dataframe with the following columns:
  
  ```
  x$variable # celltype
  x$value # cell count
  x$batch # condition+donor
  x$timepoint # condition (e.g. adult, fetal)
  
  ```
  
  Montoro, D.T., Haber, A.L., Biton, M. et al. A revised airway epithelial hierarchy includes CFTR-expressing ionocytes. Nature 560, 319–324 (2018) doi:10.1038/s41586-018-0393-7
  
  
  ---
  
  