Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull Request by Zilin Huang regarding Issue #216 #226

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

huangz73
Copy link

Updated the documentation for scale_ggsurvfit.R to address the issue of truncated number in risk table, along with code example to remedy this issue.

@huangz73 huangz73 marked this pull request as draft October 16, 2024 19:53
@huangz73 huangz73 closed this Oct 16, 2024
@huangz73 huangz73 reopened this Oct 16, 2024
Copy link
Collaborator

@ddsjoberg ddsjoberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @huangz73 !

I left a couple of comments that need to be addressed. Also, you will need to re-document the site with devtools::document().

@@ -34,8 +34,20 @@
#' # specify additional scales
#' ggsurvfit +
#' scale_ggsurvfit(x_scales = list(breaks = seq(0, 8, by = 2)))
#'
#' # Specical case: in the risk table, large numbers (with more than 4 digits) may not
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of putting this text as a comment in the examples section, let's add it to a new section the help file using the #' @details tag.

#' # Specical case: in the risk table, large numbers (with more than 4 digits) may not
#' # be shown completely, with some digits truncated outside the plot region.
#' # To remedy this, consider the following example code for a simulated large-size survival dataset:
#' # Here, adjust the size in `add_risktable(size = 2.5)` (as an example) can decrease the font size of the risk table
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason people see this issue is because the default padding when using scale_ggsurvit() is too restrictive, so the best "fix" is going to live here in this function rather than reducing the font size of the risk table.

The proposed fix is going to be a change to the expand scale argument in this function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ddsjoberg a lot for your suggestion, I've already addressed this issue and inside the new commit.

@ddsjoberg ddsjoberg marked this pull request as ready for review October 16, 2024 20:21
Copy link
Collaborator

@ddsjoberg ddsjoberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more small change and we can merge, thank you

#' @inherit ggsurvfit seealso
scale_ggsurvfit <- function(x_scales = list(), y_scales = list()){
scale_ggsurvfit <-
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put this back on one line?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have already done this. It'll be ready to merge.

Comment on lines +39 to +50
#' Specical case: in the risk table, large numbers (with more than 4 digits) may not
#' be shown completely, with some digits truncated outside the plot region.
#' To remedy this, consider the following example code for a simulated large-size survival dataset:
#' Here, adjust the expand size in `scale_ggsurvfit(x_scales = list(expand = c(0.05, 0)))` (for example)
#' can modify the position of numbers in the risk table
#' and make them all fit in the plot region. The scale of the `expand` argument differs by cases.
#'
#' df_colon_large <- df_colon[sample(1:nrow(df_colon), size = 15*nrow(df_colon), replace = TRUE), ]
#' ggsurvfit <-
#' survfit2(Surv(time, status) ~ surg, data = df_colon_large) %>%
#' ggsurvfit() + add_risktable() +
#' scale_ggsurvfit()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thank you!

upon looking at it, perhaps we don't need the full example, and just keep this part: scale_ggsurvfit(x_scales = list(expand = c(0.05, 0)))

Comment on lines +61 to +62
"Argument {.arg x} does not support {.cls survfit.coxphms} object.
Please fit a multi-state model with another project, such as {.fn coxph}."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you for adding. Let's keep the message simple with "Argument {.arg x} does not support {.cls survfit.coxphms} object.".

Can you also add a unit test to test appropriate error messaging with expect_error()?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ddsjoberg, I'll work with the unit test later (on Issue #222 PR)

@huangz73
Copy link
Author

scale_ggsurvfit.R has an updated documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants