Giter Site home page Giter Site logo

nih.joinpoint's Introduction

Metrics

nih.joinpoint's People

Contributors

danchaltiel avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nih.joinpoint's Issues

How to customize plot compnents in NIH Joinpoint package in R

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 ofx<double>. Runrlang::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?

**

data structre

str(Female_sex) tibble [28 × 4] (S3: tbl_df/tbl/data.frame) $ sex : chr [1:28] "Female" "Female" "Female" "Female" ... $ year: num [1:28] 1990 1991 1992 1993 1994 ... $ asr : num [1:28] 416 396 620 520 649 ... $ se : num [1:28] 69.6 64.4 83.1 76.8 83.3 ... > str(Male_sex) tibble [28 × 4] (S3: tbl_df/tbl/data.frame) $ sex : chr [1:28] "Male" "Male" "Male" "Male" ... $ year: num [1:28] 1990 1991 1992 1993 1994 ... $ asr : num [1:28] 780 569 709 678 684 ... $ se : num [1:28] 89.6 67.7 79.9 76.4 78.6 ...
**Session info**
``` r sessionInfo() R version 4.4.0 (2024-04-24 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 10 x64 (build 19045)

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

Could you please give me an advice on exporting jp result as table?

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:

  • I am using years as the x variable, ranging from 2000 to 2020.
  • I have 100 clusters which I am using as the "by" argument.

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.

run_opt creates an empty file and the run_options()'s default has not valid values.

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:

  • Not using the graphic interface of the joinpoint software. I installed the command-line version.
  • The version number in the ReadMe.txt file that lies beside the software .exe is Joinpoint 4.9.0.0 Command.
  • I ran the example you provided on the README file as it is.

1st try: run_opt creates an empty file

Running your code as it is, the run_opt object return as an empty character representation. The same thing happens with export_opt.

image

image

2nd try: default has non-valid values

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 )

image

image

Joinpoint function signals no error but produces non-sensical results

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)

test.nih.joinpoint.pdf

about the file "session_run.RunSummary.txt" , it looks like that the file was created by the code,but it was never been found, i checked the R code and found it no where but a line where it serves as a inut file, could you please check this? thank you very much, best regards

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/.

Session info

``` r #Paste here the output of `sessionInfo()` here ```

export_options() broken with version 5.0

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

Session info

``` r

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>

How to display different groups in the same chart

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.