-
Notifications
You must be signed in to change notification settings - Fork 0
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
Gate annotation in DensityScatterPlot #75
Conversation
b3648a3
to
c3a9281
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, but I will try it out on some examples to get a feel for how to use these additions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some minor edits to the code (updated assertions and applied our styling) but everything seems to work as expected.
I know that multiple people have worked on this function now but if there's anything I'd ask for (if time allows) would be to refactor parts of the code into smaller parts and document some of the more complicated steps. Right now it's quite complicated to follow. For example, the code to create density_plot_x
and density_plot_y
is virtually the same except for a coord_flip()
. This code could be wrapped in a small internal function.
Thanks for taking the time to go through it. I completely agree that the code can be a bit hard to follow at times. I am considering to just delay merging this a bit to try and refactor the code. This is important functionality that we will likely expand on so maintainability/readability is important. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one comment to add on the documentation :)
Otherwise I agree with Ludvig that a refactorization would do wonders for this function.
R/density_scatter_plot.R
Outdated
#' @param marker1 Name of first marker to plot. | ||
#' @param marker2 Name of second marker to plot. | ||
#' @param facet_vars Optional character vector of length 1 or 2 specifying variables to facet by. | ||
#' @param plot_gate Optional data frame containing gate parameters. If provided, `gate_type` must also be specified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to specify the format of the plot_gate
either here or in a details section below. This information should be provided somewhere:
A data frame with columns 'xmin', 'xmax', 'ymin', 'ymax' to plot a gate. This data frame can also contain the variables in 'facet_vars' to plot different gates in different facets.
Would also be important to specify the format of plot_gate
if gate_type = "quadrant"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expanded the documentation for plot_gate
to specify the format of the dataframe.
Also split up the function into a few parts and wrapped them in internal functions, which should make the code easier to follow (I hope).
0ed6538
to
b0815e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work. It's much easier to follow now!
I just had one comment on the assertions that should be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just add the expect_MASS
utility function please.
R/density_scatter_plot.R
Outdated
gate_data <- gate_data %>% | ||
group_by(!!!syms(facet_vars)) %>% | ||
group_modify(function(.x, .y) { | ||
# Get the current facet's data by filtering based on group keys | ||
current_data <- if (!is.null(facet_vars)) { | ||
filter_conds <- lapply(facet_vars, function(var) { | ||
facet_var <- sym(var) | ||
quo(!!facet_var == .y[[var]]) | ||
}) | ||
plot_data %>% | ||
filter(!!!filter_conds) | ||
} else { | ||
plot_data | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be a bit difficult to follow, but as long it works all is good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few intermediate steps which can be skipped. I refactored this part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, well done!
Description
This PR improves gate annotations in density scatter plots and introduces a new gate type. The changes include:
geom_text
geom_text
Fixes: TECH-228
Type of change
How Has This Been Tested?
The changes have been tested with the following test cases:
Gate Types:
Gate Annotation Parameters:
PR checklist: