Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Quantile regression for QTL association testing

Under active development. This module is a work in progress: its interface, parameters and outputs may still change, and it is not yet covered by the automated test suite.

Fits quantile regression of a molecular phenotype on genotype across a grid of quantiles, and turns the fit into TWAS weights.

Overview

Standard QTL mapping models the mean: it asks whether genotype shifts average expression. That misses variants whose effect is confined to part of the distribution - acting only in highly expressing samples, or changing spread rather than centre. Quantile regression tests across the distribution instead, so those effects become visible, and the same fit yields weights that can be carried into a TWAS.

For each region the workflow fits quantile regression of the molecular phenotype on genotype across the quantile grid, combines the per-quantile p-values into a single QR p-value by the Cauchy combination method, and computes quantile TWAS weights. Covariates - genotype PCs, hidden factors and fixed covariates - are regressed out, and cis or trans windows are taken from a customized association-window file when one is given, otherwise a fixed cis-window around each region is used.

When to run it. As an alternative to mean-based association and TWAS weight estimation, when you have reason to expect distribution-dependent effects.

Input

  • --genoFile: either one PLINK .bed for the whole genome, or a two-column list of per-chromosome genotype files:

    #chr   path
    chr21  protocol_example.genotype.chr21.bed
    chr22  protocol_example.genotype.chr22.bed
  • --phenoFile: one or more per-region phenotype lists, as written by the phenotype_per_region and annotate_coord preprocessing steps. Each row names a region and points at its bed.gz, which must carry a bed.gz.tbi index. Example output/phenotype_protein/protocol_example_protein.phenotype_by_chrom_files.region_list.txt:

    #chr   start     end       ID                      path
    chr22  17592135  17628748  ENSG00000131100_P36543  output/phenotype_protein/protocol_example_protein.chr22.bed.gz
    chr22  17787648  18024560  ENSG00000243156_Q7RTP6  output/phenotype_protein/protocol_example_protein.chr22.bed.gz
  • --covFile: one or more covariate files matched to the phenotype lists, carrying genotype PCs, hidden factors and fixed covariates, samples in columns. Example output/covariate_protein/protocol_example_protein.chr22.<...>.Marchenko_PC.gz:

    #id        SAMPLE_001  SAMPLE_002  SAMPLE_003  SAMPLE_004
    msex       1           1           1           1
    age_death  90.97       80.24       83.9        74.1
    pmi        10.57       7.87        9.93        2.91
  • --customized-association-windows: an optional 4-column file giving the cis or trans window for each region. Its 4th column must match the region ID in the 4th column of the phenotype list, otherwise the window for that region is not found. Without it a fixed cis-window is used around each region. Example input/reference_data/TAD/protocol_example_protein.enhanced_cis_chr22.bed:

    #chr   start  end       gene_id
    chr22  0      18960000  ENSG00000131100_P36543
    chr22  0      19024561  ENSG00000243156_Q7RTP6
  • --region-name and --region-list: optional ways to restrict the run to selected regions, by naming them or by supplying a window file. Region IDs must match the 4th column of the phenotype list. With neither, every region in the phenotype lists is analysed.

  • --phenotype-names: names for the phenotypic conditions, defaulting to the phenotype file basenames.

  • --name: the stem of the output files.

  • --cwd: the directory outputs are written to.

  • --maf, --mac and --imiss: variant filters, 0.0025, 5 and 1.0 by default. --min-twas-maf (0.01) applies to the TWAS weight step instead.

  • --indel: True by default. Set --no-indel to drop indels from the analysis.

  • --screen-threshold and --screen-method: 0.01 and qvalue, controlling which variants survive the QR screen before weights are computed.

Output

  • {cwd}/quantile_qtl_twas_weight/{name}.{region}.univariate_qr_twas_weights.rds - one file per analysed region, holding the quantile-QTL association results and the quantile TWAS weights. Example output/quantile_twas/quantile_qtl_twas_weight/protocol_example_protein.chr22_ENSG00000241973_P42356.univariate_qr_twas_weights.rds:

    List of 1
     $ ENSG00000241973_P42356:List of 1
      ..$ protein_ENSG00000241973_P42356:List of 5
       .. ..$ vqtl_results       :'data.frame':  275 obs. of  12 variables:
       .. ..$ qr_screen_pvalue_df:'data.frame':  275 obs. of  65 variables:
       .. ..$ message            : chr "No significant SNPs detected in region ENSG00000241973_P42356_protein"
       .. ..$ region_info        :List of 3
       .. ..$ maf                : Named num [1:275] 0.2583 0.3583 0.2417 0.0536 0.0536 ...

