R/makeReport.R

Defines functions makeReport

Documented in makeReport

#' Generate a quality report of the screen data
#'
#' This function generates a customized Rmarkdown based html report for priliminary quality assurance.
#'
#' @param screenData a data table that contains the screen results generated by \code{readScreen()} function.
#' @param showCode a boolean value, whether to show code in the html report.
#' @param title a character string specifying the title for the html report
#' @param author a character string specifying the author name
#' @param ifPlatePlot a boolean value, whether to make plate heatmap plots in the report.
#' Plate heatmap plots can be time consuming for large screen datasets.
#' @export
#' @return This function creates an html file named 'report.html' in a folder named 'report' in the working directory.
#' @examples
#' # load processed data
#' data(screenData_normalized)
#'
#' # make html report
#' makeReport(screenData_normalized, showCode = TRUE,
#'            title = 'Report example',
#'            author = 'Author Name', ifPlatePlot = FALSE)
#'
makeReport <- function(screenData, showCode = FALSE, title = "Report for my drug screening project",
                       author = "Author Name", ifPlatePlot = FALSE) {

  # create a directoy for report
  dir.create("./report", showWarnings = FALSE)
  dir.create("./report/plots", showWarnings = FALSE)

  # save the screenData object to a file
  saveRDS(screenData, file = "report/screenData.rds", compress = TRUE)

  # template file
  tempRmd <- system.file("template.Rmd", package = "DrugScreenExplorer")
  file.copy(tempRmd, "./report/report.Rmd", overwrite = TRUE)

  # render html with parameters
  rmarkdown::render(input = "./report/report.Rmd", output_file = "report.html",
                    params = list(showCode = showCode,set_title = title,
                                  set_author = author, ifPlatePlot = ifPlatePlot), quiet = TRUE)
}
lujunyan1118/DrugScreenExplorer_dev documentation built on Dec. 21, 2021, 12:42 p.m.