Fit weekly differential expression analysis

Creates pairwise contrasts for all timepoints

# S4 method for Moanin
DE_timepoints(object, contrasts, use_voom_weights = TRUE)

# S4 method for Moanin
create_timepoints_contrasts(object, group1, group2)

Arguments

object

An object of class Moanin, an object containing all related information for time course data and the splines model that will be used (if applicable). See create_moanin_model for more details.

contrasts

Contrasts, either provided as a vector of strings, or a matrix of contrasts coefficients obtained using makeContrasts from the package limma. If given as a character string, will be passed to makeContrasts to be converted into such a matrix.

use_voom_weights

boolean, optional, default: TRUE. Whether to use voom weights. See details.

group1

First group to consider in making contrasts, character value that must match a value contained in moanin_model$meta.

group2

Second group to consider in making contrasts, character value that must match a value contained in moanin_model$meta.

Value

A data.frame with three columns for each of the contrasts given in contrasts, corresponding to the raw p-value of the contrast for that gene (_pval), the adjusted p-value (_qval), and the estimate of log-fold-change (_lfc). The adjusted p-values are FDR-adjusted based on the Benjamini-Hochberg method, as implemented in p.adjust. The adjustment is done across all p-values for all contrasts calculated.

create_timepoints_contrasts: a character vector with each element of the vector corresponding to a contrast to be compared.

Details

If use_voom_weights=TRUE, the data is given directly to limma via assay(object). The specific series of calls is:

   y <- edgeR::DGEList(counts=assay(object))
   y <- edgeR::calcNormFactors(y, method="upperquartile")
   v <- limma::voom(y, design, plot=FALSE)
   v <- limma::lmFit(v)

If the user set log_transform=TRUE in the creation of the Moanin object, this will not have an impact in the analysis if use_voom_weights=TRUE. Only if use_voom_weights=FALSE will this matter, in which case the log of the input data will be given to a regular call to limma:

   y<-get_log_data(object)
   v <- limma::lmFit(y, design)

create_timepoints_contrasts creates the needed contrasts for comparing two groups for every timepoint in the format needed for DE_timepoints (i.e. makeContrasts, to which the contrasts are ultimately passed). The time points are determined by the meta data in the moanin_object provided by the user.

See also

Examples

