OSCR

XGBoost-SHAP Interpretable Modeling Identifies and Validates an Eight-Gene Biomarker for Hepatic Encephalopathy Risk Prediction in Cirrhosis.

Code ↔ Paper

18 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 18 matches
  1. [1] § 4. Materials and Methods › 4.6. Construction and Validation of XGBoost–SHAP Models ↔ r.07_xgboost.R, lines 29 to 136 · score 0.89 · colsample_bytree, XGBoost regression, cross validation, squarederror, subsampling, depth · Report a mismatch
  2. [2] § 4. Materials and Methods › 4.2. Differential Expression Analysis ↔ r.01_DEG.R, lines 15 to 100 · score 0.86 · contrasts.fit, eBayes, lmFit, linear model, limma, volcano · Report a mismatch
  3. [3] § 2. Results › 2.1. Workflow of the Study ↔ r.02_Mfuzz.R, lines 15 to 56 · score 0.79 · chronic liver failure, eCLD, decompensated cirrhosis, ACLF, acute, CC · Report a mismatch
  4. [4] § 2. Results › 2.1. Workflow of the Study ↔ r.11_PCA.R, lines 17 to 63 · score 0.78 · eCLD, chronic liver failure, decompensated cirrhosis, ACLF, CC, healthy · Report a mismatch
  5. [5] § 4. Materials and Methods › 4.5. Machine Learning-Based Marker Gene Selection ↔ r.06_RF.R, lines 17 to 75 · score 0.74 · randomForest, IncMSE, IncNodePurity, regression, modeling, gene · Report a mismatch
  6. [6] § 4. Materials and Methods › 4.8. Gene Set Enrichment Analysis (GSEA) ↔ r.10_GSEA.R, lines 68 to 119 · score 0.74 · gradient permutation, minSize, maxSize, Spearman, NES, thresholds · Report a mismatch
  7. [7] § 2. Results › 2.5. Multi-Algorithm Cross-Validated Screening for HE-Specific Marker Genes ↔ r.06_RF.R, lines 17 to 75 · score 0.70 · IncMSE, IncNodePurity, random forest, genes · Report a mismatch
  8. [8] § 4. Materials and Methods › 4.3. Functional Enrichment Analysis ↔ r.03_GOKEGG.R, lines 39 to 92 · score 0.69 · enrichGO, enrichKEGG, bitr, BH, enrichment, gene · Report a mismatch
  9. [9] § 4. Materials and Methods › 4.6. Construction and Validation of XGBoost–SHAP Models ↔ r.12_ROC.R, lines 150 to 213 · score 0.64 · fusion weights, Risk scores, w1, w2, AUC, models · Report a mismatch
  10. [10] § 4. Materials and Methods › 4.8. Gene Set Enrichment Analysis (GSEA) ↔ R/fgsea.R, lines 316 to 376 · score 0.63 · minSize, maxSize, fgsea, BH, NES, permutation · Report a mismatch
  11. [11] § 4. Materials and Methods › 4.7. Structural Equation Modeling and Mediation Effect Analysis ↔ r.09_SEM.R, lines 305 to 351 · score 0.60 · TUBA1C, mediation, mediated, bootstrap, indirect, SEM · Report a mismatch
  12. [12] § 2. Results › 2.4. Identification of Prognosis-Associated DEGs ↔ r.01_DEG.R, lines 102 to 148 · score 0.57 · good prognosis, poor prognosis, limma, DEGs, cirrhotic, GSE15654 · Report a mismatch
  13. [13] § 4. Materials and Methods › 4.7. Structural Equation Modeling and Mediation Effect Analysis ↔ r.09_SEM.R, lines 70 to 93 · score 0.56 · ComBat, batch correction, SEM, Modeling · Report a mismatch
  14. [14] § 4. Materials and Methods › 4.6. Construction and Validation of XGBoost–SHAP Models ↔ r.08_model_validation.R, lines 141 to 200 · score 0.56 · KM survival, model validation, probability, median, risk · Report a mismatch
  15. [15] § 4. Materials and Methods › 4.1. Data Acquisition and Cohort Construction ↔ r.11_PCA.R, lines 17 to 63 · score 0.56 · eCLD, ACLF, DC, CC, healthy, clustering · Report a mismatch
  16. [16] § 2. Results › 2.5. Multi-Algorithm Cross-Validated Screening for HE-Specific Marker Genes ↔ r.04_LASSO.R, lines 122 to 164 · score 0.55 · partial likelihood deviance, cross validation, optimal, LASSO · Report a mismatch
  17. [17] § 2. Results › 2.6. Dual-Model Construction Based on XGBoost–SHAP and Multi-Level Clinical Validation ↔ packaging.R, lines 1 to 47 · score 0.54 · SHapley, exPlanations, Additive, XGBoost, model · Report a mismatch
  18. [18] § 2. Results › 2.7. Structural Equation Modeling-Based Analyses of Characteristic Gene Regulatory Networks ↔ r.09_SEM.R, lines 305 to 351 · score 0.51 · TUBA1C, mediated, indirect, SEM, mediation, LRRC32 · Report a mismatch

Paper

Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

