##############################Data wrangling section##########################################
##Data tidy

library(tidyverse)


base<-base %>% 
  rename(
    Diagnosis = dx,
    Symptomatic = covid_sint,
    Hospitalization = hospitalizacion,
    ICU =terapia,
    ICU_days = dias_terapia,
    s_Anosmia = covid_symptoms___0,
    s_Ageusia = covid_symptoms___1,
    s_fatigue = covid_symptoms___2,
    s_Dysnea = covid_symptoms___3,
    s_Headache = covid_symptoms___4,
    s_Fever  = covid_symptoms___5,
    s_Sore_throat = covid_symptoms___6,
    s_Rush = covid_symptoms___7,
    s_Diarrhea   = covid_symptoms___8,
    s_Nausea = covid_symptoms___9,
    s_Chest_pain = covid_symptoms___10,
    s_Delirium =    covid_symptoms___11,
    s_Sinusitis = covid_symptoms___12,
    s_Dizzyness = covid_symptoms___13,
    No_neurological_disease =   trast_neurologico___0,# double negation
    mh_epilepsy = trast_neurologico___1,
    mh_cognitive_impairment = trast_neurologico___2,
    mh_Parkinson    = trast_neurologico___3,
    mh_vertigo  = trast_neurologico___4,
    mh_multiple_Sclerosis = trast_neurologico___5,
    mh_cephalea = trast_neurologico___6,
    mh_fibromialgia = trast_neurologico___7,
    mh_stroke   = trast_neurologico___8,
    mh_others   = trast_neurologico___9,
    mh_cardiac_disease =  antecedentes_medicos___0, 
    mh_hta  = antecedentes_medicos___1,
    mh_COPD = antecedentes_medicos___2,
    mh_asthma = antecedentes_medicos___3,
    mh_diabetes = antecedentes_medicos___7,
    mh_cancer   = antecedentes_medicos___10,
    mh_smoke = antecedentes_medicos___11,
    mh_reumatological = antecedentes_medicos___12,
    mh_obesity =    antecedentes_medicos___13,
    mh_HIV = antecedentes_medicos___14,
    No_mh =antecedentes_medicos___15 # double negation
  )



# Definition of factors and labels

base$s_Anosmia<-factor(base$s_Anosmia,
                       levels = c(0,1),
                       labels = c("No", "Yes"))

base$s_Ageusia<-factor(base$s_Ageusia,
                       levels = c(0,1),
                       labels = c("No", "Yes"))

base$s_fatigue<-factor(base$s_fatigue,
                       levels = c(0,1),
                       labels = c("No", "Yes"))

base$s_Dysnea<-factor(base$s_Dysnea,
                      levels = c(0,1),
                      labels = c("No", "Yes"))

base$s_Headache<-factor(base$s_Headache,
                        levels = c(0,1),
                        labels = c("No", "Yes"))

base$s_Fever<-factor(base$s_Fever,
                     levels = c(0,1),
                     labels = c("No", "Yes"))

base$s_Sore_throat<-factor(base$s_Sore_throat,
                           levels = c(0,1),
                           labels = c("No", "Yes"))

base$s_Rush<-factor(base$s_Rush,
                    levels = c(0,1),
                    labels = c("No", "Yes"))

base$s_Diarrhea<-factor(base$s_Diarrhea,
                        levels = c(0,1),
                        labels = c("No", "Yes"))

base$s_Nausea<-factor(base$s_Nausea,
                      levels = c(0,1),
                      labels = c("No", "Yes"))

base$s_Chest_pain<-factor(base$s_Chest_pain,
                          levels = c(0,1),
                          labels = c("No", "Yes"))

base$s_Delirium<-factor(base$s_Delirium,
                        levels = c(0,1),
                        labels = c("No", "Yes"))

base$s_Sinusitis<-factor(base$s_Sinusitis,
                         levels = c(0,1),
                         labels = c("No", "Yes"))

base$s_Dizzyness<-factor(base$s_Dizzyness,
                         levels = c(0,1),
                         labels = c("No", "Yes"))

base$sex<-factor(base$sex,
                 levels = c(0,1),
                 labels = c("Male", "Female"))


base$Diagnosis<-factor(base$Diagnosis,
                       levels = c(0,1),
                       labels = c("Healthy control", "Covid"))



base$ICU<-factor(base$ICU,
                 labels = c("No", "Yes"))


#esta invertido para que quede mejor OJO!
base$mh_neurological<- ifelse(base$No_neurological_disease == 1, 0, ifelse(base$No_neurological_disease == 0,1,"Na"))


base$mh_neurological<-factor(base$mh_neurological,
                                     levels = c(0,1),
                                     labels = c("No", "Yes")) 

#esta invertido para que quede mejor OJO!
base$mh<- ifelse(base$No_mh == 0, 1, ifelse(base$No_mh == 1,0,"Na"))

base$mh<-factor(base$mh,levels = c(0,1),
                labels = c("No", "Yes")) 


base$mh_epilepsy<-factor(base$mh_epilepsy,
                         levels = c(0,1),
                         labels = c("No", "Yes"))


base$mh_cognitive_impairment<-factor(base$mh_cognitive_impairment,
                                     levels = c(0,1),
                                     labels = c("No", "Yes"))

base$mh_Parkinson<-factor(base$mh_Parkinson,
                          levels = c(0,1),
                          labels = c("No", "Yes"))

base$mh_vertigo<-factor(base$mh_vertigo,
                        levels = c(0,1),
                        labels = c("No", "Yes"))

base$mh_multiple_Sclerosis<-factor(base$mh_multiple_Sclerosis,
                                   levels = c(0,1),
                                   labels = c("No", "Yes")
)

base$mh_cephalea<-factor(base$mh_cephalea,
                         levels = c(0,1),
                         labels = c("No", "Yes"))

base$mh_stroke<-factor(base$mh_stroke,
                       levels = c(0,1),
                       labels = c("No", "Yes"))