data(exampleData) moanin <- create_moanin_model(data=testData, meta=testMeta) contrasts <- create_timepoints_contrasts(moanin,"C", "K") head(contrasts)
#> [1] "C.0-K.0" "C.3-K.3" "C.6-K.6" "C.9-K.9" "C.12-K.12" "C.18-K.18"
deTimepoints=DE_timepoints(moanin, contrasts=contrasts, use_voom_weights=FALSE) head(deTimepoints)
#> C.0-K.0_pval C.0-K.0_qval C.0-K.0_lfc C.3-K.3_pval #> NM_009912 0.97982421 0.9903882 1.4723112 0.9262110656 #> NM_008725 0.03588304 0.1269233 -0.5963006 0.8268027883 #> NM_007473 0.68739254 0.8298979 0.7217701 0.7983914753 #> ENSMUST00000094955 0.03102566 0.1138258 -0.9411395 0.0001132542 #> NM_001042489 0.66703738 0.8165900 0.9231153 0.2631128563 #> NM_008159 0.02814324 0.1066609 1.2522998 0.8635470094 #> C.3-K.3_qval C.3-K.3_lfc C.6-K.6_pval C.6-K.6_qval #> NM_009912 0.966385074 0.5845097 0.8317967 0.9136774 #> NM_008725 0.910862373 1.4724864 0.5820653 0.7590271 #> NM_007473 0.897186295 -1.0921945 0.2043003 0.4096540 #> ENSMUST00000094955 0.001679617 0.7765046 0.1124245 0.2761303 #> NM_001042489 0.478760071 0.5031046 0.3612874 0.5781898 #> NM_008159 0.930403119 -1.5421493 0.6194717 0.7827260 #> C.6-K.6_lfc C.9-K.9_pval C.9-K.9_qval C.9-K.9_lfc #> NM_009912 -1.2918000 0.63785487 0.7974610 -1.323696 #> NM_008725 1.6363998 0.70580577 0.8406739 -1.371349 #> NM_007473 -0.9523190 0.88111492 0.9394980 1.556452 #> ENSMUST00000094955 1.3604833 0.02693018 0.1031365 -1.287169 #> NM_001042489 0.7357659 0.38853903 0.6012429 -1.744406 #> NM_008159 0.5717245 0.06246384 0.1867778 -1.159570 #> C.12-K.12_pval C.12-K.12_qval C.12-K.12_lfc C.18-K.18_pval #> NM_009912 0.80026502 0.89773319 1.9155277 0.931977198 #> NM_008725 0.16453830 0.35925393 -1.2862970 0.943270940 #> NM_007473 0.28752114 0.50339082 -0.7946372 0.343379733 #> ENSMUST00000094955 0.01059202 0.05214075 1.3518499 0.008312487 #> NM_001042489 0.11072921 0.27340547 -1.6649354 0.743506121 #> NM_008159 0.27714147 0.49390816 -1.1321695 0.086408488 #> C.18-K.18_qval C.18-K.18_lfc C.24-K.24_pval C.24-K.24_qval #> NM_009912 0.96881202 1.4889108 0.708511770 0.841164785 #> NM_008725 0.97373493 -1.1952419 0.104607788 0.263780445 #> NM_007473 0.55990173 1.2431380 0.793073251 0.894760899 #> ENSMUST00000094955 0.04361875 -0.9570470 0.000677458 0.006673769 #> NM_001042489 0.86296515 0.4673417 0.613652385 0.779537706 #> NM_008159 0.23051045 -0.6784866 0.379655278 0.593381025 #> C.24-K.24_lfc C.30-K.30_pval C.30-K.30_qval C.30-K.30_lfc #> NM_009912 -1.1809659 0.147186413 0.33235642 -1.986354 #> NM_008725 1.4947617 0.631982987 0.79295231 -1.019314 #> NM_007473 -1.6558086 0.288135183 0.50398458 1.586516 #> ENSMUST00000094955 -1.1660751 0.011600519 0.05584844 0.678670 #> NM_001042489 -1.1076813 0.034370762 0.12281538 1.222367 #> NM_008159 -0.6952732 0.004594208 0.02786781 -1.659285 #> C.36-K.36_pval C.36-K.36_qval C.36-K.36_lfc C.48-K.48_pval #> NM_009912 3.025775e-02 0.1123262469 -0.9344829 9.293097e-07 #> NM_008725 4.696613e-01 0.6721792603 -1.6005233 1.146810e-01 #> NM_007473 1.039113e-02 0.0514776635 -1.4708925 5.968840e-01 #> ENSMUST00000094955 8.292780e-02 0.2249568358 -1.5174660 9.713557e-01 #> NM_001042489 7.117086e-01 0.8429712419 -1.2774313 1.318379e-03 #> NM_008159 9.815789e-06 0.0002419385 -1.1642222 5.234054e-08 #> C.48-K.48_qval C.48-K.48_lfc C.60-K.60_pval C.60-K.60_qval #> NM_009912 3.535417e-05 2.6322057 1.702467e-04 2.284884e-03 #> NM_008725 2.800024e-01 1.1956587 5.675888e-02 1.749157e-01 #> NM_007473 7.677670e-01 0.9019558 1.911065e-02 8.051181e-02 #> ENSMUST00000094955 9.862909e-01 -1.4867673 4.512280e-01 6.581780e-01 #> NM_001042489 1.123575e-02 -1.1039644 5.274032e-03 3.110213e-02 #> NM_008159 3.361319e-06 -1.4330146 6.870139e-09 6.587804e-07 #> C.60-K.60_lfc C.72-K.72_pval C.72-K.72_qval C.72-K.72_lfc #> NM_009912 -2.2736182 1.133064e-07 6.721567e-06 -1.989004 #> NM_008725 2.6490453 8.240388e-01 9.092771e-01 3.823575 #> NM_007473 1.4168729 3.959116e-01 6.078991e-01 2.550483 #> ENSMUST00000094955 -1.8475804 2.076119e-02 8.508683e-02 -1.531449 #> NM_001042489 0.7127491 6.704460e-02 1.954653e-01 -1.405711 #> NM_008159 -1.0915509 4.619503e-01 6.665950e-01 3.327829 #> C.120-K.120_pval C.120-K.120_qval C.120-K.120_lfc #> NM_009912 0.22983567 0.4418703 -2.989103 #> NM_008725 0.03070290 0.1130371 -1.818405 #> NM_007473 0.21434196 0.4233617 -1.268488 #> ENSMUST00000094955 0.12476923 0.2969595 1.123775 #> NM_001042489 0.11426630 0.2790873 0.889906 #> NM_008159 0.08399066 0.2267770 1.916022 #> C.168-K.168_pval C.168-K.168_qval C.168-K.168_lfc #> NM_009912 5.553002e-04 0.005784377 1.933203 #> NM_008725 5.660195e-01 0.750105081 -1.140409 #> NM_007473 6.204548e-01 0.783543817 1.161977 #> ENSMUST00000094955 2.142585e-03 0.016110761 -1.673580 #> NM_001042489 8.909952e-01 0.945998265 -1.152500 #> NM_008159 6.051562e-05 0.001030680 1.744230