The object is nested by region, then by phenotype condition. qr_screen_pvalue_df carries the per-quantile QR p-values and q-values alongside the integrated Cauchy p-value, and vqtl_results carries the variance-QTL fit.

Minimal Working Example

The analysis is region-based. Regions can be picked one at a time by name, or taken from a region list; if neither is given, every region present in the phenotype region lists is analysed.

One region by name

--region-name restricts the run to a single region, which is the quickest way to check the setup end to end.

Timing: TBD (on toy dataset)

Every region in a list

--region-list runs the same workflow over each region in a 4-column window file. Dropping both options analyses every region in the phenotype lists.

Timing: TBD (on toy dataset)

Command Interface

usage: sos run pipeline/qr_and_twas.ipynb
               [workflow_name | -t targets] [options] [workflow_options]
  workflow_name:        Single or combined workflows defined in this script
  targets:              One or more targets to generate
  options:              Single-hyphen sos parameters (see "sos run -h" for details)
  workflow_options:     Double-hyphen workflow-specific parameters

Workflows:
  get_analysis_regions
  quantile_qtl_twas_weight

Global Workflow Options:
  --name VAL (as str, required)
                        It is required to input the name of the analysis
  --cwd output (as path)
  --genoFile VAL (as path, required)
                        A list of file paths for genotype data, or the genotype
                        data itself.
  --phenoFile  paths

                        One or multiple lists of file paths for phenotype data.
  --phenoIDFile  paths()

                        One or multiple lists of file paths for phenotype ID
                        mapping file. The first column should be the original
                        ID, the 2nd column should be the ID to be mapped to.
  --covFile  paths

                        Covariate file path
  --region-list . (as path)
                        Optional: if a region list is provide the analysis will
                        be focused on provided region. The LAST column of this
                        list will contain the ID of regions to focus on
                        Otherwise, all regions with both genotype and phenotype
                        files will be analyzed
  --region-name  (as list)
                        Optional: if a region name is provided the analysis
                        would be focused on the union of provides region list
                        and region names
  --keep-samples . (as path)
                        Only focus on a subset of samples
  --customized-association-windows . (as path)
                        An optional list documenting the custom association
                        window for each region to analyze, with four column,
                        chr, start, end, region ID (eg gene ID). If this list is
                        not provided, the default `window` parameter (see below)
                        will be used.
  --cis-window -1 (as int)
                        Specify the cis window for the up and downstream radius
                        to analyze around the region of interest in units of bp
                        When this is set to negative, we will rely on using
                        customized_association_windows
  --[no-]save-data (default to False)
                        save data object or not
  --phenotype-names  [f'{x:bn}' for x in phenoFile]

                        Name of phenotypes
  --seed 999 (as int)
  --imiss 1.0 (as float)
                        remove a variant if it has more than imiss missing
                        individual level data
  --maf 0.0025 (as float)
                        MAF cutoff
  --mac 5 (as int)
                        MAC cutoff, on top of MAF cutoff
  --[no-]indel (default to True)
                        Remove indels if indel = False
  --min-twas-maf 0.01 (as float)
  --screen-threshold 0.01 (as float)
  --screen-method qvalue
  --[no-]screen-significant (default to True)
  --[no-]pre-filter-by-pqr (default to False)
  --initial-corr-filter-cutoff 0.8 (as float)
  --full-rank-corr-filter-cutoff 'seq(0.75, 0.5, by = -0.05)'
  --ld-reference-meta-file . (as path)
  --keep-variants . (as path)
                        Only focus on a subset of variants
  --[no-]marginal-beta-calculate (default to True)
  --[no-]twas-weight-calculate (default to True)
  --[no-]qrank-screen-calculate (default to True)
  --[no-]vqtl-calculate (default to True)
  --container ''
                        Analysis environment settings
  --job-size 200 (as int)
                        For cluster jobs, number commands to run per job
  --walltime 1h
                        Wall clock time expected
  --mem 20G
                        Memory expected
  --numThreads 1 (as int)
                        Number of threads

Sections
  get_analysis_regions:
  quantile_qtl_twas_weight:

Workflow implementation