#Rounding of numerical variables
base$age<-round(base$age, digits = 0)

base$imc<-round(base$imc, digits = 1)


# Variables dependent of branching logic for severity needs replaces NAN by Zero

base$suplemento_oxigeno[is.na(base$suplemento_oxigeno)] <- 0

base$respirador[is.na(base$respirador)] <- 0


#Severity calculation
base$severity_Calc<-base$Symptomatic+base$Hospitalization+base$suplemento_oxigeno+base$respirador


base$severity<-factor(base$severity_Calc,
                                      levels = c(0,1,2,3,4),
                                      labels = c("Asymptomatic", "Mild", "Moderate","Moderate", "Severe"))

#Variables labeling


library(expss)
base<-apply_labels(base,
                   age= "Age (y)",
                   Symptomatic = "Symptomatic covid infection",
                   Hospitalization = "Hospitalization requiered",
                   ICU ="Intensive care (ICU) requiered",
                   ICU_days = "Day in ICU",
                   s_Anosmia = "Anosmia",
                   s_Ageusia = "Ageusia",
                   s_fatigue = "Fatigue",
                   s_Dysnea = "Dysnea",
                   s_Headache = "Headache",
                   s_Fever   = "Fever",
                   s_Sore_throat = "Sore throrat",
                   s_Rush = "Skin rush",
                   s_Diarrhea    = "Diarrhea",
                   s_Nausea = "Nausea",
                   s_Chest_pain = "Chest pain or ANGOR",
                   s_Delirium = "Delirium",
                   s_Sinusitis = "Sinusitis",
                   s_Dizzyness  = "Vertigo or dizzyness",
                   mh_neurological = "Medical history of major neurological disease",
                   mh = "Medical history of chronic disease",
                   mh_epilepsy = "Epilepsy",
                   mh_cognitive_impairment = "Prior Cognitive impairment",
                   mh_Parkinson = "Parkinson disease",
                   mh_vertigo = "Vertigo",                  
                   mh_multiple_Sclerosis = "Multiple Sclerosis",
                   mh_cephalea = "Cephalea",
                   mh_fibromialgia = "Fybromialgia",
                   mh_stroke = "Stroke",
                   mh_cardiac_disease = "Cardiac disease", 
                   mh_hta = "Hypertension",
                   mh_COPD = "COPD", 
                   mh_diabetes = "Diabetes", 
                   mh_smoke = "Smoke", 
                   mh_obesity = "Obesity",
                   severity = "Covid infection severity",
                   craft_inm_textual = "Craft Story inmediate recall (textual)",
                   craft_inm_textual_z = "Craft Story inmediate recall (textual)-z score-",
                   craft_inm_parafraseo = "Craft Story inmediate recall (paraf)",
                   craft_inm_paraf_z = "Craft Story inmediate recall (paraf)-z score-",
                   craft_dif_textual = "Craft Story delayed recall (textual)",
                   craft_dif_tex_z = "Craft Story delayed recall (textual) -zscore-",
                   craft_dif_paraf= "Craft Story delayed recall (paraf)",
                   craft_dif_paraf_z = "Craft Story delayed recall (paraf) -zscore-",
                   logical_inm = "WLM inmediate recall",
                   logical_inm_z= "WLM inmediate recall-zscore-",
                   logical_dif = "WLM delayed recall",
                   logical_dif_z = "WLM delayed recall -z score-",
                   logical_rec = "WLM recognition",
                   rey_tot = "RAVLT Total",
                   rey_tot_z = "RAVLT Total -zscore-",
                   rey_dif= "RAVLT delayed recall",
                   rey_dif_z = "RAVLT delayed recall-z score",
                   rey_reconocimiento = "RAVLT recognition",
                   rey_reconocimiento_z = "RAVLT recognition -z score",
                   rey_intrusiones = "RAVLT intrusion",
                   rey_falsospos = "RAVLT FPos",
                   benson_dif = "Benson figure delayed recall",
                   benson_dif_z = "Benson figure delayed recall -zscore-",
                   benson_rec ="Benson figure recognition",
                   rey_fig_dif = "Rey figure delayed recall",
                   rey_fig_dif_z  = "Rey figure delayed recall -zscore-",
                   rey_repr ="Rey figure recognition",
                   mint = "MINT",
                   mint_z = "MINT -zscore-",
                   boston = "BNT",
                   boston_z = "BNT -zscore-",
                   crosswalk_mint_boston = "MINT/BNT crosswalk",
                   fluency_sem_anim = "Semantic fluency",
                   fluency_sem_anim_z = "Semantic fluency -zscore-",  
                   fluency_fon_p = "Phonological fluency (p)",
                   fluency_fon_p_z = "Phonological fluency (p)-zscore-",
                   fluency_fon_m = "Phonological fluency (m)",
                   fluency_fon_m_z= "Phonological fluency (m)-zscore-",
                   digitos_dir = "Digit span (direct)",
                   digitos_dir_z  = "Digit span (direct) -z score-",
                   digitos_inv = "Digit span (indirect)",
                   digitos_inv_z = "Digit span (indirect) -z score-",
                   tmt_a = "Trial making test A",
                   tmt_a_z = "Trial making test A -zscore-",
                   claves = "WAIS IV claves",
                   claves_z = "WAIS IV claves -zscore-",
                   digitos_simbolos = "DSST",
                   digitos_simbolos_z = "DSST -zscore-",
                   tmt_b = "Trial making test B",
                   tmt_b_z = "Trial making test B -zscore-",
                   fab = "FAB",
                   fab_z = "FAB -z score-",
                   stroop_pc = "Stroop word-colour",
                   stroop_pc_z = "Stroop word-colour- z score-",
                   stroop_int = "Stroop int",
                   stroop_int_z  = "Stroop int -z score-",
                   wcst_cat = "WCST cat",
                   wcst_cat_z = "WCST cat -z score-",
                   wcst_perseveraciones = "WCST pers ",
                   wcst_z = "WCST pers -z score-",
                   benson_cop = "Benson figure copy",
                   benson_cop_z = "Benson figure copy -zscore-",
                   rey_copia = "Rey figure copy ",
                   rey_copia_z = "Rey figure copy -zscore-",
                   reloj = "CDT",
                   gds = " GDS",
                   hads_ans = "HADS anxiety",
                   hads_dep =  "HADS depresion",
                   mmq = "MMQ",
                   faq = "FAQ",
                   moca_total= "MoCA total",
                   mmse= "MMSE",
                   crosswalk_mmse_moca = "MMSE/MoCA crosswalk",
                   imc = "BMI",
                   total_caide = "CAIDE dementia score",
                   escolaridad = "Education (y)",
                   severity = "Covid severity (WHO clinical progression scale)",
                   time_lapse = "Time of evaluation since diagnosis"
                   )

#####################################################################################################

Table 1. Demographics

Esta tabla, y la siguiente, las pense para mostrar la poblacion. Ya que es en definitiva una serie de casos, es muy importante mostrar como son los casos por eso la tabla 2

library(gtsummary)


base %>% select(Diagnosis, age, sex, escolaridad,total_caide)%>%
  tbl_summary(by=Diagnosis)%>%
  add_p()
Characteristic Healthy control, N = 371 Covid, N = 451 p-value2
Age (y) 57 (48, 64) 51 (43, 65) 0.5
sex 0.5
Male 18 (49%) 25 (56%)
Female 19 (51%) 20 (44%)
Education (y) 18.00 (15.00, 18.00) 18.00 (15.00, 18.00) 0.9
CAIDE dementia score 6.00 (5.00, 7.00) 5.00 (3.00, 7.00) 0.2

1 Median (IQR); n (%)

2 Wilcoxon rank sum test; Pearson's Chi-squared test

Table 2. Covid cases features

De esta tabla me parecio importante reportar que los pacientes son evaluados mas o menos 3 meses despues del cuadro agudo! Puse algunos factores que me parecieron los mas relevantes (podemos agregar el que consideren)

t1<-base %>% filter(Diagnosis =="Covid") %>%
  select(severity,time_lapse)%>%
  tbl_summary(missing = "no",type = list(time_lapse~ 'continuous'))%>%italicize_labels()


t2<-base %>% filter(Diagnosis =="Covid") %>%
  select(mh_cognitive_impairment,mh_epilepsy, mh_Parkinson, mh_multiple_Sclerosis, mh_stroke)%>%
  tbl_summary(missing = "no")%>%italicize_labels()

t3<-base %>% filter(Diagnosis =="Covid") %>%
  select(mh_hta,mh_obesity,mh_diabetes, mh_smoke, mh_cardiac_disease,  mh_COPD,  imc)%>%
   tbl_summary(missing = "no") %>%italicize_labels()

tbl_stack(list(t1, t2,t3), 
  group_header = c("Covid infection","Neurological disease history", "Risk factors")
  )
Characteristic N = 451
Covid infection
Covid severity (WHO clinical progression scale)
Asymptomatic 0 (0%)
Mild 22 (65%)
Moderate 10 (29%)
Severe 2 (5.9%)
Time of evaluation since diagnosis 149 (76, 218)
Neurological disease history
Prior Cognitive impairment 4 (8.9%)
Epilepsy 0 (0%)
Parkinson disease 0 (0%)
Multiple Sclerosis 0 (0%)
Stroke 0 (0%)
Risk factors
Hypertension 6 (13%)
Obesity 5 (11%)
Diabetes 2 (4.4%)
Smoke 2 (4.4%)
Cardiac disease 0 (0%)
COPD 0 (0%)
BMI 23.6 (22.5, 28.7)

1 n (%); Median (IQR)

Table 2a. Covid cases functionality after covid (WHODAS 2.0)

Estas son las preguntas de la OMS convertidas a los scores que postulan, hay que sacar la columna de asintomaticos y severos (que no tenemos), me parece importante mostrar que el mayor compromiso funcional de estos pacientes se encuentra en la cognicion

###Whodas calculation

base$WHODAS_total<-base$oms_parado + 
  base$oms_tareasdomest +
  base$oms_nuevoaprend +
  base$oms_actcom +
  base$oms_afectemoc+
  base$oms_concentr+
  base$oms_caminar+
  base$oms_higiene +
  base$oms_vest +
  base$oms_desconoc+
  base$oms_amist+
  base$oms_trab

base$WHODAS_cognition<-base$oms_concentr+base$oms_nuevoaprend
base$WHODAS_mobility<- base$oms_parado+base$oms_caminar
base$WHODAS_self_Care<-base$oms_higiene+base$oms_vest
base$WHODAS_getting_along<-base$oms_desconoc+base$oms_amist
base$WHODAS_life_activities<-base$oms_tareasdomest+base$oms_trab
base$WHODAS_participation<-base$oms_afectemoc+base$covid_actcom

base<-apply_labels(base,
                   oms_parado = "Standing long periods",
                   oms_tareasdomest =   "Household responsabilities",
                   oms_nuevoaprend  =   "Learning new tasks",
                   oms_actcom   =   "Joining community activities",
                   oms_afectemoc    =   "Emotionally affected",
                   oms_concentr =   "Concentrating",
                   oms_caminar  =   "Walking long distance",
                   oms_higiene  =   "Washing whole body",
                   oms_vest =   "Getting dressed",
                   oms_desconoc =   "Dealing with strangers",
                   oms_amist    =   "Maintaining friendships",
                   oms_trab =    "Work/school activities",
                   covid_parado =   "Standing long periods (comparing prior covid)",
                   covid_tareasdom  =   "Household responsabilities  (comparing prior covid)",
                   covid_aprendizaje    =   "Learning new tasks  (comparing prior covid)",
                   covid_actcom =   "Joining community activities  (comparing prior covid)",
                   covid_afectemoc  =   "Emotionally affected  (comparing prior covid)",
                   covid_concentr   =   "Concentrating  (comparing prior covid)",
                   covid_caminar    =   "Walking long distance  (comparing prior covid)",
                   covid_higiene    =   "Washing whole body  (comparing prior covid)",
                   covid_vest   =   "Getting dressed  (comparing prior covid)", 
                   covid_desconoc   =   "Dealing with strangers  (comparing prior covid)",
                   covid_amist  = "Maintaining friendships  (comparing prior covid)",
                   covid_trab   =    "Work/school activities  (comparing prior covid)",
                   WHODAS_total = "WHODAS total",
                   WHODAS_cognition= "Cognition",
                   WHODAS_mobility = "Mobility",
                   WHODAS_life_activities = "Life activities",
                   WHODAS_self_Care = "Self-care",
                   WHODAS_getting_along = "Getting along",
                   WHODAS_participation = "Participation")
#############




base %>%  select(WHODAS_cognition, WHODAS_life_activities, WHODAS_mobility, WHODAS_self_Care, WHODAS_getting_along, WHODAS_participation, WHODAS_mobility, WHODAS_total, severity) %>%
  tbl_summary(by=severity, missing = "no", type = list(WHODAS_cognition~ 'continuous', WHODAS_life_activities~ 'continuous', WHODAS_mobility~ 'continuous', WHODAS_self_Care~ 'continuous', WHODAS_getting_along~ 'continuous', WHODAS_participation~ 'continuous', WHODAS_mobility~ 'continuous', WHODAS_total~ 'continuous')) %>%
  add_p() %>%
  add_overall()
Characteristic Overall, N = 351 Asymptomatic, N = 01 Mild, N = 221 Moderate, N = 111 Severe, N = 21 p-value2
Cognition 2.00 (1.00, 3.75) NA (NA, NA) 2.00 (0.00, 2.00) 4.00 (3.00, 5.00) 2.50 (2.25, 2.75) 0.008
Life activities 1.00 (0.00, 3.00) NA (NA, NA) 1.00 (0.00, 2.00) 3.00 (1.00, 5.00) 1.00 (0.50, 1.50) 0.13
Mobility 1.00 (0.00, 2.00) NA (NA, NA) 1.00 (0.00, 2.00) 1.00 (1.00, 5.00) 3.00 (2.50, 3.50) 0.13
Self-care 0.00 (0.00, 0.00) NA (NA, NA) 0.00 (0.00, 0.00) 0.00 (0.00, 0.50) 0.00 (0.00, 0.00) 0.3
Getting along 0.00 (0.00, 2.00) NA (NA, NA) 0.00 (0.00, 1.75) 2.00 (0.00, 3.00) 1.50 (0.75, 2.25) 0.2
Participation 3.00 (2.00, 4.00) NA (NA, NA) 2.00 (1.25, 3.00) 4.00 (2.50, 5.00) 4.00 (3.50, 4.50) 0.030
WHODAS total 8 (3, 13) NA (NA, NA) 6 (1, 11) 13 (9, 26) 11 (10, 12) 0.027

1 Median (IQR)

2 Kruskal-Wallis rank sum test

Table 3 Cognition cases and controls

La vieja tablita neuropsicologica

# Tabla 3 Cognition by groups
t1<- base %>% select(mmse, moca_total, crosswalk_mmse_moca, reloj, Diagnosis) %>%
  tbl_summary(by=Diagnosis, type = list(mmse ~ 'continuous', reloj~ 'continuous'),
              statistic = list(all_continuous() ~ "{mean} ({sd})",
                               all_categorical() ~ "{n} / {N} ({p}%)")) %>%italicize_labels()%>%
  add_p()

t2<- base %>% select(craft_inm_textual, craft_inm_parafraseo,   craft_dif_textual,  craft_dif_paraf,    rey_tot,    rey_dif, rey_reconocimiento,    benson_dif, rey_fig_dif,    
                     Diagnosis) %>%  
  tbl_summary(by=Diagnosis,type = list(rey_reconocimiento ~ 'continuous', rey_fig_dif~ 'continuous'),
              statistic = list(all_continuous() ~ "{mean} ({sd})",
                               "rey_dif"~"{mean} ({sd})",
                               all_categorical() ~ "{n} / {N} ({p}%)")) %>%italicize_labels()%>%
  add_p()


t3<-base %>% select(mint,boston,    crosswalk_mint_boston,  fluency_sem_anim,   fluency_fon_p,  fluency_fon_m, Diagnosis) %>%
  tbl_summary(by=Diagnosis,
              type = list(mint ~ 'continuous', boston~ 'continuous', crosswalk_mint_boston~ 'continuous'),
              statistic = list(all_continuous() ~ "{mean} ({sd})",
                               all_categorical() ~ "{n} / {N} ({p}%)")) %>%italicize_labels()%>%
  add_p()

t4 <-base %>% select(digitos_dir,   digitos_inv,    tmt_a,  claves, digitos_simbolos, Diagnosis) %>%
  tbl_summary(by=Diagnosis,
              type = list(digitos_dir ~ 'continuous', digitos_inv~ 'continuous', digitos_simbolos~ 'continuous'),
              statistic = list(all_continuous() ~ "{mean} ({sd})",
                               all_categorical() ~ "{n} / {N} ({p}%)")) %>%italicize_labels()%>%
  add_p()




t5<-base %>% select(tmt_b,  fab,    stroop_pc,  stroop_int, wcst_cat,   wcst_perseveraciones, Diagnosis) %>%
  tbl_summary(by= Diagnosis, 
              type = list(fab ~ 'continuous', wcst_cat~ 'continuous', wcst_perseveraciones~ 'continuous'),
              statistic = list(all_continuous() ~ "{mean} ({sd})",
                               all_categorical() ~ "{n} / {N} ({p}%)")) %>%italicize_labels()%>%
  add_p()


