Rows: 1391 Columns: 2
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): SSID
dbl (1): SID
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 1387 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): sid
dbl (3): tellen, telfracdup, telfracmap
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 1340 Columns: 36
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (9): record_id, subject_id, visit, sex, technically_adequate, inadequat...
dbl (27): scan_date, inadequate_reasons___resolution, inadequate_reasons___i...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
mil <-read_csv("G:/GroupAccess/Pulm-Research/John Kim/PFF Registry Data/HRCT/pff-pr_mil-uip_01Mar2024.csv", col_types =cols(ct_date =col_date(format ="%m/%d/%Y")))
Clean
# Add clean Diagnosis columns (IPF, CTD-ILD, FHP, IIP, and other)PFF <- PFF %>%mutate(Dx =case_when( DiagCateg_Current =="Collagen Vascular Disease/Autoimmune Diseases"~"CTD-ILD", DiagCateg_Current =="Hypersensitivity pneumonitis"~"FHP", DiagCateg_Current %in%c("Other specific ILD", "Occupational exposure") ~"other", Primary_Diag_Current =="IIP: Idiopathic pulmonary fibrosis"~"IPF",TRUE~"IIP" ) )# Link PFF to telomere and Automated CT detection variablescolnames(telomere)[1] <-"SID"Telomere_linkage <-merge(telomere, SSID_SID, by ="SID")PFF_telomere <-merge(PFF, Telomere_linkage, by ="SSID")colnames(DTA)[2] <-"SSID"complete <- PFF_telomere %>%left_join(DTA, by ="SSID") %>%left_join(mil, by ="SSID")# Replace NA with Zero in Cigarette Years Columncomplete <- complete %>%mutate(CigYears =replace_na(CigYears, 0))# rename MIL-UIP for easecolnames(complete)[159] <-"mil"# Generate above/below 10th percentile age adjusted telomere length columncomplete <- complete %>%mutate(age_nom =floor(AgeConsent), # map to integer ageage_nom =pmin(pmax(age_nom, 18), 95) # clamp to 18–95 ) %>%left_join( df.mesa.copd.normogram %>%mutate(age_nom =as.integer(age)) %>%# <-- change "Age" if your nomogram age column has a different nameselect(age_nom, p10 =`adj.telomere.10th`), # <-- change `10th` if the column name differsby ="age_nom" ) %>%mutate(Below10th_age_adj =if_else(!is.na(tellen) &!is.na(p10) & tellen <= p10,TRUE, FALSE,missing =NA ) ) %>%select(-age_nom, -p10)# Generate above/below 50th percentile age adjusted telomere length columncomplete <- complete %>%mutate(age_nom =floor(AgeConsent), # map to integer ageage_nom =pmin(pmax(age_nom, 18), 95) # clamp to 18–95 ) %>%left_join( df.mesa.copd.normogram %>%mutate(age_nom =as.integer(age)) %>%# <-- change "Age" if your nomogram age column has a different nameselect(age_nom, p50 =`adj.telomere.50th`), # <-- change `10th` if the column name differsby ="age_nom" ) %>%mutate(Below50th_age_adj =if_else(!is.na(tellen) &!is.na(p50) & tellen <= p50,TRUE, FALSE,missing =NA ) ) %>%select(-age_nom)# Generate age adjusted telomere lengthcomplete$AgeAdjTL <- complete$tellen - complete$p50 # Filter to those with automated CT values within 1 year of consentcomplete_1yr <- complete %>%mutate(gap_dta =abs(as.numeric(difftime(Consent_Date, study_date, units ="days"))),gap_mil =abs(as.numeric(difftime(Consent_Date, ct_date, units ="days"))),gap_sum = gap_dta + gap_mil # or use pmax(gap_study, gap_ct) ) %>%filter(!is.na(gap_dta), !is.na(gap_mil), gap_dta <=365, gap_mil <=365 ) %>%group_by(SSID) %>%slice_min(order_by = gap_sum, n =1, with_ties =FALSE) %>%ungroup()
Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
ℹ Please use the `linewidth` argument instead.
ℹ The deprecated feature was likely used in the ggpubr package.
Please report the issue at <https://github.com/kassambara/ggpubr/issues>.
Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0.
ℹ Please use the `linewidth` argument instead.
ℹ The deprecated feature was likely used in the ggpubr package.
Please report the issue at <https://github.com/kassambara/ggpubr/issues>.