R · 484 lines · 17 KB · MIT · 3 matches

  1. rm(list = ls()); gc()
  2. ORIGINAL_DIR <- ""
  3. output <- file.path(ORIGINAL_DIR, "09_SEM")
  4. if (!dir.exists(output)) {
  5. dir.create(output, recursive = TRUE)
  6. }
  7. setwd(ORIGINAL_DIR)
  8. library(tidyverse)
  9. library(mediation)
  10. library(limma)
  11. library(sva)
  12. library(corrplot)
  13. library(pheatmap)
  14. library(lavaan)
  15. library(semPlot)
  16. library(dplyr)
  17. library(ggplot2)
  18. library(scales)
  19. library(grid)
  20. library(ggrepel)
  21. # Helper function for normality testing
  22. test_normality <- function(exp_data, by_group = FALSE, group_info = NULL) {
  23. if (is.data.frame(exp_data)) exp_data <- as.matrix(exp_data)
  24. if (!by_group) {
  25. pvals <- apply(exp_data, 1, function(x) {
  26. x <- as.numeric(x)
  27. if (all(is.na(x)) || sum(!is.na(x)) < 3) return(NA_real_)
  28. res <- tryCatch(shapiro.test(x), error = function(e) NULL)
  29. if (is.null(res)) NA_real_ else as.numeric(res$p.value)
  30. })
  31. df <- data.frame(gene = rownames(exp_data), p.value = as.numeric(pvals), stringsAsFactors = FALSE)
  32. df$adj.p <- p.adjust(df$p.value, method = "BH")
  33. return(df[order(df$adj.p), ])
  34. } else {
  35. if (is.null(group_info)) stop("group_info required for by_group = TRUE")
  36. groups <- levels(factor(group_info))
  37. res_list <- list()
  38. for (g in groups) {
  39. cols <- which(group_info == g)
  40. if (length(cols) < 3) {
  41. tmp <- data.frame(gene = rownames(exp_data), group = g, p.value = NA_real_, stringsAsFactors = FALSE)
  42. } else {
  43. pvals <- apply(exp_data[, cols, drop = FALSE], 1, function(x) {
  44. x <- as.numeric(x)
  45. if (all(is.na(x)) || sum(!is.na(x)) < 3) return(NA_real_)
  46. res <- tryCatch(shapiro.test(x), error = function(e) NULL)
  47. if (is.null(res)) NA_real_ else as.numeric(res$p.value)
  48. })
  49. tmp <- data.frame(gene = rownames(exp_data), group = g, p.value = as.numeric(pvals), stringsAsFactors = FALSE)
  50. tmp$adj.p <- p.adjust(tmp$p.value, method = "BH")
  51. }
  52. res_list[[g]] <- tmp
  53. }
  54. df_all <- do.call(rbind, lapply(res_list, function(x) {
  55. if (!"adj.p" %in% colnames(x)) x$adj.p <- NA_real_
  56. x
  57. }))
  58. rownames(df_all) <- NULL
  59. return(df_all[order(df_all$group, df_all$adj.p), ])
  60. }
  61. }
  62. # Helper function for batch correction
  63. perform_batch_correction <- function(exp_data, batch_info, group_info = NULL) {
  64. sample_order <- colnames(exp_data)
  65. batch_factor <- batch_info[match(sample_order, names(batch_info))]
  66. unique_batches <- unique(batch_factor)
  67. cat("Unique batches:", unique_batches, "\n")
  68. cat("Number of unique batches:", length(unique_batches), "\n")
  69. if (length(unique_batches) > 1 && !any(is.na(unique_batches))) {
  70. if (!is.null(group_info)) {
  71. group_factor <- group_info[match(sample_order, names(group_info))]
  72. mod <- model.matrix(~ group_factor)
  73. exp_corrected <- ComBat(dat = exp_data, batch = batch_factor, mod = mod)
  74. } else {
  75. exp_corrected <- ComBat(dat = exp_data, batch = batch_factor)
  76. }
  77. } else {
  78. warning("Batch correction not performed - insufficient batches")
  79. exp_corrected <- exp_data
  80. }
  81. return(exp_corrected)
  82. }
  83. # Helper function for PCA plot
  84. create_pca_plot <- function(exp_data, group_info, project_info = NULL, title = "PCA Plot") {
  85. pca <- prcomp(t(exp_data), scale. = TRUE)
  86. pca_data <- data.frame(
  87. PC1 = pca$x[, 1],
  88. PC2 = pca$x[, 2],
  89. Sample = colnames(exp_data),
  90. Group = group_info
  91. )
  92. if (!is.null(project_info)) {
  93. pca_data$Project <- project_info
  94. }
  95. var_explained <- pca$sdev^2 / sum(pca$sdev^2)
  96. pc1_var <- round(var_explained[1] * 100, 2)
  97. pc2_var <- round(var_explained[2] * 100, 2)
  98. p <- ggplot(pca_data, aes(x = PC1, y = PC2, color = factor(Group))) +
  99. geom_point(size = 2, alpha = 0.7) +
  100. labs(
  101. x = paste0("PC1 (", pc1_var, "%)"),
  102. y = paste0("PC2 (", pc2_var, "%)"),
  103. title = title,
  104. color = "Group"
  105. ) +
  106. theme_minimal()
  107. return(list(plot = p, pca = pca, data = pca_data))
  108. }
  109. # Helper function for correlation heatmap
  110. create_correlation_heatmap <- function(exp_data, output_dir, filename_prefix) {
  111. cor_matrix <- cor(t(exp_data), use = "pairwise.complete.obs")
  112. p_matrix <- cor.mtest(cor_matrix)$p
  113. genes <- colnames(cor_matrix)
  114. cor_df <- as.data.frame(as.table(cor_matrix), stringsAsFactors = FALSE) %>%
  115. rename(gene_y = Var1, gene_x = Var2, r = Freq)
  116. p_df <- as.data.frame(as.table(p_matrix), stringsAsFactors = FALSE) %>%
  117. rename(gene_y = Var1, gene_x = Var2, p = Freq)
  118. plot_df <- cor_df %>%
  119. left_join(p_df, by = c("gene_y", "gene_x")) %>%
  120. mutate(
  121. sig = case_when(
  122. p < 0.001 ~ "***",
  123. p < 0.01 ~ "**",
  124. p < 0.05 ~ "*",
  125. TRUE ~ ""
  126. ),
  127. label = ifelse(gene_x == gene_y, sprintf("%.2f", r), sprintf("%.2f%s", r, sig))
  128. )
  129. plot_df$gene_x <- factor(plot_df$gene_x, levels = genes)
  130. plot_df$gene_y <- factor(plot_df$gene_y, levels = rev(genes))
  131. p <- ggplot(plot_df, aes(x = gene_x, y = gene_y, fill = r)) +
  132. geom_tile(color = "white", linewidth = 0.4) +
  133. geom_text(aes(label = label), size = 2.8, color = "black") +
  134. scale_fill_gradient2(
  135. low = "#8491B4", mid = "white", high = "#F39B7F",
  136. midpoint = 0, limits = c(-1, 1), name = "Correlation"
  137. ) +
  138. scale_x_discrete(position = "top") +
  139. coord_fixed() +
  140. theme_minimal(base_size = 11) +
  141. theme(
  142. panel.grid = element_blank(),
  143. axis.title = element_blank(),
  144. axis.text.x.top = element_text(face = "italic", color = "black",
  145. angle = 45, hjust = 0, vjust = 0,
  146. margin = margin(b = 0)),
  147. axis.text.y.left = element_text(face = "italic", color = "black",
  148. margin = margin(r = 0))
  149. )
  150. ggsave(file.path(output_dir, paste0(filename_prefix, "_corrplot_full.pdf")),
  151. p, width = 4.5, height = 4.5, dpi = 300)
  152. ggsave(file.path(output_dir, paste0(filename_prefix, "_corrplot_full.png")),
  153. p, width = 4.5, height = 4.5, dpi = 300)
  154. return(list(plot = p, cor_matrix = cor_matrix, p_matrix = p_matrix))
  155. }
  156. #### Load and prepare data ####
  157. # Load expression data
  158. exp01 <- read.csv(file.path("00_rawdata", "00.rawdata_GSE139602_exp.csv"), row.names = 1)
  159. group01 <- read.csv(file.path("00_rawdata", "00.rawdata_GSE139602_group.csv"), row.names = 1)
  160. group01 <- group01[colnames(exp01), , drop = FALSE]
  161. # Convert group labels
  162. group01$group <- ifelse(group01$characteristics_ch1 == "disease state: Healthy", 0,
  163. ifelse(group01$characteristics_ch1 == "disease state: eCLD", 1,
  164. ifelse(group01$characteristics_ch1 == "disease state: Compensated Cirrhosis", 2,
  165. ifelse(group01$characteristics_ch1 == "disease state: Decompesated Cirrhosis", 3,
  166. ifelse(group01$characteristics_ch1 == "disease state: Acute-on-chronic liver failure", 4, NA)))))
  167. exp02 <- read.csv(file.path("00_rawdata", "00.rawdata_GSE15654_exp.csv"), row.names = 1)
  168. group02 <- read.csv(file.path("00_rawdata", "00.rawdata_GSE15654_group.csv"), row.names = 1)
  169. # Load models and gene lists
  170. model1 <- readRDS(file.path("07_xgboost", "07_xgboost_GSE139602_final_xgboost_model.Rdata"))
  171. model2 <- readRDS(file.path("07_xgboost", "07_xgboost_GSE15654_final_xgboost_model_cox.Rdata"))
  172. model1_gene <- read.csv(file.path("07_xgboost", "07_xgboost_GSE139602_shap_mat.csv"), row.names = 1)
  173. model2_gene <- read.csv(file.path("07_xgboost", "07_xgboost_GSE15654_shap_mat.csv"), row.names = 1)
  174. all_features <- c(colnames(model1_gene), colnames(model2_gene))
  175. # Find common genes
  176. common_genes <- intersect(rownames(exp01), rownames(exp02))
  177. exp01 <- exp01[common_genes, ]
  178. exp02 <- exp02[common_genes, ]
  179. exp_merged <- cbind(exp01, exp02)
  180. # Prepare group information
  181. group01$project <- "GSE139602"
  182. group02$project <- "GSE15654"
  183. group_merged <- data.frame(
  184. row.names = c(rownames(group01), rownames(group02)),
  185. group = c(group01$group, group02$group),
  186. project = c(group01$project, group02$project)
  187. )
  188. group_merged <- group_merged[colnames(exp_merged), ]
  189. #### Batch correction ####
  190. # Pre-correction visualization
  191. png(file.path(output, "09_SEM_pre_merged.png"), width = 5, height = 4, res = 300, units = "in")
  192. boxplot(exp_merged, xaxt = "n", col = "lightblue",
  193. main = "Gene Expression Distribution (Pre-batch Correction)",
  194. ylab = "Expression Value")
  195. dev.off()
  196. pdf(file.path(output, "09_SEM_pre_merged.pdf"), width = 5, height = 4)
  197. boxplot(exp_merged, xaxt = "n", col = "lightblue",
  198. main = "Gene Expression Distribution (Pre-batch Correction)",
  199. ylab = "Expression Value")
  200. dev.off()
  201. # Perform batch correction
  202. group_merged$sample <- rownames(group_merged)
  203. sample_order <- colnames(exp_merged)
  204. batch_info <- group_merged$project[match(sample_order, group_merged$sample)]
  205. group_info <- group_merged$group[match(sample_order, group_merged$sample)]
  206. names(batch_info) <- sample_order
  207. names(group_info) <- sample_order
  208. exp_corrected <- perform_batch_correction(exp_merged, batch_info, group_info)
  209. # Post-correction visualization
  210. png(file.path(output, "09_SEM_post_merged.png"), width = 5, height = 4, res = 300, units = "in")
  211. boxplot(exp_corrected, xaxt = "n", col = "lightblue",
  212. main = "Gene Expression Distribution (Post-batch Correction)",
  213. ylab = "Expression Value")
  214. dev.off()
  215. pdf(file.path(output, "09_SEM_post_merged.pdf"), width = 5, height = 4)
  216. boxplot(exp_corrected, xaxt = "n", col = "lightblue",
  217. main = "Gene Expression Distribution (Post-batch Correction)",
  218. ylab = "Expression Value")
  219. dev.off()
  220. # Save corrected data
  221. write.csv(group_merged, file.path(output, "09_SEM_group_merged.csv"))
  222. write.csv(exp_merged, file.path(output, "09_SEM_exp_merged.csv"))
  223. write.csv(exp_corrected, file.path(output, "09_SEM_exp_corrected.csv"))
  224. # PCA plots
  225. pca_pre <- create_pca_plot(exp_merged, group_merged$group, group_merged$project,
  226. "PCA of Pre-corrected Expression Data")
  227. ggsave(file.path(output, "09_SEM_pca_pre.png"), pca_pre$plot, width = 6, height = 5)
  228. ggsave(file.path(output, "09_SEM_pca_pre.pdf"), pca_pre$plot, width = 6, height = 5)
  229. pca_post <- create_pca_plot(exp_corrected, group_merged$group, group_merged$project,
  230. "PCA of Post-corrected Expression Data")
  231. ggsave(file.path(output, "09_SEM_pca_post.png"), pca_post$plot, width = 6, height = 5)
  232. ggsave(file.path(output, "09_SEM_pca_post.pdf"), pca_post$plot, width = 6, height = 5)
  233. #### Normality testing ####
  234. exp_data <- exp_corrected[all_features, ]
  235. norm_res <- test_normality(exp_data, by_group = FALSE)
  236. write.csv(norm_res, file.path(output, "09_SEM_normality_shapiro_overall.csv"))
  237. #### Correlation analysis ####
  238. cor_results <- create_correlation_heatmap(exp_data, output, "09_SEM")
  239. #### Mediation analysis ####
  240. # Prepare data for mediation
  241. X <- as.data.frame(t(exp_corrected[all_features, ]))
  242. X <- scale(X)
  243. X <- as.data.frame(X)
  244. # Predict progression and survival
  245. progression <- predict(model1, scale(t(exp_corrected[colnames(model1_gene), ])))
  246. survival <- predict(model2, scale(t(exp_corrected[colnames(model2_gene), ])))
  247. X$progression <- progression
  248. X$survival <- survival
  249. # Define mediator and outcome models
  250. mediator_vars <- c("NPC2", "TLN1", "TUBA1C", "LRRC32", "PRB2")
  251. outcome_vars <- c("SOX9", "RNASE4", "SERPINA3")
  252. # Linear regression models for mediation
  253. model_a <- lm(progression ~ NPC2 + TLN1 + TUBA1C + LRRC32 + PRB2, data = X)
  254. model_bc <- lm(survival ~ NPC2 + TLN1 + TUBA1C + LRRC32 + PRB2 + SOX9 + RNASE4 + SERPINA3 + progression, data = X)
  255. # Perform mediation analysis
  256. mediation_results <- list()
  257. for (treat in mediator_vars) {
  258. med_result <- mediate(model.m = model_a,
  259. model.y = model_bc,
  260. treat = treat,
  261. mediator = "progression",
  262. boot = TRUE,
  263. sims = 1000)
  264. mediation_results[[treat]] <- summary(med_result)
  265. }
  266. #### Structural Equation Modeling (SEM) ####
  267. # Define SEM model
  268. sem_model <- '
  269. # Direct effects on progression
  270. progression ~ a_NPC2*NPC2 + a_TLN1*TLN1 + a_TUBA1C*TUBA1C + a_LRRC32*LRRC32 + a_PRB2*PRB2
  271. # Effects on outcome mediators
  272. SOX9 ~ b_SOX9*progression
  273. RNASE4 ~ b_RNASE4*progression
  274. SERPINA3 ~ b_SERPINA3*progression
  275. # Effects on survival
  276. survival ~ c_SOX9*SOX9 + c_RNASE4*RNASE4 + c_SERPINA3*SERPINA3 + c_progression*progression
  277. # Indirect effects
  278. indirect_NPC2_SOX9 := a_NPC2 * b_SOX9 * c_SOX9
  279. indirect_NPC2_RNASE4 := a_NPC2 * b_RNASE4 * c_RNASE4
  280. indirect_NPC2_SERPINA3 := a_NPC2 * b_SERPINA3 * c_SERPINA3
  281. indirect_TLN1_SOX9 := a_TLN1 * b_SOX9 * c_SOX9
  282. indirect_TLN1_RNASE4 := a_TLN1 * b_RNASE4 * c_RNASE4
  283. indirect_TLN1_SERPINA3 := a_TLN1 * b_SERPINA3 * c_SERPINA3
  284. indirect_TUBA1C_SOX9 := a_TUBA1C * b_SOX9 * c_SOX9
  285. indirect_TUBA1C_RNASE4 := a_TUBA1C * b_RNASE4 * c_RNASE4
  286. indirect_TUBA1C_SERPINA3 := a_TUBA1C * b_SERPINA3 * c_SERPINA3
  287. indirect_LRRC32_SOX9 := a_LRRC32 * b_SOX9 * c_SOX9
  288. indirect_LRRC32_RNASE4 := a_LRRC32 * b_RNASE4 * c_RNASE4
  289. indirect_LRRC32_SERPINA3 := a_LRRC32 * b_SERPINA3 * c_SERPINA3
  290. indirect_PRB2_SOX9 := a_PRB2 * b_SOX9 * c_SOX9
  291. indirect_PRB2_RNASE4 := a_PRB2 * b_RNASE4 * c_RNASE4
  292. indirect_PRB2_SERPINA3 := a_PRB2 * b_SERPINA3 * c_SERPINA3
  293. '
  294. # Fit SEM model
  295. set.seed(123)
  296. fit <- sem(sem_model, data = X, se = "bootstrap", bootstrap = 2000, missing = "FIML")
  297. # Extract results
  298. fit_summary <- summary(fit, standardized = TRUE, rsquare = TRUE)
  299. fit_measures <- fitmeasures(fit, c("cfi", "tli", "rmsea", "srmr"))
  300. parameter_estimates <- parameterEstimates(fit, standardized = TRUE)
  301. # Save results
  302. write.csv(parameter_estimates, file.path(output, "09_SEM_sem_results.csv"))
  303. write.csv(fit_measures, file.path(output, "09_SEM_fit_measures.csv"))
  304. # Extract indirect effects
  305. indirect_effects <- parameter_estimates[grepl("^indirect_", parameter_estimates$label), ]
  306. indirect_effects <- indirect_effects %>%
  307. mutate(p_adj = p.adjust(pvalue, method = "fdr"))
  308. write.csv(indirect_effects, file.path(output, "09_SEM_indirect_effects.csv"))
  309. write.csv(indirect_effects[indirect_effects$pvalue < 0.05, ],
  310. file.path(output, "09_SEM_significant_indirect.csv"))
  311. #### Create SEM path diagram ####
  312. # Prepare node positions
  313. nodes <- bind_rows(
  314. tibble(node = c("NPC2", "TLN1", "TUBA1C", "LRRC32", "PRB2"),
  315. x = c(-4, -2, 0, 2, 4), y = 4),
  316. tibble(node = "progression", x = 0, y = 3),
  317. tibble(node = c("SOX9", "RNASE4", "SERPINA3"),
  318. x = c(-2, 0, 2), y = 2),
  319. tibble(node = "survival", x = 0, y = 1)
  320. )
  321. # Prepare edges
  322. pe <- parameter_estimates %>%
  323. filter(op == "~") %>%
  324. transmute(
  325. from = rhs,
  326. to = lhs,
  327. est = std.all,
  328. pval = pvalue
  329. )
  330. edges <- pe %>%
  331. inner_join(nodes %>% rename(from = node, x = x, y = y), by = "from") %>%
  332. inner_join(nodes %>% rename(to = node, xend = x, yend = y), by = "to") %>%
  333. mutate(
  334. dx = xend - x,
  335. curve_type = case_when(
  336. dx > 0 ~ "right",
  337. dx < 0 ~ "left",
  338. TRUE ~ "vertical"
  339. ),
  340. xm = (x + xend) / 2 + ifelse(dx == 0, 0.18, 0),
  341. ym = (y + yend) / 2 + ifelse(dx == 0, 0, 0.12 * sign(dx))
  342. )
  343. # Prepare node labels with italics for genes
  344. gene_nodes <- c("NPC2", "TLN1", "TUBA1C", "LRRC32", "PRB2", "SOX9", "RNASE4", "SERPINA3")
  345. nodes <- nodes %>%
  346. mutate(
  347. label_expr = ifelse(
  348. node %in% gene_nodes,
  349. paste0("italic('", node, "')"),
  350. paste0("'", node, "'")
  351. )
  352. )
  353. # Create SEM path diagram
  354. p_sem <- ggplot() +
  355. geom_curve(
  356. data = edges %>% filter(curve_type == "right"),
  357. aes(x = x, y = y, xend = xend, yend = yend, color = est, linewidth = abs(est)),
  358. curvature = 0.25, alpha = 0.9, lineend = "round",
  359. arrow = arrow(length = unit(0.18, "cm"), type = "closed")
  360. ) +
  361. geom_curve(
  362. data = edges %>% filter(curve_type == "left"),
  363. aes(x = x, y = y, xend = xend, yend = yend, color = est, linewidth = abs(est)),
  364. curvature = -0.25, alpha = 0.9, lineend = "round",
  365. arrow = arrow(length = unit(0.18, "cm"), type = "closed")
  366. ) +
  367. geom_curve(
  368. data = edges %>% filter(curve_type == "vertical"),
  369. aes(x = x, y = y, xend = xend, yend = yend, color = est, linewidth = abs(est)),
  370. curvature = 0.20, alpha = 0.9, lineend = "round",
  371. arrow = arrow(length = unit(0.18, "cm"), type = "closed")
  372. ) +
  373. geom_point(
  374. data = nodes,
  375. aes(x = x, y = y),
  376. shape = 21, size = 14, stroke = 0.9,
  377. fill = alpha("#F2F2F2", 0.45), color = "#4D4D4D"
  378. ) +
  379. geom_label_repel(
  380. data = edges,
  381. aes(x = xm, y = ym, label = sprintf("%.2f", est)),
  382. size = 3.0, color = "black", fill = "#F7F7F7",
  383. alpha = 0.95, label.size = 0.15, label.r = unit(0.08, "lines"),
  384. box.padding = 0.12, point.padding = 0.05,
  385. min.segment.length = 0, segment.color = NA,
  386. segment.size = 0.25, force = 1.2,
  387. max.overlaps = Inf, show.legend = FALSE
  388. ) +
  389. geom_text(
  390. data = nodes,
  391. aes(x = x, y = y, label = label_expr),
  392. parse = TRUE, size = 4.3, fontface = "bold", color = "#1F1F1F"
  393. ) +
  394. scale_color_gradient2(
  395. low = "#2C7BB6", mid = "#BDBDBD", high = "#D7191C", midpoint = 0,
  396. name = "Standardized coefficient"
  397. ) +
  398. scale_linewidth(range = c(0.7, 2.8), name = "|Standardized coefficient|") +
  399. coord_cartesian(xlim = c(-5, 5), ylim = c(0.6, 4.4), clip = "off") +
  400. theme_void(base_size = 13) +
  401. theme(
  402. legend.position = "right",
  403. plot.margin = margin(10, 20, 10, 20)
  404. )
  405. ggsave(file.path(output, "09_SEM_semplot.png"), p_sem, width = 7.5, height = 6, dpi = 300)
  406. ggsave(file.path(output, "09_SEM_semplot.pdf"), p_sem, width = 7.5, height = 6, dpi = 300)
  407. message("SEM analysis completed successfully!")
  408. # Print summary
  409. cat("\n=== SEM Fit Measures ===\n")
  410. print(fit_measures)
  411. cat("\n=== Significant Indirect Effects ===\n")
  412. print(indirect_effects[indirect_effects$pvalue < 0.05, c("label", "est", "pvalue", "p_adj")])

