CHOP-CGTInformatics / ggswim

Create swimmer plots with ggplot2
https://chop-cgtinformatics.github.io/ggswim/
Other
22 stars 3 forks source link

[FEATURE] Add Arrow Markers to `geom_swim_lane()` #31

Closed rsh52 closed 5 months ago

rsh52 commented 7 months ago

Feature Request Description

A requested feature for markers is to have down-pointing arrows/triangles at certain marker points. For example, in the test data, to have down triangles at infusion/reinfusion points.

Proposed Solution

Add an additional set of parameters and a new geom reference to geom point internal to gridList().

Checklist

rsh52 commented 7 months ago

I believe this should be something as solvable as:

patient_data |> 
  ggswim(mapping = aes(x = start_time, xend = end_time, y = pt_id,
                       color = disease_assessment),
         arrow = status,
         arrow_neck_length = status_length,
         linewidth = linewidth
  ) + 
  new_scale_color() +
  add_marker(
    data = infusion_events,
    aes(x = time_from_initial_infusion, y = pt_id, color = infusion_type),
    position = ggplot2::position_dodge2(width = linewidth/2), shape = 25, size = 5, fill = "black"
  ) +
  scale_color_manual(name = "Markers", values = c("black", "black"))

Thereby not something we even really have to support outside of convenience, but looking to see if I can get a response via SO since linewidth and nudge aren't working how I expect.

rsh52 commented 7 months ago

It seems we have two options with pluses and minuses.

Option 1

Add new parameters to add_marker() to indicate this is to be a indication application.

Pluses

Minuses

Option 2

Create new geoms that handle the calculations themselves and are extensions of geom_segment() and geom_point()

Pluses

Minuses

rsh52 commented 7 months ago

Another complication to keep in mind is that use of ggnewscale::new_scale_color() removes attributes we're currently adding to layers for identification. Issue opened here.

rsh52 commented 6 months ago

Another issue with annotation_custom() is it does not play well with the legend, i.e. it doesn't appear in the legend.

rsh52 commented 5 months ago

Closing this in the interest of updating and rewriting the issue with the new ggswim setup