diff --git a/DESCRIPTION b/DESCRIPTION index 224b451..1feae68 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,15 +1,21 @@ Package: Rseb Type: Package Title: A package for NGS data managing and visualization -Version: 0.1.6 +Version: 0.1.7 Author: Sebastian Gregoricchio Maintainer: Sebastian Gregoricchio Description: An R-package for daily tasks required to handle biological data as well as avoid re-coding of small functions for quick but necessary data managing. License: GNU GENERAL PUBLIC LICENSE version 3 Depends: - R (>= 3.2.0), BiocManager, Biostrings, biomaRt, GO.db, rtracklayer, cowplot, data.table, ggplot2 (>= 3.3.3), ggrepel, matrixStats, plyr, dplyr, purrr, robustbase, stringr, tidyr, tools, labeling, devtools, rvcheck, curl + R (>= 4.0.0) +Imports: + BiocManager, Biostrings, biomaRt, GO.db, rtracklayer, cowplot, data.table, ggplot2 (>= 3.3.3), ggrepel, ggpubr, matrixStats, plyr, dplyr, tidyr, purrr, robustbase, stringr, tools, devtools, rvcheck, curl biocViews: Encoding: UTF-8 LazyData: true RoxygenNote: 7.1.1 -git_url: https://github.com/sebastian-gregoricchio/Rseb/ +URL: + https://sebastian-gregoricchio.github.io/Rseb/ + https://github.com/sebastian-gregoricchio/Rseb/ + https://sebastian-gregoricchio.github.io/ +BugReports: https://github.com/sebastian-gregoricchio/Rseb/issues diff --git a/NEWS.md b/NEWS.md index 1402e83..b6ee4c2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -53,6 +53,24 @@ First releasing * Optimization for different labeling and better handle of Y-axis autoscale in `plot.density.profile` function * Optimization of `uniform.x.axis` and `uniform.y.axis` with the new functions `floating.ceiling` and `floating.floor` and to support a given number of digits +
+ +#### [v0.1.7](https://github.com/sebastian-gregoricchio/Rseb/releases/tag/0.1.7) - February 20th 2021 +* Updated information in DESCRIPTION file +* Updated the dependencies to require an R version >= 4.0.0 +* Moved all "depending" packages in "imports" to avoid attaching of all packages. Morover, added `ggpubr` and removed `labeling` +* Bug fixing in `actualize` and `uniform.x.axis` functions +* Optimization for better definition of the breaks in the functions `uniform.x.axis` and `uniform.y.axis` +* Optimization of package handling for `plot.density.summary` and `plot.density.profile` +* Optimized color handling for summary plots in `plot.density.summary` function +* Now computation and plot of the statistical mean comparisons is available for `plot.density.summary` +* In the `plot.density.summary` function a density profile corresponding to the summary plot subset range is generated +* The data.table of `plot.density.summary` now contains also the orignal positions used to generate the matrix +* Optimization of `IGVsnap` function and improvment of relative manual information +* `IGVsnap` allows the addiction of a delay time between snap generation + + +

diff --git a/R/IGVsnap.R b/R/IGVsnap.R index a6cfdea..fad9a12 100644 --- a/R/IGVsnap.R +++ b/R/IGVsnap.R @@ -6,14 +6,15 @@ #' @param input_type Define the input type. Allowed values are \code{genes} and \code{regions}. #' @param biomart Defines the \code{biomart} parameter for \code{biomaRt} package, by default \code{ensembl}. #' @param dataset Defines the \code{dataset} parameter for \code{biomaRt} package, by default \code{mmusculus_gene_ensembl}. -#' @param reference_genome [optional] Defines the genome to use, e.g. "mm10", "hg19", ... . By default \code{NULL}. -#' @param fivePrime Numeric value to define how many bases [bp] exapand from full gene position at it's 5'-end, default 1000bp. -#' @param threePrime Numeric value to define how many bases [bp] exapand from full gene position at it's 3'-end, default 1000bp. +#' @param reference_genome [optional] Defines the genome to use, e.g. "mm9", "mm10", "hg19", "hg38", ... . By default \code{NULL}. +#' @param fivePrime Numeric value to define of how many base-pairs (bp) expand from full gene position at it's 5'-end, default 1000bp. +#' @param threePrime Numeric value to define of how many base-pairs (bp) expand from full gene position at it's 3'-end, default 1000bp. #' @param snap_names [optional] String vector to define the names of images (without extention), by default uses \code{loci_vector}. #' @param IGV_batch_file String for the batch_script_file_name/path, by default \code{/IGV_batch.txt}. #' @param snap_image_format String to define the format of the images, e.g. "png", "jpeg", "svg", ... . By default \code{png}. #' @param snap_directory String for the output directory for the snapshoots. By default . -#' @param maxPanelHeight Numeric value to define the height in pixel of the IGV pannel that will be captured on IGV. +#' @param maxPanelHeight Numeric value to define the height in pixel of the IGV pannel that will be captured on IGV. By default \code{1000}. +#' @param delay.interval Sets a delay (sleep) time in milliseconds. The sleep interval is invoked between successive commands. By default \code{10}. helps to give the time to IGV to adapt the view before the snap (such as the autoscale). #' @param session [optional] FULL path to an IGV session file (session.xml) to use for the images. By default \code{NULL}. #' @param exit Logical value to indicate whether exit IGV after image capture ended. By default \code{FALSE}. #' @@ -41,6 +42,7 @@ IGVsnap = function(loci_vector, snap_image_format = "png", snap_directory = getwd(), maxPanelHeight = 1000, + delay.interval = 10, session = NULL, exit = FALSE) { @@ -64,6 +66,7 @@ IGVsnap = function(loci_vector, "snap_image_format image format such as 'png', 'jpeg', 'svg', ..., by default 'png'. \n", " snap_directory output directory for snapshoots, by default . \n", " maxPanelHeight heigth in pixel of the IGV pannel that will be captured. \n", + " delay.interval Sets a delay (sleep) time in milliseconds. The sleep interval is invoked between successive commands, default 10. \n", " session [optional] define an IGV session file .xml to use for the images, 'NULL' by default - USE FULL PATH -. \n", " exit logical to indicate whether exit IGV after image capture ended, FALSE by default. \n", " help logical to indicate whether display the help, FALSE by default. \n", @@ -116,7 +119,7 @@ IGVsnap = function(loci_vector, } else if (input_type == "regions") { if (is.null(snap_names)) {snap_names = loci_vector} - list = unique(loci_vector) + list = loci_vector } # Initialization/Creation of the batch_file @@ -130,7 +133,7 @@ IGVsnap = function(loci_vector, append = T) } else if (!is.null(reference_genome)){ write(file = IGV_batch_file, - x = paste("genome", reference_genome), + x = paste("genome", tolower(reference_genome)), append = T) } @@ -152,6 +155,11 @@ IGVsnap = function(loci_vector, x = paste("goto", list[i]), append = T) + # Write the command to delay interval + write(file = IGV_batch_file, + x = paste("setSleepInterval", delay.interval), + append = T) + # Write the command to take a snapshot with the name of the gene/position with the chosen extension write(file = IGV_batch_file, x = paste("snapshot ", snap_names[i], "_snapshot.", snap_image_format, sep =""), diff --git a/R/actualize.R b/R/actualize.R index 1c546e2..74fc1d9 100644 --- a/R/actualize.R +++ b/R/actualize.R @@ -1,41 +1,56 @@ -#' @title \code{Rseb} updates verification -#' -#' @description It verifies if \code{Rseb} is up-to-date and installs it when required. -#' -#' @param update Logical value to define whether update the \code{Rseb} package. By default \code{TRUE}. -#' @param verbose Logical value to define whether print messages. By default \code{TRUE}. -#' @param force Logical value to define whether to force the installation of \code{Rseb} even though already up-to-date. Parameter passed to \code{devtools::install_github()}. By default \code{FALSE}. -#' -#' @return Warnings and/or messages. Installation of the latest version of \code{Rseb} if required. -#' -#' @details This function will check for internet availability. -#' -#' @export actualize - - -actualize = function(update = TRUE, - verbose = TRUE, - force = FALSE) { - - # Check internet connection - if (isFALSE(curl::has_internet())) {return(invisible(NULL))} - - # Store Rseb package versions - check = suppressMessages(rvcheck::check_github("sebastian-gregoricchio/Rseb")) - # When up-to-date == NA it means that it is a developmental version higher then the last release - if (is.na(check$up_to_date)) {return(invisible(NULL))} - - # Check if Rseb is up-to-date - if (check$up_to_date == FALSE) { - return(warning(paste("The Rseb package is not up-to-date. Installed version", - check$installed_version, "-->", check$latest_version, - "available. \nTo update Rseb type: Rseb::actualize()"))) - } - - # Update Rseb if required - if (check$up_to_date == FALSE & update == TRUE) { - devtools::install_github("sebastian-gregoricchio/Rseb", force = force) - } else if (verbose == T) { - return(message(paste("Rseb's latest version (v", check$installed_version, ") is already installed.", sep = "")))} - -} # END function +#' @title \code{Rseb} updates verification +#' +#' @description It verifies if \code{Rseb} is up-to-date and installs it when required. +#' +#' @param update Logical value to define whether update the \code{Rseb} package. By default \code{TRUE}. +#' @param verbose Logical value to define whether print messages. By default \code{TRUE}. +#' @param force Logical value to define whether to force the installation of \code{Rseb} even though already up-to-date. Parameter passed to \code{devtools::install_github()}. By default \code{FALSE}. +#' +#' @return Warnings and/or messages. Installation of the latest version of \code{Rseb} if required. +#' +#' @details This function will check for internet availability. +#' +#' @export actualize + + +actualize = function(update = TRUE, + verbose = TRUE, + force = FALSE) { + + # Check internet connection + if (isFALSE(curl::has_internet())) {return(invisible(NULL))} + + # Store Rseb package versions + check = suppressMessages(rvcheck::check_github("sebastian-gregoricchio/Rseb")) + # When up-to-date == NA it means that it is a developmental version higher then the last release + if (is.na(check$up_to_date)) {return(invisible(NULL))} + + # Check if Rseb is up-to-date and return a message if not up-to-date + if (check$up_to_date == FALSE) { + message = paste("| The 'Rseb' package is not up-to-date. Installed version", + check$installed_version, "-->", check$latest_version, + "available. |") + command = "| To update Rseb type: Rseb::actualize()" + + return(message(paste("\033[0;37;44m", + paste(rep("-", nchar(message)), collapse = ""), + "\n", message, "\n", + command, paste(rep(" ", (nchar(message) - nchar(command)) - 1), collapse = ""), "|", + "\n", paste(rep("-", nchar(message)), collapse = ""), + "\033[0m", + sep = ""))) + } + + + + # Update Rseb if required + if (check$up_to_date == F & update == T) {devtools::install_github("sebastian-gregoricchio/Rseb")} + else if (check$up_to_date == T) { + if (force == T) {devtools::install_github("sebastian-gregoricchio/Rseb", force = force)} + else if (verbose == T) {return(message(paste("Rseb's latest version (v", check$installed_version, ") is already installed.", sep = "")))} + } + + + + +} # END function \ No newline at end of file diff --git a/R/plot.density.profile.R b/R/plot.density.profile.R index 13f5258..d714fe2 100644 --- a/R/plot.density.profile.R +++ b/R/plot.density.profile.R @@ -58,7 +58,6 @@ #' #' @export plot.density.profile #' -# @import tidyr # @import dplyr # @import ggplot2 # @importFrom data.table fread @@ -107,7 +106,6 @@ plot.density.profile = function( ############################################################################## # Load all libraries - require(tidyr) require(dplyr) require(ggplot2) # require(data.table) diff --git a/R/plot.density.summary.R b/R/plot.density.summary.R index 2caf281..a0fcaff 100644 --- a/R/plot.density.summary.R +++ b/R/plot.density.summary.R @@ -55,6 +55,7 @@ #' \item \code{data.table} with the computed values used for the plot; #' \item \code{metadata} table with the information obtained from the matrix_file.gz; #' \item \code{plot.list} with a plot for each list element; +#' \item \code{density.profile} with the density profile of the mean signal generated by \link{plot.density.profile} corresponding to the regions/samples for which the summary multiplot have been generated; #' \item \code{multiplot} with the image of all the plots together; #' \item \code{summary.plot.samples} with a plot showing the scores of all regions per each sample; #' \item \code{summary.plot.regions} with a plot showing the scores of all samples per each region; @@ -66,7 +67,6 @@ #' #' @export plot.density.summary #' -# @import tidyr # @import dplyr # @import ggplot2 # @importFrom data.table fread @@ -77,7 +77,6 @@ # @importFrom purrr reduce # @importFrom cowplot plot_grid # @importFrom tools toTitleCase -# @importFrom labeling extended plot.density.summary = function( matrix.file, @@ -127,7 +126,6 @@ plot.density.summary = function( ############################################################################## # Load all libraries - require(tidyr) require(dplyr) require(ggplot2) # require(ggpubr) @@ -138,7 +136,6 @@ plot.density.summary = function( # require(purrr) # require(cowplot) # require(tools) - # require(labeling) # Check if Rseb is up-to-date # Rseb::actualize(update = F, verbose = F) @@ -953,10 +950,48 @@ plot.density.summary = function( ############################################################################## # RETURN a list of data + ## generate the table with regions (from the matrix, equivalent to the bed used) to add then to the full.stat.table + + # Bed files from original matrix + regions.position = m$matrix.data[, 1:6] + names(regions.position) = c("chr", "start", "end", "name", "score", "strand") + + # Repeating the regions n times as the number of samples + regions.position = purrr::reduce(.x = replicate(n = length(unique(full.stat.table$sample)), + expr = regions.position, + simplify = F), + .f = rbind) + + + # Generation of density profile + density.profile = Rseb::plot.density.profile(matrix.file = matrix.file, + plot.by.group = plot.by.group, + missing.data.as.zero = missing.data.as.zero, + sample.names = sample.names, + region.names = region.names, + signal.type = "mean", + error.type = error.type, + plot.error = T, + x.lim = subset.range, + y.lim = y.lim, + y.identical.auto = F, + y.ticks.interval = , + y.digits = y.digits, + text.size = text.size, + legend.position = legend.position, + plot.vertical.lines = T, + write.reference.points = F, + colors = colors, + n.row.multiplot = n.row.multiplot, + by.row = by.row, + print.multiplot = F) + + # Build the output list if (show.stat.multiplot == T) { - return(list(data.table = full.stat.table, + return(list(data.table = cbind(regions.position, full.stat.table), metadata = metadata, plot.list = plot.list, + density.profile = density.profile$multiplot, multiplot = multiplot, summary.plot.samples = summary.plot.samples, summary.plot.regions = summary.plot.groups, @@ -965,6 +1000,7 @@ plot.density.summary = function( return(list(data.table = full.stat.table, metadata = metadata, plot.list = plot.list, + density.profile = density.profile$multiplot, multiplot = multiplot, summary.plot.samples = summary.plot.samples, summary.plot.regions = summary.plot.groups, diff --git a/R/substract.bw.R b/R/substract.bw.R index 7a2d14d..faf3cbc 100644 --- a/R/substract.bw.R +++ b/R/substract.bw.R @@ -4,9 +4,8 @@ #' #' @param bw1 Full path to the first bigWig (the second one will be substracted to this one). #' @param bw2 Full path to the second bigWig (it will be substracted to the first one). -#' @param return.substracted.bw Logic value to define whether return the resulting bigWig as GRanges object. By default \code{FALSE}. -#' @param export.substracted.bw Logic value to define whether export the resulting bigWig. By default \code{TRUE}. -#' @param substracted.bw.file String for the path of the resulting bigwig file to be exported. \cr By default \code{/subtraction.bw}. +#' @param return.substracted.bw Logic value to define whether return the resulting bigWig as GRanges object. By default \code{TRUE}. +#' @param substracted.bw.file String for the path of the resulting bigwig file to be exported. \cr By default \code{NULL}, any file will be exported. #' #' @return If required a subtraction bigWig is returned as GRanges object. The resulting bigWig can be also directly exported. #' @@ -17,10 +16,8 @@ substract.bw = function(bw1, bw2, - wd = getwd(), - return.substracted.bw = F, - export.substracted.bw = T, - substracted.bw.file = paste(getwd(), "subtraction.bw", sep = "/")) { + return.substracted.bw = T, + substracted.bw.file = NULL) { #-----------------------------# # Check if Rseb is up-to-date # @@ -63,9 +60,9 @@ substract.bw = function(bw1, score(bws[[1]]) = score(bws[[1]]) - score(bws[[2]]) # Export the subtracted file if required - if (export.substracted.bw == T) { + if (!is.null(substracted.bw.file)) { export(bws[[1]], substracted.bw.file) - message("The result was exported has", substracted.bw.file) + message("The resulting bigWig was exported has", substracted.bw.file) } # Return the subtracted bigWig if required diff --git a/R/uniform.x.axis.R b/R/uniform.x.axis.R index be88fb3..1f90cdd 100644 --- a/R/uniform.x.axis.R +++ b/R/uniform.x.axis.R @@ -1,98 +1,103 @@ -#' @title Plot X-axis uniforming -#' -#' @description Takes a list of ggplot2 plots, compares their X-axis ranges and applies the highest/lowest limits to each plot in order to uniform all the plots. It can be used also to set the ticks step (to just change the breaks set all parameters as \code{FALSE}). -#' -#' @param plot.list A single plot or a list of plots. -#' @param x.min Either a logical value to define whether uniform the lower limit or a numeric value defining the lower limit. By default \code{TRUE}. -#' @param x.max Either a logical value to define whether uniform the upper limit or a numeric value defining the upper limit. By default \code{TRUE}. -#' @param ticks.each Numeric value to define every how much should be placed a tick. By default \code{NULL}, ticks will be placed automatically. -#' @param digits A single integer indicating the maximum number of digits required for the rounding of the axis values. -#' -#' @return Returns a plot list (or a single plot when only one input plot is provided) equivalent to the input list provided by the user in which the X-axis of all the plots will be uniformed. -#' -#' @export uniform.x.axis - -uniform.x.axis = function( - plot.list, - x.min = TRUE, - x.max = TRUE, - ticks.each = NULL) - -{ # BEGIN function ----------------------------------------------------------------------- - - #-----------------------------# - # Check if Rseb is up-to-date # - Rseb::actualize(update = F, verbose = F) # - #-----------------------------# - - # Check list length - if (!("list" %in% class(plot.list))) { - if ("ggplot" %in% class(plot.list) | "gg" %in% class(plot.list)) { - plot.list = list(plot.list) - } else { - return(warning("The 'plot.list' parameter must be a ggplot object or a list of ggplot objects."))} - } - - - - # Load required libraries - require(ggplot2) - - - - # Get current X ranges - x.min_list = c() - x.max_list = c() - - for (i in 1:length(plot.list)) { - x.min_list = c(x.min_list, ggplot_build(plot.list[[i]])$layout$panel_params[[1]]$x$limits[1]) - x.max_list = c(x.max_list, ggplot_build(plot.list[[i]])$layout$panel_params[[1]]$x$limits[2]) - } - - - - # Re-define the limits - if (length(x.min) != 1 | length(x.max) != 1) {return(warning("The 'x.min' and 'x.max' parameters must be either a unique logical or numeric value."))} - - if (is.na(x.min) | is.numeric(x.min) | is.null(x.min)) { - new_x.min = x.min} else if (x.min == TRUE) { - new_x.min = min(x.min_list)} else { - new_x.min = NA} - - if (is.na(x.max) | is.numeric(x.max) | is.null(x.max)) { - new_x.max = x.max} else if (x.max == TRUE) { - new_x.max = max(x.max_list)} else { - new_x.max = NA} - - # Rund the new range - if (!is.na(new_x.min)) {new_x.min = Rseb::floating.floor(new_x.min, digits = digits)} - if (!is.na(new_x.max)) {new_x.max = Rseb::floating.ceiling(new_x.max, digits = digits)} - - - # Re-define breaks - if (!is.null(ticks.each)) { - breaks_list = list() - - for (i in 1:length(plot.list)) { - min = ifelse(test = is.na(new_x.min), yes = x.min_list[i], no = new_x.min) - max = ifelse(test = is.na(new_x.max), yes = x.max_list[i], no = new_x.max) - breaks_list[[i]] = seq(min, max, ticks.each) - } - } - - - - # Re-define the X-axis - for (i in 1:length(plot.list)) { - if (is.null(ticks.each)) { - plot.list[[i]] = plot.list[[i]] + scale_x_continuous(limits = c(new_x.min, new_x.max)) - } else { - plot.list[[i]] = plot.list[[i]] + scale_x_continuous(breaks = breaks_list[[i]], limits = c(new_x.min, new_x.max)) - } - } - - - # Return the modified plots - if (length(plot.list) == 1) {return(plot.list[[1]])} else {return(plot.list)} - -} # END function +#' @title Plot X-axis uniforming +#' +#' @description Takes a list of ggplot2 plots, compares their X-axis ranges and applies the highest/lowest limits to each plot in order to uniform all the plots. It can be used also to set the ticks step (to just change the breaks set all parameters as \code{FALSE}). +#' +#' @param plot.list A single plot or a list of plots. +#' @param x.min Either a logical value to define whether uniform the lower limit or a numeric value defining the lower limit. By default \code{TRUE}. +#' @param x.max Either a logical value to define whether uniform the upper limit or a numeric value defining the upper limit. By default \code{TRUE}. +#' @param ticks.each Numeric value to define every how much should be placed a tick. By default \code{NULL}, ticks will be placed automatically. +#' @param digits A single integer indicating the maximum number of digits required for the rounding of the axis values. By default \code{1}. +#' +#' @return Returns a plot list (or a single plot when only one input plot is provided) equivalent to the input list provided by the user in which the X-axis of all the plots will be uniformed. +#' +#' @export uniform.x.axis + +uniform.x.axis = function( + plot.list, + x.min = TRUE, + x.max = TRUE, + ticks.each = NULL, + digits = 1) + +{ # BEGIN function ----------------------------------------------------------------------- + + #-----------------------------# + # Check if Rseb is up-to-date # + Rseb::actualize(update = F, verbose = F) # + #-----------------------------# + + # Check list length + if (!("list" %in% class(plot.list))) { + if ("ggplot" %in% class(plot.list) | "gg" %in% class(plot.list)) { + plot.list = list(plot.list) + } else { + return(warning("The 'plot.list' parameter must be a ggplot object or a list of ggplot objects."))} + } + + + + # Load required libraries + require(ggplot2) + + + + # Get current X ranges + x.min_list = c() + x.max_list = c() + + for (i in 1:length(plot.list)) { + x.min_list = c(x.min_list, ggplot_build(plot.list[[i]])$layout$panel_params[[1]]$x$limits[1]) + x.max_list = c(x.max_list, ggplot_build(plot.list[[i]])$layout$panel_params[[1]]$x$limits[2]) + } + + + + # Re-define the limits + if (length(x.min) != 1 | length(x.max) != 1) {return(warning("The 'x.min' and 'x.max' parameters must be either a unique logical or numeric value."))} + + if (is.na(x.min) | is.numeric(x.min) | is.null(x.min)) { + new_x.min = x.min} else if (x.min == TRUE) { + new_x.min = min(x.min_list)} else { + new_x.min = NA} + + if (is.na(x.max) | is.numeric(x.max) | is.null(x.max)) { + new_x.max = x.max} else if (x.max == TRUE) { + new_x.max = max(x.max_list)} else { + new_x.max = NA} + + # Round the new range + if (!is.na(new_x.min)) {new_x.min = Rseb::floating.floor(new_x.min, digits = digits)} + if (!is.na(new_x.max)) {new_x.max = Rseb::floating.ceiling(new_x.max, digits = digits)} + + + # Re-define breaks + if (!is.null(ticks.each)) { + breaks_list = list() + ticks.each = round(ticks.each, digits = digits) + + for (i in 1:length(plot.list)) { + min = ifelse(test = is.na(new_x.min), yes = x.min_list[i], no = new_x.min) + max = ifelse(test = is.na(new_x.max), yes = x.max_list[i], no = new_x.max) + min = floor((min/ticks.each)) * ticks.each # gets minimum multiple of the ticks bin + max = ceiling((max/ticks.each)) * ticks.each # gets maximum multiple of the ticks bin + breaks_list[[i]] = seq(from = min, to = max, by = ticks.each) + breaks_list[[i]] = breaks_list[[i]][breaks_list[[i]] >= new_x.min & breaks_list[[i]] <= new_x.max] # removes ticks not in the axis range + } + } + + + + # Re-define the X-axis + for (i in 1:length(plot.list)) { + if (is.null(ticks.each)) { + plot.list[[i]] = plot.list[[i]] + scale_x_continuous(limits = c(new_x.min, new_x.max)) + } else { + plot.list[[i]] = plot.list[[i]] + scale_x_continuous(breaks = breaks_list[[i]], limits = c(new_x.min, new_x.max)) + } + } + + + # Return the modified plots + if (length(plot.list) == 1) {return(plot.list[[1]])} else {return(plot.list)} + +} # END function \ No newline at end of file diff --git a/R/uniform.y.axis.R b/R/uniform.y.axis.R index d20369d..6ea6971 100644 --- a/R/uniform.y.axis.R +++ b/R/uniform.y.axis.R @@ -6,7 +6,7 @@ #' @param y.min Either a logical value to define whether uniform the lower limit or a numeric value defining the lower limit. By default \code{TRUE}. #' @param y.max Either a logical value to define whether uniform the upper limit or a numeric value defining the upper limit. By default \code{TRUE}. #' @param ticks.each Numeric value to define every how much should be placed a tick. By default \code{NULL}, ticks will be placed automatically. -#' @param digits A single integer indicating the maximum number of digits required for the rounding of the axis values. +#' @param digits A single integer indicating the maximum number of digits required for the rounding of the axis values. By default \code{1}. #' #' @return Returns a plot list (or a single plot when only one input plot is provided) equivalent to the input list provided by the user in which the Y-axis of all the plots will be uniformed. #' @@ -66,7 +66,7 @@ uniform.y.axis = function( new_y.max = NA} - # Rund the new range + # Round the new range if (!is.na(new_y.min)) {new_y.min = Rseb::floating.floor(new_y.min, digits = digits)} if (!is.na(new_y.max)) {new_y.max = Rseb::floating.ceiling(new_y.max, digits = digits)} @@ -74,11 +74,15 @@ uniform.y.axis = function( # Re-define breaks if (!is.null(ticks.each)) { breaks_list = list() + ticks.each = round(ticks.each, digits = digits) for (i in 1:length(plot.list)) { min = ifelse(test = is.na(new_y.min), yes = y.min_list[i], no = new_y.min) max = ifelse(test = is.na(new_y.max), yes = y.max_list[i], no = new_y.max) - breaks_list[[i]] = seq(min, max, ticks.each) + min = floor((min/ticks.each)) * ticks.each # gets minimum multiple of the ticks bin + max = ceiling((max/ticks.each)) * ticks.each # gets maximum multiple of the ticks bin + breaks_list[[i]] = seq(from = min, to = max, by = ticks.each) + breaks_list[[i]] = breaks_list[[i]][breaks_list[[i]] >= new_y.min & breaks_list[[i]] <= new_y.max] # removes ticks not in the axis range } } diff --git a/Rseb_manual.pdf b/Rseb_manual.pdf index d67951d..e24ed79 100644 Binary files a/Rseb_manual.pdf and b/Rseb_manual.pdf differ diff --git a/man/IGVsnap.Rd b/man/IGVsnap.Rd index 6fe56aa..0b9dd94 100644 --- a/man/IGVsnap.Rd +++ b/man/IGVsnap.Rd @@ -17,6 +17,7 @@ IGVsnap( snap_image_format = "png", snap_directory = getwd(), maxPanelHeight = 1000, + delay.interval = 10, session = NULL, exit = FALSE ) @@ -30,11 +31,11 @@ IGVsnap( \item{dataset}{Defines the \code{dataset} parameter for \code{biomaRt} package, by default \code{mmusculus_gene_ensembl}.} -\item{reference_genome}{[optional] Defines the genome to use, e.g. "mm10", "hg19", ... . By default \code{NULL}.} +\item{reference_genome}{[optional] Defines the genome to use, e.g. "mm9", "mm10", "hg19", "hg38", ... . By default \code{NULL}.} -\item{fivePrime}{Numeric value to define how many bases [bp] exapand from full gene position at it's 5'-end, default 1000bp.} +\item{fivePrime}{Numeric value to define of how many base-pairs (bp) expand from full gene position at it's 5'-end, default 1000bp.} -\item{threePrime}{Numeric value to define how many bases [bp] exapand from full gene position at it's 3'-end, default 1000bp.} +\item{threePrime}{Numeric value to define of how many base-pairs (bp) expand from full gene position at it's 3'-end, default 1000bp.} \item{snap_names}{[optional] String vector to define the names of images (without extention), by default uses \code{loci_vector}.} @@ -44,7 +45,9 @@ IGVsnap( \item{snap_directory}{String for the output directory for the snapshoots. By default .} -\item{maxPanelHeight}{Numeric value to define the height in pixel of the IGV pannel that will be captured on IGV.} +\item{maxPanelHeight}{Numeric value to define the height in pixel of the IGV pannel that will be captured on IGV. By default \code{1000}.} + +\item{delay.interval}{Sets a delay (sleep) time in milliseconds. The sleep interval is invoked between successive commands. By default \code{10}. helps to give the time to IGV to adapt the view before the snap (such as the autoscale).} \item{session}{[optional] FULL path to an IGV session file (session.xml) to use for the images. By default \code{NULL}.} diff --git a/man/plot.density.summary.Rd b/man/plot.density.summary.Rd index d4288b9..1f30707 100644 --- a/man/plot.density.summary.Rd +++ b/man/plot.density.summary.Rd @@ -143,6 +143,7 @@ The functions returns a list containing: \item \code{data.table} with the computed values used for the plot; \item \code{metadata} table with the information obtained from the matrix_file.gz; \item \code{plot.list} with a plot for each list element; + \item \code{density.profile} with the density profile of the mean signal generated by \link{plot.density.profile} corresponding to the regions/samples for which the summary multiplot have been generated; \item \code{multiplot} with the image of all the plots together; \item \code{summary.plot.samples} with a plot showing the scores of all regions per each sample; \item \code{summary.plot.regions} with a plot showing the scores of all samples per each region; diff --git a/man/substract.bw.Rd b/man/substract.bw.Rd index a184625..e26d9a4 100644 --- a/man/substract.bw.Rd +++ b/man/substract.bw.Rd @@ -4,25 +4,16 @@ \alias{substract.bw} \title{Combination of two or more list in a unique one.} \usage{ -substract.bw( - bw1, - bw2, - wd = getwd(), - return.substracted.bw = F, - export.substracted.bw = T, - substracted.bw.file = paste(getwd(), "subtraction.bw", sep = "/") -) +substract.bw(bw1, bw2, return.substracted.bw = T, substracted.bw.file = NULL) } \arguments{ \item{bw1}{Full path to the first bigWig (the second one will be substracted to this one).} \item{bw2}{Full path to the second bigWig (it will be substracted to the first one).} -\item{return.substracted.bw}{Logic value to define whether return the resulting bigWig as GRanges object. By default \code{FALSE}.} +\item{return.substracted.bw}{Logic value to define whether return the resulting bigWig as GRanges object. By default \code{TRUE}.} -\item{export.substracted.bw}{Logic value to define whether export the resulting bigWig. By default \code{TRUE}.} - -\item{substracted.bw.file}{String for the path of the resulting bigwig file to be exported. \cr By default \code{/subtraction.bw}.} +\item{substracted.bw.file}{String for the path of the resulting bigwig file to be exported. \cr By default \code{NULL}, any file will be exported.} } \value{ If required a subtraction bigWig is returned as GRanges object. The resulting bigWig can be also directly exported. diff --git a/man/uniform.x.axis.Rd b/man/uniform.x.axis.Rd index 9535267..cbdaa8a 100644 --- a/man/uniform.x.axis.Rd +++ b/man/uniform.x.axis.Rd @@ -4,7 +4,13 @@ \alias{uniform.x.axis} \title{Plot X-axis uniforming} \usage{ -uniform.x.axis(plot.list, x.min = TRUE, x.max = TRUE, ticks.each = NULL) +uniform.x.axis( + plot.list, + x.min = TRUE, + x.max = TRUE, + ticks.each = NULL, + digits = 1 +) } \arguments{ \item{plot.list}{A single plot or a list of plots.} @@ -15,7 +21,7 @@ uniform.x.axis(plot.list, x.min = TRUE, x.max = TRUE, ticks.each = NULL) \item{ticks.each}{Numeric value to define every how much should be placed a tick. By default \code{NULL}, ticks will be placed automatically.} -\item{digits}{A single integer indicating the maximum number of digits required for the rounding of the axis values.} +\item{digits}{A single integer indicating the maximum number of digits required for the rounding of the axis values. By default \code{1}.} } \value{ Returns a plot list (or a single plot when only one input plot is provided) equivalent to the input list provided by the user in which the X-axis of all the plots will be uniformed. diff --git a/man/uniform.y.axis.Rd b/man/uniform.y.axis.Rd index 7020d63..b5c2a27 100644 --- a/man/uniform.y.axis.Rd +++ b/man/uniform.y.axis.Rd @@ -21,7 +21,7 @@ uniform.y.axis( \item{ticks.each}{Numeric value to define every how much should be placed a tick. By default \code{NULL}, ticks will be placed automatically.} -\item{digits}{A single integer indicating the maximum number of digits required for the rounding of the axis values.} +\item{digits}{A single integer indicating the maximum number of digits required for the rounding of the axis values. By default \code{1}.} } \value{ Returns a plot list (or a single plot when only one input plot is provided) equivalent to the input list provided by the user in which the Y-axis of all the plots will be uniformed.