Project: Example bumphunter.
This report is meant to help explore a set of genomic regions and was generated using the regionReport
(Collado-Torres, Jaffe, and Leek, 2016) package. While the report is rich, it is meant to just start the exploration of the results and exemplify some of the code used to do so. If you need a more in-depth analysis for your specific data set you might want to use the customCode
argument.
Most plots were made with using ggplot2
(Wickham, 2016).
## knitrBoostrap and device chunk options
load_install('knitr')
opts_chunk$set(bootstrap.show.code = FALSE, dev = device)
if(!outputIsHTML) opts_chunk$set(bootstrap.show.code = FALSE, dev = device, echo = FALSE)
#### Libraries needed
## Bioconductor
load_install('bumphunter')
load_install('derfinder')
load_install('derfinderPlot')
load_install('GenomeInfoDb')
load_install('GenomicRanges')
load_install('ggbio')
## Transcription database to use by default
if(is.null(txdb)) {
load_install('TxDb.Hsapiens.UCSC.hg19.knownGene')
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene::TxDb.Hsapiens.UCSC.hg19.knownGene
}
## CRAN
load_install('ggplot2')
if(!is.null(theme)) theme_set(theme)
load_install('grid')
load_install('gridExtra')
load_install('knitr')
load_install('RColorBrewer')
load_install('mgcv')
load_install('whisker')
load_install('DT')
load_install('devtools')
## Working behind the scenes
# load_install('knitcitations')
# load_install('rmarkdown')
## Optionally
# load_install('knitrBootstrap')
#### Code setup
## For ggplot
tmp <- regions
names(tmp) <- seq_len(length(tmp))
regions.df <- as.data.frame(tmp)
regions.df$width <- width(tmp)
rm(tmp)
## Special subsets: need at least 3 points for a density plot
keepChr <- table(regions.df$seqnames) > 2
regions.df.plot <- subset(regions.df, seqnames %in% names(keepChr[keepChr]))
if(hasSignificant) {
## Keep only those sig
regions.df.sig <- regions.df[significantVar, ]
keepChr <- table(regions.df.sig$seqnames) > 2
regions.df.sig <- subset(regions.df.sig, seqnames %in% names(keepChr[keepChr]))
}
## Find which chrs are present in the data set
chrs <- levels(seqnames(regions))
## areaVar initialize
areaVar <- NULL
p2a <- ggplot(regions.df.plot, aes(x=log10(width), colour=seqnames)) +
geom_line(stat='density') + labs(title='Density of region lengths') +
xlab('Region width (log10)') + scale_colour_discrete(limits=chrs) +
theme(legend.title=element_blank())
p2a
This plot shows the density of the region lengths for all regions.
for(i in seq_len(length(densityVars))) {
densityVarName <- names(densityVars[i])
densityVarName <- ifelse(is.null(densityVarName), densityVars[i], densityVarName)
cat(knit_child(text = whisker.render(templateDensityInUse, list(varName = densityVars[i], densityVarName = densityVarName)), quiet = TRUE), sep = '\n')
}
p3aarea <- ggplot(regions.df.plot[is.finite(regions.df.plot[, 'area']), ], aes(x=area, colour=seqnames)) +
geom_line(stat='density') + labs(title='Density of Area') +
xlab('Area') + scale_colour_discrete(limits=chrs) +
theme(legend.title=element_blank())
p3aarea
This plot shows the density of the Area for all regions.
p3avalue <- ggplot(regions.df.plot[is.finite(regions.df.plot[, 'value']), ], aes(x=value, colour=seqnames)) +
geom_line(stat='density') + labs(title='Density of Value') +
xlab('Value') + scale_colour_discrete(limits=chrs) +
theme(legend.title=element_blank())
p3avalue
This plot shows the density of the Value for all regions.
p3aclusterL <- ggplot(regions.df.plot[is.finite(regions.df.plot[, 'clusterL']), ], aes(x=clusterL, colour=seqnames)) +
geom_line(stat='density') + labs(title='Density of Cluster Length') +
xlab('Cluster Length') + scale_colour_discrete(limits=chrs) +
theme(legend.title=element_blank())
p3aclusterL
This plot shows the density of the Cluster Length for all regions.
The following plots were made using ggbio
(Yin, Cook, and Lawrence, 2012) which in turn uses ggplot2
(Wickham, 2016). For more details check plotOverview
in derfinderPlot
(Collado-Torres, Jaffe, and Leek, 2017).
This plot shows the genomic locations of the regions found in the analysis. The significant regions are highlighted and the of the regions is shown on top of each chromosome (skipped because there was no applicable variable).
## Annotate regions with bumphunter
if(is.null(annotation)) {
genes <- annotateTranscripts(txdb = txdb)
annotation <- matchGenes(x = regions, subject = genes)
}
## Make the plot
plotOverview(regions=regions, annotation=annotation, type='annotation', base_size=overviewParams$base_size, areaRel=overviewParams$areaRel, legend.position=c(0.97, 0.12))
This genomic overview plot shows the annotation region type for the regions as determined using bumphunter
(Jaffe, Murakami, Lee, Leek, et al., 2012). Note that the regions are shown only if the annotation information is available. Below is a table of the actual number of results per annotation region type.
annoReg <- table(annotation$region, useNA='always')
annoReg.df <- data.frame(Region=names(annoReg), Count=as.vector(annoReg))
if(outputIsHTML) {
kable(annoReg.df, format = 'markdown', align=rep('c', 3))
} else {
kable(annoReg.df)
}
Region | Count |
---|---|
upstream | 10 |
promoter | 0 |
overlaps 5’ | 0 |
inside | 0 |
overlaps 3’ | 0 |
close to 3’ | 0 |
downstream | 5 |
covers | 0 |
NA | 0 |
This genomic overview plot shows the annotation region type for the statistically significant regions. Note that the regions are shown only if the annotation information is available. Plot skipped because there are no significant regions.
Below is a table summarizing the number of genomic states per region as determined using derfinder
(Collado-Torres, Nellore, Frazee, Wilks, et al., 2017).
## Construct genomic state object
genomicState <- makeGenomicState(txdb = txdb, chrs = chrs, verbose = FALSE)
## 'select()' returned 1:1 mapping between keys and columns
## Annotate regions by genomic state
annotatedRegions <- annotateRegions(regions, genomicState$fullGenome, verbose = FALSE)
## Genomic states table
info <- do.call(rbind, lapply(annotatedRegions$countTable, function(x) { data.frame(table(x)) }))
colnames(info) <- c('Number of Overlapping States', 'Frequency')
info$State <- gsub('\\..*', '', rownames(info))
rownames(info) <- NULL
if(outputIsHTML) {
kable(info, format = 'markdown', align=rep('c', 4))
} else {
kable(info)
}
Number of Overlapping States | Frequency | State |
---|---|---|
0 | 15 | exon |
1 | 15 | intergenic |
0 | 15 | intron |
The following is a venn diagram showing how many regions overlap known exons, introns, and intergenic segments, none of them, or multiple of these groups.
## Venn diagram for all regions
venn <- vennRegions(annotatedRegions, counts.col = 'blue',
main = 'Regions overlapping genomic states')
Below is an interactive table with the top 15 regions (out of 15) as ranked by p-value without ranking because no p-value information was provided. Inf and -Inf are shown as 1e100 and -1e100 respectively. Use the search function to find your region of interest or sort by one of the columns.
## Add annotation information
regions.df <- cbind(regions.df, annotation)
## Rank by p-value (first pvalue variable supplied)
if(hasPvalueVars){
topRegions <- head(regions.df[order(regions.df[, pvalueVars[1]],
decreasing = FALSE), ], nBestRegions)
topRegions <- cbind(data.frame('pvalueRank' = seq_len(nrow(topRegions))),
topRegions)
} else {
topRegions <- head(regions.df, nBestRegions)
}
## Clean up -Inf, Inf if present
## More details at https://github.com/ramnathv/rCharts/issues/259
replaceInf <- function(df, colsubset=seq_len(ncol(df))) {
for(i in colsubset) {
inf.idx <- !is.finite(df[, i])
if(any(inf.idx)) {
inf.sign <- sign(df[inf.idx, i])
df[inf.idx, i] <- inf.sign * 1e100
}
}
return(df)
}
topRegions <- replaceInf(topRegions, which(sapply(topRegions, function(x) {
class(x) %in% c('numeric', 'integer')})))
## Make the table
greptext <- 'value$|area$|mean|log2FoldChange'
greppval <- 'pvalues$|qvalues$|fwer$'
if(hasPvalueVars) {
greppval <- paste0(paste(pvalueVars, collapse = '$|'), '$|', greppval)
}
if(hasDensityVars) {
greptext <- paste0(paste(densityVars, collapse = '$|'), '$|', greptext)
}
for(i in which(grepl(greppval, colnames(topRegions)))) topRegions[, i] <- format(topRegions[, i], scientific = TRUE)
if(outputIsHTML) {
datatable(topRegions, options = list(pagingType='full_numbers', pageLength=10, scrollX='100%'), rownames = FALSE) %>% formatRound(which(grepl(greptext, colnames(topRegions))), digits)
} else {
## Only print the top part if your output is a PDF file
df_top <- head(topRegions, 20)
for(i in which(grepl(greptext, colnames(topRegions)))) df_top[, i] <- round(df_top[, i], digits)
kable(df_top)
}
This report was generated in path /tmp/RtmpWuGyWD/Rbuild5bd04602ca38/regionReport/vignettes using the following call to renderReport()
:
## renderReport(regions = regions, project = "Example bumphunter",
## pvalueVars = NULL, densityVars = c(Area = "area", Value = "value",
## `Cluster Length` = "clusterL"), significantVar = NULL,
## outdir = ".", output = "bumphunterExampleOutput", device = "png",
## template = "regionReportBumphunter.Rmd")
Date the report was generated.
## [1] "2018-07-24 20:16:38 EDT"
Wallclock time spent generating the report.
## Time difference of 2.125 mins
R
session information.
## Session info ----------------------------------------------------------------------------------------------------------
## setting value
## version R version 3.5.1 (2018-07-02)
## system x86_64, linux-gnu
## ui X11
## language (EN)
## collate C
## tz America/New_York
## date 2018-07-24
## Packages --------------------------------------------------------------------------------------------------------------
## package * version date source
## acepack 1.4.1 2016-10-29 CRAN (R 3.5.1)
## annotate 1.58.0 2018-07-24 Bioconductor
## AnnotationDbi * 1.42.1 2018-07-24 Bioconductor
## AnnotationFilter 1.4.0 2018-07-24 Bioconductor
## assertthat 0.2.0 2017-04-11 CRAN (R 3.5.1)
## backports 1.1.2 2017-12-13 CRAN (R 3.5.1)
## base * 3.5.1 2018-07-23 local
## base64enc 0.1-3 2015-07-28 CRAN (R 3.5.1)
## bibtex 0.4.2 2017-06-30 CRAN (R 3.5.1)
## bindr 0.1.1 2018-03-13 CRAN (R 3.5.1)
## bindrcpp 0.2.2 2018-03-29 CRAN (R 3.5.1)
## Biobase * 2.40.0 2018-07-24 Bioconductor
## BiocGenerics * 0.26.0 2018-07-24 Bioconductor
## BiocInstaller 1.30.0 2018-07-24 Bioconductor
## BiocParallel 1.14.2 2018-07-24 Bioconductor
## BiocStyle * 2.8.2 2018-07-24 Bioconductor
## biomaRt 2.36.1 2018-07-24 Bioconductor
## Biostrings 2.48.0 2018-07-24 Bioconductor
## biovizBase 1.28.1 2018-07-24 Bioconductor
## bit 1.1-14 2018-05-29 CRAN (R 3.5.1)
## bit64 0.9-7 2017-05-08 CRAN (R 3.5.1)
## bitops 1.0-6 2013-08-17 CRAN (R 3.5.1)
## blob 1.1.1 2018-03-25 CRAN (R 3.5.1)
## bookdown 0.7 2018-02-18 CRAN (R 3.5.1)
## BSgenome 1.48.0 2018-07-24 Bioconductor
## bumphunter * 1.22.0 2018-07-24 Bioconductor
## checkmate 1.8.5 2017-10-24 CRAN (R 3.5.1)
## cluster 2.0.7-1 2018-04-13 CRAN (R 3.5.1)
## codetools 0.2-15 2016-10-05 CRAN (R 3.5.1)
## colorspace 1.3-2 2016-12-14 CRAN (R 3.5.1)
## compiler 3.5.1 2018-07-23 local
## crayon 1.3.4 2017-09-16 CRAN (R 3.5.1)
## crosstalk 1.0.0 2016-12-21 CRAN (R 3.5.1)
## curl 3.2 2018-03-28 CRAN (R 3.5.1)
## data.table 1.11.4 2018-05-27 CRAN (R 3.5.1)
## datasets * 3.5.1 2018-07-23 local
## DBI 1.0.0 2018-05-02 CRAN (R 3.5.1)
## DEFormats 1.8.0 2018-07-24 Bioconductor
## DelayedArray 0.6.2 2018-07-24 Bioconductor
## derfinder * 1.14.0 2018-07-24 Bioconductor
## derfinderHelper 1.14.0 2018-07-24 Bioconductor
## derfinderPlot * 1.14.0 2018-07-24 Bioconductor
## DESeq2 1.20.0 2018-07-24 Bioconductor
## devtools * 1.13.6 2018-06-27 CRAN (R 3.5.1)
## dichromat 2.0-0 2013-01-24 CRAN (R 3.5.1)
## digest 0.6.15 2018-01-28 CRAN (R 3.5.1)
## doRNG 1.7.1 2018-06-22 CRAN (R 3.5.1)
## dplyr 0.7.6 2018-06-29 CRAN (R 3.5.1)
## DT * 0.4 2018-01-30 CRAN (R 3.5.1)
## edgeR 3.22.3 2018-07-24 Bioconductor
## ensembldb 2.4.1 2018-07-24 Bioconductor
## evaluate 0.11 2018-07-17 CRAN (R 3.5.1)
## foreach * 1.4.4 2017-12-12 CRAN (R 3.5.1)
## foreign 0.8-71 2018-07-20 CRAN (R 3.5.1)
## Formula 1.2-3 2018-05-03 CRAN (R 3.5.1)
## genefilter 1.62.0 2018-07-24 Bioconductor
## geneplotter 1.58.0 2018-07-24 Bioconductor
## GenomeInfoDb * 1.16.0 2018-07-24 Bioconductor
## GenomeInfoDbData 1.1.0 2018-07-23 Bioconductor
## GenomicAlignments 1.16.0 2018-07-24 Bioconductor
## GenomicFeatures * 1.32.0 2018-07-24 Bioconductor
## GenomicFiles 1.16.0 2018-07-24 Bioconductor
## GenomicRanges * 1.32.6 2018-07-24 Bioconductor
## GGally 1.4.0 2018-05-17 CRAN (R 3.5.1)
## ggbio * 1.28.4 2018-07-24 Bioconductor
## ggplot2 * 3.0.0 2018-07-03 CRAN (R 3.5.1)
## glue 1.3.0 2018-07-17 CRAN (R 3.5.1)
## graph 1.58.0 2018-07-24 Bioconductor
## graphics * 3.5.1 2018-07-23 local
## grDevices * 3.5.1 2018-07-23 local
## grid * 3.5.1 2018-07-23 local
## gridExtra * 2.3 2017-09-09 CRAN (R 3.5.1)
## gtable 0.2.0 2016-02-26 CRAN (R 3.5.1)
## highr 0.7 2018-06-09 CRAN (R 3.5.1)
## Hmisc 4.1-1 2018-01-03 CRAN (R 3.5.1)
## hms 0.4.2 2018-03-10 CRAN (R 3.5.1)
## htmlTable 1.12 2018-05-26 CRAN (R 3.5.1)
## htmltools 0.3.6 2017-04-28 CRAN (R 3.5.1)
## htmlwidgets 1.2 2018-04-19 CRAN (R 3.5.1)
## httpuv 1.4.5 2018-07-19 CRAN (R 3.5.1)
## httr 1.3.1 2017-08-20 CRAN (R 3.5.1)
## IRanges * 2.14.10 2018-07-24 Bioconductor
## iterators * 1.0.10 2018-07-13 CRAN (R 3.5.1)
## jsonlite 1.5 2017-06-01 CRAN (R 3.5.1)
## knitcitations 1.0.8 2017-07-04 CRAN (R 3.5.1)
## knitr * 1.20 2018-02-20 CRAN (R 3.5.1)
## knitrBootstrap 1.0.2 2018-05-24 CRAN (R 3.5.1)
## labeling 0.3 2014-08-23 CRAN (R 3.5.1)
## later 0.7.3 2018-06-08 CRAN (R 3.5.1)
## lattice 0.20-35 2017-03-25 CRAN (R 3.5.1)
## latticeExtra 0.6-28 2016-02-09 CRAN (R 3.5.1)
## lazyeval 0.2.1 2017-10-29 CRAN (R 3.5.1)
## limma 3.36.2 2018-07-24 Bioconductor
## locfit * 1.5-9.1 2013-04-20 CRAN (R 3.5.1)
## lubridate 1.7.4 2018-04-11 CRAN (R 3.5.1)
## magrittr 1.5 2014-11-22 CRAN (R 3.5.1)
## markdown 0.8 2017-04-20 CRAN (R 3.5.1)
## Matrix 1.2-14 2018-04-13 CRAN (R 3.5.1)
## matrixStats 0.54.0 2018-07-23 CRAN (R 3.5.1)
## memoise 1.1.0 2017-04-21 CRAN (R 3.5.1)
## methods * 3.5.1 2018-07-23 local
## mgcv * 1.8-24 2018-06-23 CRAN (R 3.5.1)
## mime 0.5 2016-07-07 CRAN (R 3.5.1)
## munsell 0.5.0 2018-06-12 CRAN (R 3.5.1)
## nlme * 3.1-137 2018-04-07 CRAN (R 3.5.1)
## nnet 7.3-12 2016-02-02 CRAN (R 3.5.1)
## org.Hs.eg.db * 3.6.0 2018-07-23 Bioconductor
## OrganismDbi 1.22.0 2018-07-24 Bioconductor
## parallel * 3.5.1 2018-07-23 local
## pillar 1.3.0 2018-07-14 CRAN (R 3.5.1)
## pkgconfig 2.0.1 2017-03-21 CRAN (R 3.5.1)
## pkgmaker 0.27 2018-05-25 CRAN (R 3.5.1)
## plyr 1.8.4 2016-06-08 CRAN (R 3.5.1)
## prettyunits 1.0.2 2015-07-13 CRAN (R 3.5.1)
## progress 1.2.0 2018-06-14 CRAN (R 3.5.1)
## promises 1.0.1 2018-04-13 CRAN (R 3.5.1)
## ProtGenerics 1.12.0 2018-07-24 Bioconductor
## purrr 0.2.5 2018-05-29 CRAN (R 3.5.1)
## qvalue 2.12.0 2018-07-24 Bioconductor
## R6 2.2.2 2017-06-17 CRAN (R 3.5.1)
## RBGL 1.56.0 2018-07-24 Bioconductor
## RColorBrewer * 1.1-2 2014-12-07 CRAN (R 3.5.1)
## Rcpp 0.12.18 2018-07-23 CRAN (R 3.5.1)
## RCurl 1.95-4.11 2018-07-15 CRAN (R 3.5.1)
## RefManageR 1.2.0 2018-04-25 CRAN (R 3.5.1)
## regionReport * 1.14.3 2018-07-24 Bioconductor
## registry 0.5 2017-12-03 CRAN (R 3.5.1)
## reshape 0.8.7 2017-08-06 CRAN (R 3.5.1)
## reshape2 1.4.3 2017-12-11 CRAN (R 3.5.1)
## rlang 0.2.1 2018-05-30 CRAN (R 3.5.1)
## rmarkdown 1.10 2018-06-11 CRAN (R 3.5.1)
## rngtools 1.3.1 2018-05-15 CRAN (R 3.5.1)
## rpart 4.1-13 2018-02-23 CRAN (R 3.5.1)
## rprojroot 1.3-2 2018-01-03 CRAN (R 3.5.1)
## Rsamtools 1.32.2 2018-07-24 Bioconductor
## RSQLite 2.1.1 2018-05-06 CRAN (R 3.5.1)
## rstudioapi 0.7 2017-09-07 CRAN (R 3.5.1)
## rtracklayer 1.40.3 2018-07-24 Bioconductor
## S4Vectors * 0.18.3 2018-07-24 Bioconductor
## scales 0.5.0 2017-08-24 CRAN (R 3.5.1)
## shiny 1.1.0 2018-05-17 CRAN (R 3.5.1)
## splines 3.5.1 2018-07-23 local
## stats * 3.5.1 2018-07-23 local
## stats4 * 3.5.1 2018-07-23 local
## stringi 1.2.4 2018-07-20 CRAN (R 3.5.1)
## stringr 1.3.1 2018-05-10 CRAN (R 3.5.1)
## SummarizedExperiment 1.10.1 2018-07-24 Bioconductor
## survival 2.42-6 2018-07-13 CRAN (R 3.5.1)
## tibble 1.4.2 2018-01-22 CRAN (R 3.5.1)
## tidyselect 0.2.4 2018-02-26 CRAN (R 3.5.1)
## tools 3.5.1 2018-07-23 local
## TxDb.Hsapiens.UCSC.hg19.knownGene * 3.2.2 2018-07-23 Bioconductor
## utils * 3.5.1 2018-07-23 local
## VariantAnnotation 1.26.1 2018-07-24 Bioconductor
## whisker * 0.3-2 2013-04-28 CRAN (R 3.5.1)
## withr 2.1.2 2018-03-15 CRAN (R 3.5.1)
## xfun 0.3 2018-07-06 CRAN (R 3.5.1)
## XML 3.98-1.12 2018-07-15 CRAN (R 3.5.1)
## xml2 1.2.0 2018-01-24 CRAN (R 3.5.1)
## xtable 1.8-2 2016-02-05 CRAN (R 3.5.1)
## XVector 0.20.0 2018-07-24 Bioconductor
## yaml 2.1.19 2018-05-01 CRAN (R 3.5.1)
## zlibbioc 1.26.0 2018-07-24 Bioconductor
Pandoc version used: 2.1.
This report was created with regionReport
(Collado-Torres, Jaffe, and Leek, 2016) using rmarkdown
(Allaire, Xie, McPherson, Luraschi, et al., 2018) while knitr
(Xie, 2014) and DT
(Xie, 2018) were running behind the scenes. whisker
(de Jonge, 2013) was used for creating templates for the pvalueVars
and densityVars
.
Citations made with knitcitations
(Boettiger, 2017). The BibTeX file can be found here.
[1] J. Allaire, Y. Xie, J. McPherson, J. Luraschi, et al. rmarkdown: Dynamic Documents for R. R package version 1.10. 2018. URL: https://CRAN.R-project.org/package=rmarkdown.
[1] C. Boettiger. knitcitations: Citations for ‘Knitr’ Markdown Files. R package version 1.0.8. 2017. URL: https://CRAN.R-project.org/package=knitcitations.
[1] L. Collado-Torres, A. E. Jaffe and J. T. Leek. derfinderPlot: Plotting functions for derfinder. https://github.com/leekgroup/derfinderPlot - R package version 1.14.0. 2017. DOI: 10.18129/B9.bioc.derfinderPlot. URL: http://www.bioconductor.org/packages/derfinderPlot.
## No encoding supplied: defaulting to UTF-8.
## No encoding supplied: defaulting to UTF-8.
## No encoding supplied: defaulting to UTF-8.
[1] H. Wickham. ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York, 2016. ISBN: 978-3-319-24277-4. URL: http://ggplot2.org.
[1] Y. Xie. DT: A Wrapper of the JavaScript Library ‘DataTables’. R package version 0.4. 2018. URL: https://CRAN.R-project.org/package=DT.
[1] Y. Xie. “knitr: A Comprehensive Tool for Reproducible Research in R”. In: Implementing Reproducible Computational Research. Ed. by V. Stodden, F. Leisch and R. D. Peng. ISBN 978-1466561595. Chapman and Hall/CRC, 2014. URL: http://www.crcpress.com/product/isbn/9781466561595.
[1] T. Yin, D. Cook and M. Lawrence. “ggbio: an R package for extending the grammar of graphics for genomic data”. In: Genome Biology 13.8 (2012), p. R77.
[1] E. de Jonge. whisker: mustache for R, logicless templating. R package version 0.3-2. 2013. URL: https://CRAN.R-project.org/package=whisker.