## ----eval = FALSE-------------------------------------------------------------
# install.packages("NetSurvProx")

## ----eval = FALSE-------------------------------------------------------------
# library(NetSurvProx)

## ----eval = FALSE-------------------------------------------------------------
# 
#  # --- SHARED REGULATORY SCHEME FOR INTERCONNECTED MODULES ---
# 
#     s1 <- 5
#     s2 <- 3
# 
#     targets <- 10
# 
#     shared_scheme <- list(
#       list(tfs = c(1, 3), shared = s1, unique = c(targets - s1, targets - s1)),
#       list(tfs = c(2, 4), shared = s2, unique = c(targets - s2, targets - s2)))
# 
#  # --- SIMULATE DATA USING Simulations() ---
# 
#     simul_data <- Simulations(
#         n             = 165,
#         r             = 40,
#         targets       = targets,
#         p_active      = 40,
#         rho           = 0.7,
#         rate          = 0.5,
#         b_true        = c(0.8, 1.2, -1.2, -0.8),
#         nsimul        = 1,
#         model         = "COXNet",
#         baseline      = "weibull",
#         phi           = 0.1,
#         sigma_true    = NULL,
#         breaks        = NULL,
#         hazards       = NULL,
#         shared_scheme = shared_scheme,
#         choice        = 1,
#         save          = FALSE,
#         save_path     = NULL,
#         seed          = 2026,
#         verbose       = FALSE)
# 
#   # --- EXTRACT COMPONENTS ---
# 
#    X     <- simul_data$X_list[[1]]
#    Y     <- simul_data$time_list[[1]]
#    delta <- simul_data$delta_list[[1]]
# 
#    L <- simul_data$L_list[[1]]
# 
#    beta_true <- as.vector(simul_data$beta_list[[1]])
# 

## ----eval = FALSE-------------------------------------------------------------
# 
#  # --- SEED FOR REPRODUCIBILITY ---
# 
#   set.seed(2026)
# 
#  # --- SPLIT (50/50) ---
# 
#    train_frac <- 0.5
#    train_idx  <- sample(seq_len(nrow(X)), size = floor(train_frac * nrow(X)), replace = FALSE)
#    test_idx   <- setdiff(seq_len(nrow(X)), train_idx)
# 
#    X_train <- X[train_idx, , drop = FALSE]
#    Y_train <- Y[train_idx]
#    delta_train <- delta[train_idx]
# 
#    X_test <- X[test_idx, , drop = FALSE]
#    Y_test <- Y[test_idx]
#    delta_test <- delta[test_idx]
# 

## ----eval = FALSE-------------------------------------------------------------
# 
#  # --- FIT THE ENTIRE PROCEDURE USING NetSurvProx() ---
# 
#    fit_simulation <- NetSurvProx(
#           X_train, Y_train, delta_train,
#           X_test, Y_test, delta_test,
#           L                 = L,
#           standardize_train = TRUE,
#           standardize_test  = TRUE,
#           model             = "COXNet",
#           dist              = NULL,
#           select_lambda     = TRUE,
#           alpha_grid        = c(0.3, 0.5, 0.7),
#           nlambda           = 50,
#           lambda_ratio      = 0.01,
#           nfolds            = 5,
#           method            = "median",
#           probs             = seq(0.25, 0.80, by = 0.05),
#           cutoffplot        = FALSE,
#           seed              = 2026,
#           value             = 2,
#           niter             = 1000,
#           conv              = 1e-3,
#           parallel_cv       = TRUE,
#           plotCV            = FALSE,
#           colors_pcv        = NULL,
#           errorbar          = FALSE,
#           ncore_max         = 5,
#           p_active          = 40,
#           times_auc         = NULL,
#           beta_true         = beta_true,
#           metrics           = c("CIndex", "FNR", "FPR", "NSR"),
#           verbose           = FALSE,
#           plot_test         = TRUE)
# 

## ----eval = FALSE-------------------------------------------------------------
# 
#  # --- PERFORMANCE RESULTS ---
# 
#   data.frame(fit_simulation$fit_testing$performance)
# 

## ----eval = FALSE-------------------------------------------------------------
# 
#  # --- LOAD DATASET ---
# 
#   data(LUADdataset)
# 

