Title: | muReportR |
---|---|
Description: | Generate HTML reports from R. Based on code from the RnBeads package. |
Authors: | Yassen Assenov [aut], Fabian Mueller [aut, cre] |
Maintainer: | Fabian Mueller <[email protected]> |
License: | GPL-3 |
Version: | 0.3 |
Built: | 2024-11-11 06:16:06 UTC |
Source: | https://github.com/demuellae/muReportR |
Generates HTML code for a figure in the specified report. A figure is a collection of images (plots), of which only one is visible at any given moment.
addReportFigure(report, description, repPlots, setting.names = list(), selected.image = as.integer(1))
addReportFigure(report, description, repPlots, setting.names = list(), selected.image = as.integer(1))
report |
Report to write the text to. |
description |
Human-readable description of the figure. This must be a non-empty |
repPlots |
Object of type |
setting.names |
List of plot file element descriptors. Every variable elements in the plot file names must be included in this list. Set this to empty list if no variable elements are present, that is, if the figure should present a single report plot. |
selected.image |
Index of plot to be initially selected in the figure. |
The modified report.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
addReportTables
for adding a listing of tables; Report
for other functions
adding contents to an HTML report
Generates HTML code for a list in the specified report.
addReportList(report, txt, type = "u")
addReportList(report, txt, type = "u")
report |
Report to write the text to. |
txt |
Non-empty list of items to be written. An attribute named |
type |
List type to be used for the list and/or its sublists in case the attribute |
There are two ways to specify a list type: (1) setting a value for the attribute type
of the list, or
(2) using the function's parameter type
. The value of the function's parameter is used only for lists
and sublists that do not contain an attribute named type
. The following types are supported:
"o"
Ordered list using arabic numbers - 1
, 2
, 3
, etc.
"u"
Unordered list using bullet points.
Note that every list type must be a one-element character
vector containing one of the codes listed
above. Specifying any other value for list type results in an error.
The modified report, invisibly.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
Report
for other functions adding contents to an HTML report
report <- createReport("example.html", "Example", init.configuration = TRUE) recipe <- list("Sift flour in a bowl", "Add sugar and mix", "Add milk and mix") addReportList(report, recipe, type="o")
report <- createReport("example.html", "Example", init.configuration = TRUE) recipe <- list("Sift flour in a bowl", "Add sugar and mix", "Add milk and mix") addReportList(report, recipe, type="o")
Generates HTML code for a new paragraph in the specified report.
addReportParagraph(report, txt, pClass = NULL)
addReportParagraph(report, txt, pClass = NULL)
report |
Report to write the text to. |
txt |
|
pClass |
CSS class definition of the paragraph. This must be either
|
The modified report, invisibly.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
Report
for other functions adding contents to an HTML report
report <- createReport("example.html", "Example", init.configuration = TRUE) txt <- "A pessimist is a person who has had to listen to too many optimists." txt <- c(txt, " <i>Don Marquis</i>") addReportParagraph(report, txt)
report <- createReport("example.html", "Example", init.configuration = TRUE) txt <- "A pessimist is a person who has had to listen to too many optimists." txt <- c(txt, " <i>Don Marquis</i>") addReportParagraph(report, txt)
Adds a reference item to the given report.
addReportReference(report, txt)
addReportReference(report, txt)
report |
Report to add a reference item to. |
txt |
Text of the reference in the form of a non-empty |
The modified report.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
getReportReference
for adding citations in the report's text; Report
for
other functions adding contents to an HTML report
report <- createReport("example.html", "Example", init.configuration = TRUE) txt.reference <- c("Bird A. ", "<i>Nucleic Acids Res.</i> <b>8</b> (1980)") report <- addReportReference(report, txt.reference) txt <- c("This was shown in ", getReportReference(report, txt.reference), ".") addReportParagraph(report, txt)
report <- createReport("example.html", "Example", init.configuration = TRUE) txt.reference <- c("Bird A. ", "<i>Nucleic Acids Res.</i> <b>8</b> (1980)") report <- addReportReference(report, txt.reference) txt <- c("This was shown in ", getReportReference(report, txt.reference), ".") addReportParagraph(report, txt)
Generates HTML code for a new section in the specified report.
addReportSection(report, title, description, level = 1L, collapsed = FALSE)
addReportSection(report, title, description, level = 1L, collapsed = FALSE)
report |
Report to write the text to. |
title |
Section header. This must be a single-element |
description |
Human-readable paragraph text of the section in the form of a |
level |
Section level as a single |
collapsed |
Flag indicating if the contents of this section is to be initially collapsed. Possible values are
|
The modified report.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
Report
for other functions adding contents to an HTML report
report <- createReport("example.html", "Example", init.configuration = TRUE) report <- addReportSection(report, "Introduction", "This is how it's done.")
report <- createReport("example.html", "Example", init.configuration = TRUE) report <- addReportSection(report, "Introduction", "This is how it's done.")
Generates HTML code for a table in the specified report.
addReportTable(report, tdata, row.names = TRUE, first.col.header = FALSE, indent = 0, tag.attrs = c(class = "tabdata"), thead = NULL, tcaption = NULL, na = "<span class=\"disabled\">n/a</span>")
addReportTable(report, tdata, row.names = TRUE, first.col.header = FALSE, indent = 0, tag.attrs = c(class = "tabdata"), thead = NULL, tcaption = NULL, na = "<span class=\"disabled\">n/a</span>")
report |
Report to write the text to. |
tdata |
Matrix or data frame to be presented in HTML form. Column names, if present, are used to define table columns. If this table contains 0 (zero) rows or 0 columns, calling this function has no effect. |
row.names |
Flag indicating if row names should also be printed. If this parameter is |
first.col.header |
Flag indicating if all cells in the first column must be displayed as header cells. Note
that, if both this parameter and |
indent |
Default indentation, in number of tabulation characters, to apply to HTML tags. This
indentation is also applied to |
tag.attrs |
Named |
thead |
|
tcaption |
Text to include as a caption below the table, or |
na |
|
The modified report, invisibly.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
addReportTables
for adding a listing of tables; Report
for other functions
adding contents to an HTML report
Generates HTML code for a listing of tables (of which only one is visible at any moment) in the specified report.
addReportTables(report, tables, setting.names, selected.table = 1L, indent = 2L, ...)
addReportTables(report, tables, setting.names, selected.table = 1L, indent = 2L, ...)
report |
Report to write the text to. |
tables |
Non-empty |
setting.names |
List of table name element descriptors. Every variable elements in the table names must be included in this list. |
selected.table |
Index of the table to be initially selected in this listing. |
indent |
Default indentation, in number of tabulation characters, to apply to every table. |
... |
Other parameters passed to |
The modified report.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
addReportTable
for adding a single table to a report; Report
for other
functions adding contents to an HTML report
Creates a new report object.
createReport(fname, title, page.title = "muReportR report", authors = NULL, dirs = NULL, init.configuration = FALSE, theme = "thesis")
createReport(fname, title, page.title = "muReportR report", authors = NULL, dirs = NULL, init.configuration = FALSE, theme = "thesis")
fname |
Single-element |
title |
Title of the report in the form of a single-element |
page.title |
Web page title. This usually appears in the web browser's window title when the report is open. If specified, this must be a vector. Note that only the first element is used. |
authors |
Optional list of authors in the form of a |
dirs |
Location of the supporting directories, that is, paths that are expected to contain additional files linked to from the HTML report. See the Details section for a list of these directories. |
init.configuration |
Flag indicating if the report configuration data should be initialized. If this parameter
is |
theme |
character specifying the theme to be used for the report files. Currently only |
If specified, the parameter dirs
must be a character
vector. The following names are read:
"configuration"
Directory that contains the auxilliary configuration files, such as style sheets and
Javascript files. If missing or NA
, the default value used is "configuration"
.
"data"
Directory to contain the tables, lists and other generated data files that are linked to in
the HTML report. If missing or NA
, the value used is formed from the file name fname
(without
the extension) and the suffix "_data"
.
"pngs"
Directory to contain the low resolution PNG images shown in the HTML report. If missing or
NA
, the value used is formed from the file name fname
(without the extension) and the suffix
"_images"
.
"pdfs"
Directory to contain the PDF images (if such are created). If not missing or NA
, the
value used is formed from the file name fname
(without the extension) and the suffix "_pdf"
.
"high"
Directory to contain the high resolution PNG images (if such are created). If missing or
NA
, the value used is the same as the pngs
directory.
Any other elements, if present, are ignored. Note that these directories are not required to point to different
locations. In particular, if the directories for low and for high resolution images are identical, the
high-resolution image files are assumed to be the ones with suffix "_highres.png"
. See
createReportPlot
for creating image files.
In order to ensure independence of the operating system, there are strong restrictions on the names of the file and
directories. The name of the report's HTML file can consist of the following symbols only: Latin letters, digits, dot
(.
), dash (-
) and underline (_
). The extension of the report's HTML file must be one of
htm
, html
, xhtml
or xml
. The supporting directories must be given as relative paths;
the restrictions on the path names are identical to the ones for file name. Forward slash (/
) is to be used as
path separator. Path names cannot start or end with a slash. None of the directory names can be
an empty string, use "."
instead. A value in the form "mypath/.html"
for fname
is invalid.
Upon initialization, the report attempts to create or overwrite the specified fname
. If the path to it does
not exist, or if the current process does not have permissions to write to the file, report initialization will fail.
The report object visits each supporting directory (except configuration
) and attempts to create it, unless it
is an existing empty directory. Report initialization will fail if any of the visited directories does not meet the
criteria and could not be created. Hidden files (file names starting with "."
on Unix platforms) are ignored.
Thus, all supporting directories that already exist and contain hidden files only are considered valid.
Newly created Report
object.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
Report
for functions adding contents to an HTML report
report <- createReport("example.html", "Example", init.configuration = TRUE)
report <- createReport("example.html", "Example", init.configuration = TRUE)
creates a report plot containing a ggplot object
. Except for the ggp
parameter, the signature and
behavior is identical to createReportPlot
.
createReportGgPlot(ggp, fname, report = NULL, width = 7, height = 7, create.pdf = TRUE, low.png = as.integer(100), high.png = as.integer(0))
createReportGgPlot(ggp, fname, report = NULL, width = 7, height = 7, create.pdf = TRUE, low.png = as.integer(100), high.png = as.integer(0))
ggp |
|
fname |
|
report |
Report (object of type |
width |
|
height |
|
create.pdf |
Flag indicating if a PDF image is to be created. The length of this vector must be |
low.png |
Resolution, in dots per inch, used for the figure image. Set this to |
high.png |
Resolution, in dots per inch, used for a dedicated image. Set this to |
Newly created ReportGgPlot
object.
Fabian Mueller
Initializes a report plot and opens a device to create it. The type of the device created depends on the
parameters create.pdf
, low.png
and high.png
. If create.pdf
is TRUE
, a PDF device
is opened and its contents are later copied to PNG device(s) if needed. Otherwise, a PNG device is opened. Note that
at least one of the following conditions must be met:
create.pdf == TRUE
low.png > 0
high.png > 0
createReportPlot(fname, report = NULL, width = 7, height = 7, create.pdf = TRUE, low.png = 100L, high.png = 0L)
createReportPlot(fname, report = NULL, width = 7, height = 7, create.pdf = TRUE, low.png = 100L, high.png = 0L)
fname |
|
report |
Report (object of type |
width |
|
height |
|
create.pdf |
Flag indicating if a PDF image is to be created. The length of this vector must be |
low.png |
Resolution, in dots per inch, used for the figure image. Set this to |
high.png |
Resolution, in dots per inch, used for a dedicated image. Set this to |
In order to ensure independence of the operating system, there are strong restrictions on the name of the file. It
can consist of the following symbols only: Latin letters, digits, dot (.
), dash (-
) and underline
(_
). The name must not include paths, that is, slash (/
) or backslash (\
) cannot be used.
Newly created ReportPlot
object.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
pdf
for manually initializing a graphics device; Report
for other
functions adding contents to an HTML report
plot.image <- createReportPlot('scatterplot_tumors') plot(x = c(0.4, 1), y = c(9, 3), type = 'p', main = NA, xlab = expression(beta), ylab = 'Measure') off(plot.image)
plot.image <- createReportPlot('scatterplot_tumors') plot(x = c(0.4, 1), y = c(9, 3), type = 'p', main = NA, xlab = expression(beta), ylab = 'Measure') off(plot.image)
Gets the location of the given report-specific directory.
getReportDir(report, dir = c("data", "images", "images_highres", "pdfs"), absolute = FALSE)
getReportDir(report, dir = c("data", "images", "images_highres", "pdfs"), absolute = FALSE)
report |
Report of interest. |
dir |
Type of directory to get. Must be one of |
absolute |
Flag indicating if the absolute path of the directory is to be returned. If this is |
Path of the requested directory as a single-element character
vector.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
Report
for functions adding contents to an HTML report
report <- createReport("example.html", "Example", init.configuration = TRUE) getReportDir(report, "data")
report <- createReport("example.html", "Example", init.configuration = TRUE) getReportDir(report, "data")
Gets the list of all files that are planned to be generated, or were already generated by the given report plot.
getReportPlotFiles(repPlot)
getReportPlotFiles(repPlot)
repPlot |
Report plot of interest. This must be an object of type |
Non-empty character
vector of absolute file names.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
plot.image <- createReportPlot('scatterplot', high.png = 200) getReportPlotFiles(plot.image)
plot.image <- createReportPlot('scatterplot', high.png = 200) getReportPlotFiles(plot.image)
Creates a string that points to the given reference item in the specified report.
getReportReference(report, txt)
getReportReference(report, txt)
report |
Report that contains the reference to be cited. |
txt |
Text of the reference in the form of a non-empty |
Citation of the reference item (including a link) in the form of a one-element character
vector. If
the specified reference item is not found in the report, this method returns an empty string.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
addReportReference
for adding a reference item to a report; Report
for
other functions adding contents to an HTML report
report <- createReport("example.html", "Example", init.configuration = TRUE) txt.reference <- c("Bird A. ", "<i>Nucleic Acids Res.</i> <b>8</b> (1980)") report <- addReportReference(report, txt.reference) txt <- c("This was shown in ", getReportReference(report, txt.reference), ".") addReportParagraph(report, txt)
report <- createReport("example.html", "Example", init.configuration = TRUE) txt.reference <- c("Bird A. ", "<i>Nucleic Acids Res.</i> <b>8</b> (1980)") report <- addReportReference(report, txt.reference) txt <- c("This was shown in ", getReportReference(report, txt.reference), ".") addReportParagraph(report, txt)
Creates a plot, using ggplot2, with a single text message.
ggMsgPlot(txt)
ggMsgPlot(txt)
txt |
Text to be plotted. |
The newly initialized ggplot
instance.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
x11(width = 5, height = 5) ggMsgPlot("Missing data")
x11(width = 5, height = 5) ggMsgPlot("Missing data")
Creates a new directory to host HTML reports and copies the shared configuration files.
initializeReports(reportDir, configDir = "_config", theme = "thesis")
initializeReports(reportDir, configDir = "_config", theme = "thesis")
reportDir |
Directory to host report files. This must be a |
configDir |
Subdirectory to host configuration files shared by the reports. This must be a
|
theme |
character specifying the theme to be used for the report files. Currently only |
TRUE
if the report directory was successfully created and the configuration files were copied to the
specified location; FALSE
otherwise.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
createReport
for initializing an HTML report
reportDir <- "~/infinium_studies/cancer_study/reports" if (!initializeReports(reportDir)) { cat("ERROR: Could not initialize configuration in ", reportDir, "\n", sep = "") }
reportDir <- "~/infinium_studies/cancer_study/reports" if (!initializeReports(reportDir)) { cat("ERROR: Could not initialize configuration in ", reportDir, "\n", sep = "") }
Generate HTML reports from R. Based on code from the RnBeads package.
Performs cleanup and/or other finishing activities and closes the specified device, connection, or document.
## S4 method for signature 'Report' off(.Object) ## S4 method for signature 'ReportPlot' off(.Object) ## S4 method for signature 'ReportGgPlot' off(.Object, handle.errors = FALSE)
## S4 method for signature 'Report' off(.Object) ## S4 method for signature 'ReportPlot' off(.Object) ## S4 method for signature 'ReportGgPlot' off(.Object, handle.errors = FALSE)
.Object |
Object to be closed. |
handle.errors |
Flag indicating if the method should attempt to catch and process errors (e.g. I/O errors)
internally. Setting this to |
The closed object, invisibly.
Handler of a generated HTML report. Reports are initialized using the function createReport
.
fname
Name of the file that contains the HTML report.
dir.conf
Directory that contains configuration files; usually shared between reports.
dir.data
Directory that contains the generated external lists and tables.
dir.pngs
Directory that contains the generated figure image files.
dir.pdfs
Directory that contains the generated figure PDF files.
dir.high
Directory that contains the generated high-resolution image file.
sections
Number of sections and subsections currently added to the report.
opensections
Indices of currently active section and subsections.
figures
Number of figures currently added to the report.
tables
Number of selectable tables added to the report.
references
List of references to be added at the end of the report.
getReportDir
Gets the location of a given report-specific directory.
addReportSection
Generates HTML code for a new section in the report.
addReportParagraph
Generates HTML code for a new paragraph in the report.
addReportList
Generates HTML code for a list in the report.
addReportTable
Generates HTML code for a table in the report.
addReportTables
Generates HTML code for a listing of tables in the report.
addReportFigure
Generates HTML code for a figure in the report.
addReportReference
Adds a reference item to the report.
off
Completes the HTML report by adding a reference section (if needed),
a footer notice and closing the <body>
and <html>
tags.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov
Information about the files created to store one generated plot in a report. Report plots are initialized using the
function createReportGgPlot
. It inherits from the ReportPlot
class and handling is
analogous, except that it contains an additional slot to store a ggplot
object.
ggp
ggplot
object to be printed
No device is being opened until off(reportGgPlot)
is called.
Fabian Mueller
Information about the files created to store one generated plot in a report. Report plots are initialized using the
function createReportPlot
.
fname
Relative file name. It does not include path or extension.
width
Width of the image in inches.
height
Height of the image in inches.
create.pdf
Flag indicating if a PDF image is created.
low.png
Resolution, in dots per inch, used for the figure image.
high.png
Resolution, in dots per inch, used for the high-resolution image.
dir.pdf
Directory that contains the generated PDF file.
dir.png.low
Directory that contains the generated figure image file.
dir.png.high
Directory that contains the generated high-resolution image file.
getReportPlotFiles
Gets the list of all files that are planned to be generated, or were already generated by the report plot.
off
Copies the figure to a PNG file (if needed) and closes the device associated with the report plot.
adapted by Fabian Mueller from RnBeads code by Yassen Assenov