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

Calculate PGA per chromosome; updates to prettyRainfallPlot #251

Merged
merged 5 commits into from
Dec 20, 2023

Conversation

kmcoyle
Copy link
Member

@kmcoyle kmcoyle commented Dec 20, 2023

Pull Request Checklists

Important: When opening a pull request, keep only the applicable checklist and delete all other sections.

Checklist for all PRs

Required

  • I tested the new code for my use case (please provide a reproducible example of how you tested the new functionality)

  • I ensured all dplyr functions that commonly conflict with other packages are fully qualified.

This can be checked and addressed by running check_functions.pl and responding to the prompts. Test your code after you do this.

  • I generated the documentation and checked for errors relating to the new function (e.g. devtools::document()) and added NAMESPACE and all other modified files in the root directory and under man.

Optional but preferred with PRs

  • I updated and/or successfully knitted a vignette that relies on the modified code (which ones?)

Checklist for New Functions

Required

  • I documented my function using Roxygen style.)

  • Adequate function documentation (see new-function documentation template for more info)

  • I have ran devtools::document() to add the newly created function to NAMESPACE (do not manually add anything to this file!).

Example:

#' @title ASHM Rainbow Plot
#'
#' @description Make a rainbow plot of all mutations in a region, ordered and coloured by metadata.
#'
#' @details This function creates a rainbow plot for all mutations in a region. Region can either be specified with the `region` parameter,
#' or the user can provide a maf that has already been subset to the region(s) of interest with `mutation_maf`.
#' As a third alternative, the regions can also be specified as a bed file with `bed`.
#' Lastly, this function has a variety of parameters that can be used to further customize the returned plot in many different ways.
#' Refer to the parameter descriptions, examples as well as the vignettes for more demonstrations how this function can be called.
#'
#' @param mutations_maf A data frame containing mutations (MAF format) within a region of interest (i.e. use the get_ssm_by_region).
#' @param metadata should be a data frame with sample_id as a column.
#' @param exclude_classifications Optional argument for excluding specific classifications from a metadeta file.
#' @param drop_unmutated Boolean argument for removing unmutated sample ids in mutated cases.
#' @param classification_column The name of the metadata column to use for ordering and colouring samples.
#' @param bed Optional data frame specifying the regions to annotate (required columns: start, end, name).
#' @param region Genomic region for plotting in bed format.
#' @param custom_colours Provide named vector (or named list of vectors) containing custom annotation colours if you do not want to use standartized pallette.
#' @param hide_ids Boolean argument, if TRUE, ids will be removed.
#'
#' @return ggplot2 object.
#'
#' @import dplyr ggplot2
#' @export
#'
#' @examples
#' #basic usage
#' region = "chr6:90975034-91066134"
#' metadata = get_gambl_metadata()
#' plot = ashm_rainbow_plot(metadata = metadata, region = region)
#'
#' #advanced usages
#' mybed = data.frame(start = c(128806578,
#'                              128805652,
#'                              128748315),
#'                    end = c(128806992,
#'                            128809822,
#'                            128748880),
#'                    name = c("TSS",
#'                             "enhancer",
#'                             "MYC-e1"))
#'
#' ashm_rainbow_plot(mutations_maf = my_mutations,
#'                   metadata = my_metadata,
#'                   bed = mybed)
#'
  • My function uses a library that isn't already a dependency of GAMBLR and I made the package aware of this dependency using the function documentation import statement.

Example:

#' @return nothing
#' @export
#' @import tidyverse ggrepel

Checklist for changes to existing code

  • I added/removed arguments to a function and updated documentation for all changed/new arguments

  • I tested the new code for compatibility with existing functionality in the Master branch (please provide a reprex of how you tested the original functionality)

)
}

all_chr <- c(1:22,"X","Y") %>% matrix() %>%
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine to leave like this but when migrating to the child repo I will change this to directly pull from the chr_coordinates object defined just before this 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

seems fine to me!

#'
#' calculate_pga_chr(this_seg = multi_sample_seg)
#'
calculate_pga_chr = function(this_seg,
Copy link
Contributor

Choose a reason for hiding this comment

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

This can probably be an argument in the collate_pga? I think it is fine to keep as is but I can incorporate this into that function when migrating. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

That would work; I think I had a separate collate function elsewhere but inside pga would be most convenient.

stop(
"Labeling SV is only supported when a particular chromosome or zoomed region is plotted."
)
sv_chromosome = 1:22
Copy link
Contributor

Choose a reason for hiding this comment

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

I trust this works for the chr-prefixed too?

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, should probably change to
sv_chromosome = standardize_chr_prefix(incoming_vector = c(1:22,"X","Y"), projection = projection)

scale_color_manual(values = get_gambl_colours("rainfall")) +
ylab("log(IMD)") +
ylab(expression(log[10](IMD))) +
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice trick with expression!

@Kdreval
Copy link
Contributor

Kdreval commented Dec 20, 2023

Thanks for the update! I will merge this and then will transfer the updates to the appropriate child, while also modifying some small things!

@Kdreval Kdreval merged commit 4591d83 into master Dec 20, 2023
1 check failed
@Kdreval
Copy link
Contributor

Kdreval commented Dec 21, 2023

The updates introduced in this PR are now migrated to the appropriate children repos:

  • prettyRainfallPlot() is in GAMBLR.viz (#30)
  • calculate_pga_chr() is an optional argument per_chromosome in calculate_pga() of GAMBLR.utils (#27)
  • collate_pga_chr() is also an optional argument per_chromosome in collate_pga() of GAMBLR.results (#22)

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.

2 participants