Skip to content

Commit

Permalink
v1.5.6 -- switch to rmarkdown as the default, use DT package
Browse files Browse the repository at this point in the history
With rmarkdown v0.9.5 released today and described at
http://blog.rstudio.org/2016/03/21/rmarkdown-v0-9-5/ it doesn't look like
knitrBootstrap adds much anymore as commented by Jim Hester himself at
jimhester/knitrBootstrap#68 (comment)

With this in mind, I'm switching the default to rmarkdown instead of using
knitrBootstrap. Specially because the version of knitrBootstrap I like to use
is only available via GitHub and will probably never make it to CRAN.

It might even make sense to completely drop the knitrBootstrap dependency,
although I'll leave it for now since there is no immediate need to drop it.

I'm also testing using the DT package for the datatables features instead of
the JS code that was included before. This might not work on this commit but
I'll get it to work soon anyway.
  • Loading branch information
lcolladotor committed Mar 21, 2016
1 parent 95d40cf commit e9d8aeb
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 161 deletions.
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: regionReport
Type: Package
Title: Generate HTML reports for exploring a set of regions
Version: 1.5.5
Version: 1.5.6
Date: 2016-03-21
Authors@R: c(person("Leonardo", "Collado-Torres", role = c("aut", "cre"), email
= "lcollado@jhu.edu"), person(c("Andrew", "E."), "Jaffe", role = "aut",
Expand All @@ -24,6 +24,7 @@ Imports:
derfinder (>= 1.1.0),
derfinderPlot (>= 1.3.2),
devtools (>= 1.6),
DT,
GenomeInfoDb,
GenomicRanges,
ggbio (>= 1.13.13),
Expand All @@ -36,10 +37,11 @@ Imports:
knitrBootstrap (>= 0.9.0),
mgcv,
RColorBrewer,
rmarkdown (>= 0.3.3),
rmarkdown (>= 0.9.5),
whisker
Suggests:
BiocStyle,
biovizBase,
Cairo,
TxDb.Hsapiens.UCSC.hg19.knownGene
RoxygenNote: 5.0.1
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by roxygen2 (4.1.1): do not edit by hand
# Generated by roxygen2: do not edit by hand

export(derfinderReport)
export(derfinder_report)
Expand All @@ -7,6 +7,7 @@ export(render_report)
export(templateDensity)
export(templateManhattan)
export(templatePvalueDensity)
import(DT)
import(GenomeInfoDb)
import(GenomicRanges)
import(IRanges)
Expand Down
51 changes: 26 additions & 25 deletions R/derfinderReport.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#' This function generates a HTML report exploring the basic results from
#' single base-level approach derfinder analysis results
#' (www.bioconductor.org/packages/derfinder). The HTML report itself
#' is generated using knitrBoostrap which uses knitr (http://yihui.name/knitr/)
#' behind the scenes. It works best after using \link[derfinder]{mergeResults}.
#' is generated using rmarkdown (http://rmarkdown.rstudio.com/). It works best
#' after using \link[derfinder]{mergeResults}.
#'
#' @param prefix The main data directory path where
#' \link[derfinder]{mergeResults} was run. It should be the same as
Expand Down Expand Up @@ -68,6 +68,7 @@
#' @import knitcitations
#' @import RColorBrewer
#' @import mgcv
#' @import DT
#' @import GenomeInfoDb
#' @importFrom devtools session_info
#'
Expand Down Expand Up @@ -153,48 +154,48 @@ derfinderReport <- function(prefix, outdir = 'basicExploration',
startTime <- Sys.time()

## Advanced parameters
#' @param chrsStyle The naming style of the chromosomes. By default, UCSC. See
#' \link[GenomeInfoDb]{seqlevelsStyle}.
# @param chrsStyle The naming style of the chromosomes. By default, UCSC. See
# \link[GenomeInfoDb]{seqlevelsStyle}.
chrsStyle <- .advanced_argument('chrsStyle', 'UCSC', ...)

#' @param species Species name. See \link[derfinder]{extendedMapSeqlevels} for
#' more information.
# @param species Species name. See \link[derfinder]{extendedMapSeqlevels} for
# more information.
species <- .advanced_argument('species', getOption('species', 'homo_sapiens'), ...)

#' @param currentStyle Current naming style used. See
#' \link[derfinder]{extendedMapSeqlevels} for more information.
# @param currentStyle Current naming style used. See
# \link[derfinder]{extendedMapSeqlevels} for more information.
currentStyle <- .advanced_argument('currentStyle', 'UCSC', ...)


#' @param fullRegions Part of the output of \link[derfinder]{mergeResults}.
#' Specify it only if you have already loaded it in memory.
# @param fullRegions Part of the output of \link[derfinder]{mergeResults}.
# Specify it only if you have already loaded it in memory.
fullRegions <- .advanced_argument('fullRegions', NULL, ...)


#' @param fullNullSummary Part of the output of \link[derfinder]{mergeResults}.
#' Specify it only if you have already loaded it in memory.
# @param fullNullSummary Part of the output of \link[derfinder]{mergeResults}.
# Specify it only if you have already loaded it in memory.
fullNullSummary <- .advanced_argument('fullNullSummary', NULL, ...)


#' @param fullAnnotatedRegions Part of the output of
#' \link[derfinder]{mergeResults}. Specify it only if you have already loaded
#' it in memory.
# @param fullAnnotatedRegions Part of the output of
# \link[derfinder]{mergeResults}. Specify it only if you have already loaded
# it in memory.
fullAnnotatedRegions <- .advanced_argument('fullAnnotatedRegions', NULL,
...)


#' @param optionsStats Part of the output of \link[derfinder]{analyzeChr}.
#' Specify it only if you have already loaded it in memory.
# @param optionsStats Part of the output of \link[derfinder]{analyzeChr}.
# Specify it only if you have already loaded it in memory.
optionsStats <- .advanced_argument('optionsStats', NULL, ...)


#' @param optionsMerge Part of the output of \link[derfinder]{mergeResults}.
#' Specify it only if you have already loaded it in memory.
# @param optionsMerge Part of the output of \link[derfinder]{mergeResults}.
# Specify it only if you have already loaded it in memory.
optionsMerge <- .advanced_argument('optionsMerge', NULL, ...)


#' @param overviewParams A two element list with \code{base_size} and
#' \code{areaRel} that control the text size for the genomic overview plots.
# @param overviewParams A two element list with \code{base_size} and
# \code{areaRel} that control the text size for the genomic overview plots.
overviewParams <- .advanced_argument('overviewParam', list(base_size = 10,
areaRel = 5), ...)

Expand Down Expand Up @@ -233,7 +234,7 @@ derfinderReport <- function(prefix, outdir = 'basicExploration',
derfinder = citation('derfinder')[1],
derfinderPlot = citation('derfinderPlot')[1],
regionReport = citation('regionReport')[1],
knitrBootstrap = citation('knitrBootstrap'),
DT = citation('DT'),
ggbio = citation('ggbio'),
ggplot2 = citation('ggplot2'),
knitr = citation('knitr')[3],
Expand All @@ -244,7 +245,7 @@ derfinderReport <- function(prefix, outdir = 'basicExploration',

## Assign short names
names(bib) <- c('knitcitations', 'derfinder', 'derfinderPlot',
'regionReport', 'knitrBootstrap', 'ggbio', 'ggplot2', 'knitr',
'regionReport', 'DT', 'ggbio', 'ggplot2', 'knitr',
'rmarkdown')

## Load files
Expand Down Expand Up @@ -282,7 +283,7 @@ derfinderReport <- function(prefix, outdir = 'basicExploration',
## Are there significant regions?
sigVar <- switch(significantVar, pvalue = 'significant', qvalue = 'significantQval', fwer = 'significantFWER')
if(significantVar == 'fwer' & !fwerExist) {
warning('There are no FWER adjusted P-values, will use FDR adjsuted p-values instead.')
warning('There are no FWER adjusted P-values, will use FDR adjusted p-values instead.')
significantVar <- 'significantQval'
}
pvalText <- switch(sigVar, significant = 'P-value', significantQval = 'FDR adjusted P-value', significantFWER = 'FWER adjusted P-value')
Expand All @@ -308,7 +309,7 @@ derfinderReport <- function(prefix, outdir = 'basicExploration',
file.copy(template, to = paste0(output, '.Rmd'))

## Output format
output_format <- .advanced_argument('output_format', 'knitrBootstrap::bootstrap_document', ...)
output_format <- .advanced_argument('output_format', 'html_document', ...)
outputIsHTML <- output_format %in% c('knitrBootstrap::bootstrap_document', 'html_document')

## Check knitrBoostrap version
Expand Down
4 changes: 2 additions & 2 deletions R/regionReport-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#' Generate an HTML reports to explore a set of regions such as the
#' results from annotation-agnostic expression analysis of RNA-seq data at
#' base-pair resolution performed by derfinder.
#' The HTML report itself is generated using knitrBootstrap
#' (https://github.com/jimhester/knitrBootstrap).
#' The HTML report itself is generated using rmarkdown
#' (http://rmarkdown.rstudio.com/).
#'
#' @name regionReport-package
#' @aliases regionReport-package
Expand Down
11 changes: 6 additions & 5 deletions R/renderReport.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#' @import mgcv
#' @import GenomeInfoDb
#' @import whisker
#' @import DT
#' @importFrom devtools session_info
#'
#' @examples
Expand Down Expand Up @@ -139,8 +140,8 @@ renderReport <- function(regions, project, pvalueVars = c('P-values' = 'pval'),
if(hasCustomCode) stopifnot(length(customCode) == 1)
if(!is.null(annotation)) stopifnot(nrow(annotation) == length(regions))

#' @param overviewParams A two element list with \code{base_size} and
#' \code{areaRel} that control the text size for the genomic overview plots.
# @param overviewParams A two element list with \code{base_size} and
# \code{areaRel} that control the text size for the genomic overview plots.
overviewParams <- .advanced_argument('overviewParam', list(base_size = 10,
areaRel = 5), ...)

Expand Down Expand Up @@ -200,7 +201,7 @@ renderReport <- function(regions, project, pvalueVars = c('P-values' = 'pval'),
knitcitations = citation('knitcitations'),
regionReport = citation('regionReport')[1],
derfinderPlot = citation('derfinderPlot')[1],
knitrBootstrap = citation('knitrBootstrap'),
DT = citation('DT'),
ggbio = citation('ggbio'),
ggplot2 = citation('ggplot2'),
knitr = citation('knitr')[3],
Expand All @@ -214,7 +215,7 @@ renderReport <- function(regions, project, pvalueVars = c('P-values' = 'pval'),

## Assign short names
names(bib) <- c('knitcitations', 'regionReport', 'derfinderPlot',
'knitrBootstrap', 'ggbio', 'ggplot2', 'knitr', 'rmarkdown', 'whisker',
'DT', 'ggbio', 'ggplot2', 'knitr', 'rmarkdown', 'whisker',
'bumphunter', 'derfinder')

## Save the call
Expand All @@ -230,7 +231,7 @@ renderReport <- function(regions, project, pvalueVars = c('P-values' = 'pval'),
file.copy(template, to = paste0(output, '.Rmd'))

## Output format
output_format <- .advanced_argument('output_format', 'knitrBootstrap::bootstrap_document', ...)
output_format <- .advanced_argument('output_format', 'html_document', ...)
outputIsHTML <- output_format %in% c('knitrBootstrap::bootstrap_document', 'html_document')

## Check knitrBoostrap version
Expand Down
2 changes: 1 addition & 1 deletion inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ c(
),
year = 2015,
url = "http://www.bioconductor.org/packages/release/bioc/html/regionReport.html",
note = pkgVer('regionReport', '1.5.5')
note = pkgVer('regionReport', '1.5.6')
),
bibentry(bibtype="article",
title = "derfinder: Software for annotation-agnostic RNA-seq differential expression analysis",
Expand Down
53 changes: 13 additions & 40 deletions inst/basicExploration/basicExploration.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
output:
html_document:
toc: true
theme: united
toc_float: true
code_folding: hide
theme: spacelab
pdf_document:
toc: true
knitrBootstrap::bootstrap_document:
Expand Down Expand Up @@ -46,10 +48,12 @@ library('gridExtra')
library('knitr')
library('RColorBrewer')
library('mgcv')
library('DT')
## Working behind the scenes
# library('knitcitations')
# library('rmarkdown')
## Optionally
# library('knitrBootstrap')
#### Code setup
Expand Down Expand Up @@ -167,7 +171,7 @@ qtable <- lapply(c(1e-04, 0.001, 0.01, 0.025, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5,
})
qtable <- do.call(rbind, qtable)
if(outputIsHTML) {
kable(qtable, format = 'html', align = c('c', 'c'))
kable(qtable, format = 'markdown', align = c('c', 'c'))
} else {
kable(qtable)
}
Expand All @@ -190,7 +194,7 @@ fwertable <- lapply(c(1e-04, 0.001, 0.01, 0.025, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5,
})
fwertable <- do.call(rbind, fwertable)
if(outputIsHTML) {
kable(fwertable, format = 'html', align = c('c', 'c'))
kable(fwertable, format = 'markdown', align = c('c', 'c'))
} else {
kable(fwertable)
}
Expand Down Expand Up @@ -381,7 +385,7 @@ This genomic overview plot shows the annotation region type for the __candidate_
annoReg <- table(fullRegions$region, useNA='always')
annoReg.df <- data.frame(Region=names(annoReg), Count=as.vector(annoReg))
if(outputIsHTML) {
kable(annoReg.df, format = 'html', align=rep('c', 3))
datatable(annoReg.df, format = 'markdown', align=rep('c', 3))
} else {
kable(annoReg.df)
}
Expand Down Expand Up @@ -428,7 +432,7 @@ colnames(info) <- c('Number of Overlapping States', 'Frequency')
info$State <- gsub('\\..*', '', rownames(info))
rownames(info) <- NULL
if(outputIsHTML) {
kable(info, format = 'html', align=rep('c', 4))
kable(info, format = 'markdown', align=rep('c', 4))
} else {
kable(info)
}
Expand Down Expand Up @@ -459,10 +463,6 @@ vennSig <- vennRegions(fullAnnotatedRegions, counts.col = 'blue',

Below is an interactive table with the top `r min(nrow(regions.df), nBestRegions * 5)` regions (out of `r nrow(regions.df)`) as ranked by area. Inf and -Inf are shown as 1e100 and -1e100 respectively.

```{r jsInfo, results='asis', eval = outputIsHTML, echo = FALSE}
cat("<link rel='stylesheet' href='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css' />
<script src='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js'></script>")
```

```{r bestAreaInfo, results='asis'}
topArea <- head(regions.df, nBestRegions * 5)
Expand All @@ -484,28 +484,14 @@ topArea <- replaceInf(topArea, grep('log2FoldChange|value|area',
## Make the table
if(outputIsHTML) {
kable(topArea, format = 'html', table.attr='id="regions_table"')
datatable(topArea, options = list(pagingType='full_numbers', pageLength=50, scrollX='100%'))
} else {
## Only print the top part if your output is a PDF file
kable(head(topArea, 20))
}
```

```{r jsTable, results='asis', eval = outputIsHTML, echo = FALSE}
cat('<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$("#regions_table").dataTable({
"sPaginationType": "full_numbers",
"sScrollX": "100%"
});
});
</script>
')
```





# Best region clusters

The following plots were made using `ggbio` `r citep(bib[['ggbio']])` which in turn uses `ggplot2` `r citep(bib[['ggplot2']])`. For more details check `plotCluster()` in `derfinder` `r citep(bib[['derfinder']])`.
Expand Down Expand Up @@ -623,26 +609,14 @@ The following table shows how the group labels were permuted. `r ifelse(usedPerm

```{r permuteTable, results='asis', eval=usedPermutations, echo=usedPermutations}
if(outputIsHTML) {
kable(permuteDetail, format = 'html', table.attr='id="permutation_table"')
datatable(permuteDetail, options = list(pagingType='full_numbers', pageLength=50, scrollX='100%'))
} else {
## Only print the top part if your output is a PDF file
kable(head(permuteDetail, 20))
}
```

```{r jsTablePermute, results='asis', eval = outputIsHTML, echo = FALSE}
cat('<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$("#permutation_table").dataTable({
"sPaginationType": "full_numbers",
"sScrollX": "100%"
});
});
</script>
')
```

```{r child = customCode, eval = hasCustomCode}
```

Expand Down Expand Up @@ -701,8 +675,7 @@ session_info()

# Bibliography

This report was created with `regionReport` `r citep(bib[['regionReport']])` using `knitrBootstrap` `r citep(bib[['knitrBootstrap']])`
to format the html while `knitr` `r citep(bib[['knitr']])` and `rmarkdown` `r citep(bib[['rmarkdown']])` were running behind the scenes.
This report was created with `regionReport` `r citep(bib[['regionReport']])` using `rmarkdown` `r citep(bib[['rmarkdown']])` while `knitr` `r citep(bib[['knitr']])` and `DT` `r citep(bib[['DT']])` were running behind the scenes.

Citations made with `knitcitations` `r citep(bib[['knitcitations']])`. The [BibTeX](http://www.bibtex.org/) file can be found [here](`r paste0(output, '.bib')`).

Expand Down
Loading

0 comments on commit e9d8aeb

Please sign in to comment.