ADNI progression summaries using the ADNIMERGE R package

This package vignette demonstrates how to use the ADNIMERGE package to generate progression summaries and plots with R and knitr.

Report generated from Progresssion.Rmd

This report contains estimates of the ADNI conversion rates using a nonparametric multistate modeling approach (Nicole Ferguson, Somnath Datta, Guy Brock (2012). msSurv: An R Package for Nonparametric Estimation of Multistate Models. Journal of Statistical Software, 50(14), 1-24. http://www.jstatsoft.org/v50/i14/).

This report does not consider transition to EMCI at any followup visits. The label LMCI, when applied at followup visits, actually refer to any MCI (EMCI or LMCI).

Only subjects with at least one followup Diagnostic Summary are included in this report.

Load required R packages and functions

mmse_bl <- mmse
mmse_bl$VISCODE <- with(mmse_bl, ifelse(VISCODE == "sc", "bl", VISCODE))
neurobat_bl <- subset(neurobat, VISCODE != "bl")
neurobat_bl$VISCODE <- with(neurobat_bl, ifelse(VISCODE == "sc", "bl", VISCODE))
cdr_bl <- cdr
cdr_bl$VISCODE <- with(cdr_bl, ifelse(VISCODE == "sc", "bl", VISCODE))
dd <- merge(dxsum[, c("RID", "COLPROT", "VISCODE", "DXCHANGE", paste("DXMPTR", 
    1:6, sep = ""))], mmse_bl[, c("RID", "COLPROT", "VISCODE", "MMSCORE")], 
    by = c("RID", "COLPROT", "VISCODE"), all = TRUE)
dd <- merge(dd, neurobat_bl[, c("RID", "COLPROT", "VISCODE", "LDELTOTAL")], 
    by = c("RID", "COLPROT", "VISCODE"), all = TRUE)
dd <- merge(dd, cdr_bl[, c("RID", "COLPROT", "VISCODE", "CDGLOBAL", "CDMEMORY")], 
    by = c("RID", "COLPROT", "VISCODE"), all = TRUE)
dd <- merge(dd, ecogpt[, c("RID", "COLPROT", "VISCODE", "CONCERN")], by = c("RID", 
    "COLPROT", "VISCODE"), all = TRUE)
dd <- merge(dd, registry[, c("RID", "COLPROT", "VISCODE", "EXAMDATE")], by = c("RID", 
    "COLPROT", "VISCODE"), all = TRUE)

dd <- merge(dd, subset(registry, VISCODE == "bl" & COLPROT == ORIGPROT, c("RID", 
    "COLPROT", "VISCODE", "EXAMDATE")), by = "RID", all = TRUE, suffixes = c("", 
    ".bl"))
dd <- merge(dd, subset(arm, COLPROT == ORIGPROT, c("RID", "DX")), by = "RID", 
    all = TRUE)
dd <- merge(dd, subset(ptdemog, VISCODE == "sc" & COLPROT == ORIGPROT, c("RID", 
    "PTEDUCAT")), by = "RID", all = TRUE)

COHORT <- unique(subset(registry, (RGCONDCT == "Yes" | VISTYPE == "Standard") & 
    VISCODE == "bl")$RID)
dd <- subset(dd, RID %in% COHORT & !VISCODE %in% c("sc", "scmri") & !is.na(DXCHANGE))

dd$Year <- as.numeric(with(dd, EXAMDATE - EXAMDATE.bl)/365.25)

dd$Dx <- as.character(dd$DXCHANGE)
dd$Dx <- gsub("Stable: ", "", dd$Dx)
dd$Dx <- gsub("Conversion: ", "", dd$Dx)
dd$Dx <- gsub("Reversion: ", "", dd$Dx)
dd$Dx <- gsub("MCI to ", "", dd$Dx)
dd$Dx <- gsub("Dementia to ", "", dd$Dx)
dd$Dx <- gsub("NL to ", "", dd$Dx)

dd$Dx.sc <- gsub("AD", "Dementia", dd$DX)

dd$obj_memory_loss <- apply(dd[, c("PTEDUCAT", "LDELTOTAL")], 1, obj_memory)
dd$subj_memory_comp <- with(dd, DXMPTR1 == "Yes" | DXMPTR2 == "Yes" | CONCERN == 
    "Yes" | Dx.sc == "EMCI")

dd <- subset(dd, !is.na(Year))
dd <- dd[order(dd$RID, dd$Year), ]
# LOCF for ojective memory complaint since Log Memory II not done at m06 and
# m18
for (rid in unique(dd$RID[!is.na(dd$obj_memory_loss)])) {
    dd[dd$RID == rid, "obj_memory_loss"] <- na.locf(dd[dd$RID == rid, "obj_memory_loss"], 
        na.rm = TRUE)
}

# MMSCORE %in% 24:30 & subj_memory_comp & CDGLOBAL == 0.5 & CDMEMORY >= 0.5

dd$Dx2 <- with(dd, ifelse(Dx == "MCI" & obj_memory_loss %in% c("EMCI", "NL"), 
    "EMCI", Dx))
dd$Dx2 <- ifelse(is.na(dd$Dx2), dd$Dx, dd$Dx2)
dd$stage4 <- as.numeric(as.character(factor(dd$Dx2, levels = c("NL", "EMCI", 
    "MCI", "Dementia"), labels = 1:4)))
# Dx3, stage3: no EMCI allowed at followup
dd$Dx3 <- with(dd, ifelse(Year == 0, Dx2, Dx))
dd$stage3 <- as.numeric(as.character(factor(dd$Dx3, levels = c("NL", "EMCI", 
    "MCI", "Dementia"), labels = 1:4)))

# remove duplicated RID EXAMDATEs
dd <- subset(dd, !duplicated(paste(RID, EXAMDATE)))

# first to final transition (including transitions to EMCI)
dd_first_to_final_4 <- with(dd, make_first_to_final_trans(RID, stage4, Year))
dd_all_int_final_4 <- with(dd, make_all_intermediate_trans(RID, stage4, Year))

# first to final transition (excluding transitions to EMCI)
dd_first_to_final_3 <- with(dd, make_first_to_final_trans(RID, stage3, Year))
dd_all_int_final_3 <- with(dd, make_all_intermediate_trans(RID, stage3, Year))

# Nodes <- c('1', '2', '3', '4') Edges <- list('1' = list(edges = c('2',
# '3', '4')), '2' = list(edges = c('1', '3', '4')), '3' = list(edges =
# c('1', '2', '4')), '4' = list(edges = c('3'))) treeobj <- new('graphNEL',
# nodes = Nodes, edgeL = Edges, edgemode = 'directed') fit4 <-
# msSurv(dd_all_int_final_4, treeobj, bs = TRUE, LT = TRUE)

Nodes <- c("1", "2", "3", "4")
Edges <- list(`1` = list(edges = c("3", "4")), `2` = list(edges = c("1", "3", 
    "4")), `3` = list(edges = c("1", "4")), `4` = list(edges = c("3")))
treeobj <- new("graphNEL", nodes = Nodes, edgeL = Edges, edgemode = "directed")
fit3 <- msSurv(dd_all_int_final_3, treeobj, bs = TRUE, LT = TRUE)

No states eligible for entry distribution calculation.

Exit distributions calculated for states 2 .

Using bootstrap to calculate variances ... 

Transition counts (first to last stage transitions)

           end.stage
start.stage   NL EMCI LMCI   AD  Sum
       NL    348    0   48   14  410
       EMCI   26   17  224   37  304
       LMCI   11    0  155   93  259
       AD      0    0    1  231  232
       Sum   385   17  428  375 1205

Transition probabilities (%)

dx <- c("NL", "EMCI", "LMCI", "AD")
tab1 <- Pst(fit3, s = 0, t = 1.1)
tab2 <- Pst(fit3, s = 0, t = 2.1)
tab3 <- Pst(fit3, s = 0, t = 3.1)
tab4 <- Pst(fit3, s = 0, t = 4.1)

Year 0 to 1

         NL EMCI   LMCI     AD Sum
NL   79.048 0.00  18.99   1.96 100
EMCI  4.908 1.74  82.38  10.97 100
LMCI  4.336 0.00  74.92  20.74 100
AD    0.142 0.00   5.23  94.63 100
Sum  88.435 1.74 181.52 128.30 400

Year 0 to 2

        NL  EMCI   LMCI     AD Sum
NL   71.28 0.000  23.89   4.84 100
EMCI  6.98 0.697  71.20  21.13 100
LMCI  6.22 0.000  64.34  29.44 100
AD    0.37 0.000   8.03  91.60 100
Sum  84.84 0.697 167.46 147.01 400

Year 0 to 3

         NL  EMCI   LMCI    AD Sum
NL   69.069 0.000  24.54   6.4 100
EMCI  8.839 0.348  65.40  25.4 100
LMCI  7.894 0.000  59.11  33.0 100
AD    0.618 0.000   9.88  89.5 100
Sum  86.419 0.348 158.93 154.3 400

Year 0 to 4

        NL EMCI  LMCI     AD Sum
NL   65.94    0  25.7   8.33 100
EMCI 12.17    0  58.0  29.86 100
LMCI 10.92    0  52.5  36.56 100
AD    1.32    0  12.2  86.50 100
Sum  90.35    0 148.4 161.24 400

R Session Information

R version 3.5.2 (2018-12-20)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] zoo_1.8-4           msSurv_1.2-2        graph_1.60.0       
 [4] BiocGenerics_0.28.0 ADNIMERGE_0.0.1     Hmisc_4.2-0        
 [7] ggplot2_3.1.1       Formula_1.2-3       survival_2.43-1    