r.09_SEM.R at commit b1fc48c, under MIT · at the source

Overview

Authors: Yuanfeng Lan1,2,3,4, Tian Zhao1,2,3, Ying Xu4, Haihong Ye1,2,3
  1. Department of Medical Genetics and Developmental Biology, School of Basic Medical Sciences, Capital Medical University, Beijing 100069, China; (Y.L.); (T.Z.)
  2. Laboratory for Clinical Medicine, Capital Medical University, Beijing 100069, China
  3. Beijing Key Laboratory of Cell and Gene Therapy in Otology, Beijing 100069, China
  4. Department of Human Cell Biology and Genetics, SUSTech Homeostatic Medicine Institute, School of Medicine, Southern University of Science and Technology, Shenzhen 518055, China
Journal: International journal of molecular sciences, volume 27, issue 15, article 6925
Dates: received 1 July 2026; accepted 30 July 2026; published online 1 August 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.3390/ijms27156925 · PMID 42589578 · PMCID PMC13467542 · OpenAlex W7172247900
Open access: gold, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: genetics / omics (modality), human (organism), other condition (population)
Methods: Connectivity, Statistics, Smoothing, state filtering, decompositions, Machine learning, Preprocessing
Keywords: cirrhosis, hepatic encephalopathy, machine learning, prediction model, prognostic analysis
MeSH: Biomarkers*, Hepatic Encephalopathy*, Liver Cirrhosis*, Boosting Machine Learning Algorithms, Gene Expression Profiling, Humans, Prognosis, Transcriptome (* major topic)
Topic: Liver Disease and Transplantation (Hepatology, Medicine), according to OpenAlex
Funding: Beijing Municipal Natural Science Foundation (7262004)
Citations: not cited yet (Europe PMC); 39 references in the paper

