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

plot pgs densities #24

Merged
merged 31 commits into from
Apr 15, 2024
Merged

plot pgs densities #24

merged 31 commits into from
Apr 15, 2024

Conversation

alkaZeltser
Copy link
Collaborator

@alkaZeltser alkaZeltser commented Mar 27, 2024

  • Add function for plotting density curves, optionally split by categorical phenotypes

  • Add tests for said function

  • I have read the code review guidelines and the code review best practice on GitHub check-list.

  • The name of the branch is meaningful and well formatted following the standards, using [AD_username (or 5 letters of AD if AD is too long)-[brief_description_of_branch].

  • I have set up or verified the branch protection rule following the github standards before opening this pull request.

  • I have added the changes included in this pull request to NEWS under the next release version or unreleased, and updated the date.

  • I have updated the version number in metadata.yaml and DESCRIPTION.

  • Both R CMD build and R CMD check run successfully.

Testing Results

All tests pass

R/plot-pgs.R Outdated
Comment on lines 142 to 154
density.multipanel <- BoutrosLab.plotting.general::create.multipanelplot(
plot.objects = pgs.density.plots,
filename = file.path(output.dir, filename.for.density.multiplot),
layout.height = 1,
layout.width = length(pgs.density.plots),
main = '',
main.cex = 0,
width = width,
height = height
);

}
return(density.multipanel); # this returns null when filename is provided to create.multipanelplot
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dan-knight Pulling you in for a BPG question:
It seems that create.multipanelplot does not return a plot object if a filename is specified (it just writes the plot to the file). Is that expected behavior? Also, when an object is returned, it seems to be of class "multipanel" - is that something that was made up for BPG or is that an actual lattice-related class?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. Off the top of my head, I don't think that should be the case. That would be inconsistent with the other plotting functions. It's possible that there's some technical limitation specific to multipanel plots, but I'd hope that wouldn't be the case. You can see here that it's returning the grob rather than returning the result of write.plot. This is inconsistent with other plotting functions..

The class name is set here. I think that should be changed to include the other trellis/grid classnames (adding multipanel) rather than setting it to only multipanel.

@alkaZeltser alkaZeltser marked this pull request as ready for review April 11, 2024 22:09
R/run-pgs-statistics.R Outdated Show resolved Hide resolved
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dan-knight would appreciate your thoughts on how my tests turned out. Is there a way to check dimensions of a multipanel object? I couldn't figure it out.

Copy link
Contributor

Choose a reason for hiding this comment

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

Look good to me! I left another comment in the code, but the tests look good. I think with plotting code like this, you can accomplish a lot with validation as you have here. It's much easier to test, and lets you handle problems earlier on (rather than deep in the internal plotting code).

@alkaZeltser alkaZeltser changed the title plot pgs summaries plot pgs densities Apr 11, 2024
Copy link

@forbiddenpersimmon forbiddenpersimmon left a comment

Choose a reason for hiding this comment

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

LGTM!

density.multipanel <- BoutrosLab.plotting.general::create.multipanelplot(
plot.objects = pgs.density.plots,
filename = output.path,
layout.height = 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Only way you might test this is if you broke this logic out into another function and tested that. For example, you might write get.pgs.layout() which returns a width and height value. Then, you could test those values. This logic is sufficiently simple that it's probably not necessary unless you see the layout changing or becoming more complex in the future.

@dan-knight dan-knight self-requested a review April 15, 2024 23:21
@alkaZeltser alkaZeltser merged commit 4a3bc42 into main Apr 15, 2024
7 checks passed
@alkaZeltser alkaZeltser deleted the nzeltser-plot-pgs branch April 15, 2024 23:59
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.

3 participants