danchaltiel / nih.joinpoint Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
Hi Dan,
I have been using the National Institutes of Health's (NIH) Joinpoint Regression Software (version 4.8.0.1) to analyse the trend of cancer by sex. Then, I utilised the nih.joinpoint R package to plot a regression output. Specifically, I used the jp_plot function with default parameters, which resulted in a plot displaying the trends for "Both sexes", "Females", and "Males". I attempted to customise the plots by modifying labels, colours, and axis ranges using the themes function from R. However, I encountered an issue where the customisation only applied to specific plots (e.g., only the male plot). I then tried using the patchwork package with themes, but this did not produce the desired customised plots either. As a third approach, I split the data into three subsets - "Both_sex", "Male_sex", and "Female_sex" - and applied the code below to each of these datasets separately.
#================================================
run_opt = run_options(model="ln", max_joinpoints=3, n_cores=3)
export_opt = export_options()
JP_male = joinpoint(Male_sex, x=year, y=asr, se=se,
run_opts=run_opt, export_opts=export_opt)
jp_plot(JP_male)
#=================================================
This worked only for the "Both_sex" dataset. Applying the same function to the other "Male_sex" and "Female_sex" datasets produces an error message described below.
Error in mutate( ): ℹ In argument:
slope0 = na_if(apc, ".") %>% zoo::na.locf(fromLast = TRUE) %>% as_factor(). Caused by error in
na_if(): ! Can't convert
y<character> to match type of
x<double>. Run
rlang::last_trace()` to see where the error occurred.
Q1. Is there any parameter to work around inside the jp_function ( ) to customise the plot to my requirements, such as background colour and axis title and label?
Q2. Why was the dependent variable considered a character in the error message while it is numeric in structure, as shown below?
**
Matrix products: default
locale:
[1] LC_COLLATE=English_Australia.utf8 LC_CTYPE=English_Australia.utf8 LC_MONETARY=English_Australia.utf8 LC_NUMERIC=C
[5] LC_TIME=English_Australia.utf8
time zone: Australia/Adelaide
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] patchwork_1.2.0 readxl_1.4.3 nih.joinpoint_0.1.0.9003 lubridate_1.9.3 forcats_1.0.0
[6] stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2 readr_2.1.5 tidyr_1.3.1
[11] tibble_3.2.1 ggplot2_3.5.1 tidyverse_2.0.0
loaded via a namespace (and not attached):
[1] gtable_0.3.5 htmlwidgets_1.6.4 devtools_2.4.5 remotes_2.5.0 lattice_0.22-6 tzdb_0.4.0 vctrs_0.6.5
[8] tools_4.4.0 generics_0.1.3 parallel_4.4.0 fansi_1.0.6 pkgconfig_2.0.3 lifecycle_1.0.4 farver_2.1.2
[15] compiler_4.4.0 munsell_0.5.1 janitor_2.2.0 snakecase_0.11.1 httpuv_1.6.15 htmltools_0.5.8.1 usethis_2.2.3
[22] crayon_1.5.2 later_1.3.2 pillar_1.9.0 urlchecker_1.0.1 ellipsis_0.3.2 cachem_1.1.0 sessioninfo_1.2.2
[29] mime_0.12 tidyselect_1.2.1 digest_0.6.35 stringi_1.8.4 labeling_0.4.3 fastmap_1.2.0 grid_4.4.0
[36] colorspace_2.1-0 cli_3.6.2 magrittr_2.0.3 pkgbuild_1.4.4 utf8_1.2.4 withr_3.0.0 scales_1.3.0
[43] promises_1.3.0 bit64_4.0.5 timechange_0.3.0 bit_4.0.5 cellranger_1.1.0 zoo_1.8-12 hms_1.1.3
[50] memoise_2.0.1 shiny_1.8.1.1 miniUI_0.1.1.1 profvis_0.3.8 rlang_1.1.3 Rcpp_1.0.12 xtable_1.8-4
[57] glue_1.7.0 pkgload_1.3.4 rstudioapi_0.16.0 vroom_1.6.5 R6_2.5.1 fs_1.6.4
</details>
sex year asr se
<chr> <dbl> <dbl> <dbl>
1 Both 1990 603. 56.8
2 Both 1991 498. 47.5
3 Both 1992 671. 57.6
4 Both 1993 614. 54.8
5 Both 1994 669. 57.0
6 Both 1995 700. 58.4
7 Both 1996 562. 49.5
8 Both 1997 722. 58.2
9 Both 1998 562. 50.5
10 Both 1999 654. 54.2
11 Both 2000 623. 52.2
12 Both 2001 628. 53.3
13 Both 2002 591. 51.0
14 Both 2003 660. 54.5
15 Both 2004 689. 57.3
head(Female_sex,15)
# A tibble: 15 × 4
sex year asr se
<chr> <dbl> <dbl> <dbl>
1 Female 1990 416. 69.6
2 Female 1991 396. 64.4
3 Female 1992 620. 83.1
4 Female 1993 520. 76.8
5 Female 1994 649. 83.3
6 Female 1995 541. 76.8
7 Female 1996 457. 66.9
8 Female 1997 680. 85.9
9 Female 1998 437. 71.1
10 Female 1999 550. 75.1
11 Female 2000 550. 74.4
12 Female 2001 539. 74.9
13 Female 2002 538. 73.3
14 Female 2003 589. 78.9
15 Female 2004 535. 79.1
head(Male_sex,15)
# A tibble: 15 × 4
sex year asr se
<chr> <dbl> <dbl> <dbl>
1 Male 1990 780. 89.6
2 Male 1991 569. 67.7
3 Male 1992 709. 79.9
4 Male 1993 678. 76.4
5 Male 1994 684. 78.6
6 Male 1995 823. 85.5
7 Male 1996 652. 72.6
8 Male 1997 749. 79.0
9 Male 1998 617. 67.0
10 Male 1999 735. 77.1
11 Male 2000 671. 72.1
12 Male 2001 690. 74.6
13 Male 2002 631. 70.6
14 Male 2003 702. 74.1
15 Male 2004 773. 78.2
Hi, Dan!
It's me again. Thanks for the constant support you provide for the users of your great package.
This time, I am writing to ask your advice and to ask for more information about the info in name(jp).
Important info about my dataset and joinpoint settings:
Therefore, as you may imagine, I cannot display all plots at once to assess the result. I want to export it as a table and then only plot significant clusters. Any suggestions? Anything is welcome :)
What I am thinking:
The most important information for me is the significance of the final selected model, the number and years of joinpoint and APC. A plus would be the significance of non-selected models, intercept value and MSE.
Therefore, my current idea is to create a sequence of unique values for the jp (not sure yet how to do this, tho). And then merge the jp$report and jp$apc based on the unique value and export the result as CSV. What would you think about that?
Bonus question!! 🎉
Could you please recommend materials to understand better the outcomes of jp? For example: in jp$report, what the df mean? or the auto_corr? and the difference between joinpoin_95_lcl and _ucl?
Well, that's all. Thank you very much!!
Best,
C.
Hi, Dan.
Thank you for your effort and for sharing your code with the community.
I am trying to use your package, but I got an error as a return for the run_options function. Would you mind helping me out?
Some important information for your reference:
Running your code as it is, the run_opt object return as an empty character representation. The same thing happens with export_opt.
Based on R Help Window, I edited the run_options() function to run the code with default options. The run_opt object is not empty anymore, but it gets not valid values.
run_opt = run_options( model = "ln", data_shift = 0, min_joinpoints = 0, max_joinpoints = 3, pairwise = NULL, pairwise_signif_lvl = 0.05, pairwise_n_permut = 4499, method = "grid", min_obs_end = 2, min_obs_between = 2, n_obs_between = 0, model_selection_method = "permutation test", permutation_signif_lvl = 0.05, n_permutations = 4499, early_stopping = "b-value", run_type = "provided", rates_per_n = 1e+05, dependent_variable_type = "percent", het_error = "standard error", het_error_var_location = NULL, ci_method = "parametric", n_cores = 3, delay_type = "non-delay", autocorr_errors = "number", jump_model = FALSE, comparability_ratio = FALSE, include_std_analysis = FALSE, jump_location = 9999, comparability_ratio_value = 0, cr_variance = 0, joinpoint_alpha_lvl = 0.05, apc_alpha_lvl = 0.05, aapc_alpha_lvl = 0.05, jump_cr_alpha_lvl = 0.05, random_seed = 7160, empirical_quantile_seed = 10000, empirical_quantile_seed_type = "constant", n_resample = 1000, madwd = FALSE, madwd_psi = 0 )
Hi Dan,
Thank you for maintaining a package to use NIH Joinpoint Regression Software from R.
We have installed the Command-Line version of Joinpoint for institutional use on our server and updated all the packages listed in imports in https://github.com/DanChaltiel/EDCimport/blob/main/DESCRIPTION .
I have tried to run the R code from the README.md Vignette. The joinpoint function runs for a couple of seconds without producing an error message, but the results from the analysis make no sense, i.e. it finds no joinpoints.
My problem appears similar to closed issues here but these threads did not help me resolve it.
I attach a PDF of the R Console output. Please find the R Code I used below. Your help is highly appreciated.
library(tidyverse)
library(nih.joinpoint)
nih_sample_data %>% group_by(sex) %>% slice(1, 2, n()-1, n())
run_opt = run_options(model="ln", max_joinpoints=3, n_cores=3)
export_opt = export_options()
run_opt
export_opt
reprex::reprex(session_info=TRUE)
jp = joinpoint(nih_sample_data, x=year, y=rate, by=sex, se=se,
run_opts=run_opt, export_opts=export_opt)
names(jp)
jp_plot(jp) + patchwork::plot_layout(ncol=1)
summary(jp)
str(jp)
Describe the bug
Please be as clear and thorough as possible. If possible include the version of JoinPoint you are using.
Reproducible example
Share the code that caused the bug, along with all error and warning messages.
Please also use dput(df)
to provide a sample dataset so I can reproduce the error. If your dataset is too large, select a minimal number of columns and rows, or use https://pastebin.com/.
export_options()
throws error as shown below. Running under Joinpoint 5.0.2, downloaded 2024-03-11.
Thanks!
library(nih.joinpoint)
export_opt = export_options()
#> Error in eval(call("force", as.symbol(paste0("..", x)))): argument "..40" is missing, with no default
Created on 2024-03-12 with reprex v2.1.0
R version 4.3.3 (2024-02-29 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22000)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
time zone: America/New_York
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] reprex_2.1.0 nih.joinpoint_0.1.0.9001
loaded via a namespace (and not attached):
[1] utf8_1.2.4 generics_0.1.3 stringi_1.8.3 lattice_0.22-5 hms_1.1.3
[6] digest_0.6.35 magrittr_2.0.3 evaluate_0.23 grid_4.3.3 timechange_0.3.0
[11] fastmap_1.1.1 processx_3.8.3 ps_1.7.6 purrr_1.0.2 fansi_1.0.6
[16] scales_1.3.0 cli_3.6.2 rlang_1.1.3 munsell_0.5.0 withr_3.0.0
[21] yaml_2.3.8 tools_4.3.3 tzdb_0.4.0 dplyr_1.1.4 colorspace_2.1-0
[26] ggplot2_3.5.0 forcats_1.0.0 vctrs_0.6.5 R6_2.5.1 zoo_1.8-12
[31] lifecycle_1.0.4 lubridate_1.9.3 snakecase_0.11.1 stringr_1.5.1 fs_1.6.3
[36] janitor_2.2.0 pkgconfig_2.0.3 callr_3.7.5 clipr_0.8.0 pillar_1.9.0
[41] gtable_0.3.4 glue_1.7.0 xfun_0.42 tibble_3.2.1 tidyselect_1.2.1
[46] rstudioapi_0.15.0 knitr_1.45 htmltools_0.5.7 patchwork_1.2.0 rmarkdown_2.26
[51] readr_2.1.5 compiler_4.3.3
</details>
Hi Dan,
Trying to use your excellent package but keep getting the following error: "'session_run.RunSummary.txt' does not exist in current working directory".
What would you recommend me to do?
I am writing to seek your advice on a problem I am facing with a chart generating program from your source code library. My dataset has multiple groups and I would like to display them all in the same chart.
I have tried merging the data for each group into a single data frame and then using the plotting function in your code to create the chart. However, this approach is not suitable for my data as different groups have different attributes and proportions, and combining them would definitely result in loss of information.
Is there a feasible way to display the data for each group in the same chart while still retaining their unique characteristics? I would like to leverage your tool as it fits my requirements very well.
Thank you for your kind assistance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.