eQTL discovery pipeline for the GTEx Consortium: RNA-seq preprocessing
This notebook converts the RNA-seq data processing workflow of eQTL discovery pipeline for the GTEx Consortium (version July 31, 2017), originally written in Python, R and WDL into a single, self-contained SoS script with narratives.
The workflow perform two analysis on RNA-seq data:
- Quantile normalization
- PEER factor anlaysis
The WDL system is developed by Broad institute. Its syntax particularly focuses on human readability, and has recently became a github official language.
Caution that this example aims to demonstrate migrating workflows written in another workflow system to SoS, for readers to compare between them code organization, readibility, syntax and interface to remote computing environment. The data involved are private thus cannot be provided. However, these data will become available in the future at https://gtexportal.org/home/. In the mean time, readers interested in adopting this example for their own analysis can edit [global]
section to input their own examples and execute the pipeline. We are happy to provide support with it on github.
Please note that here we have specified paths to pre-existing directories in the [global]
section, with parameter
keyword. This setup allows users to configure all paths in one places for a “default” run, and optionally can configure them from command-line or %sosrun
magic. To elaborate, for example:
[global]
parameter: cwd = path('~/Documents/GTEx')
can be override by command argument --cwd /path/to/new/dir
. An alternative implementation is to use configuration file, eg, create a file called config.yml
and write:
cwd: path('~/Documents/GTEx')
and execute with %sosrun -c config.yml
. The downside is that a config.yml
file will have to be maintained.
Data file format conversion
Code chunk below is prototyping codes to convert RNA-seq file to HDF5 format. It is not needed when the normalization workflow is executed (next section) because normalization workflow performs format conversion on original data. But it is useful to have here, in case the original data will have to be processed separately.
Quantile normalization
Quantile normalization of RNA-seq data
- input are rpkm file (for normalization), count file (for QC) and vcf file (for removing samples that do not have genotypes)
- Expression values are quantile normalized to the average empirical distribution observed across samples
- For each gene, expression values are inverse quantile normalized to a standard normal distribution across samples
- genes are selected based on expression thresholds of >0.1 RPKM in >10 samples and >5 reads in >10 samples
It results in 4 analysis ready expression data files in HDF5 format of different versions / organizations of the same information: emperical quantile normalized and standard normal quantile normalized, saved as flat tables or grouped by tissues. Additionally 2 original Count and RPKM files are converted to HDF5 format grouped by tissues.
Notice that the implementation is memory intensive. As a result we use task
to specifically configure the required resource on a big memory server (lab_server
) that is required to run it. See remote tasks for more details on remote computer configurations.
See code chunk below for an implementation.
PEER factor analysis package has a number of configuable parameters. For this analysis I use default values hard-coded into the script (see code chunk below, step rnaseq_2
). Therefore these settings cannot be configured from input parameter though it is straightforward to implement it otherwise.
For every tissue I compute PEER factor using the top 10,000 expressed genes. It takes 1hr to 3hrs to complete each tissue.