Skip to contents

Residualize the per-context phenotype matrices against the per-context phenotype covariates and the genotype covariates, for one or more requested contexts.

Usage

residualizedPhenotypes(x, ...)

# S4 method for class 'QtlDataset'
residualizedPhenotypes(
  x,
  contexts,
  traitId = NULL,
  region = NULL,
  naAction = c("keep", "drop", "impute"),
  outlierAction = c("keep", "drop"),
  outlierPvalThreshold = 0.001,
  outlierArgs = CovMcdOptions(),
  residualizationParam = ResidualizationParam()
)

Arguments

x

A QtlDataset object.

...

Selection arguments: contexts (required), traitId, region, phenotypeCovariatesToRemove, genotypeCovariatesToRemove, and covariateNaAction ("impute", the default, mean-imputes missing covariate cells; "drop" removes samples with any missing covariate).

contexts

Character vector. Context(s) whose data to extract.

traitId

Character or NULL. Molecular trait / feature identifier to select; NULL matches all traits in the dataset.

region

Character (length 1, "chr:start-end") or NULL. Restrict variants to this region; NULL uses the full cis window / all regions.

naAction

Character. How to handle missing phenotype values: one of "keep", "drop", or "impute".

outlierAction

Character. How to handle phenotype outliers: one of "keep" or "drop".

outlierPvalThreshold

Numeric. Two-sided p-value threshold for flagging phenotype outliers. Default 1e-3.

outlierArgs

Extra arguments for robustbase::covMcd(), the robust covariance estimator the outlier rule is built on, supplied with CovMcdOptions – alpha in particular. Only consulted when outlierAction = "drop".

residualizationParam

What the data is residualized on, built with ResidualizationParam: phenotypeCovariates and genotypeCovariates choose the covariate sets, residualizePhenotype / residualizeGenotype turn each side on or off, and covariateNaAction says how missing covariate values are handled. The same record the pipelines take, so a setting means the same thing by either route.

Value

A named list of numeric matrices keyed by context.

Examples

