Author: Weijia Fu, Seungjun Ahn

# SMAHP

#### Weijia Fu, Seungjun Ahn

#### Feb 5th, 2025

## Introduction

Welcome to the SMAHP vignette! This document provides an overview of the SMAHP package. SMAHP (Survival Mediation Analysis of High-dimensional Proteogenomic data) is a novel method for survival mediation analysis that simultaneously handles high-dimensional exposures and mediators, integrates multi-omics data, and offers a robust statistical framework for identifying causal pathways on survival outcomes. SMAHP package is a software extension of our methodology work.

### Installation

To install the package, please use:

    #install.packages("SMAHP")

## Example Usage

We will use the example data built in the package to demonstrate how to use the main function.

    library(SMAHP)
    # load example data
    data("example_dat")

The example data is a simulated dataset for demonstration purpose. It contains exposure (X), mediators (M), covariates (C) and survival data (surv_dat).

    surv_dat <- example_dat$surv_dat
    res <- SMAHP(example_dat$X, example_dat$M, example_dat$C,
                 time = surv_dat$time, status = surv_dat$status)
    #> CV through:  ###                 20 %
    #> CV through:  ### ###             40 %
    #> CV through:  ### ### ###         60 %
    #> CV through:  ### ### ### ###     80 %
    #> CV through:  ### ### ### ### ###  100 %
    #> Using a basic kernel estimate for local fdr; consider installing the ashr package for more accurate estimation.  See ?local_mfdr
    #> CV through:  ###                 20 %
    #> CV through:  ### ###             40 %
    #> CV through:  ### ### ###         60 %
    #> CV through:  ### ### ### ###     80 %
    #> CV through:  ### ### ### ### ###  100 %

    print(res$p_final_matrix)
    #>     M5          M16          M11          M12       M13        M7
    #> X1  NA           NA           NA           NA        NA        NA
    #> X2  NA 8.726353e-14 7.263079e-13 3.916867e-13 0.1832984        NA
    #> X3  NA           NA           NA           NA        NA        NA
    #> X4  NA           NA           NA           NA        NA        NA
    #> X5  NA           NA           NA           NA        NA        NA
    #> X6  NA           NA           NA           NA        NA        NA
    #> X7  NA           NA           NA           NA        NA        NA
    #> X8  NA 8.726353e-14           NA 3.916867e-13 0.1832984        NA
    #> X9  NA 8.726353e-14 7.263079e-13 3.916867e-13        NA        NA
    #> X10 NA           NA           NA           NA        NA        NA
    #> X11 NA           NA 7.263079e-13           NA 0.1832984        NA
    #> X12 NA           NA           NA           NA        NA        NA
    #> X13 NA           NA           NA           NA        NA        NA
    #> X14 NA           NA           NA           NA        NA        NA
    #> X15 NA           NA           NA           NA        NA        NA
    #> X16 NA           NA           NA           NA        NA        NA
    #> X17 NA           NA           NA           NA        NA        NA
    #> X18 NA           NA           NA           NA        NA        NA
    #> X19 NA           NA           NA           NA        NA        NA
    #> X20 NA           NA           NA           NA        NA        NA
    #> X21 NA           NA           NA           NA        NA        NA
    #> X22 NA           NA           NA           NA        NA        NA
    #> X23 NA           NA           NA           NA        NA        NA
    #> X24 NA           NA           NA           NA        NA        NA
    #> X25  0           NA           NA           NA        NA 0.6737463
    #> X26 NA           NA           NA           NA        NA        NA
    #> X27 NA           NA           NA           NA        NA        NA
    #> X28 NA           NA           NA           NA        NA        NA
    #> X29 NA           NA           NA           NA        NA        NA
    #> X30 NA           NA           NA           NA        NA        NA
    #> X31 NA           NA           NA           NA        NA        NA
    #> X32 NA           NA           NA           NA        NA        NA
    #> X33 NA           NA           NA           NA        NA        NA
    #> X34 NA           NA           NA           NA        NA        NA
    #> X35  0           NA           NA           NA        NA 0.6737463
    #> X36 NA           NA           NA           NA        NA        NA
    #> X37 NA           NA           NA           NA        NA        NA
    #> X38 NA           NA           NA           NA        NA        NA
    #> X39  0           NA           NA           NA        NA 0.6737463
    #> X40 NA           NA           NA           NA        NA        NA

    print(res$p_adjusted_matrix)
    #>     M5          M16          M11          M12 M13 M7
    #> X1  NA           NA           NA           NA  NA NA
    #> X2  NA 3.490541e-12 1.452616e-11 1.044498e-11   1 NA
    #> X3  NA           NA           NA           NA  NA NA
    #> X4  NA           NA           NA           NA  NA NA
    #> X5  NA           NA           NA           NA  NA NA
    #> X6  NA           NA           NA           NA  NA NA
    #> X7  NA           NA           NA           NA  NA NA
    #> X8  NA 3.490541e-12           NA 1.044498e-11   1 NA
    #> X9  NA 3.490541e-12 1.452616e-11 1.044498e-11  NA NA
    #> X10 NA           NA           NA           NA  NA NA
    #> X11 NA           NA 1.452616e-11           NA   1 NA
    #> X12 NA           NA           NA           NA  NA NA
    #> X13 NA           NA           NA           NA  NA NA
    #> X14 NA           NA           NA           NA  NA NA
    #> X15 NA           NA           NA           NA  NA NA
    #> X16 NA           NA           NA           NA  NA NA
    #> X17 NA           NA           NA           NA  NA NA
    #> X18 NA           NA           NA           NA  NA NA
    #> X19 NA           NA           NA           NA  NA NA
    #> X20 NA           NA           NA           NA  NA NA
    #> X21 NA           NA           NA           NA  NA NA
    #> X22 NA           NA           NA           NA  NA NA
    #> X23 NA           NA           NA           NA  NA NA
    #> X24 NA           NA           NA           NA  NA NA
    #> X25  0           NA           NA           NA  NA  1
    #> X26 NA           NA           NA           NA  NA NA
    #> X27 NA           NA           NA           NA  NA NA
    #> X28 NA           NA           NA           NA  NA NA
    #> X29 NA           NA           NA           NA  NA NA
    #> X30 NA           NA           NA           NA  NA NA
    #> X31 NA           NA           NA           NA  NA NA
    #> X32 NA           NA           NA           NA  NA NA
    #> X33 NA           NA           NA           NA  NA NA
    #> X34 NA           NA           NA           NA  NA NA
    #> X35  0           NA           NA           NA  NA  1
    #> X36 NA           NA           NA           NA  NA NA
    #> X37 NA           NA           NA           NA  NA NA
    #> X38 NA           NA           NA           NA  NA NA
    #> X39  0           NA           NA           NA  NA  1
    #> X40 NA           NA           NA           NA  NA NA

    print(res$p_med_matrix)
    #>     M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12 M13 M14 M15 M16 M17 M18 M19 M20
    #> X1   0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X2   0  0  0  0  0  0  0  0  0   0   1   1   0   0   0   1   0   0   0   0
    #> X3   0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X4   0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X5   0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X6   0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X7   0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X8   0  0  0  0  0  0  0  0  0   0   0   1   0   0   0   1   0   0   0   0
    #> X9   0  0  0  0  0  0  0  0  0   0   1   1   0   0   0   1   0   0   0   0
    #> X10  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X11  0  0  0  0  0  0  0  0  0   0   1   0   0   0   0   0   0   0   0   0
    #> X12  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X13  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X14  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X15  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X16  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X17  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X18  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X19  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X20  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X21  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X22  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X23  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X24  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X25  0  0  0  0  1  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X26  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X27  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X28  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X29  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X30  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X31  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X32  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X33  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X34  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X35  0  0  0  0  1  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X36  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X37  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X38  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X39  0  0  0  0  1  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0
    #> X40  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0   0   0