[10] lattice_0.20-38    

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1          class_7.3-14        assertthat_0.2.1   
 [4] rprojroot_1.3-2     digest_0.6.18       R6_2.4.0           
 [7] plyr_1.8.4          backports_1.1.4     acepack_1.4.1      
[10] stats4_3.5.2        evaluate_0.13       pillar_1.3.1       
[13] rlang_0.3.4         lazyeval_0.2.2      rstudioapi_0.8     
[16] data.table_1.12.2   rpart_4.1-13        Matrix_1.2-15      
[19] checkmate_1.9.1     rmarkdown_1.12      pkgdown_1.1.0      
[22] labeling_0.3        desc_1.2.0          splines_3.5.2      
[25] stringr_1.4.0       foreign_0.8-71      htmlwidgets_1.3    
[28] munsell_0.5.0       compiler_3.5.2      xfun_0.6           
[31] pkgconfig_2.0.2     base64enc_0.1-3     htmltools_0.3.6    
[34] nnet_7.3-12         tidyselect_0.2.5    tibble_2.1.1       
[37] gridExtra_2.3       htmlTable_1.12      roxygen2_6.1.1     
[40] crayon_1.3.4        dplyr_0.8.0.1       withr_2.1.2        
[43] MASS_7.3-51.1       commonmark_1.6      grid_3.5.2         
[46] gtable_0.3.0        magrittr_1.5        formatR_1.5        
[49] scales_1.0.0        stringi_1.4.3       fs_1.2.6           
[52] latticeExtra_0.6-28 xml2_1.2.0          RColorBrewer_1.1-2 
[55] tools_3.5.2         glue_1.3.1          purrr_0.3.2        
[58] yaml_2.2.0          colorspace_1.4-1    cluster_2.0.7-1    
[61] memoise_1.1.0       knitr_1.22