-
Notifications
You must be signed in to change notification settings - Fork 20
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
Feature request: Allow/retain strata fill mapping when only one level is present #155
Comments
Thanks for the post @RiversPharmD . As you noted, it's a bit tricky because the Can you provide more details on what you want to see when there are unobserved levels? Are you looking to have the colors match when there is only one level and when there is more than one level? Do you expect the unobserved levels to appear in the legend? In the risktable? |
Of course! I don't necessarily expect this to be fixed by y'all, but I would love it. My naive exploration of this issue suggests two phenotypes, one that occurs when we go from For the specific case where we go from 2 levels to 1, in rank order of what I would selfishly prefer being solved:
Happy to find time to chat if that's easier. |
I think this kind of update would be a lot of work with many edge cases that would need to be accounted for. Just an FYI, I don't have immediate plans to look into this, but I'll leave the issue open for review in the future. Couple of notes for myself:
|
No stress @ddsjoberg, I appreciate you taking the time to consider this feedback/feature. |
I have a request similar to the one here. I have two groping variables (à two levels) that I want to use. |
Is your feature request related to a problem? Please describe.
I often loop over subsets of data to generate survival plots for the sub-populations. When the stratifying variable is only present in one level in the sub-population, the formatting for that variable is lost. Because it is lost at the fitting of the survival curve, changing the scale_fill_* or the scale_color_* values do not solve this problem.
Describe the solution you'd like
A perfect solution would be one that checks if any levels of the factor used to stratify the survival plot are not present in the
survfit()/survfit2()
call. If they are not present, it automatically reformats the fill and color variables, as well as the legend, to contain all levels of the factor. This could be controlled by a boolean input to theggsurvfit()
function, such asggsurvfit(..., drop_unused_factors = TRUE)
Describe alternatives you've considered
Alternatives to this solution would be directly modifying the raw data to include a single patient with 0 survival time, but this runs the risk of contaminating downstream analyses. I'm not familiar enough with the structure of the output of the
survfit()
call, but this would be another opportunity to address the missing factors.I think that because the "problem" is associated with the visualization function, the cleanest solution is one that is close to the source of the problem.
Additional context
Here's a reprex with dummy data to illustrate what I'm experiencing
Created on 2023-06-21 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: