Dr Augustina Badu-Peprah - PTB Analysis

Author

Dr Samuel Blay Nguah

First read in the data

Code
df_ptb <- 
    readxl::read_xlsx("./Data/PTB Response.xlsx") %>% 
    janitor::clean_names() %>% 
    select(-c(timestamp, question, dropdown, stephanie_janet_badu_peprah)) %>% 
    rename(
        ghon_focus = question_persistent_calcification_ghons_focus,
        tuberculoma = question_tuberculoma,
        miliary = question_miliary_nodules, 
        peribronchial_fibrosis = question_peribronchial_fibrosis,
        consolidation = question_consolidation,
        cavitation = question_cavitation,
        perihilar_lymphadenopathy = question_perihilar_lymphadenopathy,
        reticulonodular_infiltrates = question_reticulonodular_infiltrates,
        reticular_infiltrates = question_reticular_infiltrates,
        lung_volume_loss = question_lung_volume_loss,
        cxr_conclusion = based_on_xtics_above_cxr_signifies,
        extent_of_lung_involved_segment = extent_of_lung_involved,
        extent_of_effusion_minimal = extent_of_effusion,
        pleural_effusion_present_unilateral = pleural_effusion_present
        ) %>% 
    mutate(
        consolid_rul = case_when(
            str_detect(consolidation, "Right upper lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        consolid_lul = case_when(
            str_detect(consolidation, "Left upper lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        consolid_rml = case_when(
            str_detect(consolidation, "Right middle lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        consolid_lml = case_when(
            str_detect(consolidation, "Left middle")~"Yes", 
            TRUE ~ "No") %>% factor(),
        consolid_rll = case_when(
            str_detect(consolidation, "Right lower lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        consolid_lll = case_when(
            str_detect(consolidation, "Left lower lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        cavit_rul = case_when(
            str_detect(cavitation, "Right upper lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        cavit_lul = case_when(
            str_detect(cavitation, "Left upper lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        cavit_rml = case_when(
            str_detect(cavitation, "Right middle lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        cavit_lml = case_when(
            str_detect(cavitation, "Left middle")~"Yes", 
            TRUE ~ "No") %>% factor(),
        cavit_rll = case_when(
            str_detect(cavitation, "Right lower lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        cavit_lll = case_when(
            str_detect(cavitation, "Left lower lobe")~"Yes", 
            TRUE ~ "No") %>% factor(levels = c("No", "Yes")),
        tuberculoma = case_when(
            str_detect(tuberculoma, ".")~"Yes", 
            TRUE ~ "No") %>% factor(levels = c("No", "Yes")),
        miliary = case_when(
            str_detect(miliary, ".")~"Yes", 
            TRUE ~ "No") %>% factor(levels = c("No", "Yes")),
        peri_lymph_rml = case_when(
            str_detect(perihilar_lymphadenopathy, "Right middle")~"Yes", 
            TRUE ~ "No") %>% factor(),
        peri_lymph_lml = case_when(
            str_detect(perihilar_lymphadenopathy, "Left middle")~"Yes", 
            TRUE ~ "No") %>% factor(),
        
        ret_nod_rul = case_when(
            str_detect(reticulonodular_infiltrates, "Right upper lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        ret_nod_lul = case_when(
            str_detect(reticulonodular_infiltrates, "Left upper lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        ret_nod_rml = case_when(
            str_detect(reticulonodular_infiltrates, "Right middle lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        ret_nod_lml = case_when(
            str_detect(reticulonodular_infiltrates, "Left middle")~"Yes", 
            TRUE ~ "No") %>% factor(),
        ret_nod_rll = case_when(
            str_detect(reticulonodular_infiltrates, "Right lower lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        ret_nod_lll = case_when(
            str_detect(reticulonodular_infiltrates, "Left lower lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        
        ret_rul = case_when(
            str_detect(reticular_infiltrates, "Right upper lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        ret_lul = case_when(
            str_detect(reticular_infiltrates, "Left upper lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        ret_rml = case_when(
            str_detect(reticular_infiltrates, "Right middle lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        ret_lml = case_when(
            str_detect(reticular_infiltrates, "Left middle")~"Yes", 
            TRUE ~ "No") %>% factor(),
        ret_rll = case_when(
            str_detect(reticular_infiltrates, "Right lower lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        ret_lll = case_when(
            str_detect(reticular_infiltrates, "Left lower lobe")~"Yes", 
            TRUE ~ "No") %>% factor(),
        
        total_lung_damaged = factor(
            total_lung_damaged, 
            levels = c("None", "Small", "Moderate", "Large")
            ),
        ghon_focus = ifelse(is.na(ghon_focus), "None", ghon_focus),
        lung_volume_loss = ifelse(
            is.na(lung_volume_loss), "None", lung_volume_loss
            ),
        peribronchial_fibrosis = ifelse(
            is.na(peribronchial_fibrosis), "None", peribronchial_fibrosis
            ),
        cxr_conclusion = ifelse(
            cxr_conclusion == "Previous/Chronic TB", "Active TB", cxr_conclusion
            ) %>% factor(),
        extent_of_lung_involved_segment = ifelse(
            is.na(extent_of_lung_involved_segment), 
            "No", 
            extent_of_lung_involved_segment
            ),
        extent_of_lung_involved_one_lobe = ifelse(
            is.na(extent_of_lung_involved_one_lobe), 
            "No", 
            extent_of_lung_involved_one_lobe
            ),
        extent_of_lung_involved_two_lobes = ifelse(
            is.na(extent_of_lung_involved_two_lobes), 
            "No", 
            extent_of_lung_involved_two_lobes
            ),
        extent_of_lung_involved_more_than_2lobes = ifelse(
            is.na(extent_of_lung_involved_more_than_2lobes), 
            "No", 
            extent_of_lung_involved_more_than_2lobes
            ),
        extent_of_lung_involved_none = ifelse(
            is.na(extent_of_lung_involved_none), 
            "No", 
            extent_of_lung_involved_none
            ),
        extent_of_effusion_minimal = ifelse(
            is.na(extent_of_effusion_minimal), 
            "No", 
            extent_of_effusion_minimal
            ),
        extent_of_effusion_up_to_middle_lung_zone = ifelse(
            is.na(extent_of_effusion_up_to_middle_lung_zone), 
            "No", 
            extent_of_effusion_up_to_middle_lung_zone
            ),
        extent_of_effusion_massive = ifelse(
            is.na(extent_of_effusion_massive), 
            "No", 
            extent_of_effusion_massive
            ) %>% factor(levels = c("No", "Yes")),
        extent_of_effusion_none = ifelse(
            is.na(extent_of_effusion_none), 
            "No", 
            extent_of_effusion_none
            ) %>% factor(levels = c("No", "Yes")),
        pleural_effusion_present_unilateral = ifelse(
            is.na(pleural_effusion_present_unilateral), 
            "No", 
            pleural_effusion_present_unilateral
            ) %>% factor(levels = c("No", "Yes")),
        pleural_effusion_present_bilateral = ifelse(
            is.na(pleural_effusion_present_bilateral), 
            "No", 
            pleural_effusion_present_bilateral
            ) %>% factor(levels = c("No", "Yes")),
        pleural_effusion_present_none = ifelse(
            is.na(pleural_effusion_present_none), 
            "No", 
            pleural_effusion_present_none
            ) %>% factor(levels = c("No", "Yes"))
        )

df_ptb <-
    df_ptb %>% 
    labelled::set_variable_labels(
        consolid_rul = "Consolidation: Right Upper Lobe",
        consolid_rml = "Consolidation: Right Middle Lobe",
        consolid_rll = "Consolidation: Right Lower Lobe",
        consolid_lul = "Consolidation: Left Upper Lobe",
        consolid_lml = "Consolidation: Left Middle Lung Zone",
        consolid_lll = "Consolidation: Left Lower Lobe",
        #---------------------------------------------
        cavit_rul = "Cavitation: Right Upper Lobe",
        cavit_rml = "Cavitation: Right Middle Lobe",
        cavit_rll = "Cavitation: Right Lower Lobe",
        cavit_lul = "Cavitation: Left Upper Lobe",
        cavit_lml = "Cavitation: Left Middle Lung Zone",
        cavit_lll = "Cavitation: Left Lower Lobe",
        #----------------------------------------------
        tuberculoma = "Tuberculoma",
        miliary = "Miliary",
        #----------------------------------------------
        peri_lymph_lml = "Perihilar Lymphadenopathy: Left Middle Lung Zone",
        peri_lymph_rml = "Perihilar Lymphadenopathy: Right Middle Lobe",
        #----------------------------------------------
        ret_nod_rul = "Ret. Nodular Infiltrates: Right Upper Lobe",
        ret_nod_rml = "Ret. Nodular Infiltrates: Right Middle Lobe",
        ret_nod_rll = "Ret. Nodular Infiltrates: Right Lower Lobe",
        ret_nod_lul = "Ret. Nodular Infiltrates: Left Upper Lobe",
        ret_nod_lml = "Ret. Nodular Infiltrates: Left Middle Lung Zone",
        ret_nod_lll = "Ret. Nodular Infiltrates: Left Lower Lobe",
        #---------------------------------------------
        ret_rul = "Reticular Infiltrates: Right Upper Lobe",
        ret_rml = "Reticular Infiltrates: Right Middle Lobe",
        ret_rll = "Reticular Infiltrates: Right Lower Lobe",
        ret_lul = "Reticular Infiltrates: Left Upper Lobe",
        ret_lml = "Reticular Infiltrates: Left Middle Lung Zone",
        ret_lll = "Reticular Infiltrates: Left Lower Lobe",
        #---------------------------------------------
        total_lung_damaged = "Total Lung Damage",
        ghon_focus = "Persistent Calcification Ghon Focus",
        cxr_conclusion = "CXR conclusion",
        extent_of_lung_involved_segment = "Extent of lung involved: Segment",
        extent_of_lung_involved_one_lobe = "Extent of lung involved: One Lobe",
        extent_of_lung_involved_two_lobes = "Extent of lung involved: Two Lobes",
        extent_of_lung_involved_more_than_2lobes = "Extent of lung involved: > Two Lobes",
        extent_of_lung_involved_none = "Extent of lung involved: None",
        extent_of_effusion_minimal = "Extent of Effusion: Minimal",
        extent_of_effusion_up_to_middle_lung_zone = "Extent of Effusion: Up to middle lung zone",
        extent_of_effusion_massive = "Extent of Effusion: Massive",
        extent_of_effusion_none = "Extent of Effusion: None",
        pleural_effusion_present_unilateral = "Pleural Effusion Present: Unilateral",
        pleural_effusion_present_bilateral = "Pleural Effusion Present: Bilateral",
        pleural_effusion_present_none = "Pleural Effusion Present: None",
        lung_volume_loss = "Lung volume loss",
        peribronchial_fibrosis = "Peribronchail Fibrosis"
        )

# df_ptb %>% summarytools::dfSummary(labels.col = F, graph.col = F)
df_ptb2 <- df_ptb
df_ptb <- 
    df_ptb %>% 
    filter(!is.na(cxr_conclusion))

write_rds(x = df_ptb, file = "ptb_data.rds")

Table 1

Reticular nodular

Code
gtsummary::theme_gtsummary_compact()
Setting theme `Compact`
Code
ret_nod <- 
    df_ptb %>% 
    select(starts_with("ret_nod"),
        cxr_conclusion
        ) %>% 
    gtsummary::tbl_summary(
        by = cxr_conclusion,
        digits = gtsummary::all_categorical()~ c(0, 1),
        statistic = gtsummary::all_categorical() ~ "{n}({p})"
        ) %>% 
    gtsummary::bold_labels() %>% 
    gtsummary::modify_spanning_header(
        gtsummary::all_stat_cols() ~ "**Tuberculosis Status**"
        ) %>% 
    gtsummary::add_overall(last = T) %>% 
    gtsummary::add_p(pvalue_fun = ~ gtsummary::style_pvalue(.x, digits = 3))

ret_nod
Characteristic Tuberculosis Status Overall, N = 1541 p-value2
Active TB, N = 971 Latent TB, N = 571
Ret. Nodular Infiltrates: Right Upper Lobe 13(13.4) 1(1.8) 14(9.1) 0.015
Ret. Nodular Infiltrates: Left Upper Lobe 13(13.4) 0(0.0) 13(8.4) 0.002
Ret. Nodular Infiltrates: Right Middle Lobe 26(26.8) 0(0.0) 26(16.9) <0.001
Ret. Nodular Infiltrates: Left Middle Lung Zone 26(26.8) 0(0.0) 26(16.9) <0.001
Ret. Nodular Infiltrates: Right Lower Lobe 11(11.3) 0(0.0) 11(7.1) 0.007
Ret. Nodular Infiltrates: Left Lower Lobe 10(10.3) 0(0.0) 10(6.5) 0.014
1 n(%)
2 Pearson’s Chi-squared test; Fisher’s exact test

Reticular

Code
ret_only <- 
    df_ptb %>% 
    select(ret_rul, ret_lul, ret_rll, ret_lll, ret_rml, ret_lml, 
        cxr_conclusion
        ) %>% 
    gtsummary::tbl_summary(
        by = cxr_conclusion,
        digits = gtsummary::all_categorical()~ c(0, 1),
        statistic = gtsummary::all_categorical() ~ "{n}({p})"
        ) %>% 
    gtsummary::bold_labels() %>% 
    gtsummary::modify_spanning_header(
        gtsummary::all_stat_cols() ~ "**Tuberculosis Status**"
        ) %>% 
    gtsummary::add_overall(last = T) %>% 
    gtsummary::add_p(pvalue_fun = ~ gtsummary::style_pvalue(.x, digits = 3))

ret_only
Characteristic Tuberculosis Status Overall, N = 1541 p-value2
Active TB, N = 971 Latent TB, N = 571
Reticular Infiltrates: Right Upper Lobe 8(8.2) 0(0.0) 8(5.2) 0.026
Reticular Infiltrates: Left Upper Lobe 8(8.2) 0(0.0) 8(5.2) 0.026
Reticular Infiltrates: Right Lower Lobe 7(7.2) 0(0.0) 7(4.5) 0.047
Reticular Infiltrates: Left Lower Lobe 7(7.2) 0(0.0) 7(4.5) 0.047
Reticular Infiltrates: Right Middle Lobe 14(14.4) 0(0.0) 14(9.1) 0.003
Reticular Infiltrates: Left Middle Lung Zone 10(10.3) 0(0.0) 10(6.5) 0.014
1 n(%)
2 Fisher’s exact test; Pearson’s Chi-squared test

Cavitation

Code
cavit_only <- 
    df_ptb %>% 
    select(
        cavit_rul, 
        cavit_lul, 
        cavit_rll, 
        cavit_lll, 
        cavit_rml, 
        cavit_lml,
        cxr_conclusion
        ) %>% 
    gtsummary::tbl_summary(
        by = cxr_conclusion,
        digits = gtsummary::all_categorical()~ c(0, 1),
        statistic = gtsummary::all_categorical() ~ "{n}({p})"
        ) %>% 
    gtsummary::bold_labels() %>% 
    gtsummary::modify_spanning_header(
        gtsummary::all_stat_cols() ~ "**Tuberculosis Status**"
        ) %>% 
    gtsummary::add_overall(last = T) %>% 
    gtsummary::add_p(pvalue_fun = ~ gtsummary::style_pvalue(.x, digits = 3))

cavit_only
Characteristic Tuberculosis Status Overall, N = 1541 p-value2
Active TB, N = 971 Latent TB, N = 571
Cavitation: Right Upper Lobe 8(8.2) 0(0.0) 8(5.2) 0.026
Cavitation: Left Upper Lobe 8(8.2) 0(0.0) 8(5.2) 0.026
Cavitation: Right Lower Lobe 3(3.1) 0(0.0) 3(1.9) 0.296
Cavitation: Left Lower Lobe 0(0.0) 0(0.0) 0(0.0) >0.999
Cavitation: Right Middle Lobe 13(13.4) 0(0.0) 13(8.4) 0.002
Cavitation: Left Middle Lung Zone 7(7.2) 0(0.0) 7(4.5) 0.047
1 n(%)
2 Fisher’s exact test

Consolidation

Code
consolid_only <- 
    df_ptb %>% 
    select(
        consolid_rul, 
        consolid_lul, 
        consolid_rll, 
        consolid_lll, 
        consolid_rml, 
        consolid_lml,
        cxr_conclusion
        ) %>% 
    gtsummary::tbl_summary(
        by = cxr_conclusion,
        digits = gtsummary::all_categorical()~ c(0, 1),
        statistic = gtsummary::all_categorical() ~ "{n}({p})"
        ) %>% 
    gtsummary::bold_labels() %>% 
    gtsummary::modify_spanning_header(
        gtsummary::all_stat_cols() ~ "**Tuberculosis Status**"
        ) %>% 
    gtsummary::add_overall(last = T) %>% 
    gtsummary::add_p(pvalue_fun = ~ gtsummary::style_pvalue(.x, digits = 3))

consolid_only
Characteristic Tuberculosis Status Overall, N = 1541 p-value2
Active TB, N = 971 Latent TB, N = 571
Consolidation: Right Upper Lobe 19(19.6) 1(1.8) 20(13.0) 0.001
Consolidation: Left Upper Lobe 17(17.5) 0(0.0) 17(11.0) <0.001
Consolidation: Right Lower Lobe 6(6.2) 0(0.0) 6(3.9) 0.085
Consolidation: Left Lower Lobe 9(9.3) 0(0.0) 9(5.8) 0.027
Consolidation: Right Middle Lobe 15(15.5) 0(0.0) 15(9.7) 0.002
Consolidation: Left Middle Lung Zone 10(10.3) 0(0.0) 10(6.5) 0.014
1 n(%)
2 Pearson’s Chi-squared test; Fisher’s exact test

Lung involvement

Code
lung_involve <- 
    df_ptb %>% 
    select(
        extent_of_lung_involved_none, 
        extent_of_lung_involved_segment,
        extent_of_lung_involved_one_lobe,
        extent_of_lung_involved_two_lobes,
        extent_of_lung_involved_more_than_2lobes,
        cxr_conclusion
        ) %>% 
    gtsummary::tbl_summary(
        by = cxr_conclusion,
        digits = gtsummary::all_categorical()~ c(0, 1),
        statistic = gtsummary::all_categorical() ~ "{n}({p})"
        ) %>% 
    gtsummary::bold_labels() %>% 
    gtsummary::modify_spanning_header(
        gtsummary::all_stat_cols() ~ "**Tuberculosis Status**"
        ) %>% 
    gtsummary::add_overall(last = T) %>% 
    gtsummary::add_p(pvalue_fun = ~ gtsummary::style_pvalue(.x, digits = 3))

lung_involve
Characteristic Tuberculosis Status Overall, N = 1541 p-value2
Active TB, N = 971 Latent TB, N = 571
Extent of lung involved: None 2(2.1) 55(96.5) 57(37.0) <0.001
Extent of lung involved: Segment 17(17.5) 0(0.0) 17(11.0) <0.001
Extent of lung involved: One Lobe 19(19.6) 2(3.5) 21(13.6) 0.005
Extent of lung involved: Two Lobes 32(33.0) 0(0.0) 32(20.8) <0.001
Extent of lung involved: > Two Lobes 38(39.2) 0(0.0) 38(24.7) <0.001
1 n(%)
2 Pearson’s Chi-squared test

Perihilar lymphadenopathy

Code
perihilar_lymph <- 
    df_ptb %>% 
    select(
        peri_lymph_rml,
        peri_lymph_lml,
        cxr_conclusion
        ) %>% 
    gtsummary::tbl_summary(
        by = cxr_conclusion,
        digits = gtsummary::all_categorical()~ c(0, 1),
        statistic = gtsummary::all_categorical() ~ "{n}({p})"
        ) %>% 
    gtsummary::bold_labels() %>% 
    gtsummary::modify_spanning_header(
        gtsummary::all_stat_cols() ~ "**Tuberculosis Status**"
        ) %>% 
    gtsummary::add_overall(last = T) %>% 
    gtsummary::add_p(pvalue_fun = ~ gtsummary::style_pvalue(.x, digits = 3))

perihilar_lymph
Characteristic Tuberculosis Status Overall, N = 1541 p-value2
Active TB, N = 971 Latent TB, N = 571
Perihilar Lymphadenopathy: Right Middle Lobe 25(25.8) 0(0.0) 25(16.2) <0.001
Perihilar Lymphadenopathy: Left Middle Lung Zone 16(16.5) 0(0.0) 16(10.4) 0.001
1 n(%)
2 Pearson’s Chi-squared test

Pleural Effusion

Code
pleural_eff <- 
    df_ptb %>% 
    select(
        pleural_effusion_present_none,
        pleural_effusion_present_unilateral, 
        pleural_effusion_present_bilateral,
                cxr_conclusion
        ) %>% 
    gtsummary::tbl_summary(
        by = cxr_conclusion,
        digits = gtsummary::all_categorical()~ c(0, 1),
        statistic = gtsummary::all_categorical() ~ "{n}({p})"
        ) %>% 
    gtsummary::bold_labels() %>% 
    gtsummary::modify_spanning_header(
        gtsummary::all_stat_cols() ~ "**Tuberculosis Status**"
        ) %>% 
    gtsummary::add_overall(last = T) %>% 
    gtsummary::add_p(pvalue_fun = ~ gtsummary::style_pvalue(.x, digits = 3))

pleural_eff
Characteristic Tuberculosis Status Overall, N = 1541 p-value2
Active TB, N = 971 Latent TB, N = 571
Pleural Effusion Present: None 85(87.6) 57(100.0) 142(92.2) 0.004
Pleural Effusion Present: Unilateral 11(11.3) 0(0.0) 11(7.1) 0.007
Pleural Effusion Present: Bilateral 0(0.0) 0(0.0) 0(0.0) >0.999
1 n(%)
2 Fisher’s exact test

Extent of Effusion

Code
extent_eff <- 
    df_ptb %>% 
    select(
        extent_of_effusion_none, 
        extent_of_effusion_minimal,
        extent_of_effusion_up_to_middle_lung_zone,
        extent_of_effusion_massive,
        cxr_conclusion
        ) %>% 
    gtsummary::tbl_summary(
        by = cxr_conclusion,
        digits = gtsummary::all_categorical()~ c(0, 1),
        statistic = gtsummary::all_categorical() ~ "{n}({p})"
        ) %>% 
    gtsummary::bold_labels() %>% 
    gtsummary::modify_spanning_header(
        gtsummary::all_stat_cols() ~ "**Tuberculosis Status**"
        ) %>% 
    gtsummary::add_overall(last = T) %>% 
    gtsummary::add_p(pvalue_fun = ~ gtsummary::style_pvalue(.x, digits = 3))

extent_eff
Characteristic Tuberculosis Status Overall, N = 1541 p-value2
Active TB, N = 971 Latent TB, N = 571
Extent of Effusion: None 86(88.7) 57(100.0) 143(92.9) 0.007
Extent of Effusion: Minimal 6(6.2) 0(0.0) 6(3.9) 0.085
Extent of Effusion: Up to middle lung zone 5(5.2) 0(0.0) 5(3.2) 0.158
Extent of Effusion: Massive 0(0.0) 0(0.0) 0(0.0) >0.999
1 n(%)
2 Fisher’s exact test

Extent of Effusion

Code
other_features <- 
    df_ptb %>% 
    select(
        total_lung_damaged,
        miliary,
        tuberculoma,
        ghon_focus,
        lung_volume_loss,
        peribronchial_fibrosis,
        cxr_conclusion
        ) %>% 
    gtsummary::tbl_summary(
        by = cxr_conclusion,
        digits = gtsummary::all_categorical()~ c(0, 1),
        statistic = gtsummary::all_categorical() ~ "{n}({p})"
        ) %>% 
    gtsummary::bold_labels() %>% 
    gtsummary::modify_spanning_header(
        gtsummary::all_stat_cols() ~ "**Tuberculosis Status**"
        ) %>% 
    gtsummary::add_overall(last = T) %>% 
    gtsummary::add_p(pvalue_fun = ~ gtsummary::style_pvalue(.x, digits = 3))
There was an error in 'add_p()/add_difference()' for variable 'peribronchial_fibrosis', p-value omitted:
Error in stats::chisq.test(x = structure(c("None", "None", "None", "None", : 'x' and 'y' must have at least 2 levels
Code
other_features
Characteristic Tuberculosis Status Overall, N = 1541 p-value2
Active TB, N = 971 Latent TB, N = 571
Total Lung Damage


<0.001
    None 0(0.0) 55(96.5) 55(35.7)
    Small 20(20.6) 2(3.5) 22(14.3)
    Moderate 38(39.2) 0(0.0) 38(24.7)
    Large 39(40.2) 0(0.0) 39(25.3)
Miliary 0(0.0) 0(0.0) 0(0.0) >0.999
Tuberculoma 0(0.0) 0(0.0) 0(0.0) >0.999
Persistent Calcification Ghon Focus


0.370
    None 97(100.0) 56(98.2) 153(99.4)
    Right middle lobe 0(0.0) 1(1.8) 1(0.6)
Lung volume loss


0.531
    None 95(97.9) 57(100.0) 152(98.7)
    Right upper lobe 2(2.1) 0(0.0) 2(1.3)
Peribronchail Fibrosis



    None 97(100.0) 57(100.0) 154(100.0)
1 n(%)
2 Pearson’s Chi-squared test; Fisher’s exact test