Skip to content

Fix SNP-density plot color parameter and improve API intuition in MVP.Report (issue #116)#118

Open
zankrut20 wants to merge 2 commits into
xiaolei-lab:masterfrom
zankrut20:issue_116
Open

Fix SNP-density plot color parameter and improve API intuition in MVP.Report (issue #116)#118
zankrut20 wants to merge 2 commits into
xiaolei-lab:masterfrom
zankrut20:issue_116

Conversation

@zankrut20

Copy link
Copy Markdown
Contributor

Description

This PR addresses an issue where users were unable to change the colors of the SNP-density plot using the col parameter in MVP.Report. It also fixes a bug that caused a crash when providing a vector of colors to chr.den.col and resolves a documentation warning in MVP.Utility.r.

🛠️ Changes

1. MVP.Report API & Logic Improvements (R/MVP.Report.r)

  • Improved API Intuition: Added a fallback mechanism where MVP.Report now checks if chr.den.col is set to its default value ("black"). If it is, and the user has provided a vector of colors in the col parameter, the function now automatically uses col for the SNP-density plot. This allows users to control the overall color scheme of the report more intuitively.
  • Bug Fix (Logical Coercion): Fixed a critical error: Error in chr.den.col == "black" && is.vector(col) : 'length = 3' in coercion to 'logical(1)'. This occurred because the && operator was used with a logical vector. I replaced the comparison with identical(chr.den.col, "black") to ensure the check is scalar and safe regardless of whether chr.den.col is a single string or a vector.

2. Documentation Updates (README.md)

  • Corrected Examples: Updated the "SNP-density plot" section in the README. The parameter description and the code example now correctly reference chr.den.col instead of col, ensuring users are guided toward the correct parameter for explicit density plot coloring.

3. Roxygen2 Fix (R/MVP.Utility.r)

  • Fixed Documentation Warning: Resolved a Roxygen2 error in the print_info function where the @param authors tag was missing a description. Added "authors of the package" as the description to ensure a clean package check.

🧪 How to Verify

  1. Test SNP-density colors via col:
    # This should now use the provided colors for the density plot
    MVP.Report(pig60K[, c(1:3)], plot.type="d", col=c("purple", "green", "yellow"), file.type="jpg")
Col1 Col0 SNP-Density
  1. Test SNP-density colors via chr.den.col:
    # This should explicitly override and work without errors
    MVP.Report(pig60K[, c(1:3)], plot.type="d", chr.den.col=c("blue", "white", "red"), file.type="jpg")
Col1 Col0 SNP-Density
  1. Run Package Check:
    Run devtools::check() or rhub::rhub_check() to verify that the @param authors warning in MVP.Utility.r is gone.

….Report

Fixed an issue where the col parameter in MVP.Report did not affect the SNP-density plot. Improved API intuition by allowing col to act as a fallback for chr.den.col. Fixed a bug where providing a vector to chr.den.col caused a logical coercion error. Updated README.md and documentation.
Fixed a missing description for the @param authors tag in the print_info function documentation.
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.

1 participant