Abstract

Cirrhosis, accounting for 2.4% of global mortality in 2019, represents a leading cause of death in chronic liver disease. Hepatic encephalopathy (HE), a decompensated complication of cirrhosis, is associated with a median survival of only 0.92 years post-diagnosis. Current screening methods relying on neuropsychological tests (e.g., Psychometric Hepatic Encephalopathy Score, PHES) have limitations such as time-consuming procedures and subjective interpretation, potentially delaying diagnosis. To address this, we integrated four cirrhotic transcriptomic cohorts (GSE41919, GSE57193, GSE139602, and GSE15654) and employed an integrated algorithm (LASSO [Least Absolute Shrinkage and Selection Operator]–RFE [Recursive Feature Elimination]–random forest) to identify HE-specific biomarker genes. Ultimately, we developed an HE risk-prediction system centered on eight HE-specific marker genes, namely, PRB2, TUBA1C, NPC2, LRRC32, TLN1, SOX9, SERPINA3 and RNASE4. Based on these genes, an XGBoost (eXtreme Gradient Boosting)-based HE risk stratification model was constructed, and SHAP (SHapley Additive exPlanations) analysis was further introduced to address the “black-box” limitation of conventional machine learning models and to improve the interpretability. The finalized eight-gene system enables accurate, efficient, and interpretable HE risk assessment in patients with cirrhosis. Functional characterization through gene set enrichment analysis and structural equation modeling further revealed that these marker genes converge on four interconnected biological processes, namely, metabolic homeostasis, synaptic and neural transmission, immune inflammatory signaling, and hepatic detoxification, which collectively reflect the gut–liver–brain axis disruption central to HE pathogenesis. This dual-model system, incorporating both cirrhosis progression and survival prognosis, provides a reliable and clinically applicable tool for early HE risk warning and stratification, reducing the limitations of traditional neuropsychological screening and offering a translational foundation for timely intervention and prognostic optimization in high-risk cirrhotic patients.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repositories

Its files are read in the Code ↔ Paper reader above, with 18 matches between paragraphs and lines of code.

seandavi/GEOquery

License: MIT
State: the link answers, verified on 26 September 2026
Evidence: files inventoried
Commit: cb12423bf2691af82f742fc10f891835e8bab3ce, 17 August 2026
Languages: R (53), Quarto (6)
Size: 154 files, 59 scripts
Software Heritage: not archived
Found in: the text, “4.1. Data Acquisition and Cohort Construction”
Holds: README, license file, CITATION.cff, environment (DESCRIPTION, Dockerfile), tests, continuous integration, documentation, 6 notebooks
Tools: tidyverse (6 files), data.table (3 files), limma (2 files), SingleCellExperiment (2 files), Seurat (1 file)
Availability: 1 check, the latest on 26 September 2026: the link answers
  • 26 September 2026: the link answers
62 files

ModelOriented/shapviz

License: GPL-2.0
State: the link answers, verified on 26 September 2026
Evidence: files inventoried
Commit: a3ead2491c66b7345eaf23e212eb1edda03b4697, 31 August 2026
Languages: R (28)
Size: 101 files, 28 scripts
Software Heritage: not archived
Found in: the text, “4.6. Construction and Validation of XGBoost–SHAP”
Holds: README, license file, environment (DESCRIPTION), tests, continuous integration, documentation, 4 notebooks
Not found: CITATION.cff
Tools: ggplot2 (12 files), XGBoost (9 files), patchwork (7 files), LightGBM (1 file)
Availability: 1 check, the latest on 26 September 2026: the link answers
  • 26 September 2026: the link answers
30 files

alserglab/fgsea

License: MIT
State: the link answers, verified on 12 November 2026
Evidence: files inventoried
Commit: 570f5903545835cb340e699fcdfdf444b1ba07ec, 22 September 2026
Languages: R (33), C++ (10), C/C++ (8)
Size: 107 files, 51 scripts
Software Heritage: archived
Found in: the text, “4.8. Gene Set Enrichment Analysis (GSEA)”
Holds: README, license file, environment (DESCRIPTION), tests, continuous integration, documentation, 2 notebooks
Not found: CITATION.cff
Tools: data.table (12 files), ggplot2 (4 files), limma (4 files), cowplot (3 files), Seurat (2 files)
Availability: 2 checks, the latest on 12 November 2026: the link answers
  • 12 November 2026: the link answers
  • 26 September 2026: the link answers
53 files

yuanfeng-lan/HE-risk-Prediction

License: MIT
State: the link answers, verified on 26 September 2026
Evidence: files inventoried
Commit: b1fc48c5cbe5977c65ab0cb4a0b9cccdeb51e2d4, 24 July 2026
Languages: R (13)
Size: 17 files, 13 scripts
Software Heritage: not archived
Found in: the text, “4.9. Statistical Analysis and Data Visualization”
Holds: README, environment (renv.lock)
Not found: license file, CITATION.cff, tests, continuous integration, documentation
Tools: ggplot2 (11 files), tidyverse (10 files), survival (4 files), caret (3 files), cowplot (3 files), XGBoost (3 files), data.table (2 files), limma (2 files), patchwork (2 files), clusterProfiler (1 file), ggpubr (1 file), glmnet (1 file), lavaan (1 file), pheatmap (1 file), pROC (1 file), randomForest (1 file), reshape2 (1 file)
Availability: 1 check, the latest on 26 September 2026: the link answers
  • 26 September 2026: the link answers