data(qtlDatasetExample)
residualizedPhenotypes(qtlDatasetExample, contexts = "brain")
#>         ENSG_example
#> NA06989   0.07167318
#> NA11891   2.75786526
#> NA11843   0.47197104
#> NA12341   2.47442915
#> NA12739   1.36411662
#> NA10850  -1.71736462
#> NA06984   0.20969721
#> NA12877  -0.44452772
#> NA12275   1.26848404
#> NA06986  -0.41315456
#> NA12272   0.24394256
#> NA10845   0.95715294
#> NA10852  -0.18384509
#> NA07051   0.37188489
#> NA12400   0.01301770
#> NA12344  -0.34435438
#> NA12777  -1.18499697
#> NA12287  -1.15480963
#> NA10837   0.39870441
#> NA12383   0.42995429
#> NA12340   0.84008879
#> NA12708   1.66686907
#> NA12273  -0.27270854
#> NA11892  -2.43893341
#> NA12546  -0.30699370
#> NA12843   0.70294387
#> NA12766   2.04979578
#> NA12348   0.68359018
#> NA12817  -0.62560855
#> NA10840  -0.87667670
#> NA06997   1.52468124
#> NA11917  -0.33125604
#> NA12718  -0.51886700
#> NA12282   0.71148839
#> NA11920   1.17037107
#> NA12776  -0.25043657
#> NA12283   0.27096527
#> NA07435   0.24885197
#> NA12828  -1.93102973
#> NA07045   1.10393016
#> NA07031  -0.70813492
#> NA12336   0.28582678
#> NA07349   0.83604578
#> NA12827  -1.54396356
#> NA12375   0.09773920
#> NA12343  -0.90723342
#> NA12335   1.23967723
#> NA12778  -0.19124943
#> NA12832   0.81891538
#> NA11930  -0.65548341
#> NA12890   0.34362842
#> NA07037  -2.03656760
#> NA07347   1.55015479
#> NA12829   0.84243449
#> NA12749   0.03116427
#> NA11894  -0.20565526
#> NA12286   0.49752754
#> NA10865  -1.09225798
#> NA10864  -0.46465159
#> NA10853  -1.50005081
#> NA11918   0.65693527
#> NA12830  -0.17828262
#> NA12818  -0.91663891
#> NA10836   0.89334627
#> NA11893  -0.72699886
#> NA11919   0.71393524
#> NA12489   0.33433783
#> NA12399  -0.23909673
#> NA12413  -0.65967337
#> NA10843  -0.81602854
#> NA12842  -0.02012843
#> NA12347   2.50658029
#> NA07346   0.06612011
#> NA12775   0.08086174
#> NA07014  -1.62120299
#> NA12767  -0.32605859
#> NA12889   0.99002830
#> NA12386  -0.05053963
#> NA06995  -0.64696644
#> NA12376  -0.65870262
#> NA12342  -0.44568155
#> NA12748   0.12752562
#> NA11931   0.28810277
#> NA12045   0.35141511
#> NA12750  -1.46178759
#> NA11831  -0.27036485
#> NA12146   1.36769655
#> NA11882   0.70570055
#> NA07056  -0.77440301
#> NA12707   0.29918713
#> NA12154  -0.11189399
#> NA12753  -0.33852331
#> NA11839  -1.77417239
#> NA10859  -0.51293970
#> NA12875  -1.01876662
#> NA07348   0.97779868
#> NA12156   1.98134506
#> NA12044   0.41292860
#> NA11992  -0.44276672
#> NA11829  -0.13874363
#> NA12239  -0.54262360
#> NA12762   1.41869222
#> NA12716  -1.87801686
#> NA12878  -0.54898996
#> NA10856  -0.57746518
#> NA12874  -0.20439765
#> NA12760  -0.41621311
#> NA06985  -0.70558901
#> NA12003  -0.39320620
#> NA10835   0.38326654
#> NA07022  -0.25259164
#> NA12813   1.36834132
#> NA10839   0.73308873
#> NA07055  -0.88839305
#> NA12056  -0.16451663
#> NA10863   0.60963297
#> NA12145   1.39650374
#> NA12814   1.70629143
#> NA10847   0.02578332
#> NA12006  -0.53344399
#> NA12763  -0.52548356
#> NA07357   0.29950163
#> NA12144   1.02502559
#> NA10831  -0.51368002
#> NA07000  -1.02432345
#> NA11832  -0.98329113
#> NA06991  -0.01080641
#> NA11840   1.14028778
#> NA12802   0.80116324
#> NA12761   0.94938720
#> NA10830  -1.92545420
#> NA10855  -0.95041393
#> NA06994   0.78382906
#> NA11993   0.79148009
#> NA11995  -0.89932611
#> NA12891  -0.22183703
#> NA12864   0.27199723
#> NA12751  -1.52545998
#> NA10861   0.86969632
#> NA12005  -0.95431882
#> NA12234   0.31260681
#> NA07345   0.68199047
#> NA07029  -0.74462130
#> NA12892  -0.13958898
#> NA12248   0.55939301
#> NA10846   3.56972082
#> NA12801  -0.17727323
#> NA12872  -0.96576636
#> NA12155  -0.56506454
#> NA06993  -0.20279664
#> NA11830   1.15774856
#> NA10838  -0.88536055
#> NA12249  -1.65717467
#> NA12057  -0.88198305
#> NA12812  -0.31398374
#> NA11881  -0.26358421
#> NA11994  -0.57094114
#> NA12873  -1.70000858
#> NA12815  -1.38137291
#> NA12740  -0.19237917
#> NA12752   1.34989954
#> NA12043  -0.28515058
#> NA12264   1.21112749
#> NA10854  -0.04540513
#> NA12865  -0.65641461