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

boxplotSubarray() produces a "dangling" boxplot legend when color.by=NULL #27

Open
1 of 3 tasks
amanda-hi opened this issue Nov 29, 2023 · 0 comments
Open
1 of 3 tasks
Assignees
Labels
bug Something isn't working

Comments

@amanda-hi
Copy link
Contributor

amanda-hi commented Nov 29, 2023

Description

When boxplotSubarray() is used without specifying a color variable, a "dangling" legend is produced on the top of the plot. "Dangling" here refers to a legend with only 1 color category (i.e. an uninformative legend). By default, the legend title is removed, so only the box icon is displayed. This shrinks the overall size of the boxplot area (to accommodate the legend), and results in an unclean final plot. The ultimate goal of this package is to produce out-of-the-box, polished figures for SomaScan, and this unused legend would need to be trimmed off of any final figure.

I think this issue stems from the use of a dummy variable for the fill argument of ggplot(). When fill= or color= is specified, a legend is produced by default. In the example below, "class" is a dummy variable that contains no grouping information and is generated and added to plot_data when boxplotSubarray(..., color.by=NULL):

p <- plot_data |>
    ggplot(aes(x = as.character(.id), y = RFU_values, fill = class)) +
    geom_boxplot(notch = TRUE, alpha = 0.75, outlier.alpha = 0.2) +
    scale_fill_soma() +
NULL

Note: this is not an urgent issue, because boxplotSubarray() is typically used with a column specified for the color.by= argument. However, when using the default (color.by=NULL), this uninformative legend is produced.

Output

reprex::reprex(
    SomaPlotr::boxplotSubarray(SomaDataIO::example_data, color.by = NULL)
)

Priority Level

  • High
  • Medium
  • Low

Thanks for reporting 🥳!

@amanda-hi amanda-hi added the bug Something isn't working label Nov 29, 2023
@amanda-hi amanda-hi self-assigned this Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant