Quantitative pathology and APOE genotype reveal dementia risk and progression in Lewy body disease.
The 7 matches
- [1] § Materials and methods › Logistic regression modelling of dementia risk ↔ QuantPath_Figure_4_and_5.R, lines 90 to 130 · score 0.87 · logistic regression models, continuous predictors, predicted probabilities, categorical variables, Marginal, binomial · Report a mismatch
- [2] § Materials and methods › Pathology burden classification and diagnostic performance metrics ↔ QuantPath_Figure_1_and_2.R, lines 1212 to 1270 · score 0.78 · pathology presence ratio, pathology absence ratio, odds ratio, PPR, PAR, PPV · Report a mismatch
- [3] § Materials and methods › Statistical analysis ↔ SuStaIn_ASyn_Subtype.ipynb, lines 446 to 508 · score 0.75 · AMY_LS, AMY_MI, DA, MFG, MTG, PTEGM · Report a mismatch
- [4] § Materials and methods › Neuropathological assessment ↔ QuantPath_Table1_and_Suppl_Tables_3_4_5.R, lines 553 to 595 · score 0.73 · NIA AA, Thal phase, ischaemic pathology, Braak stage, ADNC, pTau · Report a mismatch
- [5] § Materials and methods › Neuropathological assessment ↔ QuantPath_Figure_1_and_2.R, lines 1212 to 1270 · score 0.67 · pathology absence ratio, odds ratio, PPR, PAR, Segments, PPV · Report a mismatch
- [6] § Materials and methods › Statistical analysis ↔ QuantPath_Figure_4_and_5.R, lines 90 to 130 · score 0.66 · logistic regression models, predicted probabilities, biological sex, death, duration, age · Report a mismatch
- [7] § Materials and methods › Statistical analysis ↔ QuantPath_Table1_and_Suppl_Tables_3_4_5.R, lines 553 to 595 · score 0.62 · Kruskal Wallis, Thal phase, Lewy bodies, Braak stage, density, ADNC · 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 · 728 lines · 23 KB · CC-BY-4.0 · 2 matches
- #MULTIVARIATE LOGISTICAL REGRESSUION#####################
- # Load required libraries
- library(readxl)
- library(tidyverse)
- library(ggplot2)
- library(gridExtra)
- library(reshape2)
- library(FactoMineR)
- library(factoextra)
- library(dplyr)
- library(ggeffects)
- library(gtsummary)
- library(flextable)
- # Set directories
- setwd("DIR")
- datadir <- "DIR"
- dir.create(datadir, showWarnings = FALSE)
- setwd(datadir)
- # Load data
- ex <- read_excel("EXCEL",
- sheet = "SHEET")
- excel <- as.data.frame(ex)
- excel_main <- excel
- ########### Bin variables: Duration>15 and Age_at_Death>77
- # Load dplyr package
- library(dplyr)
- # Filter the dataframe to remove rows where ApoE and INFARCT have NA values
- # Ensure no missing values
- excel_main <- excel_main %>% filter(!is.na(Duration))
- # Calculate the median of Duration
- median_duration <- median(excel_main$Duration, na.rm = TRUE, 0)
- print(median_duration)
- # Bin the values at the median
- excel_main$Duration_Binned <- cut(excel_main$Duration,
- breaks = c(-Inf, median_duration, Inf),
- labels = c(paste0("< ", median_duration, "yrs"),
- paste0("≥ ", median_duration, "yrs")), # Use median in labels
- include.lowest = TRUE, right = FALSE) # left-inclusive binning
- table(excel_main$Duration_Binned)
- # Ensure no missing values
- excel_main <- excel_main %>% filter(!is.na(Age_at_Death))
- # Calculate the median of Age_at_Death
- median_Age_at_Death <- median(excel_main$Age_at_Death, na.rm = TRUE)
- print(median_Age_at_Death)
- # Bin the values at the median
- excel_main$Age_at_Death_Binned <- cut(excel_main$Age_at_Death,
- breaks = c(-Inf, median_Age_at_Death, Inf),
- labels = c(paste0("< ", median_Age_at_Death, "yrs"),
- paste0("≥ ", median_Age_at_Death, "yrs")), # Use median in labels
- include.lowest = TRUE, right = FALSE) # left-inclusive binning
- table(excel_main$Age_at_Death_Binned)
- # Convert categorical variables to factors
- excel_main$Duration_Binned <- as.factor(excel_main$Duration_Binned)
- excel_main$Age_at_Death_Binned <- as.factor(excel_main$Age_at_Death_Binned)
- excel_main$INFARCT <- as.factor(excel_main$INFARCT)
- excel_main$ApoE <- as.factor(excel_main$ApoE)
- # View first few rows to check binning
- head(excel_main[, c("Duration", "Duration_Binned", "Age_at_Death", "Age_at_Death_Binned")])
- # View first few rows to check binning
- head(excel_main)
- ####################################################FULL_MODEL
- UPPR_DIR <- paste0(datadir,"/FULL_MODEL")
- dir.create(UPPR_DIR)
- setwd(UPPR_DIR)
- excel_main <- subset(excel_main, select = c(DEMENTIA, ApoE, ASYN_FRNT_HIPP, AT8_FRNT_HIPP, ABETA_FRNT_HIPP, INFARCT, Duration_Binned, Age_at_Death_Binned, BIOLOGICAL_SEX))
- # Define predictors and outcome
- predictors <- c("ASYN_FRNT_HIPP", "AT8_FRNT_HIPP", "ABETA_FRNT_HIPP", "INFARCT", "Duration_Binned", "Age_at_Death_Binned", "BIOLOGICAL_SEX")
- outcome <- "DEMENTIA"
- # Ensure outcome variable is a factor
- excel_main[[outcome]] <- as.factor(excel_main[[outcome]])
- ####################################################APOE
- # Manually define x-axis limits for continuous predictors
- xlims_list <- list(
- "ASYN_FRNT_HIPP" = c(0, 50),
- "ABETA_FRNT_HIPP" = c(0, 8),
- "AT8_FRNT_HIPP" = c(0, 15)
- )
- # Run the analysis separately for ApoE3 and ApoE4
- for (apoe_type in c("ApoE3", "ApoE4")) {
- # Filter dataset for current ApoE type
- #apoe_type <- "ApoE3"
- subset_data <- excel_main %>% filter(ApoE == apoe_type)
- # Train logistic regression model
- model_base <- glm(DEMENTIA ~ ., data = subset_data[, c(predictors, outcome)], family = "binomial")
- library(car)
- vif(model_base)
- library(sjPlot)
- library(sjmisc)
- library(ggeffects)
- library(cowplot)
- library(RColorBrewer)
- library(ggplot2)
- # Generate marginal effects for all predictors
- effects_list <- ggpredict(model_base) # Get predicted probabilities
- plot_order <- c(
- "ASYN_FRNT_HIPP", "ABETA_FRNT_HIPP", "AT8_FRNT_HIPP",
- "BIOLOGICAL_SEX", "INFARCT", "Duration_Binned", "Age_at_Death_Binned"
- )
- effects_list <- effects_list[plot_order]
- # Define categorical variables
- categorical_vars <- c("INFARCT", "Age_at_Death_Binned", "Duration_Binned", "BIOLOGICAL_SEX")
- # Define colors for continuous variable lines
- continuous_colors <- c("α-synuclein" = "forestgreen",
- "Aβ" = "firebrick",
- "pTau" = "dodgerblue")
- # Define x-axis label mapping
- x_axis_labels <- c(
- "ASYN_FRNT_HIPP" = "α-synuclein",
- "ABETA_FRNT_HIPP" = "Aβ",
- "AT8_FRNT_HIPP" = "pTau",
- "INFARCT" = "Ischaemia",
- "BIOLOGICAL_SEX" = "Biological sex",
- "Duration_Binned" = "Duration",
- "Age_at_Death_Binned" = "Age at death"
- )
- # Recode levels for INFARCT
- infarct_labels <- c("INF_0" = "Absent", "INF_1" = "Present")
- bsex_labels <- c("M" = "Male", "F" = "Female")
- # Create individual plots
- common_ylim <- c(0, 100)
- plot_list <- lapply(seq_along(effects_list), function(i) {
- var_name <- names(effects_list)[i]
- effects_data <- as.data.frame(effects_list[[i]])
- if (nrow(effects_data) == 0) return(NULL) # Skip empty frames
- is_categorical <- var_name %in% categorical_vars
- if (!is_categorical) {
- plot_obj <- ggplot(effects_data, aes(x = x, y = predicted * 100)) +
- geom_ribbon(
- aes(ymin = conf.low * 100, ymax = conf.high * 100),
- fill = continuous_colors[[x_axis_labels[[var_name]]]],
- alpha = 0.2
- ) +
- geom_line(
- size = 3,
- color = continuous_colors[[x_axis_labels[[var_name]]]]
- ) +
- labs(
- x = x_axis_labels[[var_name]],
- y = if (i == 1) "Dementia probability (%)" else NULL
- ) +
- xlim(xlims_list[[var_name]]) + # 👈 Apply manual x-axis limit here
- ylim(common_ylim) +
- theme_minimal() +
- theme(
- plot.title = element_blank(),
- axis.title.x = element_text(size = 34),
- axis.title.y = element_text(size = 34),
- axis.text = element_text(size = 34),
- plot.margin = margin(t = 40, r = 5, b = 5, l = 5, unit = "pt"),
- legend.position = "none"
- )
- } else {
- if (var_name == "INFARCT") {
- effects_data$x <- factor(effects_data$x,
- levels = names(infarct_labels),
- labels = infarct_labels)
- } else if (var_name == "BIOLOGICAL_SEX") {
- effects_data$x <- factor(effects_data$x,
- levels = names(bsex_labels),
- labels = bsex_labels)
- }
- plot_obj <- ggplot(effects_data, aes(x = x, y = predicted * 100, color = as.factor(x))) +
- geom_point(size = 10) +
- geom_errorbar(aes(ymin = conf.low * 100, ymax = conf.high * 100),
- width = 0.7, linetype = "dotted", size = 2) +
- scale_color_manual(values = c("orchid1", "darkorchid4")) +
- labs(
- x = x_axis_labels[[var_name]],
- y = if (i == 1) "Dementia probability (%)" else NULL,
- color = "Category"
- ) +
- ylim(common_ylim) +
- theme_minimal() +
- theme(
- plot.title = element_blank(),
- axis.title.x = element_text(size = 34),
- axis.title.y = element_text(size = 34),
- axis.text = element_text(size = 34),
- plot.margin = margin(t = 40, r = 5, b = 5, l = 5, unit = "pt"),
- legend.position = "none"
- )
- }
- # Remove y-axis title for plots after the first one
- if (i != 1) {
- plot_obj <- plot_obj + theme(axis.title.y = element_blank())
- }
- return(plot_obj)
- })
- # Remove NULLs from empty predictors
- plot_list <- plot_list[!sapply(plot_list, is.null)]
- # Arrange plots
- sjplot <- cowplot::plot_grid(plotlist = plot_list, nrow = 1, align = "h")
- # Display plot
- print(sjplot)
- # Save
- ggsave(paste0("sjplot_UPPERQUARTILE_", apoe_type, ".png"), sjplot, width = 35, height = 5, dpi = 300)
- }
- #######################DECISION TREE################
- # Define continuous variables
- continuous_vars <- c("ASYN_FRNT_HIPP", "ABETA_FRNT_HIPP", "AT8_FRNT_HIPP")
- # Apply per group
- get_fixed_splits_by_apoe <- function(data, apoe_group) {
- df_sub <- data %>%
- filter(ApoE == apoe_group) %>%
- mutate(DEMENTIA_BIN = ifelse(DEMENTIA == "Dem", 1, 0))
- # Define cutoffs
- asyn_75 <- quantile(df_sub$ASYN_FRNT_HIPP, 0.75, na.rm = TRUE)
- abeta_75 <- quantile(df_sub$ABETA_FRNT_HIPP, 0.75, na.rm = TRUE)
- at8_85 <- quantile(df_sub$AT8_FRNT_HIPP, 0.85, na.rm = TRUE)
- tibble(
- ApoE = apoe_group,
- variable = c("ASYN_FRNT_HIPP", "ABETA_FRNT_HIPP", "AT8_FRNT_HIPP"),
- percentile = c("75th", "75th", "85th"),
- fixed_cut = c(asyn_75, abeta_75, at8_85)
- )
- }
- # Run for both ApoE groups
- split_apoe3 <- get_fixed_splits_by_apoe(df_binned, "APOE ε3")
- split_apoe4 <- get_fixed_splits_by_apoe(df_binned, "APOE ε4")
- # Combine
- split_results_all <- bind_rows(split_apoe3, split_apoe4)
- # View results
- print(split_results_all)
- # Save to CSV
- write_csv(split_results_all, "logistic_best_splits_by_apoe.csv")
- # Define the fixed splits for each ApoE group
- fixed_splits <- split_results_all %>%
- arrange(ApoE, variable) %>%
- select(ApoE, variable, fixed_cut) %>%
- mutate(fixed_cut = round(fixed_cut, 2))
- df_binned <- df_binned %>%
- mutate(DEMENTIA_BIN = ifelse(DEMENTIA == "Dem", 1, 0))
- ###DT_apoe3
- # -- 1. Rename variables in importance table
- result_apoe3_renamed <- as.data.frame(result_apoe3$importance) %>%
- mutate(Variable = case_when(
- Variable == "INFARCTINF_1" ~ "INFARCT",
- Variable == "BIOLOGICAL_SEXM" ~ "BIOLOGICAL_SEX",
- Variable == "Age_at_Death_Binned≥ 77" ~ "Age_at_Death_Binned",
- Variable == "Duration_Binned≥ 15" ~ "Duration_Binned",
- TRUE ~ Variable
- ))
- # -- 2. Get ordered variables by importance
- importance_apoe3 <- result_apoe3_renamed %>%
- arrange(desc(Importance)) %>%
- pull(Variable)
- # -- 3. Merge with fixed splits
- ordered_variables_apoe3 <- fixed_splits %>%
- filter(ApoE == "APOE ε3") %>%
- arrange(match(variable, importance_apoe3))
- ordered_vars <- importance_apoe3
- var_rename <- c(
- ASYN_FRNT_HIPP = "α-synuclein",
- ABETA_FRNT_HIPP = "Aβ",
- Duration_Binned = "Duration",
- INFARCT = "Ischaemia",
- Age_at_Death_Binned = "Age at death",
- BIOLOGICAL_SEX = "Biological sex",
- AT8_FRNT_HIPP = "pTau"
- )
- # Apply renaming
- ordered_vars <- unname(var_rename[ordered_vars])
- ordered_vars
- # -- 4. Create binned columns
- cutoffs <- ordered_variables_apoe3$fixed_cut
- names(cutoffs) <- ordered_variables_apoe3$variable
- df_binned1 <- df_binned %>%
- mutate(
- ASYN_FRNT_HIPP_CAT = ifelse(ASYN_FRNT_HIPP >= cutoffs["ASYN_FRNT_HIPP"], paste0("\u2265", cutoffs["ASYN_FRNT_HIPP"]), paste0("<", cutoffs["ASYN_FRNT_HIPP"])),
- ABETA_FRNT_HIPP_CAT = ifelse(ABETA_FRNT_HIPP >= cutoffs["ABETA_FRNT_HIPP"], paste0("\u2265", cutoffs["ABETA_FRNT_HIPP"]), paste0("<", cutoffs["ABETA_FRNT_HIPP"])),
- AT8_FRNT_HIPP_CAT = ifelse(AT8_FRNT_HIPP >= cutoffs["AT8_FRNT_HIPP"], paste0("\u2265", cutoffs["AT8_FRNT_HIPP"]), paste0("<", cutoffs["AT8_FRNT_HIPP"]))
- )
- # -- 5. Prepare dataset for APOE ε3 group
- df_apoe3 <- df_binned1 %>%
- filter(ApoE == "APOE ε3") %>%
- mutate(
- `α-synuclein` = ASYN_FRNT_HIPP_CAT,
- `Aβ` = ABETA_FRNT_HIPP_CAT,
- `pTau` = AT8_FRNT_HIPP_CAT,
- Ischaemia = factor(INFARCT, levels = c("INF_0", "INF_1"), labels = c("Absent", "Present")),
- `Biological sex` = factor(BIOLOGICAL_SEX, levels = c("F", "M"), labels = c("FEMALE", "MALE")),
- `Age at death` = Age_at_Death_Binned,
- Duration = Duration_Binned
- ) %>%
- select(DEMENTIA, DEMENTIA_BIN, `α-synuclein`, `Aβ`, `pTau`, Ischaemia, `Biological sex`, `Age at death`, Duration) %>%
- mutate(across(everything(), as.character))
- # -- 6. Evaluate path-level risk
- library(dplyr)
- # -- 1. Evaluate path-level risk
- tree_paths_eval_apoe3 <- df_apoe3 %>%
- group_by(`α-synuclein`, `Aβ`, `pTau`, Ischaemia, `Biological sex`, `Age at death`, Duration) %>%
- summarise(
- n = n(),
- pct_high = mean(DEMENTIA_BIN == 1, na.rm = TRUE),
- .groups = "drop"
- ) %>%
- mutate(
- risk_label = case_when(
- is.na(pct_high) ~ "No data",
- pct_high >= 0.7 ~ "High risk",
- TRUE ~ "Low risk"
- ),
- label = paste0(risk_label, "\n(n=", n, ", ",
- ifelse(is.na(pct_high), "NA", round(pct_high * 100)), "%)"),
- display_label = risk_label
- )
- write.csv(tree_paths_eval_apoe3, "ApoE3_risk_bins_OBS.csv", row.names = FALSE)
- # -- 2. Define ordered variables for tree depth (same as image structure)
- ordered_vars
- # -- 3. Create custom PathString that stops branching when pct_high ≥ 0.7 <20
- tree_paths_eval_apoe3$PathString <- apply(tree_paths_eval_apoe3, 1, function(row) {
- path <- c("Start")
- label_to_use <- row[["display_label"]] # default
- for (v in ordered_vars) {
- value <- row[[v]]
- path <- c(path, paste0(v, ": ", value))
- # Check if this subgroup exceeds threshold
- subset_rows <- tree_paths_eval_apoe3
- for (i in seq_along(path)[-1]) {
- parts <- strsplit(path[i], ": ")[[1]]
- subset_rows <- subset_rows[subset_rows[[parts[1]]] == parts[2], ]
- }
- if (nrow(subset_rows) > 0) {
- avg_pct <- mean(subset_rows$pct_high)
- if (avg_pct >= 0.6) {
- label_to_use <- "High risk"
- break
- } else if (avg_pct <= 0.30) {
- label_to_use <- "Low risk"
- break
- }
- }
- } # <-- closes the for loop
- paste(c(path, label_to_use), collapse = "/")
- })
- library(dplyr)
- library(DiagrammeR)
- library(stringr)
- library(digest)
- # ---- Step 1: Extract node paths from tree_paths_eval
- paths <- strsplit(tree_paths_eval_apoe3$PathString, "/")
- # ---- Step 2: Create edges and unique node labels
- edges <- data.frame(from = character(), to = character(), label = character())
- nodes <- data.frame(id = character(), label = character(), group = character(), stringsAsFactors = FALSE)
- for (p in paths) {
- for (i in 2:length(p)) {
- from <- paste(p[1:(i - 1)], collapse = "/")
- to <- paste(p[1:i], collapse = "/")
- label <- p[i]
- # Generate unique, clean IDs for Graphviz
- from_id <- paste0("node_", digest(from, algo = "crc32"))
- to_id <- paste0("node_", digest(to, algo = "crc32"))
- edges <- rbind(edges, data.frame(from = from_id, to = to_id, label = label))
- group <- ifelse(grepl("risk", label), "risk",
- ifelse(grepl("^α-syn", label), "asyn",
- ifelse(grepl("^Aβ", label), "abeta",
- ifelse(grepl("^pTau", label), "ptau",
- ifelse(grepl("Ischa", label), "isch",
- ifelse(grepl("Sex", label), "sex",
- ifelse(grepl("Duration", label), "dur", "default")))))))
- nodes <- rbind(nodes, data.frame(
- id = to_id,
- label = label,
- group = group,
- stringsAsFactors = FALSE
- ))
- }
- }
- # Remove duplicates
- nodes <- nodes[!duplicated(nodes$id), ]
- edges <- edges[!duplicated(edges), ]
- # Get root node ID from the first edge
- root_id <- edges$from[1]
- # If it's not in the node list, add it manually
- if (!(root_id %in% nodes$id)) {
- nodes <- rbind(nodes, data.frame(
- id = root_id,
- label = "APOE ε3",
- group = "apoe",
- stringsAsFactors = FALSE
- ))
- }
- # ---- Step 3: Build Graphviz DOT syntax
- color_map <- c(
- "asyn" = "lawngreen",
- "abeta" = "lightpink",
- "isch" = "khaki1",
- "ptau" = "lightskyblue1",
- "sex" = "plum1",
- "dur" = "lemonchiffon",
- "risk" = "mistyrose",
- "apoe" = "dodgerblue1", # ← custom color for APOE root
- "default" = "white"
- )
- # Fix labels: escape quotes, remove newlines for Graphviz compatibility
- nodes$label <- gsub("\"", "'", nodes$label) # Replace double quotes
- nodes$label <- gsub("\n", "\\n", nodes$label) # Escape line breaks
- node_defs <- paste0(
- nodes$id, ' [label="', nodes$label,
- '", style=filled, fillcolor="', color_map[nodes$group], '"];'
- )
- edge_defs <- paste0(
- edges$from, ' -> ', edges$to, ';'
- )
- # ---- Step 4: Wrap in grViz
- dot_code_apoe3 <- paste0(
- "digraph G {\n",
- " graph [layout = dot, rankdir = TB];\n",
- " node [shape=box, fontname=Helvetica];\n\n",
- paste(node_defs, collapse = "\n"), "\n\n",
- paste(edge_defs, collapse = "\n"), "\n}"
- )
- # ---- Step 5: Render the final publication-style graph
- grViz(dot_code_apoe3)
- library(rsvg)
- library(DiagrammeRsvg)
- # Render and export to PDF
- grViz(dot_code_apoe3) %>%
- export_svg() %>%
- charToRaw() %>%
- rsvg_pdf("decision_tree_apoe3_min_split_ObsOnly.pdf")
- ###DT_apoe4
- # -- 1. Rename variables in importance table
- result_apoe4_renamed <- as.data.frame(result_apoe4$importance) %>%
- mutate(Variable = case_when(
- Variable == "INFARCTINF_1" ~ "INFARCT",
- Variable == "BIOLOGICAL_SEXM" ~ "BIOLOGICAL_SEX",
- Variable == "Age_at_Death_Binned≥ 77" ~ "Age_at_Death_Binned",
- Variable == "Duration_Binned≥ 15" ~ "Duration_Binned",
- TRUE ~ Variable
- ))
- # -- 2. Get ordered variables by importance
- importance_apoe4 <- result_apoe4_renamed %>%
- arrange(desc(Importance)) %>%
- pull(Variable)
- # -- 3. Merge with fixed splits
- ordered_variables_apoe4 <- fixed_splits %>%
- filter(ApoE == "APOE ε4") %>%
- arrange(match(variable, importance_apoe4))
- ordered_vars <- importance_apoe4
- var_rename <- c(
- ASYN_FRNT_HIPP = "α-synuclein",
- ABETA_FRNT_HIPP = "Aβ",
- Duration_Binned = "Duration",
- INFARCT = "Ischaemia",
- Age_at_Death_Binned = "Age at death",
- BIOLOGICAL_SEX = "Biological sex",
- AT8_FRNT_HIPP = "pTau"
- )
- # Apply renaming
- ordered_vars <- unname(var_rename[ordered_vars])
- # -- 4. Create binned columns
- cutoffs <- ordered_variables_apoe4$fixed_cut
- names(cutoffs) <- ordered_variables_apoe4$variable
- df_binned1 <- df_binned %>%
- mutate(
- ASYN_FRNT_HIPP_CAT = ifelse(ASYN_FRNT_HIPP >= cutoffs["ASYN_FRNT_HIPP"], paste0("\u2265", cutoffs["ASYN_FRNT_HIPP"]), paste0("<", cutoffs["ASYN_FRNT_HIPP"])),
- ABETA_FRNT_HIPP_CAT = ifelse(ABETA_FRNT_HIPP >= cutoffs["ABETA_FRNT_HIPP"], paste0("\u2265", cutoffs["ABETA_FRNT_HIPP"]), paste0("<", cutoffs["ABETA_FRNT_HIPP"])),
- AT8_FRNT_HIPP_CAT = ifelse(AT8_FRNT_HIPP >= cutoffs["AT8_FRNT_HIPP"], paste0("\u2265", cutoffs["AT8_FRNT_HIPP"]), paste0("<", cutoffs["AT8_FRNT_HIPP"]))
- )
- # -- 5. Prepare dataset for APOE ε4 group
- df_apoe4 <- df_binned1 %>%
- filter(ApoE == "APOE ε4") %>%
- mutate(
- `α-synuclein` = ASYN_FRNT_HIPP_CAT,
- `Aβ` = ABETA_FRNT_HIPP_CAT,
- `pTau` = AT8_FRNT_HIPP_CAT,
- Ischaemia = factor(INFARCT, levels = c("INF_0", "INF_1"), labels = c("Absent", "Present")),
- `Biological sex` = factor(BIOLOGICAL_SEX, levels = c("F", "M"), labels = c("FEMALE", "MALE")),
- `Age at death` = Age_at_Death_Binned,
- Duration = Duration_Binned
- ) %>%
- select(DEMENTIA, DEMENTIA_BIN, `α-synuclein`, `Aβ`, `pTau`, Ischaemia, `Biological sex`, `Age at death`, Duration) %>%
- mutate(across(everything(), as.character))
- # -- 6. Evaluate path-level risk
- library(dplyr)
- # -- 1. Evaluate path-level risk
- tree_paths_eval_apoe4 <- df_apoe4 %>%
- group_by(`α-synuclein`, `Aβ`, `pTau`, Ischaemia, `Biological sex`, `Age at death`, Duration) %>%
- summarise(
- n = n(),
- pct_high = mean(DEMENTIA_BIN == 1, na.rm = TRUE),
- .groups = "drop"
- ) %>%
- mutate(
- risk_label = case_when(
- is.na(pct_high) ~ "No data",
- pct_high >= 0.7 ~ "High risk",
- TRUE ~ "Low risk"
- ),
- label = paste0(risk_label, "\n(n=", n, ", ",
- ifelse(is.na(pct_high), "NA", round(pct_high * 100)), "%)"),
- display_label = risk_label
- )
- write.csv(tree_paths_eval_apoe4, "ApoE4_risk_bins_OBS.csv", row.names = FALSE)
- # -- 2. Define ordered variables for tree depth (same as image structure)
- ordered_vars
- # -- 3. Create custom PathString that stops branching when pct_high ≥ 0.8
- tree_paths_eval_apoe4$PathString <- apply(tree_paths_eval_apoe4, 1, function(row) {
- path <- c("Start")
- label_to_use <- row[["display_label"]] # default
- for (v in ordered_vars) {
- value <- row[[v]]
- path <- c(path, paste0(v, ": ", value))
- # Check if this subgroup exceeds threshold
- subset_rows <- tree_paths_eval_apoe4
- for (i in seq_along(path)[-1]) {
- parts <- strsplit(path[i], ": ")[[1]]
- subset_rows <- subset_rows[subset_rows[[parts[1]]] == parts[2], ]
- }
- if (nrow(subset_rows) > 0) {
- avg_pct <- mean(subset_rows$pct_high)
- if (avg_pct >= 0.66) {
- label_to_use <- "High risk"
- break
- } else if (avg_pct <= 0.3) {
- label_to_use <- "Low risk"
- break
- }
- }
- } # <-- closes the for loop
- paste(c(path, label_to_use), collapse = "/")
- })
- library(dplyr)
- library(DiagrammeR)
- library(stringr)
- library(digest)
- # ---- Step 1: Extract node paths from tree_paths_eval
- paths <- strsplit(tree_paths_eval_apoe4$PathString, "/")
- # ---- Step 2: Create edges and unique node labels
- edges <- data.frame(from = character(), to = character(), label = character())
- nodes <- data.frame(id = character(), label = character(), group = character(), stringsAsFactors = FALSE)
- for (p in paths) {
- for (i in 2:length(p)) {
- from <- paste(p[1:(i - 1)], collapse = "/")
- to <- paste(p[1:i], collapse = "/")
- label <- p[i]
- # Generate unique, clean IDs for Graphviz
- from_id <- paste0("node_", digest(from, algo = "crc32"))
- to_id <- paste0("node_", digest(to, algo = "crc32"))
- edges <- rbind(edges, data.frame(from = from_id, to = to_id, label = label))
- group <- ifelse(grepl("risk", label), "risk",
- ifelse(grepl("^α-syn", label), "asyn",
- ifelse(grepl("^Aβ", label), "abeta",
- ifelse(grepl("^pTau", label), "ptau",
- ifelse(grepl("Ischa", label), "isch",
- ifelse(grepl("Sex", label), "sex",
- ifelse(grepl("Duration", label), "dur", "default")))))))
- nodes <- rbind(nodes, data.frame(
- id = to_id,
- label = label,
- group = group,
- stringsAsFactors = FALSE
- ))
- }
- }
- # Remove duplicates
- nodes <- nodes[!duplicated(nodes$id), ]
- edges <- edges[!duplicated(edges), ]
- # Get root node ID from the first edge
- root_id <- edges$from[1]
- # If it's not in the node list, add it manually
- if (!(root_id %in% nodes$id)) {
- nodes <- rbind(nodes, data.frame(
- id = root_id,
- label = "APOE ε4",
- group = "apoe",
- stringsAsFactors = FALSE
- ))
- }
- # ---- Step 3: Build Graphviz DOT syntax
- color_map <- c(
- "asyn" = "lawngreen",
- "abeta" = "lightpink",
- "isch" = "khaki1",
- "ptau" = "lightskyblue1",
- "sex" = "plum1",
- "dur" = "lemonchiffon",
- "risk" = "mistyrose",
- "apoe" = "firebrick2", # ← custom color for APOE root
- "default" = "white"
- )
- node_defs <- paste0(
- nodes$id, ' [label="', nodes$label,
- '", style=filled, fillcolor="', color_map[nodes$group], '"];'
- )
- edge_defs <- paste0(
- edges$from, ' -> ', edges$to, ';'
- )
- # ---- Step 4: Wrap in grViz
- dot_code_apoe4 <- paste0(
- "digraph G {\n",
- " graph [layout = dot, rankdir = TB];\n",
- " node [shape=box, fontname=Helvetica];\n\n",
- paste(node_defs, collapse = "\n"), "\n\n",
- paste(edge_defs, collapse = "\n"), "\n}"
- )
- # ---- Step 5: Render the final publication-style graph
- grViz(dot_code_apoe4)
- library(rsvg)
- library(DiagrammeRsvg)
- # Render and export to PDF
- grViz(dot_code_apoe4) %>%
- export_svg() %>%
- charToRaw() %>%
- rsvg_pdf("decision_tree_apoe4_min_split_ObsOnly.pdf")
QuantPath_Figure_4_and_5.R, under CC-BY-4.0 · at the source
Overview
- Department of Clinical and Movement Neurosciences, UCL Queen Square Institute of Neurology, University College London, London WC1N 3BG, UK
- Queen Square Brain Bank for Neurological Disorders, UCL Queen Square Institute of Neurology, London WC1N 1PJ, UK
- Aligning Science Across Parkinson’s (ASAP) Collaborative Research Network, Chevy Chase, MD 20815, USA
- Department of Neuromuscular Diseases, UCL Queen Square Institute of Neurology, University College London, London WC1N 3BG, UK
- Reta Lila Weston Institute of Neurological Studies, UCL Queen Square Institute of Neurology, London WC1N 3BG, UK
- Queen Square Movement Disorders Centre, UCL Queen Square Institute of Neurology, London WC1N 3BG, UK
- Department of Neurodegenerative Disease, UCL Queen Square Institute of Neurology, London WC1N 3BG, UK
- Division of Neuropathology, National Hospital for Neurology and Neurosurgery, University College London NHS Foundation Trust, London NW1 2PB, UK
- UK Dementia Research Institute at The University of Cambridge, Cambridge CB2 0AH, UK
- Centre for Preventive Neurology, Wolfson Institute of Population Health, Queen Mary University London, London E1 4NS, UK
Abstract
Dementia in Lewy body diseases (LBD) is common and arises through heterogeneous and incompletely understood pathways. Evidence suggests contributions from genetic factors, including APOE ɛ4 genotype, and co-pathology, including concomitant Alzheimer’s disease pathology and hypoperfusion related to orthostatic hypotension. However, the relative impact of these factors remains unclear.
To address this, we analysed 399 post-mortem brains from LBD cases comprising Parkinson’s disease, Parkinson’s disease dementia and dementia with Lewy bodies, and controls, integrating APOE genotype, clinical data and assessment of ischaemic pathology alongside large-scale digital pathology quantification. We established an image analysis pipeline using machine learning to enable automated, standardized measurement of α-synuclein, amyloid-β and phosphorylated tau burden across multiple brain regions.
Quantitative pathology was strongly correlated with semi-quantitative ratings and outperformed conventional staging in predicting dementia. Across multiple analytical approaches, APOE ɛ3 and ɛ4 carriers showed distinct dementia risk profiles. APOE ɛ3 carriers developed dementia at lower quantitative α-synuclein and amyloid-β thresholds than ɛ4 carriers, although overall dementia risk was dominated by ɛ4 genotype, consistent with ɛ4 both promoting greater pathology accumulation and modifying the threshold for dementia onset. Orthostatic hypotension and ischaemic pathology increased dementia risk only in ɛ3 carriers with low Lewy and Alzheimer’s proteinopathy burden, and male sex further modulated dementia risk for this subgroup. The Subtype and Stage Inference (SuStaIn) algorithm identified four trajectories of Lewy pathology progression. Two corresponded to recognized patterns: (i) brainstem first; and (ii) with early amygdala and concomitant brainstem involvement. Two further patterns showed early cortical involvement: (i) with early cingulate cortex involvement together with brainstem pathology; and (ii) starting in the neocortex before limbic and brainstem involvement. Co-pathology progression modelling identified subtypes with early predominance of amyloid-β, phosphorylated tau or α-synuclein and showed that Lewy subtypes follow two propagation trajectories in opposite directions.
Together, these findings demonstrate that integrating quantitative pathology with genotype and clinical data reveals distinct yet overlapping pathways to dementia in LBD, refining disease progression models and providing a basis for genotype- and pathology-informed patient stratification in therapeutic trials.
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 7 matches between paragraphs and lines of code.
Zenodo 18315069
Availability: 1 check, the latest on 4 November 2026: the link answers (HTTP 200)
- 4 November 2026: the link answers (HTTP 200)
6 files
- QuantPath_Figure_1_and_2
.R , R, 5,374 lines, 2 matches - QuantPath_Figure_3_and_S
uppl_Fig_1.R , R, 1,022 lines - QuantPath_Figure_4_and_5
.R , R, 728 lines, 2 matches - QuantPath_Table1_and_Sup
pl_Tables_3_4_5.R , R, 1,009 lines, 2 matches - SuStaIn_ASyn_ABeta_pTau_
Subtype.ipynb , Jupyter, 2,051 lines - SuStaIn_ASyn_Subtype.ipy
nb , Jupyter, 1,935 lines, 1 match
The paper's code and data availability statement is in the Data section.
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:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 6 scripts, each with its path and the digest of its content;
- 7 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
No dataset and no data link were found in the paper.
Data availability
The raw quantitative pathological data, protocols, R and python code and key laboratory materials used and generated in this study are listed in a Key Resource Table (KRT) alongside their persistent identifiers at https://
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, 4 November 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 19 authors, 6 keywords, 16 MeSH terms, 2 funders, 0 references, 1 RRID.
Cite
This paper
Nelvagal, H. R., Chiraki, N., Curless, T., Cullinane, P. W., Rockliffe, A., Pimparkar, S., Kawamura, H., Ollerenshaw, S., Elahi, I., Brandner, S., Wu, L., Real, R., Ryten, M., Hardy, J., De Pablo Fernandez, E., Warner, T. T., Morris, H. R., Lim, Y. M., & Jaunmuktane, Z. (2026). Quantitative pathology and APOE genotype reveal dementia risk and progression in Lewy body disease. Brain : a journal of neurology, 149(11), 3905-3922. https://
BibTeX
@article{nelvagal2026qua
author = {Nelvagal, Hemanth R and Chiraki, Nancy and Curless, Toby and Cullinane, Patrick W and Rockliffe, Alice and Pimparkar, Samarth and Kawamura, Haruka and Ollerenshaw, Sophie and Elahi, Isha and Brandner, Sebastian and Wu, Lesley and Real, Raquel and Ryten, Mina and Hardy, John and De Pablo Fernandez, Eduardo and Warner, Thomas T and Morris, Huw R and Lim, Yau Mun and Jaunmuktane, Zane},
title = {{Quantitative pathology and APOE genotype reveal dementia risk and progression in Lewy body disease}},
journal = {Brain : a journal of neurology},
year = {2026},
month = nov,
volume = {149},
number = {11},
pages = {3905--3922},
publisher = {Oxford University Press},
issn = {0006-8950},
doi = {10.1093/
url = {https://
pmid = {41889331},
pmcid = {PMC13730591}
}
RIS
TY - JOUR
AU - Nelvagal, Hemanth R
AU - Chiraki, Nancy
AU - Curless, Toby
AU - Cullinane, Patrick W
AU - Rockliffe, Alice
AU - Pimparkar, Samarth
AU - Kawamura, Haruka
AU - Ollerenshaw, Sophie
AU - Elahi, Isha
AU - Brandner, Sebastian
AU - Wu, Lesley
AU - Real, Raquel
AU - Ryten, Mina
AU - Hardy, John
AU - De Pablo Fernandez, Eduardo
AU - Warner, Thomas T
AU - Morris, Huw R
AU - Lim, Yau Mun
AU - Jaunmuktane, Zane
TI - Quantitative pathology and APOE genotype reveal dementia risk and progression in Lewy body disease
T2 - Brain : a journal of neurology
J2 - Brain
PY - 2026
DA - 2026/
VL - 149
IS - 11
SP - 3905
EP - 3922
SN - 0006-8950
PB - Oxford University Press
DO - 10.1093/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1093/
"type": "article-journal",
"title": "Quantitative pathology and APOE genotype reveal dementia risk and progression in Lewy body disease",
"container-title": "Brain : a journal of neurology",
"author": [
{
"family": "Nelvagal",
"given": "Hemanth R"
},
{
"family": "Chiraki",
"given": "Nancy"
},
{
"family": "Curless",
"given": "Toby"
},
{
"family": "Cullinane",
"given": "Patrick W"
},
{
"family": "Rockliffe",
"given": "Alice"
},
{
"family": "Pimparkar",
"given": "Samarth"
},
{
"family": "Kawamura",
"given": "Haruka"
},
{
"family": "Ollerenshaw",
"given": "Sophie"
},
{
"family": "Elahi",
"given": "Isha"
},
{
"family": "Brandner",
"given": "Sebastian"
},
{
"family": "Wu",
"given": "Lesley"
},
{
"family": "Real",
"given": "Raquel"
},
{
"family": "Ryten",
"given": "Mina"
},
{
"family": "Hardy",
"given": "John"
},
{
"family": "De Pablo Fernandez",
"given": "Eduardo"
},
{
"family": "Warner",
"given": "Thomas T"
},
{
"family": "Morris",
"given": "Huw R"
},
{
"family": "Lim",
"given": "Yau Mun"
},
{
"family": "Jaunmuktane",
"given": "Zane"
}
],
"container-title-short":
"volume": "149",
"issue": "11",
"page": "3905-3922",
"DOI": "10.1093/
"PMID": "41889331",
"PMCID": "PMC13730591",
"ISSN": "0006-8950",
"publisher": "Oxford University Press",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
11,
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.1093/brain/awag131 [code]
- Data-driven modelling of tau pathology reveals distinct progressive supranuclear palsy subtypes.Journal: Brain : a journal of neurologyIn common: Alzheimer's / dementia, 9 authors
- [2] doi:10.1212/nxg.0000000000200092 [code]
- Genome-wide Analysis of Motor Progression in Parkinson Disease.Journal: Neurology. GeneticsIn common: Plotly, reshape2, ggplot2, 4 other tools, Parkinson's, genetics / omics, 4 authors
- [3] doi:10.1038/s41467-024-52025-x [code]
- Genetic, transcriptomic, histological, and biochemical analysis of progressive supranuclear palsy implicates glial activation and novel risk genes.Journal: Nature communicationsIn common: tidyverse, pandas, Matplotlib, 1 other tool, Alzheimer's / dementia, genetics / omics, 4 authors
- [4] doi:10.1126/sciadv.adk1296 [code]
- The annotation of &
lt;i& gt;GBA1& lt;/ i& gt; has been concealed by its protein-coding pseudogene & lt;i& gt;GBAP1& lt;/ i& gt;. Journal: Science advancesIn common: rstatix, car, cowplot, 7 other tools, Parkinson's, genetics / omics, 2 authors - [5] doi:10.21203/rs.3.rs-8766017/v1 [code]
- A molecular map of the living human brain from quantitative MRIJournal: Research Square (preprint)In common: reshape2, statsmodels, ggplot2, 7 other tools, genetics / omics, 2 authors
- [6] doi:10.1126/sciadv.adp8504 [code]
- Astrocytic RNA editing regulates the host immune response to alpha-synuclein.Journal: Science advancesIn common: cowplot, reshape2, ggplot2, 4 other tools, Parkinson's, 2 authors
- [7] doi:10.1038/s41588-023-01300-6 [code]
- Brain expression quantitative trait locus and network analyses reveal downstream effects and putative drivers for brain-related diseases.Journal: Nature geneticsIn common: pROC, statannotations, Plotly, 11 other tools, genetics / omics
- [8] doi:10.1093/bioinformatics/btag592 [code]
- Network-based stratification of allele-specific expression reveals patient subgroups in Huntington's disease.Journal: Bioinformatics (Oxford, England)In common: pROC, rstatix, car, 11 other tools, genetics / omics
- [9] doi:10.1016/j.isci.2023.107522 [code]
- Deep learning for risk-based stratification of cognitively impaired individuals.Journal: iScienceIn common: scikit-posthocs, rstatix, Plotly, 10 other tools, Alzheimer's / dementia
- [10] doi:10.1038/s41467-025-66783-9 [code]
- Evidence for divergent cortical organisation in Parkinson's disease and Lewy Body Dementia.Journal: Nature communicationsIn common: scikit-posthocs, statsmodels, seaborn, 5 other tools, Parkinson's, Alzheimer's / dementia, author Mina Ryten
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.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 6 scripts, and 7 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:b178f69e2bf5ca6b…
Add the badge to the code's README
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 -->
[](https://openscicode.org/badge/doi/10.1093/brain/awag114)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.1093/brain/awag114.svg
:target: https://openscicode.org/badge/doi/10.1093/brain/awag114
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1093/brain/awag114"><img src="https://openscicode.org/badge/doi/10.1093/brain/awag114.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->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)
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
