Skip to content

Commit

Permalink
melt_finemapping_results checks is alreadu melted now
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed Oct 20, 2023
1 parent 59e4f95 commit aa2e176
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions R/is_melted.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
is_melted <- function(dat){
all(c("Method","PP","CS") %in% names(dat))
}
8 changes: 6 additions & 2 deletions R/melt_finemapping_results.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
#' @param dat Fine-mapping results data.
#' @param verbose Print messages.
#'
#' @return Melted \link[data.table]{data.table}
#' @returns Modified \link[data.table]{data.table}
#' with the new columns "Method","PP", and "CS".
#' @export
#' @importFrom data.table melt.data.table data.table
#' @importFrom stats setNames
#' @examples
#' finemap_melt <- echodata::melt_finemapping_results(dat = echodata::BST1)
melt_finemapping_results <- function(dat,
verbose=TRUE){

if(is_melted(dat)){
messager("Data is already melted. Skipping.",v=verbose)
return(dat)
}
PP_cols <- grep("\\.PP$",colnames(dat), value = TRUE)
CS_cols <- grep("\\.CS$",colnames(dat), value = TRUE)
messager("Melting PP and CS from",length(CS_cols),
Expand Down

0 comments on commit aa2e176

Please sign in to comment.