generated from neurogenomics/templateR
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add similar motif scanning and file downloads to denovo motif enrichm…
…ent section
- Loading branch information
Showing
34 changed files
with
913 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#' Create a download button | ||
#' | ||
#' Creates a download button for a file or directory, suitable to embed into | ||
#' an HTML report. | ||
#' | ||
#' @param path A character string specifying the path to the file or directory. | ||
#' @param type A character string specifying the type of download. Either | ||
#' \code{"file"} or \code{"dir"}. | ||
#' @param add_button A logical indicating whether to add the download button to | ||
#' the HTML report. (default = TRUE) | ||
#' @inheritParams downloadthis::download_file | ||
#' @inheritDotParams downloadthis::download_file | ||
#' | ||
#' @importFrom htmltools tagList | ||
#' | ||
#' @inherit downloadthis::download_file return | ||
#' | ||
#' @seealso \code{\link[downloadthis]{download_file}} | ||
#' | ||
#' @keywords internal | ||
download_button <- function(path, | ||
type, | ||
button_label, | ||
output_name = NULL, | ||
button_type = "success", | ||
has_icon = TRUE, | ||
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()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#' Get download buttons for peak file, STREME and TOMOTM output | ||
#' | ||
#' @param comparison_i Index of the comparison pair group. | ||
#' @param start_i Index of the first comparison pair. | ||
#' @param segregated_peaks A list of peak files generated from | ||
#' \code{\link{segregate_seqs}}. | ||
#' @param out_dir A character vector of the directory with STREME and TOMTOM | ||
#' output. | ||
#' @param add_buttons A logical indicating whether to prepare download buttons. | ||
#' @param verbose A logical indicating whether to print messages. | ||
#' | ||
#' @returns A list of download buttons for peak file, STREME and TOMTOM output. | ||
#' | ||
#' @keywords internal | ||
get_download_buttons <- function(comparison_i, | ||
start_i, | ||
segregated_peaks, | ||
out_dir, | ||
add_buttons = TRUE, | ||
verbose = FALSE) { | ||
if (!add_buttons) return(NULL) | ||
messager("Generating download buttons...", v = verbose) | ||
|
||
### Peak file button ### | ||
btns1 <- lapply(seq_len(4), function(x) { | ||
peak_file <- save_peak_file(segregated_peaks[[comparison_i]][[x]]) | ||
download_button( | ||
peak_file, | ||
type = "file", | ||
button_label = "Download: <code>Peak file</code>", | ||
output_name = paste0("peak_", random_string(6)) | ||
) | ||
}) | ||
|
||
### STREME output button ### | ||
btns2 <- lapply(seq_len(4), function(x) { | ||
streme_path <- file.path(out_dir, "streme", start_i + x - 1) | ||
if (!dir.exists(streme_path)) return(NULL) | ||
download_button( | ||
streme_path, | ||
type = "dir", | ||
button_label = "Download: <code>STREME output</code>", | ||
output_name = paste0("streme_", random_string(6)) | ||
) | ||
}) | ||
|
||
### TOMTOM output button ### | ||
btns3 <- lapply(seq_len(4), function(x) { | ||
tomtom_path <- file.path(out_dir, "tomtom", start_i + x - 1) | ||
if (!dir.exists(tomtom_path)) return(NULL) | ||
download_button( | ||
tomtom_path, | ||
type = "dir", | ||
button_label = "Download: <code>TOMTOM output</code>", | ||
output_name = paste0("tomtom_", random_string(6)) | ||
) | ||
}) | ||
|
||
all_btns <- list( | ||
peak_file = btns1, | ||
streme_output = btns2, | ||
tomtom_output = btns3 | ||
) | ||
return(all_btns) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.