The main function returns a list containing three matrices: (1) p_final_matrix, which is the raw p-value before adjustment, (2) p_adjusted_matrix, which contains p-values adjusted using the selected adjustment method, and (3) p_med_matrix, a mediation-exposure matrix encoded with 0s and 1s. In p_med_matrix, a value of 1 indicates a detected mediation association, while 0 means no significant mediation association. The NAs in p_final_matrix and p_adjusted_matrix mean the exposure-mediator pairs were not selected in previous steps.

The function get_sig_pathway can be used to extract the the name of exposure and mediator from identified significant mediation pathways with related adjusted p-values.

    get_sig_pathway(res_SMAHP = res)
    #>          X      M adjusted_pvalue
    #>     <char> <char>           <num>
    #>  1:    X25     M5    0.000000e+00
    #>  2:    X35     M5    0.000000e+00
    #>  3:    X39     M5    0.000000e+00
    #>  4:     X2    M11    1.452616e-11
    #>  5:     X9    M11    1.452616e-11
    #>  6:    X11    M11    1.452616e-11
    #>  7:     X2    M12    1.044498e-11
    #>  8:     X8    M12    1.044498e-11
    #>  9:     X9    M12    1.044498e-11
    #> 10:     X2    M16    3.490541e-12
    #> 11:     X8    M16    3.490541e-12
    #> 12:     X9    M16    3.490541e-12

The function get_coef can be used to extract the the name of exposure and mediator from identified significant mediation pathways with related coefficient estimates.

    get_coef(res_SMAHP = res)
    #>          X      M     beta1    beta2       beta3
    #>     <char> <char>     <num>    <num>       <num>
    #>  1:    X25     M5 0.7848745 4.499896 -0.24182382
    #>  2:    X35     M5 0.7398743 4.499896 -0.64624279
    #>  3:    X39     M5 0.6538620 4.499896 -0.53052986
    #>  4:     X2    M11 0.7700538 3.871182 -0.70411160
    #>  5:     X9    M11 0.8267428 3.871182 -1.02512189
    #>  6:    X11    M11 0.7483066 3.871182 -0.86970220
    #>  7:     X2    M12 0.7796968 3.851632 -0.70411160
    #>  8:     X8    M12 0.8338865 3.851632  0.06451432
    #>  9:     X9    M12 0.7770952 3.851632 -1.02512189
    #> 10:     X2    M16 0.7564046 4.182464 -0.70411160
    #> 11:     X8    M16 0.7814212 4.182464  0.06451432
    #> 12:     X9    M16 0.8198452 4.182464 -1.02512189