t6<-base %>% select(benson_cop, rey_copia,  reloj, Diagnosis) %>%
  tbl_summary(by= Diagnosis, 
              type = list(benson_cop ~ 'continuous', rey_copia~ 'continuous', reloj~ 'continuous'),
              statistic = list(all_continuous() ~ "{mean} ({sd})",
                               all_categorical() ~ "{n} / {N} ({p}%)"))  %>%italicize_labels()%>%
  add_p


t7<-base %>% select(hads_ans,   hads_dep,   mmq, faq, Diagnosis) %>%
  tbl_summary(by= Diagnosis, 
              type = list(faq ~ 'continuous'),
              statistic = list(all_continuous() ~ "{mean} ({sd})",
                               all_categorical() ~ "{n} / {N} ({p}%)")) %>%italicize_labels()%>%
  add_p





tbl_stack(
  list(t1, t2,t3,t4,t5,t6,t7), 
  group_header = c("Screening","Memory", "Language", "Attention", "Ejecutive System", "Visuospatial", "Neuropsych")
)%>%
  bold_p(t = 0.01)
Characteristic Healthy control, N = 371 Covid, N = 451 p-value2
Screening
MMSE NA (NA) 27.50 (3.27)
Unknown 37 39
MoCA total 27.27 (1.97) 26.28 (2.86) 0.15
Unknown 0 6
MMSE/MoCA crosswalk 27.27 (1.97) 25.87 (3.28) 0.053
CDT 9.78 (0.62) 9.14 (1.35) 0.009
Unknown 0 2
Memory
Craft Story inmediate recall (textual) 22 (4) 18 (7) 0.009
Unknown 0 8
Craft Story inmediate recall (paraf) 16.9 (2.6) 14.3 (4.1) 0.003
Unknown 0 8
Craft Story delayed recall (textual) 19 (5) 15 (8) 0.005
Unknown 0 8
Craft Story delayed recall (paraf) 15.9 (2.9) 12.8 (5.0) 0.004
Unknown 0 8
RAVLT Total 49 (8) 42 (13) 0.019
RAVLT delayed recall 10.2 (2.8) 8.4 (4.0) 0.024
RAVLT recognition 12.92 (1.66) 11.86 (2.28) 0.040
Unknown 0 2
Benson figure delayed recall 12.38 (2.30) 10.45 (3.16) 0.006
Unknown 0 7
Rey figure delayed recall NA (NA) 22.8 (8.2)
Unknown 37 41
Language
MINT 30.41 (1.46) 29.45 (2.08) 0.039
Unknown 0 7
BNT NA (NA) 27.57 (2.64)
Unknown 37 38
MINT/BNT crosswalk 30.41 (1.46) 29.47 (2.14) 0.049
Semantic fluency 23.0 (4.2) 19.0 (5.2) <0.001
Phonological fluency (p) 18.2 (4.3) 14.4 (4.8) 0.001
Phonological fluency (m) 16.1 (3.6) 14.1 (4.7) 0.055
Unknown 4 6
Attention
Digit span (direct) 6.86 (0.95) 5.89 (1.30) <0.001
Digit span (indirect) 5.11 (0.91) 4.02 (1.14) <0.001
Trial making test A 29 (6) 46 (25) <0.001
Unknown 0 1
WAIS IV claves 13.5 (3.0) 12.0 (3.6) 0.016
Unknown 1 9
DSST 1 (NA) 22 (18) 0.3
Unknown 36 40
Ejecutive System
Trial making test B 62 (21) 106 (77) <0.001
Unknown 0 4
FAB 17.71 (0.59) 16.71 (1.20) 0.011
Unknown 20 31
Stroop word-colour 51 (9) 49 (11) 0.3
Unknown 0 13
Stroop int 53 (7) 53 (6) 0.6
Unknown 0 13
WCST cat 6.00 (0.00) 5.59 (1.04) 0.022
Unknown 5 13
WCST pers 0.72 (1.20) 2.91 (4.67) 0.008
Unknown 5 13
Visuospatial
Benson figure copy 16.22 (0.95) 16.21 (3.11) 0.14
Unknown 0 6
Rey figure copy NA (NA) 34.00 (3.46)
Unknown 37 42
CDT 9.78 (0.62) 9.14 (1.35) 0.009
Unknown 0 2
Neuropsych
HADS anxiety 8.43 (3.30) 8.32 (3.29) 0.8
Unknown 9 14
HADS depresion 6.9 (7.9) 5.9 (3.5) >0.9
Unknown 8 15
MMQ 37 (14) 33 (12) 0.3
Unknown 14 21
FAQ 0.0 (0.0) 6.0 (11.2) 0.020
Unknown 29 36

1 Mean (SD)

2 Wilcoxon rank sum test

Multiple comparison corrections

Esta tabla (que parece un chino), es solo para elegir el metodo mas generoso con las correcciones multiples, despues que decidamos y despues la pongo como una columnita mas de la anterior

Input = ("
Test  Raw.p
MoCA_total  0.2
MMSE/MoCA_crosswalk 0.05
Craft_Story_inmediate_recall_textual  0.006
Craft_Story_inmediate_recall_paraf  0.001
Craft_Story_delayed_recall_textual  0.003
Craft_Story_delayed_recall_paraf  0.001
RAVLT_Total 0.003
RAVLT_delayed_recall  0.014
RAVLT_recognition 0.035
Benson_figure_delayed_recall  0.001 
MINT  0.047
MINT/BNT_crosswalk  0.061
Semantic_fluency  0.001
Phonological_fluency  0.002
Phonological_fluency_m  0.039
Digit_span_direct 0.001
Digit_span_indirect 0.001
Trial_making_test_A 0.001
WAIS_IV_claves  0.012
DSST  0.3
Trialmaking_test_B  0.001
FAB 0.02
Stroop_word-colour  0.3
Stroop_int  0.4
WCST_cat  0.023
WCST_pers 0.032
Benson_figure_copy  0.2
CDT 0.004
HADS_anxiety  0.8
HADS_depresion  0.7
MMQ 0.3
FAQ 0.057")
Data = read.table(textConnection(Input),header=TRUE)

Data = Data[order(Data$Raw.p),]

library(FSA)

Data$Bonferroni =
  p.adjust(Data$Raw.p,
           method = "bonferroni")

Data$BH =
  p.adjust(Data$Raw.p,
           method = "BH")

Data$Holm =
  p.adjust(Data$ Raw.p,
           method = "holm")

Data$Hochberg =
  p.adjust(Data$ Raw.p,
           method = "hochberg")

Data$Hommel =
  p.adjust(Data$ Raw.p,
           method = "hommel")

Data$BY =
  p.adjust(Data$ Raw.p,
           method = "BY")

knitr::kable(Data)
Test Raw.p Bonferroni BH Holm Hochberg Hommel BY
4 Craft_Story_inmediate_recall_paraf 0.001 0.032 0.0040000 0.032 0.025 0.024 0.0162340
6 Craft_Story_delayed_recall_paraf 0.001 0.032 0.0040000 0.032 0.025 0.024 0.0162340
10 Benson_figure_delayed_recall 0.001 0.032 0.0040000 0.032 0.025 0.024 0.0162340
13 Semantic_fluency 0.001 0.032 0.0040000 0.032 0.025 0.024 0.0162340
16 Digit_span_direct 0.001 0.032 0.0040000 0.032 0.025 0.024 0.0162340
17 Digit_span_indirect 0.001 0.032 0.0040000 0.032 0.025 0.024 0.0162340
18 Trial_making_test_A 0.001 0.032 0.0040000 0.032 0.025 0.024 0.0162340
21 Trialmaking_test_B 0.001 0.032 0.0040000 0.032 0.025 0.024 0.0162340
14 Phonological_fluency 0.002 0.064 0.0071111 0.048 0.048 0.044 0.0288604
5 Craft_Story_delayed_recall_textual 0.003 0.096 0.0087273 0.069 0.066 0.063 0.0354196
7 RAVLT_Total 0.003 0.096 0.0087273 0.069 0.066 0.063 0.0354196
28 CDT 0.004 0.128 0.0106667 0.084 0.084 0.080 0.0432906
3 Craft_Story_inmediate_recall_textual 0.006 0.192 0.0147692 0.120 0.120 0.108 0.0599409
19 WAIS_IV_claves 0.012 0.384 0.0274286 0.228 0.228 0.156 0.1113187
8 RAVLT_delayed_recall 0.014 0.448 0.0298667 0.252 0.252 0.168 0.1212137
22 FAB 0.020 0.640 0.0400000 0.340 0.340 0.220 0.1623398
25 WCST_cat 0.023 0.736 0.0432941 0.368 0.368 0.230 0.1757090
26 WCST_pers 0.032 1.000 0.0568889 0.480 0.480 0.305 0.2308833
9 RAVLT_recognition 0.035 1.000 0.0589474 0.490 0.490 0.315 0.2392376
15 Phonological_fluency_m 0.039 1.000 0.0624000 0.507 0.507 0.351 0.2532501
11 MINT 0.047 1.000 0.0716190 0.564 0.549 0.423 0.2906656
2 MMSE/MoCA_crosswalk 0.050 1.000 0.0727273 0.564 0.549 0.450 0.2951633
32 FAQ 0.057 1.000 0.0793043 0.570 0.549 0.456 0.3218563
12 MINT/BNT_crosswalk 0.061 1.000 0.0813333 0.570 0.549 0.480 0.3300909
1 MoCA_total 0.200 1.000 0.2461538 1.000 0.800 0.800 0.9990142
27 Benson_figure_copy 0.200 1.000 0.2461538 1.000 0.800 0.800 0.9990142
20 DSST 0.300 1.000 0.3310345 1.000 0.800 0.800 1.0000000
23 Stroop_word-colour 0.300 1.000 0.3310345 1.000 0.800 0.800 1.0000000
31 MMQ 0.300 1.000 0.3310345 1.000 0.800 0.800 1.0000000
24 Stroop_int 0.400 1.000 0.4266667 1.000 0.800 0.800 1.0000000
30 HADS_depresion 0.700 1.000 0.7225806 1.000 0.800 0.800 1.0000000
29 HADS_anxiety 0.800 1.000 0.8000000 1.000 0.800 0.800 1.0000000

Comparacion de composites

###calculo de los composites

base$composite_memory<-(base$rey_dif_z+base$rey_tot_z+base$benson_dif_z)/3

base$composite_language <-(base$fluency_sem_anim_z + base$mint_z)/2 

base$composite_attention<-(base$digitos_dir_z+base$tmt_a_z)/2

base$composite_Executive<-(base$tmt_b_z+base$fluency_fon_p_z+base$digitos_inv_z)/3


library(expss)

base<-apply_labels(base,
                   composite_memory= "Memory (composite)",
                   composite_language=  "Language (composite)",
                   composite_attention = "Attention (composite)",
                   composite_Executive = "Executive (composite)")

Tabla 4.a Cognition cases and controls (by composites)

En este caso creo que la tabla 3 y la 4a se pueden fusionar, podemos discutirlo luego

library(gtsummary)
library(gt)
library(dplyr)
library(purrr)
library(effsize)
my_EStest <- function(data, variable, by, ...) {
  effsize::cohen.d(data[[variable]] ~ as.factor(data[[by]]), 
                   conf.level=.90, paired=FALSE)$estimate
}

base_composites<-base %>% filter(incluir_en_analisis==1)

base_composites%>% select(composite_memory,composite_attention, composite_Executive, composite_language, Diagnosis) %>%
  tbl_summary(by= Diagnosis) %>%
  add_p %>%
  add_stat(
    fns = everything() ~ my_EStest,
    #fmt_fun = style_pvalue,
    header = "**Effect size**"
  )
Characteristic Healthy control, N = 181 Covid, N = 261 p-value2 Effect size
Memory (composite) 0.38 (-0.12, 0.60) -0.16 (-0.75, 0.21) 0.022 0.7700617
Attention (composite) -0.16 (-0.84, 0.05) -1.24 (-1.59, -0.68) 0.004 0.9126698
Executive (composite) 0.12 (-0.23, 0.42) -0.62 (-1.48, -0.21) <0.001 1.2036913
Unknown 0 1
Language (composite) 0.08 (-0.32, 0.43) -0.44 (-0.84, 0.14) 0.024 0.7547307

1 Median (IQR)

2 Wilcoxon rank sum test

library(psych)

cohen.d(base_composites$composite_memory,base_composites$Diagnosis)
## Call: cohen.d(x = base_composites$composite_memory, group = base_composites$Diagnosis)
## Cohen d statistic of difference between two means
##      lower effect upper
## [1,] -1.43  -0.79 -0.12
## 
## Multivariate (Mahalanobis) distance between groups
## [1] 0.79
## r equivalent of difference between two means
##  data 
## -0.36
## Spaghetti plot

base3<- base_composites %>% filter(Diagnosis== "Covid") %>% select(composite_memory,composite_attention, composite_Executive, composite_language, record_id)


library(reshape2)
## 
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
## 
##     smiths
base4<-melt(base3, id.var = "record_id")
## Warning: attributes are not identical across measure variables; they will be
## dropped
ggplot(data = base4, aes(x = variable, y = value, group = record_id, colour= "red")) +
  geom_line(alpha=.5)+
  geom_hline(yintercept = -1, linetype= "dashed")+
  geom_hline(yintercept = -1.5, linetype='dotted')+
  theme_minimal()

base3$Memory<-base3$composite_memory > -1
base3$Attention<-base3$composite_attention > -1
base3$Executive<-base3$composite_Executive > -1
base3$Language <-base3$composite_language > -1

library(ggplot2)
library(ggpubr)
## 
## Attaching package: 'ggpubr'
## The following object is masked from 'package:expss':
## 
##     compare_means
a1<-ggplot(base3, aes(x=Memory, fill=Memory))+
  geom_bar()+
  theme_minimal()+theme(axis.text.x=element_blank(),plot.title = element_text(size = 9),legend.position = "none")

a2<-ggplot(base3, aes(x=Attention, fill=Attention))+
  geom_bar()+
  theme_minimal()+theme(axis.text.x=element_blank(),plot.title = element_text(size = 9),legend.position = "none")

a3<-ggplot(base3, aes(x=Executive, fill=Executive))+
  geom_bar()+
  theme_minimal()+theme(axis.text.x=element_blank(),plot.title = element_text(size = 9),legend.position = "none")


a4<-ggplot(base3, aes(x=Language, fill=Language))+
  geom_bar()+
  scale_fill_discrete(name="Compromise", labels= c("Impaired", "Preserved"))+
  theme_minimal()+theme(axis.text.x=element_blank(),plot.title = element_text(size = 9),legend.position = c(0.19,1))



ggarrange(a1, a2, a3, a4,
          ncol = 2, nrow = 2)

a1<-ggplot(base3, aes(y=composite_memory, x=composite_attention))+
  geom_point()+
  geom_hline(yintercept = -1, linetype= "dashed")+
  geom_vline(xintercept = -1, linetype= "dashed")+
  theme_minimal()

a2<-ggplot(base3, aes(y=composite_memory, x=composite_Executive))+
  geom_point()+
  geom_hline(yintercept = -1, linetype= "dashed")+
  geom_vline(xintercept = -1, linetype= "dashed")+
  theme_minimal()

a3<-ggplot(base3, aes(y=composite_memory, x=composite_language))+
  geom_point()+
  geom_hline(yintercept = -1, linetype= "dashed")+
  geom_vline(xintercept = -1, linetype= "dashed")+
  theme_minimal()

a4<-ggplot(base3, aes(y=composite_attention, x=composite_Executive))+
  geom_point()+
  geom_hline(yintercept = -1, linetype= "dashed")+
  geom_vline(xintercept = -1, linetype= "dashed")+
  theme_minimal()

a5<-ggplot(base3, aes(y=composite_attention, x=composite_language))+
  geom_point()+
  geom_hline(yintercept = -1, linetype= "dashed")+
  geom_vline(xintercept = -1, linetype= "dashed")+
  theme_minimal()
  

a6<-ggplot(base3, aes(y=composite_Executive, x=composite_language))+
  geom_point()+
  geom_hline(yintercept = -1, linetype= "dashed")+
  geom_vline(xintercept = -1, linetype= "dashed")+
  theme_minimal()


ggarrange(a1, a2, a3, a4, a5, a6, 
          ncol = 3, nrow = 2)+
  ggtitle("Patients distribution by composites")
## Warning: Removed 1 rows containing missing values (geom_point).

## Warning: Removed 1 rows containing missing values (geom_point).

## Warning: Removed 1 rows containing missing values (geom_point).

Cognition vs severity

Esto podemos mostrarlo de diferentes formas me parece que la mas interesante es con la figura de abajo y agregandole las p, siempre podemos probar con la otra tabla, que viene mas abajo

Figure 1. Cognition vs severity

Cognitive perfomance in composites vs severity ** en este caso los graficos estan hechos solo con los seleccionados

library(ggplot2)
library(ggpubr)
base2<-base %>% filter(incluir_en_analisis==1) 
a1<-ggplot(base2, aes(x=Diagnosis, y=composite_memory))+
  ggtitle("Memory")+
  ylim(-3,2)+
  geom_jitter(aes(colour=severity),alpha=.5, width = .15, height = .15)+
    geom_hline(yintercept = -1)+
  ylab("")+
  xlab("")+
  theme(legend.position = "none")+
  theme_minimal()+theme(plot.title = element_text(size = 9),legend.position = "none")

a2<-ggplot(base2, aes(x=Diagnosis, y=composite_attention, colour=severity))+
  ggtitle("Attention")+
  ylim(-3,2)+
  geom_jitter(alpha=.5, width = .15, height = .15)+
  geom_hline(yintercept = -1)+
  ylab("")+
  xlab("")+
  theme(legend.position = "none")+
  theme_minimal()+theme(plot.title = element_text(size = 9),legend.position = "none")

a3<-ggplot(base2, aes(x=Diagnosis, y=composite_Executive, colour=severity))+
  ggtitle("Executive")+
  ylim(-3,2)+
  geom_jitter(alpha=.5, width = .15, height = .15)+
  geom_hline(yintercept = -1)+
  ylab("")+
  xlab("")+
  theme_minimal()+theme(plot.title = element_text(size = 9),legend.position = "none")

a4<-ggplot(base2, aes(x=Diagnosis, y=composite_language, colour=severity))+
  ggtitle("Language")+
  ylim(-3,2)+
  geom_jitter(alpha=.5, width = .15, height = .15)+
  geom_hline(yintercept = -1)+
  ylab("")+
  xlab("")+
  theme_minimal()+theme(plot.title = element_text(size = 9),legend.position = c(0.9,0))


ggarrange(a1, a2, a3, a4 + rremove("x.text"), 
          ncol = 2, nrow = 2)

Alternative versions

a1<-ggplot(base2, aes(x=Diagnosis, y=composite_memory, fill=severity))+
  geom_violin()+
  ggtitle("Memory")+
  ylim(-3,2)+
  geom_hline(yintercept = -1)+
  ylab("")+
  xlab("")+
  theme(legend.position = "none")+
  theme_minimal()+theme(plot.title = element_text(size = 9),legend.position = "none")

a2<-ggplot(base2, aes(x=Diagnosis, y=composite_attention, fill=severity))+
  geom_violin()+
  ggtitle("Attention")+
  ylim(-3,2)+
  geom_hline(yintercept = -1)+
  ylab("")+
  xlab("")+
  theme(legend.position = "none")+
  theme_minimal()+theme(plot.title = element_text(size = 9),legend.position = "none")

a3<-ggplot(base2, aes(x=Diagnosis, y=composite_Executive, fill=severity))+
  geom_violin()+
  ggtitle("Executive")+
  ylim(-3,2)+
  geom_hline(yintercept = -1)+
  ylab("")+
  xlab("")+
  theme_minimal()+theme(plot.title = element_text(size = 9),legend.position = "none")

a4<-ggplot(base2, aes(x=Diagnosis, y=composite_language, fill=severity))+
  geom_violin()+
  ggtitle("Language")+
  ylim(-3,2)+
  geom_hline(yintercept = -1)+
  ylab("")+
  xlab("")+
  theme_minimal()+theme(plot.title = element_text(size = 9),legend.position = c(0.9,-0.05))


ggarrange(a1, a2, a3, a4 + rremove("x.text"), 
          ncol = 2, nrow = 2)

Table Cognition vs severity

base2 %>% select(composite_memory,composite_attention, composite_Executive, composite_language, severity) %>%
  tbl_summary(by= severity, missing = "no") %>%
  add_p
Characteristic Asymptomatic, N = 01 Mild, N = 181 Moderate, N = 61 Severe, N = 21 p-value2
Memory (composite) NA (NA, NA) -0.25 (-0.73, 0.01) -0.85 (-1.10, -0.22) 0.35 (0.20, 0.49) 0.2
Attention (composite) NA (NA, NA) -1.24 (-1.53, -0.68) -1.46 (-1.83, -1.12) -1.15 (-1.60, -0.70) 0.6
Executive (composite) NA (NA, NA) -0.62 (-1.48, -0.28) -1.55 (-1.95, -0.86) -0.21 (-0.21, -0.21) 0.2
Language (composite) NA (NA, NA) -0.44 (-0.72, 0.19) -0.58 (-0.84, -0.16) -0.30 (-0.32, -0.28) 0.8

1 Median (IQR)

2 Kruskal-Wallis rank sum test

Figure 2. Cognitive complaint by domain and severity

Cognitive perfomance in the four composites by severity in correlation with WHODAS cognition domain complaint

p1<-ggplot(base2, aes(x=WHODAS_cognition, y=composite_memory, colour=severity))+
  geom_point()+
  geom_smooth(method = "glm", alpha=.1)+
  geom_jitter(alpha=.5, width = .3, height = .3)+
  geom_hline(yintercept = -1)+
  ylab("Memory")+
  xlab(" ")+
  theme_minimal()+theme(legend.position = "none")+
  facet_grid(~severity)

p2<-ggplot(base2, aes(x=WHODAS_cognition, y=composite_attention, colour=severity))+
  geom_point()+
  geom_smooth(method = "glm", alpha=.1)+
  ylab("Attention")+
  xlab(" ")+
  ylim(-3,1.5)+
  geom_jitter(alpha=.5, width = .3, height = .3)+  
  geom_hline(yintercept = -1)+
  theme_minimal()+theme(legend.position = "none")+
  facet_grid(~severity)

ggarrange(p1, p2+ rremove("x.text"), 
          ncol = 1, nrow = 2)

p3<-ggplot(base2, aes(x=WHODAS_cognition, y=composite_Executive,  colour=severity))+
  geom_point()+
  geom_smooth(method = "glm", alpha=.1)+
  geom_jitter(alpha=.5, width = .3, height = .3)+
  geom_hline(yintercept = -1)+
  ylab("Executive")+
  xlab(" ")+
  theme_minimal()+theme(legend.position = "none")+
  facet_grid(~severity)

p4<-ggplot(base2, aes(x=WHODAS_cognition, y=composite_language, colour=severity))+
  geom_point()+
  geom_smooth(method = "glm", alpha=.1)+
  ylab("Language")+
  xlab("WHODAS cognition")+
  ylim(-3,1.5)+
  geom_jitter(alpha=.5, width = .3, height = .3)+  
  geom_hline(yintercept = -1)+
  theme_minimal()+ theme(legend.position = c(0.95,0.5))+
  facet_grid(~severity)

ggarrange(p3, p4+ rremove("x.text"), 
          ncol = 1, nrow = 2)