Given a qseaGLM object with one or more contrasts, extract a wide results table of statistics, adjusted p-values, and (optionally) group means and per-sample values.

getDMRsData(
  qseaSet,
  qseaGLM,
  sampleNames = NULL,
  variable = NULL,
  keepData = FALSE,
  keepGroupMeans = FALSE,
  FDRthres = 0.05,
  keepPvals = FALSE,
  keepFragmentInfo = FALSE,
  direction = "both"
)

Arguments

qseaSet

qseaSet. Input object used to obtain metadata and counts.

qseaGLM

qseaGLM. Fitted model returned by fitQseaGLM().

sampleNames

character() or NULL. Sample names to include as per-sample columns. Default: NULL (chosen automatically when keepData = TRUE, otherwise per-sample columns are omitted).

variable

character(1) or NULL. Sample-table column on which contrasts were based (used to compute group means). Default: NULL (required if keepGroupMeans = TRUE).

keepData

logical(1). If TRUE, include per-sample values (beta/NRPM etc.) as columns. Default: FALSE.

keepGroupMeans

logical(1). If TRUE, include group mean columns for each contrast side (based on variable). Default: FALSE.

FDRthres

numeric(1). False discovery rate threshold used to flag significance. Default: 0.05.

keepPvals

logical(1). If TRUE, include raw (unadjusted) p-values in addition to FDR. Default: FALSE.

keepFragmentInfo

logical(1). If TRUE, include fragment/MAPQ metrics where available. Default: FALSE.

direction

character(1). Direction for significance calling, passed to qsea::isSignificant(): one of "up", "down", or "both". Default: "both".

Value

A tibble with one row per DMR (window) containing:

  • Per-contrast statistics (e.g., log2FC, deltaBeta, test statistic).

  • Multiple-testing output (FDR; optionally raw p-values if keepPvals).

  • Optional group summaries if keepGroupMeans = TRUE.

  • Optional per-sample columns if keepData = TRUE (for sampleNames).

  • Optional fragment/MAPQ metrics if keepFragmentInfo = TRUE.

Details

Significant rows are determined using FDRthres and direction via qsea::isSignificant(). When keepData = TRUE and sampleNames = NULL, per-sample columns are included for all samples in the fitted model (or the subset relevant to each contrast, depending on the internal representation). Group means require variable to identify the groupings used in contrasts.

See also

Examples

data(exampleTumourNormal, package = "mesa")
qs <- exampleTumourNormal
contr <- tibble::tibble(group1 = "LUAD", group2 = "NormalLung")
glmfit <- fitQseaGLM(qs, variable = "type", contrasts = contr)
#> Generating table of nrpm values for 819 regions across 5 samples.
#> Fitting initial GLM on 255 windows, without using parallelisation.
#> Performing contrast LUAD_vs_NormalLung
#> Contrasts Complete
getDMRsData(qs, glmfit, variable = "type", FDRthres = 0.1)
#> selecting regions from contrast LUAD_vs_NormalLung
#> selected 58/255 windows
#> adding test results from LUAD_vs_NormalLung
#>    chr window_start window_end CpG_density LUAD_vs_NormalLung_log2FC
#> 1    7     25107301   25107600    8.129562                -1.7065113
#> 2    7     27096001   27096300   18.819360                 3.7189840
#> 3    7     27096301   27096600   19.869991                 3.3847190
#> 4    7     27096601   27096900   12.621572                 2.4383303
#> 5    7     27096901   27097200   17.859145                 2.9924262
#> 6    7     27098401   27098700   12.091314                 1.1149731
#> 7    7     27099001   27099300   13.110241                 0.8566084
#> 8    7     27103501   27103800   13.065380                 1.7221760
#> 9    7     27106501   27106800   18.975041                 1.0607944
#> 10   7     27106801   27107100   13.121566                 1.3817939
#> 11   7     27108301   27108600   15.663462                 1.0579513
#> 12   7     27108601   27108900   16.137669                 0.9743731
#> 13   7     27113401   27113700   16.196189                 1.0095730
#> 14   7     27113701   27114000   20.416269                 0.7745009
#> 15   7     27124201   27124500   18.103046                 1.1060122
#> 16   7     27129901   27130200   15.153912                 0.9682945
#> 17   7     27130201   27130500   28.165752                 1.0704286
#> 18   7     27130501   27130800   21.505199                 1.2958221
#> 19   7     27130801   27131100   19.733660                 0.9878071
#> 20   7     27139501   27139800   20.879425                 0.5585066
#> 21   7     27142501   27142800   11.395603                 1.1687403
#> 22   7     27144601   27144900   11.126804                 1.4418483
#> 23   7     27144901   27145200   16.289011                 1.2812704
#> 24   7     27151201   27151500   16.547893                 2.3711682
#> 25   7     27156001   27156300   24.495967                 2.8051771
#> 26   7     27156301   27156600   18.493412                 3.2840309
#> 27   7     27156601   27156900   19.399213                 2.6264119
#> 28   7     27164701   27165000   13.844064                 1.9860442
#> 29   7     27165301   27165600   21.163787                 2.5736742
#> 30   7     27165901   27166200   13.562021                 2.5341204
#> 31   7     27166201   27166500   19.991182                 3.1848355
#> 32   7     27169801   27170100   18.338350                 2.3103492
#> 33   7     27173401   27173700   30.900096                 2.7063989
#> 34   7     27174001   27174300   25.134593                 3.7351692
#> 35   7     27184801   27185100   15.569914                 1.7353119
#> 36   7     27185701   27186000   12.453860                 2.7893369
#> 37   7     27191701   27192000    6.785994                 1.9947983
#> 38   7     27192301   27192600   13.204683                 1.9402505
#> 39   7     27199201   27199500   19.364907                 3.8612649
#> 40   7     27199501   27199800   34.796289                 3.7792822
#> 41   7     27199801   27200100   28.271296                 2.5713934
#> 42   7     27200101   27200400   30.300691                 2.4545847
#> 43   7     27204901   27205200   16.907609                 2.9896738
#> 44   7     27205201   27205500   18.542865                 2.9694902
#> 45   7     27205501   27205800   13.388085                 2.4793682
#> 46   7     27213601   27213900   13.029319                 1.9729611
#> 47   7     27239101   27239400   10.828802                 2.7070290
#> 48   7     27242401   27242700   11.744126                 2.0136327
#> 49   7     27242701   27243000   16.860626                 2.2424681
#> 50   7     27243001   27243300   18.365045                 2.2384077
#> 51   7     27245101   27245400   17.281498                 3.2309411
#> 52   7     27246001   27246300   29.640736                 3.1687693
#> 53   7     27246301   27246600   18.853173                 2.4288265
#> 54   7     27251401   27251700   18.043771                 2.3570533
#> 55   7     27251701   27252000   18.786051                 3.1453415
#> 56   7     27252301   27252600   14.980169                 1.6412694
#> 57   7     27507901   27508200   11.079548                -1.0032131
#> 58   7     27868201   27868500    7.998633                 1.0103877
#>    LUAD_vs_NormalLung_adjPval NormalColon_beta_means CRC_beta_means
#> 1                4.249046e-02             0.36370285     0.29310551
#> 2                1.003167e-05             0.02286389     0.02588171
#> 3                9.897733e-07             0.04307951     0.01325373
#> 4                4.445682e-02             0.03170254     0.01868625
#> 5                4.473559e-02             0.03411764     0.01357622
#> 6                5.498550e-03             0.20297172     0.48436703
#> 7                7.828511e-02             0.30363451     0.48698708
#> 8                3.659989e-03             0.24697270     0.68648415
#> 9                2.717567e-07             0.97201574     0.98292081
#> 10               4.473559e-02             0.85935983     0.95764877
#> 11               1.995176e-03             0.32507602     0.70224505
#> 12               1.152404e-05             0.89503296     0.98057606
#> 13               2.230681e-02             0.78444830     0.82435567
#> 14               6.579928e-02             0.52210043     0.60037743
#> 15               1.251189e-03             0.80256807     0.94942989
#> 16               4.775275e-02             0.13286325     0.13035800
#> 17               1.929059e-03             0.17113585     0.15290244
#> 18               3.659989e-03             0.17221249     0.08266116
#> 19               5.437887e-03             0.12017964     0.11589162
#> 20               7.828511e-02             0.65816630     0.62165157
#> 21               6.579928e-02             0.25625255     0.43063974
#> 22               1.188905e-02             0.47603677     0.78244803
#> 23               1.163464e-02             0.42298202     0.66203729
#> 24               4.249046e-02             0.03506450     0.01396020
#> 25               6.529381e-03             0.04213108     0.03699862
#> 26               1.102835e-04             0.02295578     0.01889398
#> 27               2.040101e-02             0.04335333     0.01929138
#> 28               5.437887e-03             0.03911652     0.10380498
#> 29               1.275336e-03             0.08651450     0.08482129
#> 30               3.995843e-02             0.02807925     0.03109415
#> 31               6.826916e-05             0.06829925     0.04383712
#> 32               4.994328e-02             0.04379576     0.02499268
#> 33               9.502693e-02             0.03136274     0.01858256
#> 34               2.244362e-03             0.03162274     0.04360216
#> 35               6.077270e-02             0.03519309     0.02093792
#> 36               8.894003e-03             0.10932018     0.23565668
#> 37               6.579928e-02             0.29353858     0.66436957
#> 38               2.040101e-02             0.11183070     0.26083054
#> 39               2.723638e-07             0.05432257     0.22507125
#> 40               7.482190e-06             0.02185572     0.18487265
#> 41               1.477529e-02             0.02197349     0.02483436
#> 42               8.085397e-02             0.03228571     0.01859282
#> 43               1.102835e-04             0.04687426     0.32879281
#> 44               3.659989e-03             0.02294116     0.31977962
#> 45               2.230681e-02             0.04212668     0.11388968
#> 46               5.437887e-03             0.40529413     0.45502346
#> 47               7.279364e-02             0.23813686     0.43456669
#> 48               4.994328e-02             0.03755351     0.31951249
#> 49               6.529381e-03             0.02362522     0.19523697
#> 50               9.980054e-02             0.06582101     0.31364702
#> 51               9.717466e-06             0.52197319     0.77287623
#> 52               6.529381e-03             0.19122533     0.24147975
#> 53               9.221186e-03             0.25464207     0.56599921
#> 54               2.239728e-02             0.54631149     0.76946917
#> 55               3.659989e-03             0.52886685     0.79163784
#> 56               6.365457e-02             0.23008218     0.47327538
#> 57               1.998963e-02             0.69704437     0.78735613
#> 58               5.984919e-02             0.61821816     0.79330176
#>    NormalLung_beta_means LUAD_beta_means LUSC_beta_means NormalColon_nrpm_means
#> 1             0.73101186       0.2834120      0.37480694              0.5084767
#> 2             0.01417545       0.1677325      0.01314872              0.0000000
#> 3             0.02059205       0.2348305      0.01300140              0.2542384
#> 4             0.02820954       0.1314124      0.01876518              0.0000000
#> 5             0.02564357       0.2112698      0.02459035              0.1313856
#> 6             0.30027544       0.6306922      0.18304233              1.2541261
#> 7             0.33541583       0.6099160      0.55375721              2.3853995
#> 8             0.13858124       0.4539004      0.84722430              1.8854556
#> 9             0.68344021       0.9612808      0.98247177             20.3253965
#> 10            0.42786408       0.9046260      0.95249347              8.5843745
#> 11            0.28559086       0.5758667      0.66329401              3.1481146
#> 12            0.59259935       0.9286236      0.96879647             11.1267582
#> 13            0.57302645       0.9209585      0.65024220              8.9444000
#> 14            0.39199634       0.6752420      0.51528249              5.6734326
#> 15            0.40300827       0.8333684      0.88593261              9.0041299
#> 16            0.16572093       0.3335567      0.15707347              1.1227405
#> 17            0.26332425       0.5847100      0.23708342              1.7540700
#> 18            0.17852187       0.4516687      0.19034667              1.7199386
#> 19            0.25798018       0.5234269      0.34906608              1.1227405
#> 20            0.60809558       0.8399465      0.96660709              7.7704623
#> 21            0.35330371       0.7546987      0.53534250              1.3684460
#> 22            0.36405414       0.8525419      0.93074734              2.5338508
#> 23            0.30045638       0.7203546      0.92461431              4.2623223
#> 24            0.03379956       0.1656241      0.58837300              0.1313856
#> 25            0.03130510       0.2097657      0.35308027              0.2542384
#> 26            0.01732460       0.1637919      0.20884704              0.0000000
#> 27            0.03350863       0.2112362      0.29798511              0.2457055
#> 28            0.05272678       0.2255858      0.52437717              0.1228528
#> 29            0.06349829       0.3826259      0.85650855              0.7541823
#> 30            0.04419892       0.2567779      0.26027444              0.0000000
#> 31            0.04371204       0.4043887      0.88285598              0.5255424
#> 32            0.03725410       0.1906839      0.15637345              0.2542384
#> 33            0.01706855       0.1190691      0.03538935              0.1228528
#> 34            0.02866833       0.4126316      0.02336244              0.1228528
#> 35            0.03820756       0.1212005      0.02624241              0.1228528
#> 36            0.03447713       0.2216658      0.67096195              0.6142638
#> 37            0.34993766       0.7881975      0.83614153              0.1313856
#> 38            0.04504492       0.1665715      0.13431037              0.7456494
#> 39            0.02206333       0.3376115      0.02408731              0.3685583
#> 40            0.02169769       0.2867515      0.02309541              0.0000000
#> 41            0.02006125       0.1178889      0.03549393              0.0000000
#> 42            0.02651153       0.1398045      0.02317175              0.1313856
#> 43            0.03543559       0.2937723      0.32410728              0.2627712
#> 44            0.03886381       0.3253825      0.51223154              0.0000000
#> 45            0.02284725       0.1176049      0.14803003              0.1313856
#> 46            0.05811173       0.2301713      0.31363480              3.2419759
#> 47            0.03822530       0.2484144      0.11047895              1.0340192
#> 48            0.04208650       0.1706362      0.48999286              0.0000000
#> 49            0.02923750       0.1449000      0.37899873              0.0000000
#> 50            0.03910405       0.1861609      0.24892524              0.4999439
#> 51            0.03161635       0.2928641      0.18636874              8.1203091
#> 52            0.02178503       0.1885801      0.04798069              1.9707841
#> 53            0.02526573       0.1351582      0.02422962              2.6021136
#> 54            0.03850327       0.1994017      0.70132732              7.5691681
#> 55            0.03006800       0.2716173      0.66809579             10.0910932
#> 56            0.03838645       0.1161913      0.20257960              2.0851040
#> 57            0.87876363       0.4836175      0.58430132              3.9449611
#> 58            0.69559320       0.8854112      0.60287717              1.1398062
#>    CRC_nrpm_means NormalLung_nrpm_means LUAD_nrpm_means LUSC_nrpm_means
#> 1      0.43992120            1.41798873       0.2840043       0.5385992
#> 2      0.17836794            0.00000000       1.6630471       0.0000000
#> 3      0.00000000            0.07623409       2.2237345       0.0000000
#> 4      0.00000000            0.07102760       0.8886193       0.0000000
#> 5      0.00000000            0.12113629       2.3818535       0.1346498
#> 6      3.25761743            1.88408527       3.9716880       1.0771984
#> 7      3.81051826            2.49134539       4.4328264       4.1741437
#> 8      5.96293082            1.00107859       3.1752964       6.7324899
#> 9     24.58199741            7.12035324      14.2090623      17.3698239
#> 10    13.61976028            3.12463796       8.8393165       9.6947854
#> 11     7.54404876            2.65455474       5.4429584       6.1938907
#> 12    19.14876854            5.78380509      10.9342169      13.1956802
#> 13     9.14356050            5.46226470      10.6692278       6.1938907
#> 14     6.65240799            3.96464930       6.7634311       5.2513421
#> 15    15.27846276            3.96646321       8.7178037       9.4254858
#> 16     1.18898698            1.44411413       2.7917431       1.3464980
#> 17     1.65270383            2.74120181       5.7679416       2.4236964
#> 18     0.86204540            1.73988798       4.4401477       1.8850972
#> 19     1.30796524            2.61328036       5.2292180       3.5008947
#> 20     6.91976098            6.33360793       9.1086783      13.5996295
#> 21     2.50875059            1.81249424       4.1488221       2.8276457
#> 22     6.34306450            1.70855609       4.9305712       6.1938907
#> 23     8.50687757            2.80803815       6.9844927      10.0987348
#> 24     0.00000000            0.21828929       1.6776896       5.6552915
#> 25     0.28534892            0.22168186       2.3672109       3.6355445
#> 26     0.06538832            0.03811704       1.6703683       2.0197470
#> 27     0.08918397            0.22688835       2.3745322       2.9622955
#> 28     0.71927148            0.31330018       1.6337620       4.3087935
#> 29     0.74306713            0.54018853       4.3289049       9.1561862
#> 30     0.13077663            0.23367351       2.2749833       2.0197470
#> 31     0.39832854            0.31669276       4.2996198       9.5601356
#> 32     0.15457229            0.23888000       2.0758854       1.4811478
#> 33     0.08918397            0.04150962       0.8373705       0.2692996
#> 34     0.35073723            0.16264591       3.4856371       0.1346498
#> 35     0.08918397            0.23367351       1.0803959       0.1346498
#> 36     1.95604868            0.11253722       1.5781406       4.5780931
#> 37     1.26637258            0.29610204       1.4639492       1.3464980
#> 38     2.51494816            0.23028093       1.2794938       0.9425486
#> 39     2.89547969            0.08301925       3.0684262       0.1346498
#> 40     2.47335549            0.10914464       3.2411877       0.1346498
#> 41     0.17836794            0.07962667       1.2868150       0.2692996
#> 42     0.08918397            0.15404684       1.5854619       0.1346498
#> 43     4.12025961            0.20415554       2.8210281       3.0969453
#> 44     4.07266830            0.24566516       2.8693283       5.1166923
#> 45     1.02261633            0.04150962       0.8886193       1.0771984
#> 46     3.79292018            0.31330018       1.6557258       2.2890466
#> 47     2.03303644            0.03811704       1.1945874       0.4039494
#> 48     2.40796718            0.11774371       0.9881682       2.8276457
#> 49     2.40796718            0.15586076       1.3717215       3.6355445
#> 50     4.00727998            0.27179056       2.0832066       2.4236964
#> 51     9.65447081            0.19216389       3.0420898       1.7504474
#> 52     2.33618237            0.10914464       2.1754343       0.4039494
#> 53     7.21670933            0.12113629       1.3790427       0.1346498
#> 54     9.78524744            0.26839798       2.1754343       7.0017895
#> 55    13.10225455            0.18877131       3.0640536       6.7324899
#> 56     4.69655824            0.23028093       0.9808470       1.7504474
#> 57     4.75014819            5.18458061       2.4447961       2.8276457
#> 58     1.80727612            1.27072704       2.7068367       0.9425486