Last updated: 2020-09-21

Checks: 2 0

Knit directory: misc/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 93f5395. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  analysis/contrainedclustering.Rmd
    Untracked:  analysis/count.Rmd
    Untracked:  analysis/deconvSimulation2.Rmd
    Untracked:  analysis/ideas.Rmd
    Untracked:  analysis/methylation.Rmd
    Untracked:  analysis/ridge_em.Rmd
    Untracked:  code/sccytokines.R
    Untracked:  code/scdeCalibration.R
    Untracked:  data/bart/
    Untracked:  data/cytokine/DE_controls_output_filter10.RData
    Untracked:  data/cytokine/DE_controls_output_filter10_addlimma.RData
    Untracked:  data/cytokine/README
    Untracked:  data/cytokine/test.RData
    Untracked:  data/cytokine_normalized.RData
    Untracked:  data/deconv/
    Untracked:  data/scde/

Unstaged changes:
    Modified:   analysis/deconvSimulation.Rmd
    Modified:   analysis/deconvolution.Rmd
    Deleted:    data/mout_high.RData
    Deleted:    data/scCDT.RData
    Deleted:    data/sva_sva_high.RData

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/CPM.Rmd) and HTML (docs/CPM.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 93f5395 DongyueXie 2020-09-21 wflow_publish(c(“analysis/CPM.Rmd”, “analysis/limma.Rmd”))
html 6bb0476 DongyueXie 2020-06-09 Build site.
Rmd 0143800 DongyueXie 2020-06-09 wflow_publish(“analysis/CPM.Rmd”)
html c89c7f9 DongyueXie 2020-04-13 Build site.
Rmd f4f3ac6 DongyueXie 2020-04-13 wflow_publish(“analysis/CPM.Rmd”)
html d656bc9 DongyueXie 2020-04-13 Build site.
Rmd 47f7d2a DongyueXie 2020-04-13 wflow_publish(“analysis/CPM.Rmd”)
html 2a4e9aa Dongyue Xie 2020-01-06 Build site.
html 0452cba Dongyue Xie 2020-01-04 Build site.
Rmd e033ca3 Dongyue Xie 2020-01-04 wflow_publish(“analysis/CPM.Rmd”)

Introduction

A good review of RNA-Seq expression units from Harold Pimentel.

CPM: counts per million

RPKM: reads per kilobase per million

In general, need to consider 1. library size; 2. gene length. Because libraries sequenced at a greater depth will result in higher counts.

CPM and log-CPM transformations do not account for gene length differences as RPKM and FPKM values do. CPM and log-CPM values can be calculated using a counts matrix alone. Assuming that there are no differences in isoform usage between conditions, differential expression analyses look at gene expression changes between conditions rather than comparing expression across multiple genes or drawing conclusions on absolute levels of expression. In other words, gene lengths remain constant for comparisons of interest and any observed differences are a result of changes in condition rather than changes in gene length.

RPKM values are just as easily calculated as CPM values using the rpkm function in edgeR if gene lengths are available.

Trimmed mean of M values

Observed counts as \(Y_{gk}\), gene length \(l_g\), true and unknown expression level (number of transcripts) \(\mu_{gk}\), total number of reads for library k \(N_k\), let \(s_k = \sum_g l_g \mu_{gk}\), then \[E(Y_{gk}) = \frac{\mu_{gk}l_g}{s_k}N_k\]

The ratio of expected value between two conditions is \[\frac{E(Y_{g1})}{E(Y_{g2})} = \frac{s_1}{s_2}\frac{N_2}{N_1}\frac{\mu_{g2}}{\mu_{g1}}\]

So \(s_k\) is the size of studied transcriptome in condition \(k\), \(\mu_{gk}/s_k\) is the relative expression of gene \(g\) in condition \(k\).

Let \(r\) denote the reference sample. Filter out 1. transcripts with null counts(The cases where \(Y_{gk} = 0\) or \(Y_{gr} = 0\) are trimmed); 2. the \(30\%\) more extreme \(M-value\): \(M_{gk}^r = \log\frac{y_{gk}/N_k}{y_{gr}/N_r}\); 3. the \(5\%\) more extreme \(A-value\): \(A_{gk}^r = 0.5*(\log\frac{y_{gk}}{N_k}+\log\frac{y_{gr}}{N_r})\).

After filtering out genes, we have a set of genes denoted as \(G^*\) whose neither value was trimmed. The scaling factor \(TMM_k\) is calculated as \[\log TMM_k = \frac{\sum_{g\in G^*}w_{gk}M_{gk}}{\sum_{g\in G^*}w_{gk}},\] where \(w_{gk} = \frac{N_k-Y_{gk}}{N_k Y_{gk}} - \frac{N_r-Y_{gr}}{N_r Y_{gr}}\). Usually the scaling factors are re-scaled such that they multiply to 1.

Relative Log Expression

Define the reference as the geometric mean(less sensitive to extreme values than the standard mean) of samples \(Y_{gk}^r = (\Pi_k Y_{gk})^{1/n}\), then the scaling factor for sample \(k\) is calculated as \(median(\frac{Y_{gk}}{Y_{gk}^r})\).