## ----eval = FALSE-------------------------------------------------------------
# 
#  # --- NETWORK BUIDING USING CreateNetwork() ---
# 
#   net_result <- CreateNetwork(
#       X            = LUADdataset$X_train,
#       doid         = "DOID:1324",
#       tissue       = "lung",
#       disease_file = NULL,
#       tissue_file  = NULL,
#       choice       = 1,
#       model        = NULL,
#       dist         = NULL)
# 
#  # --- FINAL LAPLACIAN MATRIX ---
# 
#   L <- net_result$L
# 
#  # --- DISEASE GENES AND SCORES ---
# 
#   disease_genes <- net_result$disease_genes$standard_name
# 

## ----eval = FALSE-------------------------------------------------------------
# 
#  # --- SCREENING USING VariableScreening() ---
# 
#     screening_res <- VariableScreening(
#         LUADdataset$X_train,
#         disease_genes = disease_genes,
#         screening     = "BMD")
# 
#  # --- LIST OF d SCREENED VARIABLES ---
# 
#     selected_genes <- screening_res$screen_vars
# 
#     index_screen   <- match(selected_genes, colnames(LUADdataset$X_train))
#     index_screen   <- index_screen[!is.na(index_screen)]
# 
#     X_train        <- as.matrix(LUADdataset$X_train[, index_screen])
#     X_test         <- as.matrix(LUADdataset$X_test[, index_screen])
#     L              <- L[index_screen, index_screen]
# 

## ----eval = FALSE-------------------------------------------------------------
# 
#  # --- FIT THE MODEL USING NetSurvProx_Training() ---
# 
#   fit_training <- NetSurvProx_Training(
#           X_train,
#           LUADdataset$Y_train,
#           LUADdataset$delta_train,
#           L             = L,
#           model         = "AFTNet",
#           dist          = "loglogistic",
#           select_lambda = TRUE,
#           alpha_grid    = c(0.3, 0.5, 0.7),
#           nlambda       = 50,
#           lambda_ratio  = 0.01,
#           nfolds        = 5,
#           method        = "median",
#           probs         = seq(0.25, 0.80, by = 0.05),
#           cutoffplot    = TRUE,
#           seed          = 2026,
#           value         = 2,
#           niter         = 1000,
#           conv          = 1e-3,
#           parallel      = TRUE,
#           plotCV        = FALSE,
#           colors_pcv    = NULL,
#           errorbar      = FALSE,
#           ncore_max     = 5,
#           standardize   = TRUE,
#           verbose       = FALSE,
#           palette       = NULL)
# 
#  # --- ESTIMATED REGRESSION COEFFICIENTS ---
# 
#     beta <- fit_training$beta
# 
#  # --- OPTIMAL CUT-OFF FOR STRATIFICATION ---
# 
#     opt_cutoff <- fit_training$cutoff.opt
# 

## ----eval = FALSE-------------------------------------------------------------
# 
#  # --- PATHWAY ANALYSIS USIGN PathwayDashboard() ---
# 
#     genes_list <- rownames(beta)[beta != 0]
# 
#     PathwayDashboard(
#         genes_list,
#         useKeggAPI       = TRUE,
#         pathwayFile      = NULL,
#         nodesCols        = c("#5C7997", "#F5C59F"),
#         diseaseNodes     = TRUE,
#         disease_file     = disease_genes,
#         top_percent      = 20,
#         batch_size       = 10,
#         background_genes = colnames(X_train),
#         min_genes        = 2,
#         top_n            = 10,
#         db_name          = "org.Hs.eg.db",
#         organism         = "hsa",
#         out_dir          = NULL,
#         open_browser     = TRUE,
#         verbose          = FALSE)
# 

## ----eval = FALSE-------------------------------------------------------------
# 
#   # --- FIT THE MODEL USING NetSurvProx_Testing() ---
# 
#   fit_testing <- NetSurvProx_Testing(
#                     X_train,
#                     standardize = TRUE,
#                     LUADdataset$Y_train,
#                     LUADdataset$delta_train,
#                     X_test,
#                     LUADdataset$Y_test,
#                     LUADdataset$delta_test,
#                     model = "AFTNet",
#                     dist  = "loglogistic",
#                     beta, opt_cutoff,
#                     times_auc = NULL,
#                     metrics   = c("CIndex", "NSR", "AUC"),
#                     verbose   = FALSE,
#                     plot      = FALSE,
#                     palette   = NULL)
# 

## ----eval = FALSE-------------------------------------------------------------
# 
#  # --- PERFORMANCE RESULTS ---
# 
#   data.frame(fit_testing$performance)
# 

## -----------------------------------------------------------------------------

  sessionInfo()


