Skip to content

Commit

Permalink
Merge pull request #1 from neurogenomics/bioc_review
Browse files Browse the repository at this point in the history
Bioc review fix 1
  • Loading branch information
HDash authored Oct 24, 2024
2 parents 9a1eb4a + c224027 commit 32bfd3f
Show file tree
Hide file tree
Showing 58 changed files with 431 additions and 475 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/rworkflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ name: rworkflows
- main
- devel
- RELEASE_**
- '*'
- '!gh-pages'
pull_request:
branches:
- master
- main
- devel
- RELEASE_**
- '*'
- '!gh-pages'
jobs:
rworkflows:
permissions: write-all
Expand Down
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: MotifPeeker
Title: Benchmarking Epigenomic Profiling Methods Using Motif Enrichment
Version: 0.99.4
Version: 0.99.5
Authors@R: c(
person(given = "Hiranyamaya",
family = "Dash",
Expand Down Expand Up @@ -57,7 +57,6 @@ Imports:
BSgenome,
memes,
S4Vectors,
magrittr,
dplyr,
purrr,
tidyr,
Expand Down
10 changes: 1 addition & 9 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,23 @@

export("%>%")
export(MotifPeeker)
export(bpapply)
export(calc_frip)
export(check_ENCODE)
export(check_JASPAR)
export(check_genome_build)
export(denovo_motifs)
export(find_motifs)
export(format_exptype)
export(get_JASPARCORE)
export(get_df_distances)
export(get_df_enrichment)
export(motif_enrichment)
export(motif_similarity)
export(plot_enrichment_individual)
export(plot_enrichment_overall)
export(pretty_number)
export(read_motif_file)
export(read_peak_file)
export(report_command)
export(report_header)
export(save_peak_file)
export(segregate_seqs)
export(summit_to_motif)
export(to_plotly)
export(trim_seqs)
import(BiocParallel)
import(dplyr)
import(ggplot2)
Expand Down Expand Up @@ -55,10 +47,10 @@ importFrom(Rsamtools,countBam)
importFrom(S4Vectors,queryHits)
importFrom(S4Vectors,subjectHits)
importFrom(SummarizedExperiment,assay)
importFrom(dplyr,"%>%")
importFrom(heatmaply,heatmaply)
importFrom(htmltools,tagList)
importFrom(htmlwidgets,JS)
importFrom(magrittr,"%>%")
importFrom(memes,meme_is_installed)
importFrom(memes,runAme)
importFrom(memes,runFimo)
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# MotifPeeker 0.99.5

## Miscellaneous

* Replace `magrittr` import by `dplyr::%>%`.
* Reduce the number of exported functions.
* Move utility functions to 'utilities.R'.
* Allow vignettes to run without MEME suite installed.
* Remove `stopper()` wrapper around `stop()`.
* Use message() for parallel executions


# MotifPeeker 0.99.4

## Miscellaneous
Expand Down
8 changes: 4 additions & 4 deletions R/MotifPeeker.R
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,18 @@ MotifPeeker <- function(
len_alignment_files <- if (is.list(alignment_files))
length(alignment_files) else 1
if (len_peak_files != len_alignment_files) {
stopper(stp_msg)
stop(stp_msg)
}
}
if (!is.null(cell_counts) && length(cell_counts) != length(peak_files)) {
stp_msg <- paste0("Length of ", shQuote("cell_counts"), " must be ",
"equal to ", shQuote("peak_files"), ".")
stopper(stp_msg)
stop(stp_msg)
}
if (denovo_motif_discovery &&
(is.null(denovo_motifs) || denovo_motifs < 1)) {
stp_msg <- "Number of de-novo motifs to find must be greater than 0."
stopper(stp_msg)
stop(stp_msg)
}

### Check duplicate labels ###
Expand All @@ -233,7 +233,7 @@ MotifPeeker <- function(
### Create output folder ###
if (!dir.exists(out_dir)) {
stp_msg <- "Output directory does not exist."
stopper(stp_msg)
stop(stp_msg)
}
out_dir <- file.path(
out_dir,
Expand Down
6 changes: 3 additions & 3 deletions R/bpapply.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#' half_it <- function(arg1) return(arg1 / 2)
#' x <- seq_len(10)
#'
#' res <- bpapply(x, half_it, workers = 2)
#' res <- MotifPeeker:::bpapply(x, half_it, workers = 2)
#' print(res)
#'
#' @export
#' @keywords internal
bpapply <- function(
X,
FUN,
Expand All @@ -36,7 +36,7 @@ bpapply <- function(
stp_msg <- paste("Supplied apply_fun is not a valid BiocParallel function.")
apply_fun_package <- attr(apply_fun, "package")
if (length(apply_fun_package) == 0 ||
apply_fun_package != "BiocParallel") stopper(stp_msg)
apply_fun_package != "BiocParallel") stop(stp_msg)

BPPARAM <- get_bpparam(workers = workers,
progressbar = progressbar,
Expand Down
4 changes: 2 additions & 2 deletions R/check_ENCODE.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ check_ENCODE <- function(encode_id, expect_format, verbose = FALSE) {
if (!grepl(id_pattern, json_data$accession) || is.null(json_data$href)) {
stp_msg <- paste("Error downloading ENCODE JSON data.",
"Check if ID is correct and leads to a file.")
stopper(stp_msg)
stop(stp_msg)
}
ext <- basename(tools::file_ext(json_data$href))
if (!ext %in% expect_format) {
stp_msg <- paste0("Error downloading file from ENCODE.\n",
"Expected file format: ", expect_format,
" but got: ", ext)
stopper(stp_msg)
stop(stp_msg)
}

### Fetch file ###
Expand Down
25 changes: 0 additions & 25 deletions R/check_dep.R

This file was deleted.

16 changes: 0 additions & 16 deletions R/check_duplicates.R

This file was deleted.

2 changes: 1 addition & 1 deletion R/check_genome_build.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ check_genome_build <- function(genome_build) {
". ",
"Try passing a BSgenome object."
)
stopper(stp_msg)
stop(stp_msg)
}
24 changes: 0 additions & 24 deletions R/confirm_meme_install.R

This file was deleted.

58 changes: 25 additions & 33 deletions R/download_button.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,29 @@ download_button <- function(path,
icon = "fa fa-save",
add_button = TRUE,
...) {
if (add_button) {
wrn_msg <- paste("Package", shQuote("downloadthis"), "is required to",
"add download buttons to the HTML report. Skipping",
"download buttons...")
check_dep("downloadthis", fatal = FALSE, custom_msg = wrn_msg)

type <- tolower(type)
if (type == "dir") {
btn <- downloadthis::download_dir(
path = path,
output_name = output_name,
button_label = button_label,
button_type = button_type,
has_icon = has_icon,
icon = icon,
self_contained = TRUE
)
} else if (type == "file") {
btn <- downloadthis::download_file(
path = path,
output_name = output_name,
button_label = button_label,
button_type = button_type,
has_icon = has_icon,
icon = icon,
self_contained = TRUE
)
}

return(btn)
} else {
return(invisible())
}
if (!add_button) return(invisible())

wrn_msg <- paste("Package", shQuote("downloadthis"), "is required to",
"add download buttons to the HTML report. Skipping",
"download buttons...")
check_dep("downloadthis", fatal = FALSE, custom_msg = wrn_msg)

btn_args <- list(
path = path,
output_name = output_name,
button_label = button_label,
button_type = button_type,
has_icon = has_icon,
icon = icon,
self_contained = TRUE
)

type <- tolower(type)
btn <- switch(
type,
"dir" = do.call(downloadthis::download_dir, btn_args),
"file" = do.call(downloadthis::download_file, btn_args)
)

return(btn)
}
2 changes: 1 addition & 1 deletion R/dt_enrichment_individual.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dt_enrichment_individual <- function(result,
motif_i,
reference_index = 1) {
stp_msg <- "reference_index cannot be the same as comparison_i."
if (reference_index == comparison_i) stopper(stp_msg)
if (reference_index == comparison_i) stop(stp_msg)

ref_label <- result$exp_labels[reference_index]
comp_label <- result$exp_labels[comparison_i]
Expand Down
12 changes: 2 additions & 10 deletions R/filter_repeats.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,12 @@ filter_repeats <- function(motifs, filter_n = 6) {
if (is.null(filter_n) || filter_n < 1) return(motifs)

if (filter_n < 4) {
warn_msg <- paste("It is not recommended to filter out motifs with",
"less than 4 consecutive nucleotide repeats.")
warn_msg <- "It is not recommended to filter out motifs with less than 4 consecutive nucleotide repeats."
warning(warn_msg)
}

repeat_pattern <- paste0("([A-Z])\\1{", filter_n - 1, ",}")
good_motif_indices <- vapply(seq_along(motifs$consensus), function(i) {
if (!grepl(repeat_pattern, motifs$consensus[i])) {
return(i)
} else {
return(-1)
}
}, numeric(1))
good_motif_indices <- good_motif_indices[good_motif_indices != -1]
good_motif_indices <- grep(repeat_pattern, motifs$consensus, invert = TRUE)
filtered_motifs <- motifs[good_motif_indices,]
return(filtered_motifs)
}
44 changes: 0 additions & 44 deletions R/format_exptype.R

This file was deleted.

2 changes: 1 addition & 1 deletion R/get_df_distances.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#'
#' @importFrom purrr map_df
#'
#' @return A \code{data.frame} with the following columns:
#' @returns A \code{data.frame} with the following columns:
#' \describe{
#' \item{exp_label}{Experiment labels.}
#' \item{exp_type}{Experiment types.}
Expand Down
Loading

0 comments on commit 32bfd3f

Please sign in to comment.