14 files

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 4 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 151 scripts, each with its path and the digest of its content;
  • 18 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

Datasets cited

Other data links

Data Availability Statement

All data utilized in this study were obtained from the Gene Expression Omnibus (GEO) database, a publicly accessible repository maintained by the National Center for Biotechnology Information (NCBI). All datasets are freely available for download without any access restrictions. The specific GEO accession numbers and corresponding datasets are cited within the manuscript.

Reproduced under the paper's license (CC BY), from the paper cited above.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 4 authors, 5 keywords, 8 MeSH terms, 1 funder, 38 references.

Cite

This paper

Lan, Y., Zhao, T., Xu, Y., & Ye, H. (2026). XGBoost-SHAP Interpretable Modeling Identifies and Validates an Eight-Gene Biomarker for Hepatic Encephalopathy Risk Prediction in Cirrhosis. International journal of molecular sciences, 27(15), 6925. https://doi.org/10.3390/ijms27156925

BibTeX

@article{lan2026xgboost,
author = {Lan, Yuanfeng and Zhao, Tian and Xu, Ying and Ye, Haihong},
title = {{XGBoost-SHAP Interpretable Modeling Identifies and Validates an Eight-Gene Biomarker for Hepatic Encephalopathy Risk Prediction in Cirrhosis}},
journal = {International journal of molecular sciences},
year = {2026},
month = aug,
volume = {27},
number = {15},
pages = {6925},
publisher = {Multidisciplinary Digital Publishing Institute (MDPI)},
issn = {1422-0067},
doi = {10.3390/ijms27156925},
url = {https://doi.org/10.3390/ijms27156925},
pmid = {42589578},
pmcid = {PMC13467542}
}

RIS

TY - JOUR
AU - Lan, Yuanfeng
AU - Zhao, Tian
AU - Xu, Ying
AU - Ye, Haihong
TI - XGBoost-SHAP Interpretable Modeling Identifies and Validates an Eight-Gene Biomarker for Hepatic Encephalopathy Risk Prediction in Cirrhosis
T2 - International journal of molecular sciences
J2 - Int J Mol Sci
PY - 2026
DA - 2026/08/01
VL - 27
IS - 15
SP - 6925
SN - 1422-0067
PB - Multidisciplinary Digital Publishing Institute (MDPI)
DO - 10.3390/ijms27156925
UR - https://doi.org/10.3390/ijms27156925
LA - en
ER -

CSL-JSON

{
"id": "10.3390/ijms27156925",
"type": "article-journal",
"title": "XGBoost-SHAP Interpretable Modeling Identifies and Validates an Eight-Gene Biomarker for Hepatic Encephalopathy Risk Prediction in Cirrhosis",
"container-title": "International journal of molecular sciences",
"author": [
{
"family": "Lan",
"given": "Yuanfeng"
},
{
"family": "Zhao",
"given": "Tian"
},
{
"family": "Xu",
"given": "Ying"
},
{
"family": "Ye",
"given": "Haihong"
}
],
"container-title-short": "Int J Mol Sci",
"volume": "27",
"issue": "15",
"page": "6925",
"DOI": "10.3390/ijms27156925",
"PMID": "42589578",
"PMCID": "PMC13467542",
"ISSN": "1422-0067",
"publisher": "Multidisciplinary Digital Publishing Institute (MDPI)",
"URL": "https://doi.org/10.3390/ijms27156925",
"language": "en",
"issued": {
"date-parts": [
[
2026,
8,
1
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.3390/ijms27104466 [code]
Uncovering the Key Circuit FOSL2/FOS/EGR3/EGR1, Contributing to the Hyperexcitability of Excitatory Neurons in the Epileptic Temporal Cortex and Hippocampus.
Journal: International journal of molecular sciences
In common: pROC, glmnet, caret, 11 other tools, genetics / omics, 2 references
[2] doi:10.1038/s42003-026-10957-8 [code]
Brain defence by the extracellular matrix protein Cochlin.
Journal: Communications biology
In common: randomForest, survival, glmnet, 12 other tools
[3] doi:10.1038/s41698-025-00909-6 [code]
Diagnostic and prognostic potential of cell-free RNAs in cerebrospinal fluid and plasma for brain tumors.
Journal: NPJ precision oncology
In common: randomForest, pROC, survival, 10 other tools, genetics / omics, other condition, 1 reference
[4] doi:10.1038/s42003-025-09115-3 [code]
Characterizing and decoding ultraconserved regions uncovers their regulatory significance in human brain development and disorders.
Journal: Communications biology
In common: pROC, survival, caret, 12 other tools
[5] doi:10.1016/j.xcrm.2026.102682 [code]
TET CpG sequence-context-specific DNA demethylation shapes progression of IDH-mutant gliomas.
Journal: Cell reports. Medicine
In common: pROC, survival, glmnet, 11 other tools, genetics / omics, other condition, 1 reference
[6] doi:10.1038/s41467-025-66109-9 [code]
Mid-gestational cell-type-specific transcriptomic signatures in the prefrontal and superior temporal cortex in Down syndrome.
Journal: Nature communications
In common: randomForest, pROC, caret, 11 other tools, genetics / omics, other condition
[7] doi:10.7717/peerj.21426 [code]
Integrated transcriptomic identification and validation reveal key autophagy-associated biomarkers in sleep deprivation.
Journal: PeerJ
In common: randomForest, pROC, glmnet, 11 other tools, genetics / omics
[8] doi:10.1016/j.isci.2026.115657 [code]
Integration of machine learning to develop a disulfidptosis model for predicting glioma prognosis, immunotherapy response, and drug.
Journal: iScience
In common: pROC, survival, glmnet, 11 other tools, other condition
[9] doi:10.1126/sciadv.adu0726 [code]
CHCHD2 mutant mice link mitochondrial deficits to PD pathophysiology.
Journal: Science advances
In common: randomForest, pROC, caret, 11 other tools
[10] doi:10.1016/j.isci.2022.105276 [code]
Integrative genomic analysis facilitates precision strategies for glioblastoma treatment.
Journal: iScience
In common: pROC, survival, SingleCellExperiment, 10 other tools, other condition, 2 references

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Add the badge to the code's README

OSCR: the badge of this paper

If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.

Markdown
<!-- oscr-badge:start -->
[![OSCR](https://openscicode.org/badge/doi/10.3390/ijms27156925.svg)](https://openscicode.org/badge/doi/10.3390/ijms27156925)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.3390/ijms27156925.svg
   :target: https://openscicode.org/badge/doi/10.3390/ijms27156925
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.3390/ijms27156925"><img src="https://openscicode.org/badge/doi/10.3390/ijms27156925.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->

On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".

If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.

Report a mismatch between the code and the paper · Report a code error (signed in)

Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.

Report a reproduction failure (signed in)

Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.