The function hdmax2::run_AS() evaluates the association between exposure variables, intermediary variables and the outcome variable using a latent factor mixed model (LFMM Caye et al. 2019) to estimate K unobserved latent factors U.
run_AS.Rd
The function run_AS() evaluates the association between exposure variables X , intermediary variables M and the outcome variable Y, using a latent factor mixed model (LFMM Caye et al. 2019) to estimate K unobserved latent factors U. First this function tests the significance of association between the exposure variables and the potential mediator variables. Then it tests association between the potential mediator variables and the outcome variable. Finally it evaluates the significance of the indirect effects by computing the squared maximum of two series of P-values with max2 test. This rejects the null-hypothesis that either the effect of X on M, or the effect of M on Y is null. Optional covariates Z, can be included as observed adjustment factors in the model.
Arguments
- exposure
An explanatory variable data frame with n rows and d columns. Each column corresponds to a distinct explanatory variable (exposure). Continuous and binary variables must be encoded in numeric format. categorical variables are factor objects. The user can use the as.factor function to encode categorical variables, and levels() and ordered() functions to define the modal order of categorical variables.
- outcome
An explanatory variable matrix with n rows and 1 columns, corresponds to a vector, which supports both continuous and binary formats.
- M
Continuous intermediary variables matrix encompassing potential mediators with n rows and p columns. Must be encoded as numeric. No NAs allowed.
- K
an integer for the number of latent factors in the regression model.
- covar
set of adjustment factors, must be numeric. No NAs allowed
- suppl_covar
possible supplementary adjustment factors for the second association study (must be nested within the first set of adjustment factors )
- each_var_pval
A logical to indicate if p-values must be estimated for each exposure variables (each_var_pval = TRUE) in addition to the pvalue of the global model (each_var_pval = FALSE, by default) Useful to visually check the fit of the estimated proportion of null p-values.
Value
an object with the following attributes
for first association study (mod1):
pValue, estimation of the effects of exposure X and outcome on the matrix M.
U, scores matrix for the K latent factors computed from the for first regression
zscore, a score matrix for the exposure X and the outcome Y.
fscore, a score matrix for the exposure X and the outcome Y.
adj_rsquared
gif, Genomic inflation factor for X and Y, expressing the deviation of the distribution of the observed test statistic compared to the distribution of the expected test statistic
for second association study (mod2):
pValue, zscore, fscore, adj_rsquared, gif
results of max2 test:
pval, results of max2 test
input element: exposition , outcome and covariates
Details
For each argument, missing values must be imputed: no NA allowed. K (number of latent factors) can be estimated with the eigenvalues of a PCA. Max2 test The P-value is computed for each markers following this formula $$pV = max(pVal1, pVal2)^2$$
Examples
# Load example dataset
attach(simu_data)
#> The following objects are masked from simu_data (pos = 3):
#>
#> M, M1, M2, X_binary, X_categorial, X_continuous, X_continuous_2,
#> Y_binary, Y_continuous, age, gender
#> The following objects are masked from simu_data (pos = 4):
#>
#> M, M1, M2, X_binary, X_categorial, X_continuous, X_continuous_2,
#> Y_binary, Y_continuous, age, gender
K = 5
# Run {hdmax2} step 1
hdmax2_step1 = run_AS(exposure = simu_data$X_continuous ,
outcome = simu_data$Y_continuous,
M = simu_data$M1,
K = K)
#> Running first regression with univariate exposure variable.
#> Running second regression.
#> Running max-squared test.
head(hdmax2_step1$max2_pvalues)
#> cg00005740 cg00006787 cg00007032 cg00008612 cg00009871 cg00009922
#> 0.47695977 0.50457875 0.68833562 0.01359132 0.44231790 0.66302923