├── .Rbuildignore ├── .github ├── .gitignore ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ ├── check-bioc-devel.yml │ └── check-bioc.yml ├── .gitignore ├── DESCRIPTION ├── LICENSE ├── LICENSE.md ├── NAMESPACE ├── NEWS.md ├── R ├── RcppExports.R ├── annoDomains.R ├── annoGenomeLabel.R ├── annoHeatmapLegend.R ├── annoHighlight.R ├── annoPixels.R ├── annoSegments.R ├── annoText.R ├── annoXaxis.R ├── annoYaxis.R ├── annoZoomLines.R ├── assembly.R ├── assemblyFunctions.R ├── colorby.R ├── defaultPackages.R ├── genomes.R ├── getExons.R ├── hicFunctions.R ├── mapColors.R ├── pageCreate.R ├── pageGuideHide.R ├── pageGuideHorizontal.R ├── pageGuideShow.R ├── pageGuideVertical.R ├── pageLayout.R ├── pagePlotPlace.R ├── pagePlotRemove.R ├── parameterFunctions.R ├── pgEnv.R ├── pgParams.R ├── placementFunctions.R ├── plotBase.R ├── plotCircle.R ├── plotGG.R ├── plotGenes.R ├── plotGenomeLabel.R ├── plotHicRectangle.R ├── plotHicSquare.R ├── plotHicTriangle.R ├── plotIdeogram.R ├── plotLegend.R ├── plotManhattan.R ├── plotMultiSignal.R ├── plotPairs.R ├── plotPairsArches.R ├── plotPolygon.R ├── plotRanges.R ├── plotRaster.R ├── plotRect.R ├── plotSegments.R ├── plotSignal.R ├── plotText.R ├── plotTranscripts.R ├── plotgardener.R ├── readBigwig.R ├── readCool.R ├── readHic.R ├── readingFunctions.R ├── sysdata.rda ├── viewportFunctions.R └── zzz.R ├── README.md ├── icons ├── plotCircle.png ├── plotGenes.png ├── plotGenomeLabel.png ├── plotHicRectangle.png ├── plotHicSquare.png ├── plotHicTriangle.png ├── plotIdeogram.png ├── plotLegend.png ├── plotManhattan.png ├── plotPairs.png ├── plotPairsArches.png ├── plotPolygon.png ├── plotRanges.png ├── plotRect.png ├── plotSegments.png ├── plotSignal.png ├── plotText.png ├── plotTranscripts.png └── plotgardener.png ├── inst ├── CITATION ├── extdata │ ├── proximanova-regitalic.otf │ ├── proximanova-regular.otf │ └── proximanova-semibold.otf ├── images │ ├── Rlogo.png │ ├── pg-gnome-hole-shadow.png │ └── pg-wordmark.png └── script │ └── fonts.R ├── man ├── annoDomains.Rd ├── annoGenomeLabel.Rd ├── annoHeatmapLegend.Rd ├── annoHighlight.Rd ├── annoPixels.Rd ├── annoSegments.Rd ├── annoText.Rd ├── annoXaxis.Rd ├── annoYaxis.Rd ├── annoZoomLines.Rd ├── assembly.Rd ├── c.Rd ├── calcSignalRange.Rd ├── colorby.Rd ├── defaultPackages.Rd ├── dot-checkCool.Rd ├── dot-checkCoolErrors.Rd ├── dot-coolAutoResolution.Rd ├── dot-coolRegion.Rd ├── dot-pullBinChunks.Rd ├── figures │ ├── homePage-1.png │ ├── icon.png │ ├── logo.png │ ├── pg-hex-text.png │ └── pg-wordmark.png ├── genomes.Rd ├── mapColors.Rd ├── pageCreate.Rd ├── pageGuideHide.Rd ├── pageGuideHorizontal.Rd ├── pageGuideShow.Rd ├── pageGuideVertical.Rd ├── pageLayoutCol.Rd ├── pageLayoutRow.Rd ├── pagePlotPlace.Rd ├── pagePlotRemove.Rd ├── pgParams.Rd ├── plotCircle.Rd ├── plotGG.Rd ├── plotGenes.Rd ├── plotGenomeLabel.Rd ├── plotHicRectangle.Rd ├── plotHicSquare.Rd ├── plotHicTriangle.Rd ├── plotIdeogram.Rd ├── plotLegend.Rd ├── plotManhattan.Rd ├── plotMultiSignal.Rd ├── plotPairs.Rd ├── plotPairsArches.Rd ├── plotPolygon.Rd ├── plotRanges.Rd ├── plotRaster.Rd ├── plotRect.Rd ├── plotSegments.Rd ├── plotSignal.Rd ├── plotText.Rd ├── plotTranscripts.Rd ├── plotgardener.Rd ├── readBigwig.Rd ├── readCool.Rd ├── readCoolBpResolutions.Rd ├── readCoolChroms.Rd ├── readCoolNorms.Rd └── readHic.Rd ├── pkgdown ├── _pkgdown.yml ├── extra.css └── favicon │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ └── favicon.ico ├── src ├── .gitignore ├── RcppExports.cpp ├── checkRow.cpp └── rebinBigwig.cpp ├── tests ├── testthat.R └── testthat │ ├── test-assemblyFunctions.R │ ├── test-colorby.R │ ├── test-hicFunctions.R │ ├── test-parameterFunctions.R │ ├── test-pgParams.R │ ├── test-placementFunctions.R │ ├── test-plotting.R │ ├── test-readingFunctions.R │ ├── test-signalFunctions.R │ ├── test-transcriptFilter.R │ └── test-viewports.R └── vignettes ├── guides ├── aesthetics.Rmd ├── annotations.Rmd ├── bioconductor_integration.Rmd ├── ideograms_and_shapes.Rmd ├── incorporating_ggplots.Rmd ├── our_philosophy.Rmd ├── plotgardener_meta_functions.Rmd ├── plotgardener_page.Rmd ├── plotting_multiomic_data.Rmd └── reading_data_for_plotgardener.Rmd └── introduction_to_plotgardener.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^_pkgdown\.yml$ 4 | ^docs$ 5 | ^pkgdown$ 6 | ^pkgdown/_pkgdown\.yml$ 7 | ^LICENSE\.md$ 8 | ^icons$ 9 | ^\.github$ 10 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Describe a bug in detail 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Describe the bug 11 | 12 | A clear and concise description of what the bug is vs what you expected to happen. 13 | 14 | ## Reproducible example 15 | 16 | If possible, please provide a reprex example with the [`reprex` package](https://reprex.tidyverse.org/articles/learn-reprex.html). Please provide all data and code to reproduce the error/bug. If an error seems to occur in only one function, please still provide the entire `plotgardener` plotting call workflow for additional context. 17 | 18 | ## R session info 19 | 20 | Please report the output of `sessionInfo()`. 21 | 22 | ## Plots 23 | 24 | If applicable, include plots or other images to help illustrate the issue. 25 | 26 | ## Additional context 27 | 28 | Add any other context about the problem here. 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | *.Rproj 3 | .Rhistory 4 | .RData 5 | .Ruserdata 6 | src/*.o 7 | src/*.so 8 | src/*.dll 9 | .DS_Store 10 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: plotgardener 2 | Title: Coordinate-Based Genomic Visualization Package for R 3 | Version: 1.15.1 4 | Date: 2024-06-28 5 | Author: Nicole Kramer [aut, cre], Eric S. Davis [aut], Craig Wenger [aut], 6 | Sarah Parker [ctb], Erika Deoudes [art], Michael Love [ctb], 7 | Douglas H. Phanstiel [aut, cre, cph] 8 | Maintainer: Nicole Kramer , 9 | Douglas Phanstiel 10 | Description: 11 | Coordinate-based genomic visualization package for R. It grants users 12 | the ability to programmatically produce complex, multi-paneled figures. Tailored for 13 | genomics, plotgardener allows users to visualize large complex genomic datasets and 14 | provides exquisite control over how plots are placed and arranged on a page. 15 | Depends: R (>= 4.1.0) 16 | License: MIT + file LICENSE 17 | URL: https://phanstiellab.github.io/plotgardener, https://github.com/PhanstielLab/plotgardener 18 | Encoding: UTF-8 19 | RoxygenNote: 7.3.2 20 | Imports: 21 | curl, 22 | data.table, 23 | dplyr, 24 | GenomeInfoDb, 25 | GenomicRanges, 26 | glue, 27 | grDevices, 28 | grid, 29 | ggplotify, 30 | IRanges, 31 | methods, 32 | plyranges, 33 | purrr, 34 | Rcpp, 35 | RColorBrewer, 36 | rhdf5, 37 | rlang, 38 | stats, 39 | strawr, 40 | tools, 41 | utils, 42 | withr 43 | biocViews: 44 | Visualization, 45 | GenomeAnnotation, 46 | FunctionalGenomics, 47 | GenomeAssembly, 48 | HiC 49 | LinkingTo: 50 | Rcpp 51 | Suggests: 52 | AnnotationDbi, 53 | AnnotationHub, 54 | BSgenome, 55 | BSgenome.Hsapiens.UCSC.hg19, 56 | ComplexHeatmap, 57 | GenomicFeatures, 58 | ggplot2, 59 | InteractionSet, 60 | knitr, 61 | org.Hs.eg.db, 62 | rtracklayer, 63 | plotgardenerData, 64 | pdftools, 65 | png, 66 | rmarkdown, 67 | scales, 68 | showtext, 69 | testthat (>= 3.0.0), 70 | TxDb.Hsapiens.UCSC.hg19.knownGene, 71 | TxDb.Hsapiens.UCSC.hg38.knownGene 72 | VignetteBuilder: knitr 73 | Config/testthat/edition: 3 74 | BugReports: https://github.com/PhanstielLab/plotgardener/issues 75 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2021 2 | COPYRIGHT HOLDER: plotgardener authors 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2021 plotgardener authors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(annoDomains) 4 | export(annoGenomeLabel) 5 | export(annoHeatmapLegend) 6 | export(annoHighlight) 7 | export(annoPixels) 8 | export(annoSegments) 9 | export(annoText) 10 | export(annoXaxis) 11 | export(annoYaxis) 12 | export(annoZoomLines) 13 | export(assembly) 14 | export(c) 15 | export(calcSignalRange) 16 | export(colorby) 17 | export(defaultPackages) 18 | export(genomes) 19 | export(mapColors) 20 | export(pageCreate) 21 | export(pageGuideHide) 22 | export(pageGuideHorizontal) 23 | export(pageGuideShow) 24 | export(pageGuideVertical) 25 | export(pageLayoutCol) 26 | export(pageLayoutRow) 27 | export(pagePlotPlace) 28 | export(pagePlotRemove) 29 | export(pgParams) 30 | export(plotCircle) 31 | export(plotGG) 32 | export(plotGenes) 33 | export(plotGenomeLabel) 34 | export(plotHicRectangle) 35 | export(plotHicSquare) 36 | export(plotHicTriangle) 37 | export(plotIdeogram) 38 | export(plotLegend) 39 | export(plotManhattan) 40 | export(plotMultiSignal) 41 | export(plotPairs) 42 | export(plotPairsArches) 43 | export(plotPolygon) 44 | export(plotRanges) 45 | export(plotRaster) 46 | export(plotRect) 47 | export(plotSegments) 48 | export(plotSignal) 49 | export(plotText) 50 | export(plotTranscripts) 51 | export(readBigwig) 52 | export(readCool) 53 | export(readCoolBpResolutions) 54 | export(readCoolChroms) 55 | export(readCoolNorms) 56 | export(readHic) 57 | import(grid) 58 | importFrom(GenomeInfoDb,keepStandardChromosomes) 59 | importFrom(GenomicRanges,GRanges) 60 | importFrom(GenomicRanges,makeGRangesFromDataFrame) 61 | importFrom(IRanges,IRanges) 62 | importFrom(IRanges,subsetByOverlaps) 63 | importFrom(RColorBrewer,brewer.pal) 64 | importFrom(Rcpp,sourceCpp) 65 | importFrom(curl,has_internet) 66 | importFrom(data.table,fread) 67 | importFrom(data.table,setDT) 68 | importFrom(dplyr,anti_join) 69 | importFrom(dplyr,bind_rows) 70 | importFrom(dplyr,group_by) 71 | importFrom(dplyr,inner_join) 72 | importFrom(dplyr,left_join) 73 | importFrom(dplyr,pull) 74 | importFrom(dplyr,select) 75 | importFrom(ggplotify,as.grob) 76 | importFrom(ggplotify,base2grob) 77 | importFrom(glue,glue) 78 | importFrom(glue,glue_collapse) 79 | importFrom(grDevices,colorRampPalette) 80 | importFrom(grDevices,dev.size) 81 | importFrom(methods,hasArg) 82 | importFrom(methods,is) 83 | importFrom(plyranges,"%>%") 84 | importFrom(purrr,map) 85 | importFrom(purrr,pmap) 86 | importFrom(rhdf5,H5Fis_hdf5) 87 | importFrom(rhdf5,h5ls) 88 | importFrom(rhdf5,h5read) 89 | importFrom(rlang,abort) 90 | importFrom(rlang,arg_match) 91 | importFrom(rlang,inform) 92 | importFrom(rlang,warn) 93 | importFrom(stats,na.omit) 94 | importFrom(strawr,readHicBpResolutions) 95 | importFrom(strawr,straw) 96 | importFrom(tools,file_ext) 97 | importFrom(utils,str) 98 | importFrom(withr,with_pdf) 99 | useDynLib(plotgardener) 100 | -------------------------------------------------------------------------------- /R/RcppExports.R: -------------------------------------------------------------------------------- 1 | # Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | checkRow <- function(x, maxRows, rowCol, wig) { 5 | .Call('_plotgardener_checkRow', PACKAGE = 'plotgardener', x, maxRows, rowCol, wig) 6 | } 7 | 8 | rebinBigwig <- function(bigwig, bins) { 9 | .Call('_plotgardener_rebinBigwig', PACKAGE = 'plotgardener', bigwig, bins) 10 | } 11 | 12 | -------------------------------------------------------------------------------- /R/assembly.R: -------------------------------------------------------------------------------- 1 | #' Make a \code{assembly} object for alternate TxDb, OrgDb,and BSgenome 2 | #' genomic annotation packages 3 | #' 4 | #' @usage assembly( 5 | #' Genome, 6 | #' TxDb, 7 | #' OrgDb, 8 | #' gene.id.column = "ENTREZID", 9 | #' display.column = "SYMBOL", 10 | #' BSgenome = NULL 11 | #' ) 12 | #' 13 | #' @param Genome String indicating the name of the genome assembly. 14 | #' @param TxDb String of existing TxDb package name or a TxDb object. 15 | #' @param OrgDb String of the desired OrgDb package name. 16 | #' @param gene.id.column String of the TxDb column name that refers to 17 | #' the given TxDb gene IDs. 18 | #' Default value is \code{gene.id.column = "ENTREZID"}. 19 | #' @param display.column String of the OrgDb column name that refers to 20 | #' the type of gene symbol to be displayed in plots. 21 | #' Default value is \code{display.column = "SYMBOL"}. 22 | #' @param BSgenome String of the desired BSgenome package name. 23 | #' 24 | #' @return Returns a \code{assembly} object containing all input parameters. 25 | #' 26 | #' @examples 27 | #' ## Create a custom `assembly` object for hg38/GRCh38 packages 28 | #' newAssembly <- assembly( 29 | #' Genome = "hg38_GRCh38", 30 | #' TxDb = "TxDb.Hsapiens.UCSC.hg38.knownGene", 31 | #' OrgDb = "org.Hs.eg.db", 32 | #' BSgenome = "BSgenome.Hsapiens.NCBI.GRCh38" 33 | #' ) 34 | #' @seealso \link[GenomicFeatures]{TxDb}, \link[AnnotationDbi]{OrgDb-class}, 35 | #' \link[BSgenome]{BSgenome} 36 | #' 37 | #' @export 38 | assembly <- function(Genome, TxDb, OrgDb, gene.id.column = "ENTREZID", 39 | display.column = "SYMBOL", BSgenome = NULL) { 40 | object <- structure(list( 41 | Genome = Genome, TxDb = TxDb, OrgDb = OrgDb, 42 | gene.id.column = gene.id.column, 43 | display.column = display.column 44 | ), 45 | class = "assembly" 46 | ) 47 | 48 | if (is(object$TxDb, "TxDb")) { 49 | object$TxDb$packageName <- paste0("TxDb.", Genome) 50 | } 51 | 52 | if (!is.null(BSgenome)) { 53 | object$BSgenome <- BSgenome 54 | } 55 | 56 | invisible(object) 57 | } 58 | -------------------------------------------------------------------------------- /R/colorby.R: -------------------------------------------------------------------------------- 1 | #' Handle plotgardener color scaling parameters 2 | #' 3 | #' \code{colorby} should be used to create a set of parameters 4 | #' that specify color scaling for the functions \code{plotPairs}, 5 | #' \code{plotPairsArches}, and \code{plotRanges}. 6 | #' 7 | #' @param column String specifying name of data column to scale colors by. 8 | #' @param palette (optional) A function describing the color palette to use for 9 | #' color scaling. 10 | #' @param range (optional) A numeric vector specifying the range of values to 11 | #' apply a color scale to. 12 | #' @param scalePerRegion A logical value indicating whether to adjust 13 | #' NULL range of numerical `colorby` values to subset of data in a plotted 14 | #' genomic region. Default value is \code{scalePerRegion = FALSE}. 15 | #' 16 | #' @return Returns a "\code{colorby}" object. 17 | #' 18 | #' @examples 19 | #' ## Load paired ranges data in BEDPE format 20 | #' library(plotgardenerData) 21 | #' data("IMR90_DNAloops_pairs") 22 | #' 23 | #' ## Add a length column 24 | #' IMR90_DNAloops_pairs$length <- 25 | #' (IMR90_DNAloops_pairs$start2 - IMR90_DNAloops_pairs$start1) / 1000 26 | #' 27 | #' ## Plot pairs with colorby object set for `length` column 28 | #' bedpePlot <- plotPairs( 29 | #' data = IMR90_DNAloops_pairs, 30 | #' chrom = "chr21", 31 | #' chromstart = 27900000, chromend = 30700000, 32 | #' assembly = "hg19", 33 | #' fill = colorby("length", palette = 34 | #' colorRampPalette(c("dodgerblue2", "firebrick2"))), 35 | #' lwd = 2, spaceHeight = .7, 36 | #' ) 37 | #' @export 38 | colorby <- function(column, palette = NULL, range = NULL, 39 | scalePerRegion = FALSE) { 40 | colorbyObject <- structure(list(column = column, palette = palette, 41 | range = range, 42 | scalePerRegion = scalePerRegion), 43 | class = "colorby" 44 | ) 45 | return(colorbyObject) 46 | } 47 | -------------------------------------------------------------------------------- /R/defaultPackages.R: -------------------------------------------------------------------------------- 1 | #' Display the default genomic annotation packages associated with a 2 | #' genome build 3 | #' 4 | #' @param Genome String indicating the name of the genome assembly. 5 | #' 6 | #' @return Returns a list of the default data packages for a genome build. 7 | #' 8 | #' @examples 9 | #' ## View default genomic annotation packages associated with "hg19" 10 | #' defaultPackages(Genome = "hg19") 11 | #' 12 | #' ## View default genomic annotation packages associated with "mm9" 13 | #' defaultPackages(Genome = "mm9") 14 | #' @export 15 | defaultPackages <- function(Genome) { 16 | 17 | availDefaults <- default_genomePackages$Genome 18 | 19 | if (!Genome %in% availDefaults) { 20 | stop("Inputted genome not an available default. To see the included ", 21 | "defaults, use `genomes()`.", call. = FALSE) 22 | } 23 | 24 | defaults <- default_genomePackages[ 25 | default_genomePackages$Genome == Genome,c("Genome", 26 | "TxDb", 27 | "OrgDb", 28 | "gene.id.column", 29 | "display.column", 30 | "BSgenome")] 31 | 32 | return(str(defaults)) 33 | } 34 | -------------------------------------------------------------------------------- /R/genomes.R: -------------------------------------------------------------------------------- 1 | #' Display the included available default genome assemblies 2 | #' 3 | #' @return Returns the included available default genome assemblies 4 | #' 5 | #' @examples 6 | #' genomes() 7 | #' @export 8 | genomes <- function() { 9 | 10 | availDefaults <- default_genomePackages$Genome 11 | 12 | return(cat(availDefaults, sep = "\n")) 13 | } 14 | -------------------------------------------------------------------------------- /R/getExons.R: -------------------------------------------------------------------------------- 1 | getExons <- function(assembly, chromosome, start, stop) { 2 | if (is(assembly$TxDb, "TxDb")) { 3 | tx_db <- assembly$TxDb 4 | } else { 5 | tx_db <- eval(parse(text = paste0(as.name(assembly$TxDb), 6 | "::", 7 | as.name(assembly$TxDb)))) 8 | } 9 | 10 | if (length(assembly$OrgDb) == 1){ 11 | 12 | ## Custom orgDb 13 | if (is(assembly$OrgDb, "OrgDb")){ 14 | org_db <- assembly$OrgDb 15 | } else { 16 | org_db <- eval(parse(text = paste0(as.name(assembly$OrgDb), 17 | "::", 18 | as.name(assembly$OrgDb)))) 19 | } 20 | } 21 | 22 | genes_on_chrom <- suppressMessages(GenomicFeatures::genes(tx_db, 23 | filter = list(tx_chrom = chromosome) 24 | )) ## Still GRanges 25 | genes_in_range <- genes_on_chrom[genes_on_chrom@ranges@start <= stop & 26 | genes_on_chrom@ranges@start + 27 | genes_on_chrom@ranges@width >= start] 28 | txs_wo_symbols <- suppressMessages(AnnotationDbi::select(tx_db, 29 | keys = genes_in_range$gene_id, 30 | columns = AnnotationDbi::columns(tx_db), 31 | keytype = "GENEID" 32 | )) 33 | ## Double check filtering of chromosome 34 | txs_wo_symbols <- txs_wo_symbols[which(txs_wo_symbols$TXCHROM==chromosome),] 35 | 36 | if (assembly$gene.id.column == assembly$display.column) { 37 | txs_w_symbols <- txs_wo_symbols 38 | } else if (assembly$gene.id.column == "ORF") { 39 | txs_wo_symbols <- cbind(txs_wo_symbols, 40 | "SHORTORF" = sub("-.+", "", txs_wo_symbols$GENEID) 41 | ) 42 | gene_symbols <- suppressMessages(AnnotationDbi::select(org_db, 43 | keys = sub("-.+", "", genes_in_range$gene_id), 44 | columns = assembly$display.column, 45 | keytype = "ORF" 46 | )) 47 | txs_w_symbols <- merge(txs_wo_symbols, gene_symbols, 48 | by.x = "SHORTORF", by.y = "ORF" 49 | ) 50 | } else { 51 | gene_symbols <- suppressMessages(AnnotationDbi::select(org_db, 52 | keys = genes_in_range$gene_id, 53 | columns = assembly$display.column, 54 | keytype = assembly$gene.id.column 55 | )) 56 | txs_w_symbols <- merge(txs_wo_symbols, gene_symbols, 57 | by.x = "GENEID", by.y = assembly$gene.id.column 58 | ) 59 | } 60 | 61 | return(txs_w_symbols) 62 | } 63 | -------------------------------------------------------------------------------- /R/pageGuideHide.R: -------------------------------------------------------------------------------- 1 | #' Remove guides from a plotgardener page 2 | #' 3 | #' @return None. 4 | #' 5 | #' @examples 6 | #' ## Make a page 7 | #' pageCreate(width = 7, height = 4, default.units = "inches") 8 | #' 9 | #' ## Hide page guides 10 | #' pageGuideHide() 11 | #' 12 | #' @note 13 | #' Please note that due to the implementation of `grid` removal functions, 14 | #' using `pageGuideHide` within a `pdf` call will result in the rendering of a 15 | #' separate, new page with the plot guides removed. To avoid this artifact, 16 | #' hide guides in the `pageCreate` function call with `showGuides = FALSE`. 17 | #' 18 | #' @export 19 | pageGuideHide <- function() { 20 | if (length(get("guide_grobs", envir = pgEnv)$children) == 0) { 21 | stop("No `plotgardener` page guides exist.") 22 | } 23 | 24 | ## Get the list of grobs from the guide grobs gTree and convert to gPaths 25 | grob_list <- lapply( 26 | get("guide_grobs", envir = pgEnv)$children, 27 | convert_gpath 28 | ) 29 | ## Get the last grob 30 | last_grob <- grob_list[length(grob_list)] 31 | 32 | ## Remove the last grob from the list of grobs 33 | grob_list <- grob_list[-length(grob_list)] 34 | 35 | ## Remove all grobs except last one, not redrawing each time (to save time) 36 | invisible(lapply(grob_list, grid.remove, redraw = FALSE)) 37 | 38 | ## Remove last grob with redrawing, now removing all the grobs 39 | invisible(lapply(last_grob, grid.remove)) 40 | } 41 | -------------------------------------------------------------------------------- /R/pageGuideHorizontal.R: -------------------------------------------------------------------------------- 1 | #' Draw a horizontal guideline at a specified y-coordinate 2 | #' on a plotgardener page 3 | #' 4 | #' @usage pageGuideHorizontal( 5 | #' y, 6 | #' default.units = "inches", 7 | #' linecolor = "grey55", 8 | #' params = NULL, 9 | #' ... 10 | #' ) 11 | #' 12 | #' @param y A numeric or unit object specifying y-coordinate of guide. 13 | #' @param default.units A string indicating the default units to use 14 | #' if \code{y} is only given as a numeric. 15 | #' Default value is \code{default.units = "inches"}. 16 | #' @param linecolor Character value indicating color of guideline. 17 | #' Default value is \code{linecolor = "grey55"}. 18 | #' @param params An optional \link[plotgardener]{pgParams} object 19 | #' containing relevant function parameters. 20 | #' @param ... Additional grid graphical parameters. See \link[grid]{gpar}. 21 | #' 22 | #' @examples 23 | #' ## Create a page 24 | #' pageCreate(width = 6, height = 5, default.units = "inches") 25 | #' 26 | #' ## Add red horizontal guideline at y = 2.5 inches 27 | #' pageGuideHorizontal(y = 2.5, linecolor = "red") 28 | #' @return None. 29 | #' 30 | #' @export 31 | pageGuideHorizontal <- function(y, default.units = "inches", 32 | linecolor = "grey55", params = NULL, ...) { 33 | 34 | 35 | # ========================================================================= 36 | # PARSE PARAMETERS 37 | # ========================================================================= 38 | 39 | hguide <- parseParams(params = params, 40 | defaultArgs = formals(eval(match.call()[[1]])), 41 | declaredArgs = lapply(match.call()[-1], 42 | eval.parent, n = 2), 43 | class = "hguide") 44 | 45 | ## Set gp 46 | hguide$gp <- gpar(col = hguide$linecolor) 47 | hguide$gp <- setGP(gpList = hguide$gp, params = hguide, ...) 48 | # ========================================================================= 49 | # ERRORS 50 | # ========================================================================= 51 | 52 | if (is.null(hguide$y)) { 53 | stop("argument \"y\" is missing, with no default.", 54 | call. = FALSE 55 | ) 56 | } 57 | 58 | # ========================================================================= 59 | # DEFAULT UNITS 60 | # ========================================================================= 61 | 62 | y <- misc_defaultUnits(value = hguide$y, 63 | name = "y", 64 | default.units = hguide$default.units, 65 | funName = "pageGuideHorizontal", 66 | yBelow = FALSE) 67 | 68 | # ========================================================================= 69 | # MAKE GROB AND ASSIGN TO GTREE 70 | # ========================================================================= 71 | 72 | y <- convertY(y, 73 | unitTo = get("page_units", envir = pgEnv), 74 | valueOnly = TRUE 75 | ) 76 | 77 | guide <- grid.segments( 78 | x0 = unit(0, units = "npc"), 79 | x1 = unit(1, units = "npc"), 80 | y0 = get("page_height", envir = pgEnv) - y, 81 | y1 = get("page_height", envir = pgEnv) - y, 82 | default.units = get("page_units", envir = pgEnv), 83 | gp = hguide$gp 84 | ) 85 | assign("guide_grobs", 86 | addGrob( 87 | gTree = get("guide_grobs", envir = pgEnv), 88 | child = guide 89 | ), 90 | envir = pgEnv 91 | ) 92 | } 93 | -------------------------------------------------------------------------------- /R/pageGuideShow.R: -------------------------------------------------------------------------------- 1 | #' Reshow guides drawn with \code{pageCreate}, 2 | #' \code{pageGuideHorizontal}, and \code{pageGuideVertical} 3 | #' 4 | #' @seealso \link[plotgardener]{pageCreate}, 5 | #' \link[plotgardener]{pageGuideHorizontal}, 6 | #' \link[plotgardener]{pageGuideVertical} 7 | #' 8 | #' @return None. 9 | #' 10 | #' @examples 11 | #' ## Load Hi-C data 12 | #' library(plotgardenerData) 13 | #' data("IMR90_HiC_10kb") 14 | #' 15 | #' ## Create a page 16 | #' pageCreate(width = 3, height = 3, default.units = "inches") 17 | #' 18 | #' ## Add a page guide 19 | #' pageGuideHorizontal(y = 0.5, default.units = "inches") 20 | #' 21 | #' ## Plot and place Hi-C plot 22 | #' hicPlot <- plotHicSquare( 23 | #' data = IMR90_HiC_10kb, resolution = 10000, 24 | #' zrange = c(0, 70), 25 | #' chrom = "chr21", 26 | #' chromstart = 28000000, chromend = 30300000, 27 | #' x = 0.5, y = 0.5, width = 2, height = 2, 28 | #' just = c("left", "top"), 29 | #' default.units = "inches" 30 | #' ) 31 | #' 32 | #' ## Hide page guides 33 | #' pageGuideHide() 34 | #' 35 | #' ## Re-show page guides 36 | #' pageGuideShow() 37 | #' 38 | #' ## Annotate genome label 39 | #' annoGenomeLabel( 40 | #' plot = hicPlot, scale = "Mb", axis = "x", 41 | #' x = 0.5, y = 2.53, just = c("left", "top") 42 | #' ) 43 | #' @export 44 | pageGuideShow <- function() { 45 | if (length(get("guide_grobs", envir = pgEnv)$children) == 0) { 46 | stop("No `plotgardener` page guides were previously drawn.") 47 | } 48 | 49 | add_guideGrobs <- function(child) { 50 | grid.add("guide_grobs", child = child, redraw = FALSE) 51 | } 52 | 53 | ## get the guide grobs 54 | grobList <- get("guide_grobs", envir = pgEnv)$children 55 | 56 | ## Get the last grob 57 | last_grob <- grobList[length(grobList)][[1]] 58 | 59 | ## Remove the last grob from the list of grobs 60 | grobList <- grobList[-length(grobList)] 61 | 62 | ## Re-add grobs to guide_grobs gTree without re-drawing 63 | invisible(lapply(grobList, add_guideGrobs)) 64 | 65 | ## Re-add last grob, this time redrawing 66 | grid.add("guide_grobs", child = last_grob) 67 | } 68 | -------------------------------------------------------------------------------- /R/pageGuideVertical.R: -------------------------------------------------------------------------------- 1 | #' Draw a vertical guideline at a specified x-coordinate on a 2 | #' plotgardener page 3 | #' 4 | #' @usage pageGuideVertical( 5 | #' x, 6 | #' default.units = "inches", 7 | #' linecolor = "grey55", 8 | #' params = NULL, 9 | #' ... 10 | #' ) 11 | #' 12 | #' @param x A numeric or unit object specifying x-coordinate of guide. 13 | #' @param default.units A string indicating the default units to use 14 | #' if \code{x} is only given as a numeric. 15 | #' Default value is \code{default.units = "inches"}. 16 | #' @param linecolor Character value indicating color of guideline. 17 | #' Default value is \code{linecolor = "grey55"}. 18 | #' @param params An optional \link[plotgardener]{pgParams} object 19 | #' containing relevant function parameters. 20 | #' @param ... Additional grid graphical parameters. See \link[grid]{gpar}. 21 | #' 22 | #' @examples 23 | #' ## Create a page 24 | #' pageCreate(width = 6, height = 5, default.units = "inches") 25 | #' 26 | #' ## Add blue vertical guideline at x = 1.7 inches 27 | #' pageGuideVertical(x = 1.7, linecolor = "blue") 28 | #' @return None. 29 | #' 30 | #' @export 31 | pageGuideVertical <- function(x, default.units = "inches", 32 | linecolor = "grey55", params = NULL, ...) { 33 | 34 | # ========================================================================= 35 | # PARSE PARAMETERS 36 | # ========================================================================= 37 | 38 | vguide <- parseParams( 39 | params = params, 40 | defaultArgs = formals(eval(match.call()[[1]])), 41 | declaredArgs = lapply(match.call()[-1], eval.parent, n = 2), 42 | class = "vguide" 43 | ) 44 | 45 | ## Set gp 46 | vguide$gp <- gpar(col = vguide$linecolor) 47 | vguide$gp <- setGP( 48 | gpList = vguide$gp, 49 | params = vguide, ... 50 | ) 51 | 52 | # ========================================================================= 53 | # ERRORS 54 | # ========================================================================= 55 | 56 | if (is.null(vguide$x)) { 57 | stop("argument \"x\" is missing, with no default.", 58 | call. = FALSE 59 | ) 60 | } 61 | 62 | # ========================================================================= 63 | # DEFAULT UNITS 64 | # ========================================================================= 65 | 66 | x <- misc_defaultUnits(value = vguide$x, 67 | name = "x", 68 | default.units = vguide$default.units) 69 | 70 | # ========================================================================= 71 | # MAKE GROB AND ASSIGN TO GTREE 72 | # ========================================================================= 73 | 74 | guide <- grid.segments( 75 | x0 = x, x1 = x, 76 | y0 = unit(0, units = "npc"), 77 | y1 = unit(1, units = "npc"), 78 | gp = vguide$gp 79 | ) 80 | assign("guide_grobs", 81 | addGrob( 82 | gTree = get("guide_grobs", envir = pgEnv), 83 | child = guide 84 | ), 85 | envir = pgEnv 86 | ) 87 | } 88 | -------------------------------------------------------------------------------- /R/pageLayout.R: -------------------------------------------------------------------------------- 1 | #' Generate row positions for a number of plot elements with a specified height 2 | #' and space between them 3 | #' 4 | #' @param y A numeric or unit object specifying the starting row y-position. 5 | #' @param height A numeric or unit object specifying the height of rows. 6 | #' @param space A numeric or unit object specifying the space between rows. 7 | #' @param n An integer specifying the number of elements to generate row 8 | #' positions for. 9 | #' @param default.units A string indicating the default units to use 10 | #' if \code{y}, \code{h}, or \code{s} are only given as numerics. 11 | #' Default value is \code{default.units = "inches"}. 12 | #' 13 | #' @examples 14 | #' # Starting at 0.5 units, return a vector of positions for 3 objects that 15 | #' # are 2 units in height with 0.1 units of space between them 16 | #' 17 | #' pageLayoutRow(y = 0.5, height = 2, space = 0.1, n = 3, 18 | #' default.units = "inches") 19 | #' 20 | #' @returns Returns a unit vector of page positions. 21 | #' @export 22 | pageLayoutRow <- function(y, height, space, n, default.units = "inches"){ 23 | ## Parse default units 24 | y <- misc_defaultUnits(value = y, 25 | name = "y", 26 | default.units = default.units) 27 | height <- misc_defaultUnits(value = height, 28 | name = "height", 29 | default.units = default.units) 30 | space <- misc_defaultUnits(value = space, 31 | name = "space", 32 | default.units = default.units) 33 | 34 | ## Calculate positions 35 | y + ((height+space) * seq(0,(n-1))) 36 | 37 | } 38 | 39 | #' Generate column positions for a number of plot elements with a specified 40 | #' width and space between them 41 | #' 42 | #' @param x A numeric or unit object specifying the starting column x-position. 43 | #' @param width A numeric or unit object specifying the width of columns. 44 | #' @param space A numeric or unit object specifying the space between columns. 45 | #' @param n An integer specifying the number of elements to generate column 46 | #' positions for. 47 | #' @param default.units A string indicating the default units to use 48 | #' if \code{x}, \code{w}, or \code{s} are only given as numerics. 49 | #' Default value is \code{default.units = "inches"} 50 | #' 51 | #' @examples 52 | #' # Starting at 0.5 units, return a vector of positions for 3 objects that 53 | #' # are 2 units in width with 0.1 units of space between them 54 | #' 55 | #' pageLayoutCol(x = 0.5, width = 2, space = 0.1, n = 3, 56 | #' default.units = "inches") 57 | #' 58 | #' @returns Returns a unit vector of page positions. 59 | #' @export 60 | pageLayoutCol <- \(x, width, space, n, default.units = "inches") 61 | 62 | ## Calculate positions 63 | pageLayoutRow(y = x, height = width, space = space, n = n, 64 | default.units = default.units) 65 | 66 | 67 | -------------------------------------------------------------------------------- /R/pagePlotRemove.R: -------------------------------------------------------------------------------- 1 | #' Remove plotgardener plots and annotations 2 | #' 3 | #' @param plot Plot object to be removed, defined by the output 4 | #' of a plotgardener plotting function. 5 | #' 6 | #' @examples 7 | #' ## Load Hi-C data 8 | #' library(plotgardenerData) 9 | #' data("IMR90_HiC_10kb") 10 | #' 11 | #' ## Create page 12 | #' pageCreate(width = 5.5, height = 4, default.units = "inches") 13 | #' 14 | #' ## Plot and place a square Hi-C plot 15 | #' hicPlot <- plotHicSquare( 16 | #' data = IMR90_HiC_10kb, resolution = 10000, 17 | #' zrange = c(0, 70), 18 | #' chrom = "chr21", 19 | #' chromstart = 28000000, chromend = 30300000, 20 | #' x = 0.5, y = 0.5, width = 2.5, height = 2.5, 21 | #' just = c("left", "top"), 22 | #' default.units = "inches" 23 | #' ) 24 | #' 25 | #' ## Remove square Hi-C plot from page 26 | #' pagePlotRemove(plot = hicPlot) 27 | #' @return None. 28 | #' 29 | #' @export 30 | pagePlotRemove <- function(plot) { 31 | 32 | if (is(plot, "yaxis") | is(plot, "xaxis")){ 33 | grid.remove(gPath(plot$grobs$childrenOrder)) 34 | } else { 35 | grid.remove(gPath(plot$grobs$name)) 36 | 37 | pg_vpTree <- get("pg_vpTree", envir = pgEnv) 38 | pg_vpTree[grep(plot$grobs$name, pg_vpTree)] <- NULL 39 | assign("pg_vpTree", pg_vpTree, envir = pgEnv) 40 | 41 | ## Need to remove outer viewport of bb_hicTriangle/bb_hicRectangle plot 42 | ## and domain Clips 43 | if (is(plot, "hicTriangle") | 44 | is(plot, "hicRectangle")) { 45 | vp_name <- plot$grobs$vp$name 46 | vp_name <- gsub("inside", "outside", vp_name) 47 | suppressMessages(seekViewport(vp_name)) 48 | suppressMessages(popViewport()) 49 | } else if (is(plot, "domain")) { 50 | if (plot$hicClass != "hicSquare") { 51 | vp_name <- plot$grobs$vp$name 52 | vp_name <- gsub("inside", "outside", vp_name) 53 | suppressMessages(seekViewport(vp_name)) 54 | suppressMessages(popViewport()) 55 | } 56 | } else if (is(plot, "signal")){ 57 | if (grepl("_v", plot$grobs$vp$name)){ 58 | vp_name <- plot$grobs$vp$name 59 | vp_name <- gsub("_v", "_vClip", vp_name) 60 | suppressMessages(seekViewport(vp_name)) 61 | suppressMessages(popViewport()) 62 | } 63 | } 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /R/pgEnv.R: -------------------------------------------------------------------------------- 1 | pgEnv <- new.env() 2 | -------------------------------------------------------------------------------- /R/placementFunctions.R: -------------------------------------------------------------------------------- 1 | ## Define a function to turn gTree child into a gPath 2 | # @param grob grob to convert to gpath 3 | convert_gpath <- function(grob) { 4 | 5 | ## Get the name of the grob 6 | name <- grob$name 7 | 8 | ## Turn it into a gPath 9 | gpath <- gPath(name) 10 | 11 | return(gpath) 12 | } 13 | 14 | ## Define a function to make sure a page viewport exists 15 | # @param error Error message if page doesn't exist 16 | check_page <- function(error) { 17 | 18 | if (is.null(current.vpPath())){ 19 | stop(error, call. = FALSE) 20 | } else { 21 | if (!grepl("page", as.character(current.vpPath()))){ 22 | stop(error, call. = FALSE) 23 | } 24 | 25 | } 26 | } 27 | 28 | ## Define a function to check dimensions/placing coordinates 29 | # @param object Plot object with dimensions/coordinates/plotted attribute 30 | check_placement <- function(object) { 31 | if (attributes(object)$plotted == TRUE) { 32 | 33 | ## If giving placement coordinates 34 | if (!is.null(object$x) | !is.null(object[["y"]])) { 35 | 36 | ## 1. Need both an x and y coordinate 37 | if (!is.null(object$x) & is.null(object[["y"]])) { 38 | stop("Placement detected with y value missing.", call. = FALSE) 39 | } 40 | 41 | if (!is.null(object[["y"]]) & is.null(object$x)) { 42 | stop("Placement detected with x value missing.", call. = FALSE) 43 | } 44 | 45 | ## 2. Need plot dimensions 46 | if (is.null(object$width)) { 47 | stop("Placement detected with plot width missing.", 48 | call. = FALSE 49 | ) 50 | } 51 | 52 | if (as.numeric(object$width) == 0) { 53 | stop("Plot width cannot be 0.", call. = FALSE) 54 | } 55 | 56 | if (is.null(object$height)) { 57 | stop("Placement detected with plot height missing.", 58 | call. = FALSE 59 | ) 60 | } 61 | 62 | if (as.numeric(object$height) == 0) { 63 | stop("Plot height cannot be 0.", call. = FALSE) 64 | } 65 | 66 | 67 | ## 3. Need a page 68 | check_page(error = paste("Must make a `plotgardener` page with", 69 | "`pageCreate()` before placing a plot.")) 70 | } 71 | } 72 | } 73 | 74 | ## Define a character vector of valid coordinate systems to work in 75 | validUnits <- c( 76 | "npc", "native", "inches", "cm", "mm", "points", 77 | "bigpts", "picas", "dida", 78 | "cicero", "scaledpts", "char", "lines", "snpc" 79 | ) 80 | 81 | ## Define a function to assign rows for pileup-style data 82 | ## (plotPairs, plotRanges, plotTranscripts) 83 | # @param data The data to assign rows to, with start in col1 and 84 | # end in col2. This can only be numeric values. 85 | # @param maxRows Maximum number of rows. 86 | # @param rowCol Number of column in `data` that corresponds to 87 | # the row column. This will depend on the number of columns included 88 | # in `data`. This is indexed from 0 for C++ syntax. 89 | # @param limitLabel Logical whether to plot '+' when some elements 90 | # can't fit. 91 | # @param side Side of a plot that rows are being assigned. 92 | # @param gTree Name of gTree of associated fxn for adding limit grobs, 93 | # if necessary 94 | # @param extraData Additional data to add on to data after rows have 95 | # been assigned. This is so non-numeric columns can be conserved. 96 | # @param colNames A vector of column names for the extraData for 97 | # appropriate column naming after row assignment and data combining. 98 | assignRows <- function(data, maxRows, wiggle, rowCol, limitLabel, side = "top", 99 | gTree, extraData = NULL, colNames = NULL){ 100 | 101 | if (nrow(data) > 0){ 102 | ## Initialize a row column 103 | data$row <- 0 104 | 105 | ## Convert to numeric matrix for Rcpp function parsing 106 | dataMatrix <- as.matrix(data) 107 | 108 | ## Assign a row for each element 109 | rowData <- as.data.frame(checkRow(dataMatrix, maxRows, rowCol, wiggle)) 110 | 111 | ## Combine with extra data columns after row assignment 112 | if (!is.null(extraData)){ 113 | rowData <- cbind(rowData, extraData) 114 | colNames <- c(colnames(data), colNames) 115 | } else { 116 | colNames <- colnames(data) 117 | } 118 | 119 | ## Update column names 120 | colnames(rowData) <- colNames 121 | 122 | ## Remove and warn if any data does not get assigned a row 123 | if (any(rowData$row == 0)){ 124 | rowData <- rowData[which(rowData$row != 0), ] 125 | message <- "Not enough plotting space for all provided elements." 126 | 127 | if (limitLabel == TRUE){ 128 | 129 | message <- paste("Not enough plotting space for all provided", 130 | "elements. ('+' indicates elements not shown.)") 131 | 132 | if (side == "top"){ 133 | y <- unit(1, "npc") 134 | just <- c("right", "top") 135 | } else{ 136 | y <- unit(0, "npc") 137 | just <- c("right", "bottom") 138 | } 139 | 140 | limitGrob <- textGrob( 141 | label = "+", x = unit(1, "npc"), 142 | y = y, 143 | just = just, 144 | gp = gpar(col = "grey", fontsize = 6) 145 | ) 146 | assign(gTree, 147 | addGrob( 148 | gTree = get(gTree, envir = pgEnv), 149 | child = limitGrob 150 | ), 151 | envir = pgEnv 152 | ) 153 | 154 | } 155 | 156 | 157 | warning(message, call. = FALSE) 158 | 159 | 160 | } 161 | 162 | ## Change row index to 0 to calculate y 163 | rowData$row <- rowData$row - 1 164 | } else { 165 | rowData <- data.frame() 166 | } 167 | 168 | return(rowData) 169 | } 170 | -------------------------------------------------------------------------------- /R/plotgardener.R: -------------------------------------------------------------------------------- 1 | #' plotgardener: Coordinate-based Genomic Visualization Package for R 2 | #' 3 | #' plotgardener is a coordinate-based genomic visualization package for R. 4 | #' It grants users the ability to programmatically produce complex, 5 | #' multi-paneled figures. Tailored for genomics, plotgardener allows users 6 | #' to visualize large complex genomic datasets and 7 | #' provides exquisite control over how plots are placed and arranged on 8 | #' a page. 9 | #' 10 | #' @author 11 | #' \strong{Maintainer}: Nicole Kramer \email{nekramer@live.unc.edu} 12 | #' (\href{https://orcid.org/0000-0001-9617-9671}{ORCID}) 13 | #' 14 | #' Authors: 15 | #' \itemize{ 16 | #' \item Eric S. Davis \email{esdavis@live.unc.edu} 17 | #' (\href{https://orcid.org/0000-0003-4051-3217}{ORCID}) 18 | #' \item Craig Wenger \email{craig.wenger@gmail.com} 19 | #' (\href{https://orcid.org/0000-0002-7361-8456}{ORCID}) 20 | #' \item Douglas H. Phanstiel \email{douglas_phanstiel@med.unc.edu} 21 | #' [copyright holder] 22 | #' } 23 | #' 24 | #' Other contributors: 25 | #' \itemize{ 26 | #' \item Sarah Parker \email{sarmae@live.unc.edu} [contributor] 27 | #' \item Erika Deoudes \email{ed@erikadudes.com} [artist] 28 | #' \item Michael Love \email{milove@email.unc.edu} [contributor] 29 | #' } 30 | #' 31 | #' @seealso 32 | #' Useful links: 33 | #' \itemize{ 34 | #' \item \url{https://phanstiellab.github.io/plotgardener} 35 | #' \item \url{https://github.com/PhanstielLab/plotgardener} 36 | #' } 37 | #' @docType package 38 | #' @name plotgardener 39 | #' @useDynLib plotgardener 40 | #' @importFrom grDevices colorRampPalette 41 | #' @importFrom grDevices dev.size 42 | #' @importFrom curl has_internet 43 | #' @importFrom methods hasArg 44 | #' @importFrom methods is 45 | #' @importFrom stats na.omit 46 | #' @importFrom utils str 47 | #' @importFrom Rcpp sourceCpp 48 | #' @importFrom data.table fread 49 | #' @importFrom data.table setDT 50 | #' @importFrom ggplotify as.grob 51 | #' @importFrom ggplotify base2grob 52 | #' @importFrom RColorBrewer brewer.pal 53 | #' @importFrom tools file_ext 54 | #' @importFrom dplyr anti_join 55 | #' @importFrom dplyr left_join 56 | #' @importFrom dplyr inner_join 57 | #' @importFrom dplyr bind_rows 58 | #' @importFrom dplyr select 59 | #' @importFrom dplyr group_by 60 | #' @importFrom purrr map 61 | #' @importFrom purrr pmap 62 | #' @import grid 63 | #' @importFrom strawr straw 64 | #' @importFrom strawr readHicBpResolutions 65 | #' @importFrom IRanges IRanges 66 | #' @importFrom IRanges subsetByOverlaps 67 | #' @importFrom withr with_pdf 68 | #' @importFrom GenomeInfoDb keepStandardChromosomes 69 | #' @importFrom GenomicRanges makeGRangesFromDataFrame 70 | "_PACKAGE" 71 | -------------------------------------------------------------------------------- /R/readBigwig.R: -------------------------------------------------------------------------------- 1 | #' Read a bigWig file and return it as a data frame 2 | #' 3 | #' @usage readBigwig( 4 | #' file, 5 | #' chrom = NULL, 6 | #' chromstart = 1, 7 | #' chromend = .Machine$integer.max, 8 | #' strand = "*", 9 | #' params = NULL 10 | #' ) 11 | #' 12 | #' @param file A character value specifying the path to the bigwig file. 13 | #' @param chrom Chromosome of data as a string, if data for a specific 14 | #' chromosome is desired. 15 | #' @param chromstart Integer start position on chromosome. 16 | #' @param chromend Integer end position on chromosome. 17 | #' @param strand A character value specifying strand. 18 | #' Default value is \code{strand = "*"}. Options are: 19 | #' \itemize{ 20 | #' \item{\code{"+"}: }{Plus strand.} 21 | #' \item{\code{"-"}: }{Minus strand.} 22 | #' \item{\code{"*"}: }{Plus and minus strands.} 23 | #' } 24 | #' @param params An optional \link[plotgardener]{pgParams} object 25 | #' containing relevant function parameters. 26 | #' 27 | #' @return Returns a 6-column dataframe of bigwig information. 28 | #' 29 | #' @examples 30 | #' if (.Platform$OS.type != "windows"){ 31 | #' bwFile <- system.file("extdata/test.bw", package="plotgardenerData") 32 | #' 33 | #' ## Read in entire file 34 | #' bwData <- readBigwig(file = bwFile) 35 | #' 36 | #' ## Read in specified region 37 | #' bwRegion <- readBigwig(file = bwFile, 38 | #' chrom = "chr2", 39 | #' chromstart = 1, 40 | #' chromend = 1500) 41 | #' } 42 | #' 43 | #' @details This function does not work on Windows. 44 | #' 45 | #' @seealso \link[rtracklayer]{import.bw} 46 | #' 47 | #' @export 48 | readBigwig <- function(file, chrom = NULL, chromstart = 1, 49 | chromend = .Machine$integer.max, 50 | strand = "*", params = NULL) { 51 | 52 | # ========================================================================= 53 | # PARSE PARAMETERS 54 | # ========================================================================= 55 | 56 | bigwig <- parseParams( 57 | params = params, 58 | defaultArgs = formals(eval(match.call()[[1]])), 59 | declaredArgs = lapply(match.call()[-1], eval.parent, n = 2), 60 | class = "bigwig" 61 | ) 62 | 63 | # ========================================================================= 64 | # ERRORS 65 | # ========================================================================= 66 | 67 | if (is.null(bigwig$file)) { 68 | stop("argument \"file\" is missing, with no default.", 69 | call. = FALSE 70 | ) 71 | } 72 | 73 | if (bigwig$chromend < bigwig$chromstart - 1) { 74 | stop("End must be >= start - 1.", call. = FALSE) 75 | } 76 | 77 | # ========================================================================= 78 | # READ FILE 79 | # ========================================================================= 80 | 81 | if (!is.null(bigwig$chrom)) { 82 | as.data.frame(rtracklayer::import.bw(bigwig$file, 83 | which = GenomicRanges::GRanges(paste0( 84 | bigwig$chrom, 85 | ":", 86 | bigwig$chromstart, 87 | "-", 88 | bigwig$chromend, 89 | ":", 90 | bigwig$strand 91 | )) 92 | )) 93 | } else { 94 | as.data.frame(rtracklayer::import.bw(bigwig$file)) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /R/sysdata.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/R/sysdata.rda -------------------------------------------------------------------------------- /icons/plotCircle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotCircle.png -------------------------------------------------------------------------------- /icons/plotGenes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotGenes.png -------------------------------------------------------------------------------- /icons/plotGenomeLabel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotGenomeLabel.png -------------------------------------------------------------------------------- /icons/plotHicRectangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotHicRectangle.png -------------------------------------------------------------------------------- /icons/plotHicSquare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotHicSquare.png -------------------------------------------------------------------------------- /icons/plotHicTriangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotHicTriangle.png -------------------------------------------------------------------------------- /icons/plotIdeogram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotIdeogram.png -------------------------------------------------------------------------------- /icons/plotLegend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotLegend.png -------------------------------------------------------------------------------- /icons/plotManhattan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotManhattan.png -------------------------------------------------------------------------------- /icons/plotPairs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotPairs.png -------------------------------------------------------------------------------- /icons/plotPairsArches.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotPairsArches.png -------------------------------------------------------------------------------- /icons/plotPolygon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotPolygon.png -------------------------------------------------------------------------------- /icons/plotRanges.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotRanges.png -------------------------------------------------------------------------------- /icons/plotRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotRect.png -------------------------------------------------------------------------------- /icons/plotSegments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotSegments.png -------------------------------------------------------------------------------- /icons/plotSignal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotSignal.png -------------------------------------------------------------------------------- /icons/plotText.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotText.png -------------------------------------------------------------------------------- /icons/plotTranscripts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotTranscripts.png -------------------------------------------------------------------------------- /icons/plotgardener.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/icons/plotgardener.png -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite plotgardener in publications use:") 2 | 3 | citEntry( 4 | entry = "Article", 5 | title = "Plotgardener: cultivating precise multi-panel figures in R", 6 | author = personList(as.person("Nicole E. Kramer"), 7 | as.person("Eric S. Davis"), 8 | as.person("Craig D. Wenger"), 9 | as.person("Erika M. Deoudes"), 10 | as.person("Sarah M. Parker"), 11 | as.person("Michael I. Love"), 12 | as.person("Douglas H. Phanstiel")), 13 | journal = "Bioinformatics", 14 | year = 2022, 15 | url = "https://doi.org/10.1093/bioinformatics/btac057", 16 | doi = "10.1093/bioinformatics/btac057", 17 | textVersion = paste("Nicole E Kramer, Eric S Davis, Craig D Wenger, 18 | Erika M Deoudes, Sarah M Parker, Michael I Love, Douglas H Phanstiel, 19 | Plotgardener: cultivating precise multi-panel figures in R, Bioinformatics, 20 | 2022") 21 | ) 22 | -------------------------------------------------------------------------------- /inst/extdata/proximanova-regitalic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/inst/extdata/proximanova-regitalic.otf -------------------------------------------------------------------------------- /inst/extdata/proximanova-regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/inst/extdata/proximanova-regular.otf -------------------------------------------------------------------------------- /inst/extdata/proximanova-semibold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/inst/extdata/proximanova-semibold.otf -------------------------------------------------------------------------------- /inst/images/Rlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/inst/images/Rlogo.png -------------------------------------------------------------------------------- /inst/images/pg-gnome-hole-shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/inst/images/pg-gnome-hole-shadow.png -------------------------------------------------------------------------------- /inst/images/pg-wordmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/inst/images/pg-wordmark.png -------------------------------------------------------------------------------- /inst/script/fonts.R: -------------------------------------------------------------------------------- 1 | ## Download font files found in inst/extdata 2 | 3 | ## Regular 4 | download.file( 5 | url = "https://www.download-free-fonts.com/details/96003/proxima-nova", 6 | destfile = "inst/extdata/proximanova-regular.otf") 7 | 8 | ## Semi-bold 9 | download.file( 10 | url = "https://www.download-free-fonts.com/details/92405/proxima-nova-semibold", 11 | destfile = "inst/extdata/proximanova-semibold.otf") 12 | 13 | ## Regular italic 14 | download.file( 15 | url = "https://www.download-free-fonts.com/details/93063/proxima-nova-regular-italic", 16 | destfile = "inst/extdata/proximanova-regitalic.otf") 17 | -------------------------------------------------------------------------------- /man/annoDomains.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/annoDomains.R 3 | \name{annoDomains} 4 | \alias{annoDomains} 5 | \title{Annotate domains in a Hi-C plot} 6 | \usage{ 7 | annoDomains( 8 | plot, 9 | data, 10 | half = "inherit", 11 | linecolor = "black", 12 | params = NULL, 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{plot}{Hi-C plot object from \code{plotHicSquare} or 18 | \code{plotHicTriangle} on which to annotate pixels.} 19 | 20 | \item{data}{A string specifying the BED file path, a dataframe in BED 21 | format, or a \link[GenomicRanges]{GRanges} object specifying 22 | domain ranges.} 23 | 24 | \item{half}{Character value specifying which half of hic plots 25 | to annotate. Triangle Hi-C plots will always default to the entirety of 26 | the triangular plot. Default value is \code{half = "inherit"}. Options are: 27 | \itemize{ 28 | \item{\code{"inherit"}: }{Domains will be annotated on the \code{half} 29 | inherited by the input Hi-C plot.} 30 | \item{\code{"both"}: }{Domains will be annotated on both halves of the 31 | diagonal of a square Hi-C plot.} 32 | \item{\code{"top"}: }{Domains will be annotated on the upper diagonal 33 | half of a square Hi-C plot.} 34 | \item{\code{"bottom"}: }{Domains will be annotated ont the bottom diagonal 35 | half of a square Hi-C plot.} 36 | }} 37 | 38 | \item{linecolor}{A character value specifying the color of the domain 39 | annotations. Default value is \code{linecolor = "black"}.} 40 | 41 | \item{params}{An optional \link[plotgardener]{pgParams} object 42 | containing relevant function parameters.} 43 | 44 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 45 | } 46 | \value{ 47 | Returns a \code{domain} object containing relevant 48 | genomic region, placement, and \link[grid]{grob} information. 49 | } 50 | \description{ 51 | Annotate domains in a Hi-C plot 52 | } 53 | \examples{ 54 | ## Define a GRanges object with TAD ranges 55 | library(GenomicRanges) 56 | library(IRanges) 57 | domains <- GRanges("chr21", 58 | ranges = IRanges( 59 | start = c(28210000, 29085000, 29430000, 29700000), 60 | end = c(29085000, 29430000, 29700000, 30125000) 61 | ) 62 | ) 63 | 64 | ## Load Hi-C data 65 | library(plotgardenerData) 66 | data("IMR90_HiC_10kb") 67 | 68 | ## Create page 69 | pageCreate(width = 4.5, height = 4, default.units = "inches") 70 | 71 | ## Plot and place a square Hi-C plot 72 | hicPlot <- plotHicSquare( 73 | data = IMR90_HiC_10kb, resolution = 10000, 74 | zrange = c(0, 70), 75 | chrom = "chr21", 76 | chromstart = 28000000, chromend = 30300000, 77 | assembly = "hg19", 78 | x = 0.5, y = 0.5, width = 3, height = 3, 79 | just = c("left", "top"), 80 | default.units = "inches" 81 | ) 82 | 83 | ## Annotate domains on bottom half 0f Hi-C plot 84 | annoDomains( 85 | plot = hicPlot, data = domains, 86 | half = "bottom", linecolor = "red" 87 | ) 88 | 89 | ## Annotate heatmap legend 90 | annoHeatmapLegend( 91 | plot = hicPlot, 92 | x = 3.6, y = 0.5, width = 0.12, height = 1.2, 93 | just = c("left", "top"), default.units = "inches" 94 | ) 95 | 96 | ## Annotate genome label 97 | annoGenomeLabel( 98 | plot = hicPlot, x = 0.5, y = 3.53, scale = "Mb", 99 | just = c("left", "top") 100 | ) 101 | 102 | ## Hide page guides 103 | pageGuideHide() 104 | } 105 | -------------------------------------------------------------------------------- /man/annoGenomeLabel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/annoGenomeLabel.R 3 | \name{annoGenomeLabel} 4 | \alias{annoGenomeLabel} 5 | \title{Annotate genomic coordinates along the x or y-axis of a plot} 6 | \usage{ 7 | annoGenomeLabel( 8 | plot, 9 | fontsize = 10, 10 | fontcolor = "black", 11 | linecolor = "black", 12 | margin = unit(1, "mm"), 13 | scale = "bp", 14 | commas = TRUE, 15 | sequence = TRUE, 16 | boxWidth = 0.5, 17 | axis = "x", 18 | at = NULL, 19 | tcl = 0.5, 20 | x, 21 | y, 22 | just = c("left", "top"), 23 | default.units = "inches", 24 | params = NULL, 25 | ... 26 | ) 27 | } 28 | \arguments{ 29 | \item{plot}{Input plot to annotate genomic coordinates. 30 | Genomic coordinates and assembly will be inherited from \code{plot}.} 31 | 32 | \item{fontsize}{A numeric specifying text fontsize in points. 33 | Default value is \code{fontsize = 10}.} 34 | 35 | \item{fontcolor}{A character value indicating the color for text. 36 | Default value is \code{fontcolor = "black"}.} 37 | 38 | \item{linecolor}{A character value indicating the color of 39 | the genome label axis. Default value is \code{linecolor = "black"}.} 40 | 41 | \item{margin}{A numeric or unit vector specifying space between axis 42 | and coordinate labels. Default value is \code{margin = unit(1, "mm")}.} 43 | 44 | \item{scale}{A character value indicating the scale of the coordinates 45 | along the genome label. Default value is \code{scale = "bp"}. Options are: 46 | \itemize{ 47 | \item{\code{"bp"}: }{base pairs.} 48 | \item{\code{"Kb"}: }{kilobase pairs. 1 kilobase pair is equal to 49 | 1000 base pairs.} 50 | \item{\code{"Mb"}: }{megabase pairs. 1 megabase pair is equal to 51 | 1000000 base pairs.} 52 | }} 53 | 54 | \item{commas}{A logical value indicating whether to include commas in 55 | start and stop labels. Default value is \code{commas = TRUE}.} 56 | 57 | \item{sequence}{A logical value indicating whether to include sequence 58 | information above the label of an x-axis (only at appropriate resolutions).} 59 | 60 | \item{boxWidth}{A numeric value indicating the width of the boxes 61 | representing sequence information at appropriate resolutions. 62 | Default value is \code{boxWidth = 0.5}.} 63 | 64 | \item{axis}{A character value indicating along which axis to 65 | add genome label. Sequence information will not be displayed along a y-axis. 66 | Default value is \code{axis = "x"}. 67 | Options are: 68 | \itemize{ 69 | \item{\code{"x"}: }{Genome label will be plotted along the x-axis.} 70 | \item{\code{"y"}: }{Genome label will be plotted along the y-axis. 71 | This is typically used for a square Hi-C plot made with 72 | \code{plotHicSquare}.} 73 | }} 74 | 75 | \item{at}{A numeric vector of x-value locations for tick marks.} 76 | 77 | \item{tcl}{A numeric specifying the length of tickmarks as a fraction of 78 | text height. Default value is \code{tcl = 0.5}.} 79 | 80 | \item{x}{A numeric or unit object specifying genome label x-location.} 81 | 82 | \item{y}{A numeric, unit object, or character containing a "b" combined 83 | with a numeric value specifying genome label y-location. 84 | The character value will place the genome label y relative to the bottom 85 | of the most recently plotted plot according to the units of the 86 | plotgardener page.} 87 | 88 | \item{just}{Justification of genome label relative to its (x, y) location. 89 | If there are two values, the first value specifies horizontal justification 90 | and the second value specifies vertical justification. 91 | Possible string values are: \code{"left"}, \code{"right"}, \code{"centre"}, 92 | \code{"center"}, \code{"bottom"}, and \code{"top"}. 93 | Default value is \code{just = c("left", "top")}.} 94 | 95 | \item{default.units}{A string indicating the default units to use 96 | if \code{x} or \code{y} are only given as numerics. 97 | Default value is \code{default.units = "inches"}.} 98 | 99 | \item{params}{An optional \link[plotgardener]{pgParams} object containing 100 | relevant function parameters.} 101 | 102 | \item{...}{Additional grid graphical parameters or digit specifications. 103 | See \link[grid]{gpar} and \link[base]{formatC}.} 104 | } 105 | \value{ 106 | Returns a \code{genomeLabel} object containing 107 | relevant genomic region, placement, and \link[grid]{grob} information. 108 | } 109 | \description{ 110 | Annotate genomic coordinates along the x or y-axis of a plot 111 | } 112 | \examples{ 113 | ## Load hg19 genomic annotation packages 114 | library("TxDb.Hsapiens.UCSC.hg19.knownGene") 115 | library("org.Hs.eg.db") 116 | 117 | ## Create page 118 | pageCreate(width = 5, height = 2, default.units = "inches") 119 | 120 | ## Plot and place gene track on page 121 | genesPlot <- plotGenes( 122 | chrom = "chr8", 123 | chromstart = 1000000, chromend = 2000000, 124 | assembly = "hg19", fill = c("grey", "grey"), 125 | fontcolor = c("grey", "grey"), 126 | x = 0.5, y = 0.25, width = 4, height = 1, 127 | just = c("left", "top"), 128 | default.units = "inches" 129 | ) 130 | 131 | ## Annotate x-axis genome labels at different scales 132 | annoGenomeLabel( 133 | plot = genesPlot, scale = "Mb", 134 | x = 0.5, y = 1.25, just = c("left", "top"), 135 | default.units = "inches" 136 | ) 137 | annoGenomeLabel( 138 | plot = genesPlot, scale = "Kb", 139 | x = 0.5, y = 1.5, just = c("left", "top"), 140 | default.units = "inches" 141 | ) 142 | annoGenomeLabel( 143 | plot = genesPlot, scale = "bp", 144 | x = 0.5, y = 1.75, just = c("left", "top"), 145 | default.units = "inches" 146 | ) 147 | 148 | ## Hide page guides 149 | pageGuideHide() 150 | } 151 | -------------------------------------------------------------------------------- /man/annoHeatmapLegend.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/annoHeatmapLegend.R 3 | \name{annoHeatmapLegend} 4 | \alias{annoHeatmapLegend} 5 | \title{Add a color scale legend for heatmap-style plots} 6 | \usage{ 7 | annoHeatmapLegend( 8 | plot, 9 | orientation = "v", 10 | fontsize = 8, 11 | fontcolor = "dark grey", 12 | scientific = FALSE, 13 | digits = 1, 14 | ticks = FALSE, 15 | breaks = NULL, 16 | border = FALSE, 17 | x, 18 | y, 19 | width, 20 | height, 21 | just = c("left", "top"), 22 | default.units = "inches", 23 | params = NULL, 24 | ... 25 | ) 26 | } 27 | \arguments{ 28 | \item{plot}{Heatmap-style plot object to add heatmap legend for.} 29 | 30 | \item{orientation}{A string specifying legend orientation. 31 | Default value is \code{orientation = "v"}. Options are: 32 | \itemize{ 33 | \item{\code{"v"}: }{Vertical legend orientation.} 34 | \item{\code{"h"}: }{Horizontal legend orientation.} 35 | }} 36 | 37 | \item{fontsize}{A numeric specifying text fontsize in points. 38 | Default value is \code{fontsize = 8}.} 39 | 40 | \item{fontcolor}{Character value specfying text fontcolor. 41 | Default value is \code{fontcolor = "dark grey"}.} 42 | 43 | \item{scientific}{Logical value specifying if numeric color value labels 44 | should be encoded in scientific format. 45 | Default value is \code{scientific = FALSE}.} 46 | 47 | \item{digits}{Numeric specifying how many significant digits to include 48 | of numeric color value labels. Default value is \code{digits = 1}.} 49 | 50 | \item{ticks}{Logical value specifying if tick marks on the heatmap 51 | colorbar should be visible. Default value is \code{ticks = FALSE}.} 52 | 53 | \item{breaks}{A numeric vector specifying tick breaks. 54 | Default value is \code{breaks = NULL}.} 55 | 56 | \item{border}{Logical value indicating whether to add a border around 57 | heatmap legend. Default value is \code{border = FALSE}.} 58 | 59 | \item{x}{A numeric or unit object specifying x-location of legend.} 60 | 61 | \item{y}{A numeric, unit object, or character containing a "b" combined 62 | with a numeric value specifying y-location of legend. 63 | The character value will place the legend y relative to the bottom of the 64 | most recently plotted plot according to the units of 65 | the plotgardener page.} 66 | 67 | \item{width}{A numeric or unit object specifying width of legend.} 68 | 69 | \item{height}{A numeric or unit object specifying height of legend.} 70 | 71 | \item{just}{Justification of heatmap legend relative to 72 | its (x, y) location. If there are two values, the first value specifies 73 | horizontal justification and the second value specifies vertical 74 | justification. Possible string values are: \code{"left"}, \code{"right"}, 75 | \code{"centre"}, \code{"center"}, \code{"bottom"}, and \code{"top"}. 76 | Default value is \code{just = c("left", "top")}.} 77 | 78 | \item{default.units}{A string indicating the default units to use if 79 | \code{x}, \code{y}, \code{width}, or \code{height} are only given as 80 | numerics. Default value is \code{default.units = "inches"}.} 81 | 82 | \item{params}{An optional \link[plotgardener]{pgParams} object containing 83 | relevant function parameters.} 84 | 85 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 86 | } 87 | \value{ 88 | Returns a \code{heatmapLegend} object with relevant 89 | color value, placement, and \link[grid]{grob} information. 90 | } 91 | \description{ 92 | Add a color scale legend for heatmap-style plots 93 | } 94 | \examples{ 95 | ## Load Hi-C data 96 | library(plotgardenerData) 97 | data("IMR90_HiC_10kb") 98 | 99 | ## Create page 100 | pageCreate(width = 4, height = 3.5, default.units = "inches") 101 | 102 | ## Plot and place a square Hi-C plot 103 | hicPlot <- plotHicSquare( 104 | data = IMR90_HiC_10kb, resolution = 10000, 105 | zrange = c(0, 70), 106 | chrom = "chr21", 107 | chromstart = 28000000, chromend = 30300000, 108 | assembly = "hg19", 109 | x = 0.5, y = 0.5, width = 2.5, height = 2.5, 110 | just = c("left", "top"), 111 | default.units = "inches" 112 | ) 113 | 114 | ## Add heatmap legend 115 | annoHeatmapLegend( 116 | plot = hicPlot, 117 | x = 3.2, y = 0.5, width = 0.12, height = 1.2, 118 | just = c("left", "top"), default.units = "inches" 119 | ) 120 | 121 | ## Annotate genome label 122 | annoGenomeLabel( 123 | plot = hicPlot, x = 0.5, y = 3.03, scale = "Mb", 124 | just = c("left", "top") 125 | ) 126 | 127 | ## Hide page guides 128 | pageGuideHide() 129 | } 130 | -------------------------------------------------------------------------------- /man/annoHighlight.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/annoHighlight.R 3 | \name{annoHighlight} 4 | \alias{annoHighlight} 5 | \title{Annotates a highlight box around a specified genomic region of a 6 | plot} 7 | \usage{ 8 | annoHighlight( 9 | plot, 10 | chrom, 11 | chromstart = NULL, 12 | chromend = NULL, 13 | fill = "grey", 14 | linecolor = NA, 15 | alpha = 0.4, 16 | y, 17 | height, 18 | just = c("left", "top"), 19 | default.units = "inches", 20 | params = NULL, 21 | ... 22 | ) 23 | } 24 | \arguments{ 25 | \item{plot}{Input plot on which to annotate genomic region.} 26 | 27 | \item{chrom}{Chromosome of region to be highlighted, as a string.} 28 | 29 | \item{chromstart}{Integer start position on chromosome to be highlighted.} 30 | 31 | \item{chromend}{Integer end position on chromosome to be highlighted.} 32 | 33 | \item{fill}{A character value specifying highlight box fill color. 34 | Default value is \code{fill = "grey"}.} 35 | 36 | \item{linecolor}{A character value specifying highlight box line color. 37 | Default value is \code{linecolor = NA}.} 38 | 39 | \item{alpha}{Numeric value specifying color transparency. 40 | Default value is \code{alpha = 0.4}.} 41 | 42 | \item{y}{A numeric, unit object, or character containing a "b" combined 43 | with a numeric value specifying square highlight box y-location. 44 | The character value will place the highlight box y relative to the 45 | bottom of the most recently plotted plot according to the 46 | units of the \code{plotgardener} page.} 47 | 48 | \item{height}{A numeric or unit object specifying highlight box height.} 49 | 50 | \item{just}{Justification of highlight box relative to its (x, y) 51 | location. If there are two values, the first value specifies horizontal 52 | justification and the second value specifies vertical justification. 53 | Possible string values are: \code{"left"}, \code{"right"}, 54 | \code{"centre"}, \code{"center"}, \code{"bottom"}, and \code{"top"}. 55 | Default value is \code{just = c("left", "top")}.} 56 | 57 | \item{default.units}{A string indicating the default units to use if 58 | \code{y} or \code{height} are only given as numerics or numeric vectors. 59 | Default value is \code{default.units = "inches"}.} 60 | 61 | \item{params}{An optional \link[plotgardener]{pgParams} object containing 62 | relevant function parameters.} 63 | 64 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 65 | } 66 | \value{ 67 | Returns a \code{highlight} object containing relevant 68 | genomic region, placement, and \link[grid]{grob} information. 69 | } 70 | \description{ 71 | Annotates a highlight box around a specified genomic region of a 72 | plot 73 | } 74 | \examples{ 75 | ## Create a page 76 | pageCreate(width = 7.5, height = 1.5, default.units = "inches") 77 | 78 | ## Plot and place a signal plot 79 | library(plotgardenerData) 80 | data("IMR90_ChIP_H3K27ac_signal") 81 | region <- pgParams( 82 | chrom = "chr21", 83 | chromstart = 28000000, chromend = 30300000, 84 | assembly = "hg19", 85 | range = c(0, 45) 86 | ) 87 | signalPlot <- plotSignal( 88 | data = IMR90_ChIP_H3K27ac_signal, params = region, 89 | x = 0.5, y = 0.25, width = 6.5, height = 0.65, 90 | just = c("left", "top"), 91 | default.units = "inches" 92 | ) 93 | 94 | ## Highlight genomic region on signal plot 95 | annoHighlight( 96 | plot = signalPlot, 97 | chrom = "chr21", 98 | chromstart = 29000000, chromend = 29125000, 99 | y = 0.25, height = 1, just = c("left", "top"), 100 | default.units = "inches" 101 | ) 102 | 103 | ## Plot text label 104 | plotText( 105 | label = "region of interest", fontsize = 8, fontcolor = "black", 106 | x = 3.5, y = 0.2, just = "bottom", default.units = "inches" 107 | ) 108 | 109 | ## Plot genome label 110 | plotGenomeLabel( 111 | chrom = "chr21", 112 | chromstart = 28000000, chromend = 30300000, 113 | assembly = "hg19", 114 | x = 0.5, y = 1.3, length = 6.5, default.units = "inches" 115 | ) 116 | 117 | ## Hide page guides 118 | pageGuideHide() 119 | } 120 | -------------------------------------------------------------------------------- /man/annoPixels.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/annoPixels.R 3 | \name{annoPixels} 4 | \alias{annoPixels} 5 | \title{Annotate pixels in a Hi-C plot} 6 | \usage{ 7 | annoPixels( 8 | plot, 9 | data, 10 | type = "box", 11 | half = "inherit", 12 | shift = 4, 13 | params = NULL, 14 | quiet = FALSE, 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{plot}{Hi-C plot object from \code{plotHicSquare} or 20 | \code{plotHicTriangle} on which to annotate pixels.} 21 | 22 | \item{data}{A string specifying the BEDPE file path, a dataframe in BEDPE 23 | format specifying pixel positions, or a 24 | \link[InteractionSet]{GInteractions} object specifying pixel 25 | positions.} 26 | 27 | \item{type}{Character value specifying type of annotation. 28 | Default value is \code{type = "box"}. Options are: 29 | \itemize{ 30 | \item{\code{"box"}: }{Boxes are drawn around each pixel.} 31 | \item{\code{"circle"}: }{Circles are drawn around each pixel.} 32 | \item{\code{"arrow"}: }{Arrows are drawn pointing to each pixel.} 33 | }} 34 | 35 | \item{half}{Character value specifying which half of hic plots 36 | to annotate. Triangle Hi-C plots will always default to the entirety of 37 | the triangular plot. Default value is \code{half = "inherit"}. Options are: 38 | \itemize{ 39 | \item{\code{"inherit"}: }{Pixels will be annotated on the \code{half} 40 | inherited by the input Hi-C plot.} 41 | \item{\code{"both"}: }{Pixels will be annotated on both halves of the 42 | diagonal of a square Hi-C plot.} 43 | \item{\code{"top"}: }{Pixels will be annotated on the upper diagonal 44 | half of a square Hi-C plot.} 45 | \item{\code{"bottom"}: }{Pixels will be annotated on the bottom diagonal 46 | half of a square Hi-C plot.} 47 | }} 48 | 49 | \item{shift}{Numeric specifying the number of pixels on either end of 50 | main pixel in a box or circle. Numeric specifying number of pixels 51 | for the length of an arrow.} 52 | 53 | \item{params}{An optional \link[plotgardener]{pgParams} object 54 | containing relevant function parameters.} 55 | 56 | \item{quiet}{A logical indicating whether or not to print messages.} 57 | 58 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 59 | } 60 | \value{ 61 | Returns a \code{pixel} object containing relevant 62 | genomic region, placement, and \link[grid]{grob} information. 63 | } 64 | \description{ 65 | Annotate pixels in a Hi-C plot 66 | } 67 | \examples{ 68 | ## Load Hi-C data and BEDPE data 69 | library(plotgardenerData) 70 | data("IMR90_HiC_10kb") 71 | data("IMR90_DNAloops_pairs") 72 | 73 | ## Create page 74 | pageCreate(width = 4.5, height = 4, default.units = "inches") 75 | 76 | ## Plot and place a square Hi-C plot 77 | hicPlot <- plotHicSquare( 78 | data = IMR90_HiC_10kb, resolution = 10000, 79 | zrange = c(0, 70), 80 | chrom = "chr21", 81 | chromstart = 28000000, chromend = 30300000, 82 | assembly = "hg19", 83 | x = 0.5, y = 0.5, width = 3, height = 3, 84 | just = c("left", "top"), 85 | default.units = "inches" 86 | ) 87 | 88 | ## Annotate loops of both sides of Hi-C plot with squares 89 | pixels <- annoPixels( 90 | plot = hicPlot, data = IMR90_DNAloops_pairs, type = "box", 91 | half = "both" 92 | ) 93 | 94 | ## Annotate loops on one side of Hi-C plot with arrows 95 | ## and the other side with circles 96 | pagePlotRemove(plot = pixels) 97 | pixels1 <- annoPixels( 98 | plot = hicPlot, data = IMR90_DNAloops_pairs, 99 | type = "arrow", half = "top", shift = 8 100 | ) 101 | pixels2 <- annoPixels( 102 | plot = hicPlot, data = IMR90_DNAloops_pairs, 103 | type = "circle", half = "bottom" 104 | ) 105 | 106 | ## Annotate heatmap legend 107 | annoHeatmapLegend( 108 | plot = hicPlot, 109 | x = 3.6, y = 0.5, width = 0.12, height = 1.2, 110 | just = c("left", "top"), default.units = "inches" 111 | ) 112 | 113 | ## Annotate genome label 114 | annoGenomeLabel( 115 | plot = hicPlot, x = 0.5, y = 3.53, scale = "Mb", 116 | just = c("left", "top") 117 | ) 118 | 119 | ## Hide page guides 120 | pageGuideHide() 121 | } 122 | -------------------------------------------------------------------------------- /man/annoSegments.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/annoSegments.R 3 | \name{annoSegments} 4 | \alias{annoSegments} 5 | \title{Annotates a line segment within a plot} 6 | \usage{ 7 | annoSegments( 8 | x0, 9 | y0, 10 | x1, 11 | y1, 12 | plot, 13 | default.units = "native", 14 | linecolor = "black", 15 | lwd = 1, 16 | lty = 1, 17 | lineend = "butt", 18 | linejoin = "mitre", 19 | arrow = NULL, 20 | params = NULL, 21 | ... 22 | ) 23 | } 24 | \arguments{ 25 | \item{x0}{A numeric vector or unit object indicating the starting 26 | x-values of the line segments.} 27 | 28 | \item{y0}{A numeric vector or unit object indicating the starting 29 | y-values of the line segments.} 30 | 31 | \item{x1}{A numeric vector or unit object indicating the stopping 32 | x-values of the line segments.} 33 | 34 | \item{y1}{A numeric vector or unit object indicating the stopping 35 | y-values of the line segments.} 36 | 37 | \item{plot}{Input plotgardener plot to internally plot line segments 38 | relative to.} 39 | 40 | \item{default.units}{A string indicating the default units to use 41 | if \code{x0}, \code{y0}, \code{x1}, or \code{y1} are only given 42 | as numeric vectors. Default value is \code{default.units = "native"}.} 43 | 44 | \item{linecolor}{A character value specifying segment line color. 45 | Default value is \code{linecolor = "black"}.} 46 | 47 | \item{lwd}{A numeric specifying segment line width. 48 | Default value is \code{lwd = 1}.} 49 | 50 | \item{lty}{A numeric specifying segment line type. 51 | Default value is \code{lty = 1}.} 52 | 53 | \item{lineend}{A character value specifying line end style. 54 | Default value is \code{lineend = "butt"}. Options are: 55 | \itemize{ 56 | \item{\code{"round"}: Segment ends are rounded.} 57 | \item{\code{"butt"}: Segment ends end exactly where ended.} 58 | \item{\code{"square"}: Segment ends are squared.} 59 | }} 60 | 61 | \item{linejoin}{A character value specifying line join style. 62 | Default value is \code{linejoin = "mitre"}. Options are: 63 | \itemize{ 64 | \item{\code{"round"}: }{Line joins are rounded.} 65 | \item{\code{"mitre"}: }{Line joins are sharp corners.} 66 | \item{\code{"bevel"}: }{Line joins are flattened corners.} 67 | }} 68 | 69 | \item{arrow}{A list describing arrow heads to place at either 70 | end of the line segments, as produced by the \link[grid]{arrow} function.} 71 | 72 | \item{params}{An optional \link[plotgardener]{pgParams} object containing 73 | relevant function parameters.} 74 | 75 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 76 | } 77 | \value{ 78 | Returns a \code{segments} object containing relevant 79 | placement and \link[grid]{grob} information. 80 | } 81 | \description{ 82 | Annotates a line segment within a plot 83 | } 84 | \examples{ 85 | library(grid) 86 | ## Create a page 87 | pageCreate(width = 7.5, height = 2.5, default.units = "inches") 88 | 89 | ## Plot a Manhattan plot 90 | library(plotgardenerData) 91 | library("TxDb.Hsapiens.UCSC.hg19.knownGene") 92 | data("hg19_insulin_GWAS") 93 | manhattanPlot <- plotManhattan( 94 | data = hg19_insulin_GWAS, assembly = "hg19", 95 | fill = c("grey", "#37a7db"), 96 | sigLine = TRUE, 97 | col = "grey", lty = 2, range = c(0, 14), 98 | x = 0.5, y = 0, width = 6.5, height = 2, 99 | just = c("left", "top"), 100 | default.units = "inches" 101 | ) 102 | 103 | ## Annotate genome label 104 | annoGenomeLabel( 105 | plot = manhattanPlot, x = 0.5, y = 2, fontsize = 8, 106 | just = c("left", "top"), 107 | default.units = "inches" 108 | ) 109 | plotText( 110 | label = "Chromosome", fontsize = 8, 111 | x = 3.75, y = 2.20, just = "center", default.units = "inches" 112 | ) 113 | 114 | ## Annotate y-axis 115 | annoYaxis( 116 | plot = manhattanPlot, at = c(0, 2, 4, 6, 8, 10, 12, 14), 117 | axisLine = TRUE, fontsize = 8 118 | ) 119 | 120 | ## Annotate a line segment for an additional significance line of 121 | ## the Manhattan plot 122 | annoSegments( 123 | x0 = unit(0, "npc"), y0 = 10, 124 | x1 = unit(1, "npc"), y1 = 10, 125 | plot = manhattanPlot, default.units = "native", 126 | linecolor = "red", lty = 2 127 | ) 128 | 129 | ## Plot y-axis label 130 | plotText( 131 | label = "-log10(p-value)", x = 0.15, y = 1, rot = 90, 132 | fontsize = 8, fontface = "bold", just = "center", 133 | default.units = "inches" 134 | ) 135 | 136 | ## Hide page guides 137 | pageGuideHide() 138 | } 139 | \seealso{ 140 | \link[grid]{grid.segments}, \link[grid]{arrow} 141 | } 142 | -------------------------------------------------------------------------------- /man/annoText.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/annoText.R 3 | \name{annoText} 4 | \alias{annoText} 5 | \title{Annotates text within a plot} 6 | \usage{ 7 | annoText( 8 | label, 9 | fontcolor = "black", 10 | fontsize = 12, 11 | rot = 0, 12 | check.overlap = FALSE, 13 | plot, 14 | x, 15 | y, 16 | just = "center", 17 | default.units = "native", 18 | params = NULL, 19 | ... 20 | ) 21 | } 22 | \arguments{ 23 | \item{label}{Character or expression of text to be plotted.} 24 | 25 | \item{fontcolor}{A character value specifying text fontcolor. 26 | Default value is \code{fontcolor = "black"}.} 27 | 28 | \item{fontsize}{A numeric specifying text fontsize in points. 29 | Default value is \code{fontsize = 12}.} 30 | 31 | \item{rot}{A numeric specifying the angle to rotate the text. 32 | Default value is \code{rot = 0}.} 33 | 34 | \item{check.overlap}{A logical value to indicate whether to check for 35 | and omit overlapping text. Default value is \code{check.overlap = FALSE}.} 36 | 37 | \item{plot}{Input plotgardener plot to internally place text relative to.} 38 | 39 | \item{x}{A numeric vector or unit object specifying text x-location.} 40 | 41 | \item{y}{A numeric vector or unit object specifying text y-location.} 42 | 43 | \item{just}{Justification of text relative to its (x, y) location. 44 | If there are two values, the first value specifies horizontal 45 | justification and the second value specifies vertical justification. 46 | Possible string values are: \code{"left"}, \code{"right"}, 47 | \code{"centre"}, \code{"center"}, \code{"bottom"}, and \code{"top"}. 48 | Default value is \code{just = "center"}.} 49 | 50 | \item{default.units}{A string indicating the default units to use if 51 | \code{x} or \code{y} are only given as numerics or numeric vectors. 52 | Default value is \code{default.units = "native"}.} 53 | 54 | \item{params}{An optional \link[plotgardener]{pgParams} object 55 | containing relevant function parameters.} 56 | 57 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 58 | } 59 | \value{ 60 | Returns a \code{text} object containing 61 | relevant placement and \link[grid]{grob} information. 62 | } 63 | \description{ 64 | Annotates text within a plot 65 | } 66 | \examples{ 67 | ## Create a page 68 | pageCreate(width = 4, height = 4, default.units = "inches") 69 | 70 | ## Plot text relative to a plotgardener plot 71 | library(plotgardenerData) 72 | data("IMR90_HiC_10kb") 73 | hicPlot <- plotHicSquare( 74 | data = IMR90_HiC_10kb, chrom = "chr21", 75 | chromstart = 28000000, chromend = 29500000, 76 | assembly = "hg19", 77 | zrange = c(0, 70), 78 | x = 0.5, y = 0.5, width = 3, height = 3, 79 | just = c("left", "top"), 80 | default.units = "inches" 81 | ) 82 | annoGenomeLabel( 83 | plot = hicPlot, x = 0.5, y = 3.55, scale = "Mb", 84 | just = c("left", "top"), default.units = "inches" 85 | ) 86 | 87 | annoText( 88 | label = "Loop", fontsize = 8, plot = hicPlot, 89 | x = 29075000, y = 28150000, 90 | just = "center", default.units = "native" 91 | ) 92 | 93 | ## Hide page guides 94 | pageGuideHide() 95 | } 96 | \seealso{ 97 | \link[grid]{grid.text} 98 | } 99 | -------------------------------------------------------------------------------- /man/annoXaxis.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/annoXaxis.R 3 | \name{annoXaxis} 4 | \alias{annoXaxis} 5 | \title{Add an x-axis to a plot} 6 | \usage{ 7 | annoXaxis( 8 | plot, 9 | at = NULL, 10 | label = TRUE, 11 | main = TRUE, 12 | scipen = 999, 13 | axisLine = FALSE, 14 | params = NULL, 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{plot}{Plot object to annotate with x-axis.} 20 | 21 | \item{at}{A numeric vector of x-value locations for tick marks.} 22 | 23 | \item{label}{A logical value indicating whether to draw the labels on 24 | the tick marks, or an expression or character vector which specify 25 | the labels to use. 26 | If not logical, must be the same length as the \code{at} argument.} 27 | 28 | \item{main}{A logical value indicating whether to draw the x-axis at the 29 | bottom of the plot. Default value is \code{main = TRUE}. Options are: 30 | \itemize{ 31 | \item{\code{TRUE}: }{x-axis is drawn at the bottom of the plot.} 32 | \item{\code{FALSE}: }{x-axis is drawn at the top of the plot.} 33 | }} 34 | 35 | \item{scipen}{An integer indicating the penalty to be applied when 36 | deciding to print numeric values in fixed or exponential notation. 37 | Default value is \code{scipen = 999}.} 38 | 39 | \item{axisLine}{A logical value indicating whether to show the axis line. 40 | Default value is \code{axisLine = FALSE}.} 41 | 42 | \item{params}{An optional \link[plotgardener]{pgParams} object 43 | containing relevant function parameters.} 44 | 45 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 46 | } 47 | \value{ 48 | Returns a \code{xaxis} object containing 49 | relevant \link[grid]{grob} information. 50 | } 51 | \description{ 52 | Add an x-axis to a plot 53 | } 54 | \examples{ 55 | ## Load transcript information 56 | library("TxDb.Hsapiens.UCSC.hg19.knownGene") 57 | library("org.Hs.eg.db") 58 | 59 | ## Create page 60 | pageCreate(width = 7.5, height = 4.5, default.units = "inches") 61 | 62 | ## Plot gene transcripts 63 | transcriptPlot <- plotTranscripts( 64 | chrom = "chr1", 65 | chromstart = 1000000, 66 | chromend = 2000000, 67 | assembly = "hg19", 68 | x = 0.5, y = 0, 69 | width = 6.5, height = 4, 70 | just = c("left", "top"), 71 | default.units = "inches" 72 | ) 73 | 74 | ## Add standard x-axis to transcript plot 75 | annoXaxis( 76 | plot = transcriptPlot, 77 | at = c(1000000, 1250000, 1500000, 1750000, 2000000), 78 | fontsize = 8 79 | ) 80 | plotText( 81 | label = "Basepairs", fontsize = 10, fontface = "bold", 82 | x = 3.75, y = 4.3, just = "top" 83 | ) 84 | 85 | ## Hide page guides 86 | pageGuideHide() 87 | } 88 | -------------------------------------------------------------------------------- /man/annoYaxis.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/annoYaxis.R 3 | \name{annoYaxis} 4 | \alias{annoYaxis} 5 | \title{Add a y-axis to a plot} 6 | \usage{ 7 | annoYaxis( 8 | plot, 9 | at = NULL, 10 | label = TRUE, 11 | main = TRUE, 12 | scipen = 999, 13 | axisLine = FALSE, 14 | params = NULL, 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{plot}{Plot object to annotate with y-axis.} 20 | 21 | \item{at}{A numeric vector of y-value locations for tick marks.} 22 | 23 | \item{label}{A logical value indicating whether to draw the labels 24 | on the tick marks, or an expression or character vector which specify 25 | the labels to use. 26 | If not logical, must be the same length as the \code{at} argument.} 27 | 28 | \item{main}{A logical value indicating whether to draw the y-axis at 29 | the left of the plot. Default value is \code{main = TRUE}. Options are: 30 | \itemize{ 31 | \item{\code{TRUE}: }{y-axis is drawn at the left of the plot.} 32 | \item{\code{FALSE}: }{y-axis is drawn at the right of the plot.} 33 | }} 34 | 35 | \item{scipen}{An integer indicating the penalty to be applied when 36 | deciding to print numeric values in fixed or exponential notation. 37 | Default value is \code{scipen = 999}.} 38 | 39 | \item{axisLine}{A logical value indicating whether to show the axis line. 40 | Default value is \code{axisLine = FALSE}.} 41 | 42 | \item{params}{An optional \link[plotgardener]{pgParams} object 43 | containing relevant function parameters.} 44 | 45 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 46 | } 47 | \value{ 48 | Returns a \code{yaxis} object containing 49 | relevant \link[grid]{grob} information. 50 | } 51 | \description{ 52 | Add a y-axis to a plot 53 | } 54 | \examples{ 55 | ## Load Hi-C data 56 | library(plotgardenerData) 57 | data("IMR90_HiC_10kb") 58 | 59 | ## Create page 60 | pageCreate(width = 4, height = 3.5, default.units = "inches") 61 | 62 | ## Plot and place a square Hi-C plot 63 | hicPlot <- plotHicSquare( 64 | data = IMR90_HiC_10kb, resolution = 10000, 65 | zrange = c(0, 70), 66 | chrom = "chr21", 67 | chromstart = 28000000, chromend = 30300000, 68 | assembly = "hg19", 69 | x = 1, y = 0.5, width = 2.5, height = 2.5, 70 | just = c("left", "top"), 71 | default.units = "inches" 72 | ) 73 | 74 | ## Add standard y-axis to Hi-C plot 75 | annoYaxis( 76 | plot = hicPlot, at = c(28000000, 29000000, 30300000), 77 | fontsize = 10 78 | ) 79 | 80 | ## Annotate genome label on x-axis 81 | annoGenomeLabel(plot = hicPlot, x = 1, y = 3.03) 82 | 83 | ## Annotate heatmap legend 84 | annoHeatmapLegend( 85 | plot = hicPlot, 86 | x = 3.6, y = 0.5, width = 0.12, height = 1.2 87 | ) 88 | 89 | ## Hide page guides 90 | pageGuideHide() 91 | } 92 | -------------------------------------------------------------------------------- /man/annoZoomLines.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/annoZoomLines.R 3 | \name{annoZoomLines} 4 | \alias{annoZoomLines} 5 | \title{Annotates zoom lines for a specified genomic region of a plot} 6 | \usage{ 7 | annoZoomLines( 8 | plot, 9 | chrom, 10 | chromstart = NULL, 11 | chromend = NULL, 12 | y0, 13 | x1 = NULL, 14 | y1, 15 | extend = 0, 16 | default.units = "inches", 17 | linecolor = "grey", 18 | lty = 2, 19 | params = NULL, 20 | ... 21 | ) 22 | } 23 | \arguments{ 24 | \item{plot}{Input plot to annotate genomic region zoom lines from.} 25 | 26 | \item{chrom}{Chromosome of region to draw zoom lines from, as a string.} 27 | 28 | \item{chromstart}{Integer start position on chromosome to draw 29 | zoom lines from.} 30 | 31 | \item{chromend}{Integer end position on chromosome to draw 32 | zoom lines from.} 33 | 34 | \item{y0}{A numeric vector or unit object indicating the starting 35 | y-values of the zoom line segments. If two values are given, 36 | the first value will correspond to the left zoom line and the 37 | second value will correspond to the right zoom line.} 38 | 39 | \item{x1}{A numeric vector or unit object indicating the stopping 40 | x-values of the zoom line segments. If two values are given, 41 | the first value will correspond to the left zoom line and the 42 | second value will correspond to the right zoom line. If NULL, 43 | straight lines from zoomed genomic region will be drawn.} 44 | 45 | \item{y1}{A numeric vector or unit object indicating the stopping 46 | y-values of the zoom line segments. If two values are given, 47 | the first value will correspond to the left zoom line and the 48 | second value will correspond to the right zoom line.} 49 | 50 | \item{extend}{A numeric vector or unit object indicating the length 51 | to extend straight lines from each end 52 | of the zoom line segments. If two values are given, the first value 53 | will correspond to the top extension length 54 | and the second value will correspond to the bottom extension length. 55 | Default value is \code{extend = 0}.} 56 | 57 | \item{default.units}{A string indicating the default units to use 58 | if \code{y0}, \code{x1}, \code{y1}, or \code{extend} are only given 59 | as numerics or numeric vectors. 60 | Default value is \code{default.units = "inches"}.} 61 | 62 | \item{linecolor}{A character value specifying zoom line color. 63 | Default value is \code{linecolor = "grey"}.} 64 | 65 | \item{lty}{A numeric specifying zoom line type. 66 | Default value is \code{lty = 2}.} 67 | 68 | \item{params}{An optional \link[plotgardener]{pgParams} 69 | object containing relevant function parameters.} 70 | 71 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 72 | } 73 | \value{ 74 | Returns a \code{zoom} object containing 75 | relevant genomic region, placement, and \link[grid]{grob} information. 76 | } 77 | \description{ 78 | Annotates zoom lines for a specified genomic region of a plot 79 | } 80 | \examples{ 81 | ## Create a page 82 | pageCreate(width = 7.5, height = 4.75, default.units = "inches") 83 | 84 | ## Plot and place a Manhattan plot 85 | library(plotgardenerData) 86 | library("TxDb.Hsapiens.UCSC.hg19.knownGene") 87 | data("hg19_insulin_GWAS") 88 | manhattanPlot <- plotManhattan( 89 | data = hg19_insulin_GWAS, assembly = "hg19", 90 | fill = c("grey", "#37a7db"), 91 | sigLine = FALSE, 92 | col = "grey", lty = 2, range = c(0, 14), 93 | x = 0.5, y = 0, width = 6.5, height = 2, 94 | just = c("left", "top"), 95 | default.units = "inches" 96 | ) 97 | annoYaxis( 98 | plot = manhattanPlot, at = c(0, 2, 4, 6, 8, 10, 12, 14), 99 | axisLine = TRUE, fontsize = 8 100 | ) 101 | 102 | ## Annotate zoom lines for a region on chromsome 21 103 | zoomRegion <- pgParams( 104 | chrom = "chr21", 105 | chromstart = 28000000, chromend = 30300000, 106 | assembly = "hg19" 107 | ) 108 | annoZoomLines( 109 | plot = manhattanPlot, params = zoomRegion, 110 | y0 = 2, x1 = c(0.5, 7), y1 = 2.5, extend = c(0, 1.1), 111 | default.units = "inches", 112 | lty = 3 113 | ) 114 | 115 | ## Annotate highlight region for zoom region 116 | annoHighlight( 117 | plot = manhattanPlot, params = zoomRegion, 118 | y = 2, height = 2, just = c("left", "bottom"), 119 | default.units = "inches", 120 | fill = "red", alpha = 0.8 121 | ) 122 | 123 | ## Plot Manhattan plot data and signal track under zoom lines 124 | manhattanPlotZoom <- plotManhattan( 125 | data = hg19_insulin_GWAS, 126 | fill = "grey", 127 | sigLine = FALSE, 128 | baseline = TRUE, 129 | params = zoomRegion, range = c(0, 14), 130 | x = 0.5, y = 2.6, 131 | width = 6.5, height = 1 132 | ) 133 | data("IMR90_ChIP_H3K27ac_signal") 134 | signalPlot <- plotSignal( 135 | data = IMR90_ChIP_H3K27ac_signal, params = zoomRegion, 136 | range = c(0, 45), 137 | x = 0.5, y = "b0.1", 138 | width = 6.5, height = 0.65, 139 | just = c("left", "top"), 140 | default.units = "inches" 141 | ) 142 | 143 | ## Plot genome label 144 | plotGenomeLabel( 145 | chrom = "chr21", 146 | chromstart = 28000000, chromend = 30300000, 147 | assembly = "hg19", 148 | x = 0.5, y = 4.4, length = 6.5, 149 | default.units = "inches" 150 | ) 151 | 152 | ## Hide page guides 153 | pageGuideHide() 154 | } 155 | -------------------------------------------------------------------------------- /man/assembly.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/assembly.R 3 | \name{assembly} 4 | \alias{assembly} 5 | \title{Make a \code{assembly} object for alternate TxDb, OrgDb,and BSgenome 6 | genomic annotation packages} 7 | \usage{ 8 | assembly( 9 | Genome, 10 | TxDb, 11 | OrgDb, 12 | gene.id.column = "ENTREZID", 13 | display.column = "SYMBOL", 14 | BSgenome = NULL 15 | ) 16 | } 17 | \arguments{ 18 | \item{Genome}{String indicating the name of the genome assembly.} 19 | 20 | \item{TxDb}{String of existing TxDb package name or a TxDb object.} 21 | 22 | \item{OrgDb}{String of the desired OrgDb package name.} 23 | 24 | \item{gene.id.column}{String of the TxDb column name that refers to 25 | the given TxDb gene IDs. 26 | Default value is \code{gene.id.column = "ENTREZID"}.} 27 | 28 | \item{display.column}{String of the OrgDb column name that refers to 29 | the type of gene symbol to be displayed in plots. 30 | Default value is \code{display.column = "SYMBOL"}.} 31 | 32 | \item{BSgenome}{String of the desired BSgenome package name.} 33 | } 34 | \value{ 35 | Returns a \code{assembly} object containing all input parameters. 36 | } 37 | \description{ 38 | Make a \code{assembly} object for alternate TxDb, OrgDb,and BSgenome 39 | genomic annotation packages 40 | } 41 | \examples{ 42 | ## Create a custom `assembly` object for hg38/GRCh38 packages 43 | newAssembly <- assembly( 44 | Genome = "hg38_GRCh38", 45 | TxDb = "TxDb.Hsapiens.UCSC.hg38.knownGene", 46 | OrgDb = "org.Hs.eg.db", 47 | BSgenome = "BSgenome.Hsapiens.NCBI.GRCh38" 48 | ) 49 | } 50 | \seealso{ 51 | \link[GenomicFeatures]{TxDb}, \link[AnnotationDbi]{OrgDb-class}, 52 | \link[BSgenome]{BSgenome} 53 | } 54 | -------------------------------------------------------------------------------- /man/c.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pgParams.R 3 | \name{c} 4 | \alias{c} 5 | \title{Combine multiple pgParams objects into a vector} 6 | \usage{ 7 | c(..., recursive = FALSE) 8 | } 9 | \arguments{ 10 | \item{...}{\link[plotgardener]{pgParams} objects to be concatenated.} 11 | 12 | \item{recursive}{logical. If \code{recursive = TRUE}, the function 13 | recursively descends through lists 14 | (and pairlists) combining all their elements into a vector.} 15 | } 16 | \value{ 17 | \code{NULL} or an expression or a vector of an appropriate mode. 18 | (With no arguments the value is \code{NULL}.) 19 | } 20 | \description{ 21 | Combine multiple pgParams objects into a vector 22 | } 23 | \examples{ 24 | ## Define parameters 25 | p1 <- pgParams(chrom = "chr1", assembly = "hg19") 26 | 27 | ## Define another set of parameters 28 | p2 <- pgParams(fontsize = 10, assembly = "hg19") 29 | 30 | ## Combine parameters into one `pgParams` object 31 | pTotal <- c(p1, p2) 32 | } 33 | -------------------------------------------------------------------------------- /man/calcSignalRange.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotMultiSignal.R 3 | \name{calcSignalRange} 4 | \alias{calcSignalRange} 5 | \title{Calculate a score range for multiple signals} 6 | \usage{ 7 | calcSignalRange( 8 | data, 9 | chrom = NULL, 10 | chromstart = 1, 11 | chromend = .Machine$integer.max, 12 | assembly = "hg38", 13 | negData = FALSE) 14 | } 15 | \arguments{ 16 | \item{data}{List of data to be plotted as character values specifying 17 | multiple bigwig file paths, dataframes in BED format, or 18 | \link[GenomicRanges]{GRanges} objects with metadata column \code{score}.} 19 | 20 | \item{chrom}{Chromosome of data region ragne as a string, if range for a 21 | specific chromosome is desired.} 22 | 23 | \item{chromstart}{Integer start position on chromosome to get data range.} 24 | 25 | \item{chromend}{Integer end position on chromosome to get data range.} 26 | 27 | \item{assembly}{Default genome assembly as a string or a 28 | \link[plotgardener]{assembly} object. 29 | Default value is \code{assembly = "hg38"}.} 30 | 31 | \item{negData}{A logical value indicating whether any of the data has both 32 | positive and negative scores and the signal range should be adjusted 33 | accordingly. Default value is \code{negData = FALSE}.} 34 | } 35 | \value{ 36 | Returns a vector of length 2 with the calculated c(min, max) range. 37 | } 38 | \description{ 39 | Calculate a score range for multiple signals 40 | } 41 | \examples{ 42 | library("plotgardenerData") 43 | data("GM12878_ChIP_CTCF_signal") 44 | data("IMR90_ChIP_CTCF_signal") 45 | data("GM12878_ChIP_H3K27ac_signal") 46 | data("IMR90_ChIP_H3K27ac_signal") 47 | 48 | calcSignalRange(data = list(GM12878_ChIP_CTCF_signal, 49 | GM12878_ChIP_H3K27ac_signal, 50 | IMR90_ChIP_CTCF_signal, 51 | IMR90_ChIP_H3K27ac_signal), 52 | chrom = "chr21", 53 | chromstart = 28150000, chromend = 29150000, 54 | assembly = "hg38", negData = FALSE) 55 | 56 | } 57 | -------------------------------------------------------------------------------- /man/colorby.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colorby.R 3 | \name{colorby} 4 | \alias{colorby} 5 | \title{Handle plotgardener color scaling parameters} 6 | \usage{ 7 | colorby(column, palette = NULL, range = NULL, scalePerRegion = FALSE) 8 | } 9 | \arguments{ 10 | \item{column}{String specifying name of data column to scale colors by.} 11 | 12 | \item{palette}{(optional) A function describing the color palette to use for 13 | color scaling.} 14 | 15 | \item{range}{(optional) A numeric vector specifying the range of values to 16 | apply a color scale to.} 17 | 18 | \item{scalePerRegion}{A logical value indicating whether to adjust 19 | NULL range of numerical `colorby` values to subset of data in a plotted 20 | genomic region. Default value is \code{scalePerRegion = FALSE}.} 21 | } 22 | \value{ 23 | Returns a "\code{colorby}" object. 24 | } 25 | \description{ 26 | \code{colorby} should be used to create a set of parameters 27 | that specify color scaling for the functions \code{plotPairs}, 28 | \code{plotPairsArches}, and \code{plotRanges}. 29 | } 30 | \examples{ 31 | ## Load paired ranges data in BEDPE format 32 | library(plotgardenerData) 33 | data("IMR90_DNAloops_pairs") 34 | 35 | ## Add a length column 36 | IMR90_DNAloops_pairs$length <- 37 | (IMR90_DNAloops_pairs$start2 - IMR90_DNAloops_pairs$start1) / 1000 38 | 39 | ## Plot pairs with colorby object set for `length` column 40 | bedpePlot <- plotPairs( 41 | data = IMR90_DNAloops_pairs, 42 | chrom = "chr21", 43 | chromstart = 27900000, chromend = 30700000, 44 | assembly = "hg19", 45 | fill = colorby("length", palette = 46 | colorRampPalette(c("dodgerblue2", "firebrick2"))), 47 | lwd = 2, spaceHeight = .7, 48 | ) 49 | } 50 | -------------------------------------------------------------------------------- /man/defaultPackages.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/defaultPackages.R 3 | \name{defaultPackages} 4 | \alias{defaultPackages} 5 | \title{Display the default genomic annotation packages associated with a 6 | genome build} 7 | \usage{ 8 | defaultPackages(Genome) 9 | } 10 | \arguments{ 11 | \item{Genome}{String indicating the name of the genome assembly.} 12 | } 13 | \value{ 14 | Returns a list of the default data packages for a genome build. 15 | } 16 | \description{ 17 | Display the default genomic annotation packages associated with a 18 | genome build 19 | } 20 | \examples{ 21 | ## View default genomic annotation packages associated with "hg19" 22 | defaultPackages(Genome = "hg19") 23 | 24 | ## View default genomic annotation packages associated with "mm9" 25 | defaultPackages(Genome = "mm9") 26 | } 27 | -------------------------------------------------------------------------------- /man/dot-checkCool.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/readCool.R 3 | \name{.checkCool} 4 | \alias{.checkCool} 5 | \title{Check for .(m)cool file and contents} 6 | \usage{ 7 | .checkCool(file) 8 | } 9 | \arguments{ 10 | \item{file}{Path to .(m)cool file} 11 | } 12 | \description{ 13 | Check for .(m)cool file and contents 14 | } 15 | \author{ 16 | Sarah Parker 17 | } 18 | -------------------------------------------------------------------------------- /man/dot-checkCoolErrors.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/readCool.R 3 | \name{.checkCoolErrors} 4 | \alias{.checkCoolErrors} 5 | \title{Error checking function for .(m)cool files} 6 | \usage{ 7 | .checkCoolErrors( 8 | file, 9 | chrom, 10 | chromstart, 11 | chromend, 12 | zrange, 13 | altchrom, 14 | altchromstart, 15 | altchromend, 16 | norm, 17 | resolution 18 | ) 19 | } 20 | \arguments{ 21 | \item{file}{Path to .(m)cool file} 22 | 23 | \item{chrom}{User-inputted chromosome} 24 | 25 | \item{chromstart}{User-inputted chromstart, can still be NULL at this point.} 26 | 27 | \item{chromend}{User-inputted chromend, can still be NULL at this point.} 28 | 29 | \item{zrange}{User-inputted zrange.} 30 | 31 | \item{altchrom}{User-inputted alt chromosome.} 32 | 33 | \item{altchromstart}{User-inputted alt chromstart.} 34 | 35 | \item{altchromend}{User-inputted alt chromend.} 36 | 37 | \item{norm}{User-inputted normalization.} 38 | 39 | \item{resolution}{Resolution, either user-inputted or determined by 'auto'.} 40 | } 41 | \description{ 42 | Error checking function for .(m)cool files 43 | } 44 | -------------------------------------------------------------------------------- /man/dot-coolAutoResolution.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/readCool.R 3 | \name{.coolAutoResolution} 4 | \alias{.coolAutoResolution} 5 | \title{Determine best resolution for size of region for .(m)cool files} 6 | \usage{ 7 | .coolAutoResolution(file, chromstart, chromend) 8 | } 9 | \arguments{ 10 | \item{file}{Path to .(m)cool file} 11 | 12 | \item{chromstart}{Chromstart of region} 13 | 14 | \item{chromend}{Chromend of region} 15 | } 16 | \description{ 17 | Determine best resolution for size of region for .(m)cool files 18 | } 19 | -------------------------------------------------------------------------------- /man/dot-coolRegion.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/readCool.R 3 | \name{.coolRegion} 4 | \alias{.coolRegion} 5 | \title{Add (alt)chromstart and (alt)chromend for NULL (alt)chrom region of 6 | .(m)cool files} 7 | \usage{ 8 | .coolRegion(file, chrom, resolution) 9 | } 10 | \arguments{ 11 | \item{file}{Path to .(m)cool file} 12 | 13 | \item{chrom}{Chromosome of region; can also be altchromosome} 14 | 15 | \item{resolution}{Resolution to read chromsome info from} 16 | } 17 | \description{ 18 | Add (alt)chromstart and (alt)chromend for NULL (alt)chrom region of 19 | .(m)cool files 20 | } 21 | -------------------------------------------------------------------------------- /man/dot-pullBinChunks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/readCool.R 3 | \name{.pullBinChunks} 4 | \alias{.pullBinChunks} 5 | \title{Read in data for a bin chunk} 6 | \usage{ 7 | .pullBinChunks( 8 | binChunk, 9 | file, 10 | bin_offsets, 11 | binChunkSize, 12 | datasetPath, 13 | end1bin, 14 | start2bin, 15 | end2bin 16 | ) 17 | } 18 | \arguments{ 19 | \item{binChunk}{The binChunk indeces to read} 20 | 21 | \item{file}{Path to .(m)cool file} 22 | 23 | \item{bin_offsets}{Read in bin1 offsets} 24 | 25 | \item{binChunkSize}{Size of bin chunk, for comparison against the end of 26 | the bin chunk} 27 | 28 | \item{datasetPath}{Dataset path, for specifying resolution in .mcool file} 29 | 30 | \item{end1bin}{Bin where end1 starts} 31 | 32 | \item{start2bin}{Bin for chr2 starts} 33 | 34 | \item{end2bin}{Bin for end2 starts} 35 | } 36 | \description{ 37 | Read in data for a bin chunk 38 | } 39 | -------------------------------------------------------------------------------- /man/figures/homePage-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/man/figures/homePage-1.png -------------------------------------------------------------------------------- /man/figures/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/man/figures/icon.png -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/man/figures/logo.png -------------------------------------------------------------------------------- /man/figures/pg-hex-text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/man/figures/pg-hex-text.png -------------------------------------------------------------------------------- /man/figures/pg-wordmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/man/figures/pg-wordmark.png -------------------------------------------------------------------------------- /man/genomes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/genomes.R 3 | \name{genomes} 4 | \alias{genomes} 5 | \title{Display the included available default genome assemblies} 6 | \usage{ 7 | genomes() 8 | } 9 | \value{ 10 | Returns the included available default genome assemblies 11 | } 12 | \description{ 13 | Display the included available default genome assemblies 14 | } 15 | \examples{ 16 | genomes() 17 | } 18 | -------------------------------------------------------------------------------- /man/mapColors.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mapColors.R 3 | \name{mapColors} 4 | \alias{mapColors} 5 | \title{Maps a numeric or character vector to a color palette and returns 6 | the vector of colors} 7 | \usage{ 8 | mapColors(vector, palette, range = NULL) 9 | } 10 | \arguments{ 11 | \item{vector}{Vector to map to color.} 12 | 13 | \item{palette}{Color palette function.} 14 | 15 | \item{range}{Range of values to map for a numerical value.} 16 | } 17 | \value{ 18 | Returns a character vector of color values. If the input vector is 19 | numerical, this vector will have additional `palette` and `range` 20 | attributes. 21 | } 22 | \description{ 23 | Maps a numeric or character vector to a color palette and returns 24 | the vector of colors 25 | } 26 | \details{ 27 | This function allows for the manual mapping of a numerical or factor 28 | vector to a palette of colors. For a more automatic implementation 29 | of this functionality in plotgardener functions, 30 | \link[plotgardener]{colorby} objects can be used. 31 | } 32 | \examples{ 33 | ## Load paired ranges data in BEDPE format 34 | library(plotgardenerData) 35 | data("IMR90_DNAloops_pairs") 36 | 37 | ## Add a length column 38 | IMR90_DNAloops_pairs$length <- (IMR90_DNAloops_pairs$start2 - 39 | IMR90_DNAloops_pairs$start1) / 1000 40 | 41 | ## Map length column to a vector of colors 42 | colors <- mapColors(vector = IMR90_DNAloops_pairs$length, 43 | palette = colorRampPalette(c("dodgerblue2", "firebrick2"))) 44 | 45 | ## Pass color vector into bbPlotPairsArches 46 | heights <- IMR90_DNAloops_pairs$length / max(IMR90_DNAloops_pairs$length) 47 | pageCreate(width = 7.5, height = 2.1, default.units = "inches", 48 | showGuides = FALSE, xgrid = 0, ygrid = 0) 49 | params <- pgParams( 50 | chrom = "chr21", 51 | chromstart = 27900000, chromend = 30700000, 52 | assembly = "hg19", 53 | width = 7 54 | ) 55 | 56 | archPlot <- plotPairsArches( 57 | data = IMR90_DNAloops_pairs, params = params, 58 | fill = colors, 59 | linecolor = "fill", 60 | archHeight = heights, alpha = 1, 61 | x = 0.25, y = 0.25, height = 1.5, 62 | just = c("left", "top"), 63 | default.units = "inches" 64 | ) 65 | 66 | annoGenomeLabel(plot = archPlot, x = 0.25, y = 1.78, scale = "Mb") 67 | annoHeatmapLegend( 68 | plot = archPlot, fontcolor = "black", 69 | x = 7.0, y = 0.25, 70 | width = 0.10, height = 1, fontsize = 10 71 | ) 72 | plotText( 73 | label = "Kb", rot = 90, x = 6.9, y = 0.75, 74 | just = c("center", "center"), 75 | fontsize = 10 76 | ) 77 | 78 | } 79 | \seealso{ 80 | \link[plotgardener]{colorby} 81 | } 82 | -------------------------------------------------------------------------------- /man/pageCreate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pageCreate.R 3 | \name{pageCreate} 4 | \alias{pageCreate} 5 | \title{Create a page for a plotgardener layout} 6 | \usage{ 7 | pageCreate( 8 | width = 8.5, 9 | height = 11, 10 | default.units = "inches", 11 | bg = NA, 12 | xgrid = 0.5, 13 | ygrid = 0.5, 14 | showGuides = TRUE, 15 | params = NULL 16 | ) 17 | } 18 | \arguments{ 19 | \item{width}{A numeric or unit object specifying page width. 20 | Default value is \code{width = 8}.} 21 | 22 | \item{height}{A numeric or unit object specifying page height. 23 | Default value is \code{height = 11}.} 24 | 25 | \item{default.units}{A string indicating the default units to use if 26 | \code{width} or \code{height} are only given as numerics. 27 | Default value is \code{default.units = "inches"}.} 28 | 29 | \item{bg}{Character value indicating page background color. 30 | Default value is \code{bg = NA}.} 31 | 32 | \item{xgrid}{A numeric indicating the increment by which to place 33 | vertical gridlines. Default value is \code{xgrid = 0.5}.} 34 | 35 | \item{ygrid}{A numeric indicating the increment by which to place 36 | horizontal gridlines. Default value is \code{ygrid = 0.5}.} 37 | 38 | \item{showGuides}{A logical value indicating whether to draw a 39 | black border around the entire page and guiding rulers along the top and 40 | left side of the page. Default value is \code{showOutline = TRUE}.} 41 | 42 | \item{params}{An optional \link[plotgardener]{pgParams} object 43 | containing relevant function parameters.} 44 | } 45 | \value{ 46 | None. 47 | } 48 | \description{ 49 | Create a page for a plotgardener layout 50 | } 51 | \details{ 52 | \code{width} and \code{height} must be specified in the same units. 53 | } 54 | \examples{ 55 | ## Create a 6-inch wide, 4.5-inch high page 56 | pageCreate(width = 6, height = 4.5, default.units = "inches") 57 | 58 | ## Create a 14-cm wide, 10-cm high page 59 | pageCreate(width = 14, height = 10, default.units = "cm") 60 | } 61 | -------------------------------------------------------------------------------- /man/pageGuideHide.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pageGuideHide.R 3 | \name{pageGuideHide} 4 | \alias{pageGuideHide} 5 | \title{Remove guides from a plotgardener page} 6 | \usage{ 7 | pageGuideHide() 8 | } 9 | \value{ 10 | None. 11 | } 12 | \description{ 13 | Remove guides from a plotgardener page 14 | } 15 | \note{ 16 | Please note that due to the implementation of `grid` removal functions, 17 | using `pageGuideHide` within a `pdf` call will result in the rendering of a 18 | separate, new page with the plot guides removed. To avoid this artifact, 19 | hide guides in the `pageCreate` function call with `showGuides = FALSE`. 20 | } 21 | \examples{ 22 | ## Make a page 23 | pageCreate(width = 7, height = 4, default.units = "inches") 24 | 25 | ## Hide page guides 26 | pageGuideHide() 27 | 28 | } 29 | -------------------------------------------------------------------------------- /man/pageGuideHorizontal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pageGuideHorizontal.R 3 | \name{pageGuideHorizontal} 4 | \alias{pageGuideHorizontal} 5 | \title{Draw a horizontal guideline at a specified y-coordinate 6 | on a plotgardener page} 7 | \usage{ 8 | pageGuideHorizontal( 9 | y, 10 | default.units = "inches", 11 | linecolor = "grey55", 12 | params = NULL, 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{y}{A numeric or unit object specifying y-coordinate of guide.} 18 | 19 | \item{default.units}{A string indicating the default units to use 20 | if \code{y} is only given as a numeric. 21 | Default value is \code{default.units = "inches"}.} 22 | 23 | \item{linecolor}{Character value indicating color of guideline. 24 | Default value is \code{linecolor = "grey55"}.} 25 | 26 | \item{params}{An optional \link[plotgardener]{pgParams} object 27 | containing relevant function parameters.} 28 | 29 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 30 | } 31 | \value{ 32 | None. 33 | } 34 | \description{ 35 | Draw a horizontal guideline at a specified y-coordinate 36 | on a plotgardener page 37 | } 38 | \examples{ 39 | ## Create a page 40 | pageCreate(width = 6, height = 5, default.units = "inches") 41 | 42 | ## Add red horizontal guideline at y = 2.5 inches 43 | pageGuideHorizontal(y = 2.5, linecolor = "red") 44 | } 45 | -------------------------------------------------------------------------------- /man/pageGuideShow.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pageGuideShow.R 3 | \name{pageGuideShow} 4 | \alias{pageGuideShow} 5 | \title{Reshow guides drawn with \code{pageCreate}, 6 | \code{pageGuideHorizontal}, and \code{pageGuideVertical}} 7 | \usage{ 8 | pageGuideShow() 9 | } 10 | \value{ 11 | None. 12 | } 13 | \description{ 14 | Reshow guides drawn with \code{pageCreate}, 15 | \code{pageGuideHorizontal}, and \code{pageGuideVertical} 16 | } 17 | \examples{ 18 | ## Load Hi-C data 19 | library(plotgardenerData) 20 | data("IMR90_HiC_10kb") 21 | 22 | ## Create a page 23 | pageCreate(width = 3, height = 3, default.units = "inches") 24 | 25 | ## Add a page guide 26 | pageGuideHorizontal(y = 0.5, default.units = "inches") 27 | 28 | ## Plot and place Hi-C plot 29 | hicPlot <- plotHicSquare( 30 | data = IMR90_HiC_10kb, resolution = 10000, 31 | zrange = c(0, 70), 32 | chrom = "chr21", 33 | chromstart = 28000000, chromend = 30300000, 34 | x = 0.5, y = 0.5, width = 2, height = 2, 35 | just = c("left", "top"), 36 | default.units = "inches" 37 | ) 38 | 39 | ## Hide page guides 40 | pageGuideHide() 41 | 42 | ## Re-show page guides 43 | pageGuideShow() 44 | 45 | ## Annotate genome label 46 | annoGenomeLabel( 47 | plot = hicPlot, scale = "Mb", axis = "x", 48 | x = 0.5, y = 2.53, just = c("left", "top") 49 | ) 50 | } 51 | \seealso{ 52 | \link[plotgardener]{pageCreate}, 53 | \link[plotgardener]{pageGuideHorizontal}, 54 | \link[plotgardener]{pageGuideVertical} 55 | } 56 | -------------------------------------------------------------------------------- /man/pageGuideVertical.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pageGuideVertical.R 3 | \name{pageGuideVertical} 4 | \alias{pageGuideVertical} 5 | \title{Draw a vertical guideline at a specified x-coordinate on a 6 | plotgardener page} 7 | \usage{ 8 | pageGuideVertical( 9 | x, 10 | default.units = "inches", 11 | linecolor = "grey55", 12 | params = NULL, 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{x}{A numeric or unit object specifying x-coordinate of guide.} 18 | 19 | \item{default.units}{A string indicating the default units to use 20 | if \code{x} is only given as a numeric. 21 | Default value is \code{default.units = "inches"}.} 22 | 23 | \item{linecolor}{Character value indicating color of guideline. 24 | Default value is \code{linecolor = "grey55"}.} 25 | 26 | \item{params}{An optional \link[plotgardener]{pgParams} object 27 | containing relevant function parameters.} 28 | 29 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 30 | } 31 | \value{ 32 | None. 33 | } 34 | \description{ 35 | Draw a vertical guideline at a specified x-coordinate on a 36 | plotgardener page 37 | } 38 | \examples{ 39 | ## Create a page 40 | pageCreate(width = 6, height = 5, default.units = "inches") 41 | 42 | ## Add blue vertical guideline at x = 1.7 inches 43 | pageGuideVertical(x = 1.7, linecolor = "blue") 44 | } 45 | -------------------------------------------------------------------------------- /man/pageLayoutCol.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pageLayout.R 3 | \name{pageLayoutCol} 4 | \alias{pageLayoutCol} 5 | \title{Generate column positions for a number of plot elements with a specified 6 | width and space between them} 7 | \usage{ 8 | pageLayoutCol(x, width, space, n, default.units = "inches") 9 | } 10 | \arguments{ 11 | \item{x}{A numeric or unit object specifying the starting column x-position.} 12 | 13 | \item{width}{A numeric or unit object specifying the width of columns.} 14 | 15 | \item{space}{A numeric or unit object specifying the space between columns.} 16 | 17 | \item{n}{An integer specifying the number of elements to generate column 18 | positions for.} 19 | 20 | \item{default.units}{A string indicating the default units to use 21 | if \code{x}, \code{w}, or \code{s} are only given as numerics. 22 | Default value is \code{default.units = "inches"}} 23 | } 24 | \value{ 25 | Returns a unit vector of page positions. 26 | } 27 | \description{ 28 | Generate column positions for a number of plot elements with a specified 29 | width and space between them 30 | } 31 | \examples{ 32 | # Starting at 0.5 units, return a vector of positions for 3 objects that 33 | # are 2 units in width with 0.1 units of space between them 34 | 35 | pageLayoutCol(x = 0.5, width = 2, space = 0.1, n = 3, 36 | default.units = "inches") 37 | 38 | } 39 | -------------------------------------------------------------------------------- /man/pageLayoutRow.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pageLayout.R 3 | \name{pageLayoutRow} 4 | \alias{pageLayoutRow} 5 | \title{Generate row positions for a number of plot elements with a specified height 6 | and space between them} 7 | \usage{ 8 | pageLayoutRow(y, height, space, n, default.units = "inches") 9 | } 10 | \arguments{ 11 | \item{y}{A numeric or unit object specifying the starting row y-position.} 12 | 13 | \item{height}{A numeric or unit object specifying the height of rows.} 14 | 15 | \item{space}{A numeric or unit object specifying the space between rows.} 16 | 17 | \item{n}{An integer specifying the number of elements to generate row 18 | positions for.} 19 | 20 | \item{default.units}{A string indicating the default units to use 21 | if \code{y}, \code{h}, or \code{s} are only given as numerics. 22 | Default value is \code{default.units = "inches"}.} 23 | } 24 | \value{ 25 | Returns a unit vector of page positions. 26 | } 27 | \description{ 28 | Generate row positions for a number of plot elements with a specified height 29 | and space between them 30 | } 31 | \examples{ 32 | # Starting at 0.5 units, return a vector of positions for 3 objects that 33 | # are 2 units in height with 0.1 units of space between them 34 | 35 | pageLayoutRow(y = 0.5, height = 2, space = 0.1, n = 3, 36 | default.units = "inches") 37 | 38 | } 39 | -------------------------------------------------------------------------------- /man/pagePlotPlace.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pagePlotPlace.R 3 | \name{pagePlotPlace} 4 | \alias{pagePlotPlace} 5 | \title{Place a plot that has been previously created but not drawn} 6 | \usage{ 7 | pagePlotPlace( 8 | plot, 9 | x = NULL, 10 | y = NULL, 11 | width = NULL, 12 | height = NULL, 13 | just = c("left", "top"), 14 | default.units = "inches", 15 | draw = TRUE, 16 | params = NULL 17 | ) 18 | } 19 | \arguments{ 20 | \item{plot}{Plot object to be placed, defined by the 21 | output of a plotgardener plotting function.} 22 | 23 | \item{x}{A numeric or unit object specifying plot x-location.} 24 | 25 | \item{y}{A numeric, unit object, or character containing a "b" combined 26 | with a numeric value specifying plot y-location. 27 | The character value will place the plot y relative to the bottom 28 | of the most recently plotted plot according to the units 29 | of the plotgardener page.} 30 | 31 | \item{width}{A numeric or unit object specifying plot width.} 32 | 33 | \item{height}{A numeric or unit object specifying plot height.} 34 | 35 | \item{just}{Justification of plot relative to its (x, y) location. 36 | If there are two values, the first value specifies horizontal 37 | justification and the second value specifies vertical justification. 38 | Possible string values are: \code{"left"}, \code{"right"}, 39 | \code{"centre"}, \code{"center"}, \code{"bottom"}, and \code{"top"}. 40 | Default value is \code{just = c("left", "top")}.} 41 | 42 | \item{default.units}{A string indicating the default units to use 43 | if \code{x}, \code{y}, \code{width}, or \code{height} are only 44 | given as numerics. Default value is \code{default.units = "inches"}.} 45 | 46 | \item{draw}{A logical value indicating whether graphics output 47 | should be produced. Default value is \code{draw = TRUE}.} 48 | 49 | \item{params}{An optional \link[plotgardener]{pgParams} object 50 | containing relevant function parameters.} 51 | } 52 | \value{ 53 | Function will update dimensions of an input plot and 54 | return an updated plot object. 55 | } 56 | \description{ 57 | Place a plot that has been previously created but not drawn 58 | } 59 | \examples{ 60 | ## Load Hi-C data 61 | library(plotgardenerData) 62 | data("IMR90_HiC_10kb") 63 | 64 | ## Create, but do not plot, square Hi-C plot 65 | hicPlot <- plotHicSquare( 66 | data = IMR90_HiC_10kb, resolution = 10000, 67 | zrange = c(0, 70), 68 | chrom = "chr21", 69 | chromstart = 28000000, chromend = 30300000, 70 | draw = FALSE 71 | ) 72 | 73 | ## Create page 74 | pageCreate(width = 3.75, height = 3.5, default.units = "inches") 75 | 76 | ## Place Hi-C plot on page 77 | pagePlotPlace( 78 | plot = hicPlot, 79 | x = 0.25, y = 0.25, width = 3, height = 3, 80 | just = c("left", "top"), 81 | default.units = "inches", draw = TRUE 82 | ) 83 | 84 | ## Annotate heatmap legend 85 | annoHeatmapLegend( 86 | plot = hicPlot, 87 | x = 3.4, y = 0.25, width = 0.12, height = 1.2, 88 | just = c("left", "top"), default.units = "inches" 89 | ) 90 | 91 | ## Hide page guides 92 | pageGuideHide() 93 | } 94 | -------------------------------------------------------------------------------- /man/pagePlotRemove.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pagePlotRemove.R 3 | \name{pagePlotRemove} 4 | \alias{pagePlotRemove} 5 | \title{Remove plotgardener plots and annotations} 6 | \usage{ 7 | pagePlotRemove(plot) 8 | } 9 | \arguments{ 10 | \item{plot}{Plot object to be removed, defined by the output 11 | of a plotgardener plotting function.} 12 | } 13 | \value{ 14 | None. 15 | } 16 | \description{ 17 | Remove plotgardener plots and annotations 18 | } 19 | \examples{ 20 | ## Load Hi-C data 21 | library(plotgardenerData) 22 | data("IMR90_HiC_10kb") 23 | 24 | ## Create page 25 | pageCreate(width = 5.5, height = 4, default.units = "inches") 26 | 27 | ## Plot and place a square Hi-C plot 28 | hicPlot <- plotHicSquare( 29 | data = IMR90_HiC_10kb, resolution = 10000, 30 | zrange = c(0, 70), 31 | chrom = "chr21", 32 | chromstart = 28000000, chromend = 30300000, 33 | x = 0.5, y = 0.5, width = 2.5, height = 2.5, 34 | just = c("left", "top"), 35 | default.units = "inches" 36 | ) 37 | 38 | ## Remove square Hi-C plot from page 39 | pagePlotRemove(plot = hicPlot) 40 | } 41 | -------------------------------------------------------------------------------- /man/pgParams.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pgParams.R 3 | \name{pgParams} 4 | \alias{pgParams} 5 | \title{pgParams: plotgardener parameters object} 6 | \usage{ 7 | pgParams(assembly = "hg38", gene = NULL, geneBuffer = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{assembly}{String defining the genome build. 11 | Default value is \code{assembly = "hg38"}.} 12 | 13 | \item{gene}{(optional) String naming a gene used to set the 14 | chrom, chromstart, and chromend arguments.} 15 | 16 | \item{geneBuffer}{(optional) Integer base-pairs to extend the 17 | start and end of a gene defined by argument \code{gene}. 18 | Can be one integer or a vector of length 2, where the first integer 19 | will extend the start of the gene and the second integer 20 | will extend the end of the gene.} 21 | 22 | \item{...}{This function will take any plotgardener function 23 | parameters and their values: 24 | \itemize{ 25 | \item{\code{alpha}} 26 | \item{\code{altchrom}} 27 | \item{\code{altchromend}} 28 | \item{\code{altchromstart}} 29 | \item{\code{archHeight}} 30 | \item{\code{arrow}} 31 | \item{\code{at}} 32 | \item{\code{axis}} 33 | \item{\code{axisLine}} 34 | \item{\code{baseline}} 35 | \item{\code{baseline.color}} 36 | \item{\code{baseline.lwd}} 37 | \item{\code{bg}} 38 | \item{\code{binCap}} 39 | \item{\code{binSize}} 40 | \item{\code{border}} 41 | \item{\code{boxHeight}} 42 | \item{\code{boxWidth}} 43 | \item{\code{breaks}} 44 | \item{\code{BSgenome}} 45 | \item{\code{cex}} 46 | \item{\code{check.overlap}} 47 | \item{\code{chrom}} 48 | \item{\code{chromend}} 49 | \item{\code{chromstart}} 50 | \item{\code{clip}} 51 | \item{\code{collapse}} 52 | \item{\code{colorbyStrand}} 53 | \item{\code{colorTrans}} 54 | \item{\code{column}} 55 | \item{\code{commas}} 56 | \item{\code{curvature}} 57 | \item{\code{data}} 58 | \item{\code{default.units}} 59 | \item{\code{digits}} 60 | \item{\code{display.column}} 61 | \item{\code{draw}} 62 | \item{\code{extend}} 63 | \item{\code{file}} 64 | \item{\code{fill}} 65 | \item{\code{flip}} 66 | \item{\code{fontcolor}} 67 | \item{\code{fontsize}} 68 | \item{\code{geneBackground}} 69 | \item{\code{geneHighlights}} 70 | \item{\code{gene.id.column}} 71 | \item{\code{geneOrder}} 72 | \item{\code{Genome}} 73 | \item{\code{half}} 74 | \item{\code{height}} 75 | \item{\code{id}} 76 | \item{\code{id.lengths}} 77 | \item{\code{image}} 78 | \item{\code{interpolate}} 79 | \item{\code{just}} 80 | \item{\code{label}} 81 | \item{\code{labels}} 82 | \item{\code{leadSNP}} 83 | \item{\code{legend}} 84 | \item{\code{length}} 85 | \item{\code{limitLabel}} 86 | \item{\code{linecolor}} 87 | \item{\code{lineend}} 88 | \item{\code{linejoin}} 89 | \item{\code{lty}} 90 | \item{\code{lwd}} 91 | \item{\code{main}} 92 | \item{\code{margin}} 93 | \item{\code{matrix}} 94 | \item{\code{negData}} 95 | \item{\code{norm}} 96 | \item{\code{OrgDb}} 97 | \item{\code{orientation}} 98 | \item{\code{palette}} 99 | \item{\code{pch}} 100 | \item{\code{plot}} 101 | \item{\code{quiet}} 102 | \item{\code{r}} 103 | \item{\code{range}} 104 | \item{\code{resolution}} 105 | \item{\code{res_scale}} 106 | \item{\code{rot}} 107 | \item{\code{scale}} 108 | \item{\code{scientific}} 109 | \item{\code{scipen}} 110 | \item{\code{sequence}} 111 | \item{\code{shift}} 112 | \item{\code{showBands}} 113 | \item{\code{showGuides}} 114 | \item{\code{sigCol}} 115 | \item{\code{sigLine}} 116 | \item{\code{sigVal}} 117 | \item{\code{spaceHeight}} 118 | \item{\code{spaceWidth}} 119 | \item{\code{strand}} 120 | \item{\code{strandLabels}} 121 | \item{\code{strandSplit}} 122 | \item{\code{stroke}} 123 | \item{\code{style}} 124 | \item{\code{tcl}} 125 | \item{\code{ticks}} 126 | \item{\code{title}} 127 | \item{\code{TxDb}} 128 | \item{\code{type}} 129 | \item{\code{width}} 130 | \item{\code{x}} 131 | \item{\code{xgrid}} 132 | \item{\code{x0}} 133 | \item{\code{x1}} 134 | \item{\code{y}} 135 | \item{\code{ygrid}} 136 | \item{\code{ymax}} 137 | \item{\code{y0}} 138 | \item{\code{y1}} 139 | \item{\code{zrange}} 140 | }} 141 | } 142 | \value{ 143 | Returns an object of class \code{pgParams} 144 | containing plotgardener function arguments. 145 | } 146 | \description{ 147 | Creates an object of class "pgParams" that can be used by 148 | plotgardener functions. pgParams can be used to set a set of parameters 149 | to be shared across multiple functions. 150 | } 151 | \details{ 152 | pgParams generates arguments from exported plotgardener functions at 153 | loading time of the package. Arguments defined in a pgParams object 154 | can be passed into the \code{params} argument of plotgardener functions. 155 | params arguments can be overridden from within plotgardener functions. 156 | 157 | pgParams also provides an alternative region definition mechanism. 158 | Given a gene name and genome assembly, pgParams returns the appropriate 159 | "chrom", "chromstart", and "chromend" with a default buffer of 160 | \code{(gene length) / 2} added to the ends of the gene coordinates. 161 | The buffer amount can be set manually with the \code{geneBuffer} 162 | parameter. Buffer extending beyond the length of the chromosome 163 | will be trimmed. 164 | } 165 | \examples{ 166 | ## Load hg19 genomic annotation packages 167 | library("TxDb.Hsapiens.UCSC.hg19.knownGene") 168 | library("org.Hs.eg.db") 169 | 170 | ## Define parameters 171 | p1 <- pgParams(gene = "IL1B", assembly = "hg19") 172 | 173 | ## Optionally add more parameters 174 | p2 <- pgParams(fontsize = 10, assembly = "hg19") 175 | 176 | ## Combine parameters and pass them to a plotgardener function 177 | plotGenes(params = c(p1, p2)) 178 | } 179 | -------------------------------------------------------------------------------- /man/plotCircle.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotCircle.R 3 | \name{plotCircle} 4 | \alias{plotCircle} 5 | \title{Plot a circle within a plotgardener layout} 6 | \usage{ 7 | plotCircle( 8 | x, 9 | y, 10 | r, 11 | default.units = "inches", 12 | linecolor = "black", 13 | lwd = 1, 14 | lty = 1, 15 | fill = NA, 16 | alpha = 1, 17 | params = NULL, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{x}{A numeric vector or unit object specifying circle 23 | x-locations relative to center.} 24 | 25 | \item{y}{A numeric vector, unit object, or a character vector 26 | of values containing a "b" combined with a numeric value 27 | specifying circle y-locations relative to center. 28 | The character vector will place circle y-locations relative to 29 | the bottom of the most recently plotted plot according 30 | to the units of the plotgardener page.} 31 | 32 | \item{r}{A numeric vector or unit object specifying radii.} 33 | 34 | \item{default.units}{A string indicating the default units to use 35 | if \code{r}, \code{x}, or \code{y} are only given as numerics or 36 | numeric vectors. Default value is \code{default.units = "inches"}.} 37 | 38 | \item{linecolor}{A character value specifying circle line color. 39 | Default value is \code{linecolor = "black"}.} 40 | 41 | \item{lwd}{A numeric specifying circle line width. 42 | Default value is \code{lwd = 1}.} 43 | 44 | \item{lty}{A numeric specifying circle line type. 45 | Default value is \code{lty = 1}.} 46 | 47 | \item{fill}{A character value specifying circle fill color. 48 | Default value is \code{fill = NA}.} 49 | 50 | \item{alpha}{Numeric value specifying color transparency. 51 | Default value is \code{alpha = 1}.} 52 | 53 | \item{params}{An optional \link[plotgardener]{pgParams} object 54 | containing relevant function parameters.} 55 | 56 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 57 | } 58 | \value{ 59 | Returns a \code{circle} object containing 60 | relevant placement and \link[grid]{grob} information. 61 | } 62 | \description{ 63 | Plot a circle within a plotgardener layout 64 | } 65 | \examples{ 66 | ## Create a page 67 | pageCreate(width = 2, height = 2, default.units = "inches") 68 | 69 | ## Plot two circles, one at a time 70 | plotCircle( 71 | x = 0.6, y = 0.5, r = 0.1, fill = "black", 72 | default.units = "inches" 73 | ) 74 | plotCircle( 75 | x = 1.4, y = 0.5, r = 0.1, fill = "black", 76 | default.units = "inches" 77 | ) 78 | 79 | ## Plot a vector of circles 80 | xVals <- 1 + (0.5 * cos(seq(0, pi, pi / 8))) 81 | yVals <- 1 + (0.5 * sin(seq(0, pi, pi / 8))) 82 | plotCircle(x = xVals, y = yVals, r = 0.05, default.units = "inches") 83 | 84 | ## Hide page guides 85 | pageGuideHide() 86 | } 87 | \seealso{ 88 | \link[grid]{grid.circle} 89 | } 90 | -------------------------------------------------------------------------------- /man/plotGG.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotGG.R 3 | \name{plotGG} 4 | \alias{plotGG} 5 | \title{Plot a ggplot2 plot, gtable, or grob object in a plotgardener layout} 6 | \usage{ 7 | plotGG( 8 | plot, 9 | x, 10 | y, 11 | width, 12 | height, 13 | just = c("left", "top"), 14 | default.units = "inches", 15 | params = NULL 16 | ) 17 | } 18 | \arguments{ 19 | \item{plot}{ggplot, gtable, or grob object.} 20 | 21 | \item{x}{A numeric or unit object specifying ggplot x-location.} 22 | 23 | \item{y}{A numeric, unit object, or character containing a "b" 24 | combined with a numeric value specifying ggplot y-location. 25 | The character value will 26 | place the ggplot y relative to the bottom of the most recently 27 | plotted plot according to the units of the plotgardener page.} 28 | 29 | \item{width}{A numeric or unit object specifying ggplot width.} 30 | 31 | \item{height}{A numeric or unit object specifying ggplot height.} 32 | 33 | \item{just}{Justification of ggplot relative to its (x, y) location. 34 | If there are two values, the first value specifies horizontal 35 | justification and the second value specifies vertical justification. 36 | Possible string values are: \code{"left"}, \code{"right"}, 37 | \code{"centre"}, \code{"center"}, \code{"bottom"}, and \code{"top"}. 38 | Default value is \code{just = c("left", "top")}.} 39 | 40 | \item{default.units}{A string indicating the default units to use 41 | if \code{x}, \code{y}, \code{width}, or \code{height} are only given 42 | as numerics. Default value is \code{default.units = "inches"}.} 43 | 44 | \item{params}{An optional \link[plotgardener]{pgParams} object containing 45 | relevant function parameters.} 46 | } 47 | \value{ 48 | Returns a \code{pg_gg} object containing 49 | relevant placement and \link[grid]{grob} information. 50 | } 51 | \description{ 52 | Plot a ggplot2 plot, gtable, or grob object in a plotgardener layout 53 | } 54 | \examples{ 55 | ## Create a plot using ggplot2 56 | library(ggplot2) 57 | p <- ggplot(mtcars) + 58 | geom_point(aes(mpg, disp)) 59 | 60 | ## Create a page 61 | pageCreate(width = 4, height = 4, default.units = "inches") 62 | 63 | ## Place ggplot in page 64 | plotGG( 65 | plot = p, x = 0.5, y = 0.5, width = 3, height = 3, 66 | just = c("left", "top"), default.units = "inches" 67 | ) 68 | 69 | ## Add title 70 | plotText( 71 | label = "mtcars", fontsize = 14, fontface = "bold", 72 | x = 1, y = 0.35 73 | ) 74 | 75 | ## Hide page guides 76 | pageGuideHide() 77 | } 78 | \seealso{ 79 | \link[ggplot2]{ggplot} 80 | } 81 | -------------------------------------------------------------------------------- /man/plotIdeogram.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotIdeogram.R 3 | \name{plotIdeogram} 4 | \alias{plotIdeogram} 5 | \title{Plot a chromosome ideogram with or without cytobands} 6 | \usage{ 7 | plotIdeogram( 8 | chrom, 9 | assembly = "hg38", 10 | data = NULL, 11 | orientation = "h", 12 | flip = FALSE, 13 | showBands = TRUE, 14 | fill = NULL, 15 | x = NULL, 16 | y = NULL, 17 | width = NULL, 18 | height = NULL, 19 | just = c("left", "top"), 20 | default.units = "inches", 21 | draw = TRUE, 22 | params = NULL 23 | ) 24 | } 25 | \arguments{ 26 | \item{chrom}{Chromosome to be plotted, as a string.} 27 | 28 | \item{assembly}{Default genome assembly as a string or a 29 | \link[plotgardener]{assembly} object. 30 | Default value is \code{assembly = "hg38"}.} 31 | 32 | \item{data}{Custom cytoband data, as a dataframe with the following 33 | columns: "seqnames", "start", "end", "width", "strand", 34 | "name", "gieStain".} 35 | 36 | \item{orientation}{Character value indicating the orientation 37 | of the ideogram. Default value is \code{orientation = "h"}. 38 | Options are: 39 | \itemize{ 40 | \item{\code{"v"}: }{Vertical ideogram orientation.} 41 | \item{\code{"h"}: }{Horizontal ideogram orientation.} 42 | }} 43 | 44 | \item{flip}{Logical value indicating whether to reverse the start and end 45 | positions of the ideogram. If \code{flip = FALSE} (default), the ideogram 46 | starts at the top/left and ends at the bottom/right. If \code{flip = TRUE}, 47 | the start and end positions are reversed, meaning the ideogram starts at the 48 | bottom/right and ends at the top/left.} 49 | 50 | \item{showBands}{Logical value indicating whether to draw 51 | colored cytobands within ideogram. 52 | Default value is \code{showBands = TRUE}.} 53 | 54 | \item{fill}{(optional) A vector specifying alternate colors for cytoband 55 | stains. To change specific gieStain values (i.e. gneg, gpos, etc.) to 56 | specific colors, this vector can be named. This vector must have the same 57 | number of colors as there are gieStain values for each genome assembly.} 58 | 59 | \item{x}{A numeric or unit object specifying ideogram x-location.} 60 | 61 | \item{y}{A numeric, unit object, or character containing a "b" 62 | combined with a numeric value specifying ideogram y-location. 63 | The character value will 64 | place the ideogram y relative to the bottom of the most recently 65 | plotted plot according to the units of the plotgardener page.} 66 | 67 | \item{width}{A numeric or unit object specifying ideogram width.} 68 | 69 | \item{height}{A numeric or unit object specifying ideogram height.} 70 | 71 | \item{just}{Justification of ideogram relative to its (x, y) location. 72 | If there are two values, the first value specifies horizontal justification 73 | and the second value specifies vertical justification. 74 | Possible string values are: \code{"left"}, \code{"right"}, 75 | \code{"centre"}, \code{"center"}, \code{"bottom"}, and \code{"top"}. 76 | Default value is \code{just = c("left", "top")}.} 77 | 78 | \item{default.units}{A string indicating the default units to use if 79 | \code{x}, \code{y}, \code{width}, or \code{height} are only given as 80 | numerics. Default value is \code{default.units = "inches"}.} 81 | 82 | \item{draw}{A logical value indicating whether graphics output should be 83 | produced. Default value is \code{draw = TRUE}.} 84 | 85 | \item{params}{An optional \link[plotgardener]{pgParams} object containing 86 | relevant function parameters.} 87 | } 88 | \value{ 89 | Returns a \code{ideogram} object containing relevant 90 | genomic region, placement, and \link[grid]{grob} information. 91 | } 92 | \description{ 93 | Plot a chromosome ideogram with or without cytobands 94 | } 95 | \details{ 96 | An ideogram can be placed on a plotgardener coordinate page by 97 | providing plot placement parameters: 98 | \preformatted{ 99 | plotIdeogram(chrom, 100 | x, y, width, height, just = c("left", "top"), 101 | default.units = "inches") 102 | } 103 | This function can also be used to quickly plot an unannotated ideogram 104 | by ignoring plot placement parameters: 105 | \preformatted{ 106 | plotIdeogram(chrom) 107 | } 108 | If no data is provided, Giemsa stain band data will first try to 109 | fetch UCSC with AnnotationHub. The results are cached for faster access, 110 | but these cached items can be deleted. If no internet connection is 111 | available and AnnotationHub has not previously cached the data, custom 112 | Giemsa stain band data can be loaded with the `data` parameter. 113 | } 114 | \examples{ 115 | ## Load Giemsa stain band information and genomic 116 | ## annotation data for hg19 genome assembly 117 | library(TxDb.Hsapiens.UCSC.hg19.knownGene) 118 | library(AnnotationHub) 119 | 120 | ## Create page 121 | pageCreate(width = 4.5, height = 1, default.units = "inches") 122 | 123 | ## Plot and place ideogram 124 | ideogramPlot <- plotIdeogram( 125 | chrom = "chr2", assembly = "hg19", 126 | x = 0.25, y = 0.25, width = 4, height = 0.3, 127 | just = c("left", "top"), 128 | default.units = "inches" 129 | ) 130 | 131 | ## Plot text 132 | plotText( 133 | label = "Chromosome 2", fontcolor = "dark grey", 134 | x = 4.25, y = 0.65, just = "right" 135 | ) 136 | 137 | ## Hide page guides 138 | pageGuideHide() 139 | } 140 | \seealso{ 141 | \link[AnnotationHub]{AnnotationHub} 142 | } 143 | -------------------------------------------------------------------------------- /man/plotLegend.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotLegend.R 3 | \name{plotLegend} 4 | \alias{plotLegend} 5 | \title{Plot a legend} 6 | \usage{ 7 | plotLegend( 8 | legend, 9 | fill = NULL, 10 | pch = NULL, 11 | lty = NULL, 12 | orientation = "v", 13 | title = NULL, 14 | fontsize = 10, 15 | border = TRUE, 16 | bg = NA, 17 | x = NULL, 18 | y = NULL, 19 | width = NULL, 20 | height = NULL, 21 | just = c("left", "top"), 22 | default.units = "inches", 23 | draw = TRUE, 24 | params = NULL, 25 | ... 26 | ) 27 | } 28 | \arguments{ 29 | \item{legend}{A character or expression vector to appear in the legend.} 30 | 31 | \item{fill}{If specified, this argument will produce boxes filled with 32 | the specified colors to appear beside the legend text.} 33 | 34 | \item{pch}{The plotting symbols appearing in the legend, as a 35 | numeric vector.} 36 | 37 | \item{lty}{The line types for lines appearing in the legend.} 38 | 39 | \item{orientation}{A string specifying legend orientation. 40 | Default value is \code{orientation = "v"}. Options are: 41 | \itemize{ 42 | \item{\code{"v"}: }{Vertical legend orientation.} 43 | \item{\code{"h"}: }{Horizontal legend orientation.} 44 | }} 45 | 46 | \item{title}{A character value giving a title to be placed at 47 | the top of the legend.} 48 | 49 | \item{fontsize}{A numeric specifying text fontsize in points. 50 | Default value is \code{fontsize = 10}.} 51 | 52 | \item{border}{Logical value indicating whether to add a border 53 | around heatmap legend. Default value is \code{border = TRUE}.} 54 | 55 | \item{bg}{Character value indicating background color. 56 | Default value is \code{bg = NA}.} 57 | 58 | \item{x}{A numeric or unit object specifying legend x-location.} 59 | 60 | \item{y}{A numeric, unit object, or character containing a "b" 61 | combined with a numeric value specifying legend y-location. 62 | The character value will 63 | place the legend y relative to the bottom of the most recently 64 | plotted plot according to the units of the plotgardener page.} 65 | 66 | \item{width}{A numeric or unit object specifying legend width.} 67 | 68 | \item{height}{A numeric or unit object specifying legend height.} 69 | 70 | \item{just}{Justification of legend relative to its (x, y) location. 71 | If there are two values, the first value specifies horizontal 72 | justification and the second value specifies vertical justification. 73 | Possible string values are: \code{"left"}, \code{"right"}, 74 | \code{"centre"}, \code{"center"}, \code{"bottom"}, and \code{"top"}. 75 | Default value is \code{just = c("left", "top")}.} 76 | 77 | \item{default.units}{A string indicating the default units to use 78 | if \code{x}, \code{y}, \code{width}, or \code{height} are only given 79 | as numerics. Default value is \code{default.units = "inches"}.} 80 | 81 | \item{draw}{A logical value indicating whether graphics output should 82 | be produced. Default value is \code{draw = TRUE}.} 83 | 84 | \item{params}{An optional \link[plotgardener]{pgParams} object 85 | containing relevant function parameters.} 86 | 87 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 88 | } 89 | \value{ 90 | Returns a \code{legend} object containing relevant 91 | placement and \link[grid]{grob} information. 92 | } 93 | \description{ 94 | Plot a legend 95 | } 96 | \examples{ 97 | ## Load BED data 98 | library(plotgardenerData) 99 | data("IMR90_ChIP_CTCF_reads") 100 | 101 | ## Create page 102 | pageCreate(width = 7.5, height = 4, default.units = "inches") 103 | 104 | ## Plot a pileup plot, coloring elements by strand 105 | pileupPlot <- plotRanges( 106 | data = IMR90_ChIP_CTCF_reads, chrom = "chr21", 107 | chromstart = 29072500, chromend = 29075000, 108 | assembly = "hg19", 109 | fill = colorby("strand", palette = 110 | colorRampPalette(c("steel blue", "light salmon"))), 111 | x = 0.5, y = 3.5, width = 6.5, height = 3.5, 112 | just = c("left", "bottom"), 113 | default.units = "inches" 114 | ) 115 | 116 | ## Add a legend depicting strand colors 117 | legendPlot <- plotLegend( 118 | legend = c("- strand", "+ strand"), 119 | fill = c("steel blue", "light salmon"), 120 | border = FALSE, 121 | x = 5, y = 0.5, width = 1.5, height = 0.7, 122 | just = c("left", "top"), 123 | default.units = "inches" 124 | ) 125 | 126 | ## Annotate genome label 127 | annoGenomeLabel( 128 | plot = pileupPlot, x = 0.5, y = 3.5, 129 | just = c("left", "top") 130 | ) 131 | 132 | ## Hide page guides 133 | pageGuideHide() 134 | } 135 | -------------------------------------------------------------------------------- /man/plotPolygon.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotPolygon.R 3 | \name{plotPolygon} 4 | \alias{plotPolygon} 5 | \title{Plot a polygon within a plotgardener layout} 6 | \usage{ 7 | plotPolygon( 8 | x, 9 | y, 10 | default.units = "inches", 11 | linecolor = "black", 12 | lwd = 1, 13 | lty = 1, 14 | fill = NA, 15 | alpha = 1, 16 | id = NULL, 17 | id.lengths = NULL, 18 | params = NULL, 19 | ... 20 | ) 21 | } 22 | \arguments{ 23 | \item{x}{A numeric vector or unit object specifying polygon 24 | vertex x-locations.} 25 | 26 | \item{y}{A numeric vector, unit object, or a character vector 27 | of values containing a "b" combined with a numeric value specifying 28 | polygon vertex y-locations. 29 | The character vector will place polygon vertex y-locations relative 30 | to the bottom of the most recently plotted plot according 31 | to the units of the plotgardener page.} 32 | 33 | \item{default.units}{A string indicating the default units to use 34 | if \code{x} or \code{y} are only given as numeric vectors. 35 | Default value is \code{default.units = "inches"}.} 36 | 37 | \item{linecolor}{A character value specifying polygon line color. 38 | Default value is \code{linecolor = "black"}.} 39 | 40 | \item{lwd}{A numeric specifying polygon line width. 41 | Default value is \code{lwd = 1}.} 42 | 43 | \item{lty}{A numeric specifying polygon line type. 44 | Default value is \code{lty = 1}.} 45 | 46 | \item{fill}{A character value specifying polygon fill color. 47 | Default value is \code{fill = NA}.} 48 | 49 | \item{alpha}{Numeric value specifying color transparency. 50 | Default value is \code{alpha = 1}.} 51 | 52 | \item{id}{A numeric vector used to separate locations in \code{x} and 53 | \code{y} into multiple polygons. All locations with the same \code{id} 54 | belong to the same polygon.} 55 | 56 | \item{id.lengths}{A numeric vector used to separate locations in 57 | \code{x} and \code{y} into multiple polygons. Specifies consecutive 58 | blocks of locations which make up separate polygons.} 59 | 60 | \item{params}{An optional \link[plotgardener]{pgParams} object containing 61 | relevant function parameters.} 62 | 63 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 64 | } 65 | \value{ 66 | Returns a \code{polygon} object containing relevant 67 | placement and \link[grid]{grob} information. 68 | } 69 | \description{ 70 | Plot a polygon within a plotgardener layout 71 | } 72 | \examples{ 73 | ## Create a page 74 | pageCreate(width = 7.5, height = 6, default.units = "inches") 75 | 76 | ## Plot complex polygons one at a time 77 | plotPolygon( 78 | x = c(2.6, 4.65, 4.75, 6.05, 1.4, 1.3), 79 | y = c(2.5, 3.1, 3.5, 4, 3.15, 2.8), 80 | fill = "#4a168e", linecolor = NA 81 | ) 82 | 83 | plotPolygon( 84 | x = c(4.65, 4.75, 6.05, 5.05, 4.4), 85 | y = c(3.1, 3.5, 4, 1.45, 1.2), 86 | fill = "#9d28b0", linecolor = NA 87 | ) 88 | 89 | ## Plot multiple triangles with different id's and colors 90 | plotPolygon( 91 | x = c( 92 | 0.45, 6.05, 3, 3, 6.05, 5.25, 4.4, 5.05, 4.95, 93 | 1.3, 2.6, 1, 4.4, 4.95, 5, 4.95, 5, 6.25 94 | ), 95 | y = c( 96 | 2.85, 4, 5.55, 5.55, 4, 5.55, 1.2, 1.45, 1.1, 97 | 2.8, 2.5, 2.1, 1.2, 1.1, 0.45, 1.1, 0.45, 1.1 98 | ), 99 | id = c(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6), 100 | fill = c( 101 | "#ce93d9", "#bb6ac9", "#4a168e", 102 | "#7b1fa0", "#bb6ac9", "#ce93d9" 103 | ), 104 | linecolor = NA 105 | ) 106 | 107 | ## Hide page guides 108 | pageGuideHide() 109 | } 110 | \seealso{ 111 | \link[grid]{grid.polygon} 112 | } 113 | -------------------------------------------------------------------------------- /man/plotRaster.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotRaster.R 3 | \name{plotRaster} 4 | \alias{plotRaster} 5 | \title{Plot a raster object within a plotgardener layout} 6 | \usage{ 7 | plotRaster( 8 | image, 9 | x, 10 | y, 11 | width, 12 | height, 13 | just = "center", 14 | default.units = "inches", 15 | interpolate = TRUE, 16 | params = NULL, 17 | ... 18 | ) 19 | } 20 | \arguments{ 21 | \item{image}{Any R object that can be coerced to a raster object.} 22 | 23 | \item{x}{A numeric vector or unit object specifying raster x-locations.} 24 | 25 | \item{y}{A numeric vector, unit object, or a character vector of values 26 | containing a "b" combined with a numeric value specifying 27 | raster y-locations. 28 | The character vector will place raster y relative to the bottom 29 | of the most recently plotted plot according to the units 30 | of the plotgardener page.} 31 | 32 | \item{width}{A numeric vector or unit object specifying raster widths.} 33 | 34 | \item{height}{A numeric vector or unit object specifying raster heights.} 35 | 36 | \item{just}{Justification of text relative to its (x, y) location. 37 | If there are two values, the first value specifies horizontal 38 | justification and the second value specifies vertical justification. 39 | Possible string values are: \code{"left"}, \code{"right"}, 40 | \code{"centre"}, \code{"center"}, \code{"bottom"}, and 41 | \code{"top"}. Default value is \code{just = "center"}.} 42 | 43 | \item{default.units}{A string indicating the default units 44 | to use if \code{x}, \code{y}, \code{width}, or \code{height} 45 | are only given as numerics or numeric vectors. 46 | Default value is \code{default.units = "inches"}.} 47 | 48 | \item{interpolate}{A logical value indicating whether to linearly 49 | interpolate the image. Default value is \code{interpolate = TRUE}.} 50 | 51 | \item{params}{An optional \link[plotgardener]{pgParams} object 52 | containing relevant function parameters.} 53 | 54 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 55 | } 56 | \value{ 57 | Returns a \code{raster} object containing 58 | relevant placement and \link[grid]{grob} information. 59 | } 60 | \description{ 61 | Plot a raster object within a plotgardener layout 62 | } 63 | \examples{ 64 | library(png) 65 | 66 | ## Load images 67 | 68 | pg_type <- readPNG(system.file("images", 69 | "pg-wordmark.png", 70 | package = "plotgardener" 71 | )) 72 | 73 | gene_gnome <- readPNG(system.file("images", 74 | "pg-gnome-hole-shadow.png", 75 | package = "plotgardener" 76 | )) 77 | 78 | rlogo <- readPNG(system.file("images", "Rlogo.png", 79 | package = "plotgardener")) 80 | 81 | ## Create page 82 | pageCreate(width = 5, height = 6) 83 | 84 | ## Plot images 85 | plotRaster( 86 | image = pg_type, 87 | x = 2.5, y = 0.25, width = 4, height = 1.5, 88 | just = "top" 89 | ) 90 | 91 | plotRaster( 92 | image = gene_gnome, 93 | x = 2.5, y = 2.25, width = 3.5, height = 3.5, 94 | just = "top" 95 | ) 96 | 97 | plotRaster( 98 | image = rlogo, 99 | x = 1, y = 1.5, width = 0.5, height = 0.45, 100 | just = c("left", "top") 101 | ) 102 | 103 | ## Hide page guies 104 | pageGuideHide() 105 | } 106 | \seealso{ 107 | \link[grid]{grid.raster} 108 | } 109 | -------------------------------------------------------------------------------- /man/plotRect.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotRect.R 3 | \name{plotRect} 4 | \alias{plotRect} 5 | \title{Plot a rectangle within a plotgardener layout} 6 | \usage{ 7 | plotRect( 8 | x, 9 | y, 10 | width, 11 | height, 12 | just = "center", 13 | default.units = "inches", 14 | linecolor = "black", 15 | lwd = 1, 16 | lty = 1, 17 | fill = NA, 18 | alpha = 1, 19 | params = NULL, 20 | ... 21 | ) 22 | } 23 | \arguments{ 24 | \item{x}{A numeric vector or unit object specifying rectangle x-locations.} 25 | 26 | \item{y}{A numeric vector, unit object, or a character vector of values 27 | containing a "b" combined with a numeric value specifying 28 | rectangle y-locations. 29 | The character vector will place rectangle y-locations relative to 30 | the bottom of the most recently plotted plot according to 31 | the units of the plotgardener page.} 32 | 33 | \item{width}{A numeric vector or unit object specifying rectangle widths.} 34 | 35 | \item{height}{A numeric vector or unit object specifying rectangle heights.} 36 | 37 | \item{just}{Justification of rectangle relative to its (x, y) location. 38 | If there are two values, the first value specifies horizontal justification 39 | and the second value specifies vertical justification. 40 | Possible string values are: \code{"left"}, \code{"right"}, 41 | \code{"centre"}, \code{"center"}, \code{"bottom"}, and \code{"top"}. 42 | Default value is \code{just = "center"}.} 43 | 44 | \item{default.units}{A string indicating the default units to use if 45 | \code{x}, \code{y}, \code{width}, and \code{height} are only given as 46 | numerics or numeric vectors. 47 | Default value is \code{default.units = "inches"}.} 48 | 49 | \item{linecolor}{A character value specifying rectangle line color. 50 | Default value is \code{linecolor = "black"}.} 51 | 52 | \item{lwd}{A numeric specifying rectangle line width. 53 | Default value is \code{lwd = 1}.} 54 | 55 | \item{lty}{A numeric specifying rectangle line type. 56 | Default value is \code{lty = 1}.} 57 | 58 | \item{fill}{A character value specifying rectangle fill color. 59 | Default value is \code{fill = NA}.} 60 | 61 | \item{alpha}{Numeric value specifying color transparency. 62 | Default value is \code{alpha = 1}.} 63 | 64 | \item{params}{An optional \link[plotgardener]{pgParams} object 65 | containing relevant function parameters.} 66 | 67 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 68 | } 69 | \value{ 70 | Returns a \code{rect} object containing 71 | relevant placement and \link[grid]{grob} information. 72 | } 73 | \description{ 74 | Plot a rectangle within a plotgardener layout 75 | } 76 | \examples{ 77 | ## Create a page 78 | pageCreate(width = 7.5, height = 6, default.units = "inches") 79 | 80 | ## Plot one rectangle with no fill 81 | plotRect( 82 | x = 0.5, y = 0.5, width = 3, height = 3, 83 | just = c("left", "top"), default.units = "inches", 84 | lwd = 2, fill = NA 85 | ) 86 | 87 | 88 | ## Plot two rectangles with same width and height at different locations 89 | plotRect( 90 | x = 4, y = c(0.5, 2.25), width = 3, height = 1.25, 91 | just = c("left", "top"), default.units = "inches", 92 | fill = "#7ecdbb" 93 | ) 94 | 95 | ## Plot two rectangles with different widths, heights, 96 | ## locations, and colors 97 | plotRect( 98 | x = 3.75, y = c(4, 5.25), width = c(6.5, 4.5), 99 | height = c(1, 0.25), 100 | just = "top", default.units = "inches", 101 | fill = c("#7ecdbb", "#37a7db"), linecolor = NA, alpha = 0.4 102 | ) 103 | 104 | ## Hide page guides 105 | pageGuideHide() 106 | } 107 | \seealso{ 108 | \link[grid]{grid.rect} 109 | } 110 | -------------------------------------------------------------------------------- /man/plotSegments.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotSegments.R 3 | \name{plotSegments} 4 | \alias{plotSegments} 5 | \title{Draw a line segment within a plotgardener layout} 6 | \usage{ 7 | plotSegments( 8 | x0, 9 | y0, 10 | x1, 11 | y1, 12 | default.units = "inches", 13 | linecolor = "black", 14 | lwd = 1, 15 | lty = 1, 16 | lineend = "butt", 17 | linejoin = "mitre", 18 | arrow = NULL, 19 | params = NULL, 20 | ... 21 | ) 22 | } 23 | \arguments{ 24 | \item{x0}{A numeric vector or unit object indicating the 25 | starting x-values of the line segments.} 26 | 27 | \item{y0}{A numeric vector, unit object, or a character vector 28 | of values containing a "b" combined with a numeric value specifying 29 | starting y-values of the line segments. 30 | The character vector will place starting y-values relative to the 31 | bottom of the most recently plotted plot according to the 32 | units of the plotgardener page.} 33 | 34 | \item{x1}{A numeric vector or unit object indicating the stopping 35 | x-values of the line segments.} 36 | 37 | \item{y1}{A numeric vector, unit object, or a character vector of v 38 | alues containing a "b" combined with a numeric value specifying 39 | stopping y-values of the line segments. 40 | The character vector will place stopping y-values relative to the 41 | bottom of the most recently plotted plot according to the 42 | units of the plotgardener page.} 43 | 44 | \item{default.units}{A string indicating the default units to use 45 | if \code{x0}, \code{y0}, \code{x1}, or \code{y1} are only given as 46 | numeric vectors. Default value is \code{default.units = "inches"}.} 47 | 48 | \item{linecolor}{A character value specifying segment line color. 49 | Default value is \code{linecolor = "black"}.} 50 | 51 | \item{lwd}{A numeric specifying segment line width. 52 | Default value is \code{lwd = 1}.} 53 | 54 | \item{lty}{A numeric specifying segment line type. 55 | Default value is \code{lty = 1}.} 56 | 57 | \item{lineend}{A character value specifying line end style. 58 | Default value is \code{lineend = "butt"}. Options are: 59 | \itemize{ 60 | \item{\code{"round"}: Segment ends are rounded.} 61 | \item{\code{"butt"}: Segment ends end exactly where ended.} 62 | \item{\code{"square"}: Segment ends are squared.} 63 | }} 64 | 65 | \item{linejoin}{A character value specifying line join style. 66 | Default value is \code{linejoin = "mitre"}. Options are: 67 | \itemize{ 68 | \item{\code{"round"}: }{Line joins are rounded.} 69 | \item{\code{"mitre"}: }{Line joins are sharp corners.} 70 | \item{\code{"bevel"}: }{Line joins are flattened corners.} 71 | }} 72 | 73 | \item{arrow}{A list describing arrow heads to place at either end of 74 | the line segments, as produced by the \link[grid]{arrow} function.} 75 | 76 | \item{params}{An optional \link[plotgardener]{pgParams} object containing 77 | relevant function parameters.} 78 | 79 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 80 | } 81 | \value{ 82 | Returns a \code{segments} object containing relevant 83 | placement and \link[grid]{grob} information. 84 | } 85 | \description{ 86 | Draw a line segment within a plotgardener layout 87 | } 88 | \examples{ 89 | library(grid) 90 | ## Create a page 91 | pageCreate(width = 7.5, height = 6, default.units = "inches") 92 | 93 | ## Plot one line segment 94 | plotSegments( 95 | x0 = 3.75, y0 = 0.25, x1 = 3.75, y1 = 5.75, 96 | default.units = "inches", 97 | lwd = 3, lty = 2 98 | ) 99 | 100 | ## Plot multiple line segments at different locations in different colors 101 | plotSegments( 102 | x0 = 0.5, y0 = c(1, 3, 5), x1 = 3.25, y1 = c(1, 3, 5), 103 | default.units = "inches", 104 | lwd = 2, linecolor = c("#7ecdbb", "#37a7db", "grey") 105 | ) 106 | 107 | ## Plot a line segment with an arrowhead 108 | plotSegments( 109 | x0 = 4.5, y0 = 0.5, x1 = 7, y1 = 3, 110 | default.units = "inches", 111 | arrow = arrow(type = "closed"), fill = "black" 112 | ) 113 | 114 | ## Plot lines with round lineends 115 | plotSegments( 116 | x0 = c(4, 7), y0 = 3.5, x1 = 5.5, y1 = 4.5, 117 | default.units = "inches", 118 | lwd = 5, lineend = "round" 119 | ) 120 | 121 | ## Hide page guides 122 | pageGuideHide() 123 | } 124 | \seealso{ 125 | \link[grid]{grid.segments}, \link[grid]{arrow} 126 | } 127 | -------------------------------------------------------------------------------- /man/plotText.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotText.R 3 | \name{plotText} 4 | \alias{plotText} 5 | \title{Plot text within a plotgardener layout} 6 | \usage{ 7 | plotText( 8 | label, 9 | fontcolor = "black", 10 | fontsize = 12, 11 | rot = 0, 12 | check.overlap = FALSE, 13 | x, 14 | y, 15 | just = "center", 16 | default.units = "inches", 17 | params = NULL, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{label}{Character or expression of text to be plotted.} 23 | 24 | \item{fontcolor}{A character value specifying text fontcolor. 25 | Default value is \code{fontcolor = "black"}.} 26 | 27 | \item{fontsize}{A numeric specifying text fontsize in points. 28 | Default value is \code{fontsize = 12}.} 29 | 30 | \item{rot}{A numeric specifying the angle to rotate the text. 31 | Default value is \code{rot = 0}.} 32 | 33 | \item{check.overlap}{A logical value to indicate whether to check 34 | for and omit overlapping text. 35 | Default value is \code{check.overlap = FALSE}.} 36 | 37 | \item{x}{A numeric vector or unit object specifying text x-location.} 38 | 39 | \item{y}{A numeric vector, unit object, or a character vector of 40 | values containing a "b" combined with a numeric value 41 | specifying text y-locations. 42 | The character vector will place text y-locations relative to the 43 | bottom of the most recently plotted plot according to the 44 | units of the plotgardener page.} 45 | 46 | \item{just}{Justification of text relative to its (x, y) location. 47 | If there are two values, the first value specifies horizontal 48 | justification and the second value specifies vertical justification. 49 | Possible string values are: \code{"left"}, \code{"right"}, 50 | \code{"centre"}, \code{"center"}, \code{"bottom"}, and \code{"top"}. 51 | Default value is \code{just = "center"}.} 52 | 53 | \item{default.units}{A string indicating the default units to use if 54 | \code{x} or \code{y} are only given as numerics or numeric vectors. 55 | Default value is \code{default.units = "inches"}.} 56 | 57 | \item{params}{An optional \link[plotgardener]{pgParams} object 58 | containing relevant function parameters.} 59 | 60 | \item{...}{Additional grid graphical parameters. See \link[grid]{gpar}.} 61 | } 62 | \value{ 63 | Returns a \code{text} object containing relevant 64 | placement and \link[grid]{grob} information. 65 | } 66 | \description{ 67 | Plot text within a plotgardener layout 68 | } 69 | \examples{ 70 | ## Create a page 71 | pageCreate(width = 4, height = 2, default.units = "inches") 72 | 73 | ## Plot text, adjusting fontsize and fontface 74 | plotText( 75 | label = "plotgardener", fontsize = 14, fontface = "bold", 76 | x = 1, y = 1, just = "center", default.units = "inches" 77 | ) 78 | 79 | ## Plot text, adjusting color, rotation, and fontfamily 80 | plotText( 81 | label = "coordinate-based", fontcolor = "#225EA8", rot = 90, 82 | fontfamily = "HersheyScript", x = 2, y = 1, just = "center", 83 | default.units = "inches" 84 | ) 85 | 86 | ## Plot a text label in multiple places at once 87 | plotText( 88 | label = "R", x = c(0.5, 1, 1.5), y = 1.5, just = "center", 89 | default.units = "inches" 90 | ) 91 | 92 | ## Plot a vector of text labels 93 | plotText( 94 | label = c("pg", "plot", "gardener"), x = 3, y = c(0.5, 1, 1.75), 95 | just = "center", default.units = "inches" 96 | ) 97 | 98 | ## Hide page guides 99 | pageGuideHide() 100 | } 101 | \seealso{ 102 | \link[grid]{grid.text} 103 | } 104 | -------------------------------------------------------------------------------- /man/plotgardener.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotgardener.R 3 | \docType{package} 4 | \name{plotgardener} 5 | \alias{plotgardener-package} 6 | \alias{plotgardener} 7 | \title{plotgardener: Coordinate-based Genomic Visualization Package for R} 8 | \description{ 9 | plotgardener is a coordinate-based genomic visualization package for R. 10 | It grants users the ability to programmatically produce complex, 11 | multi-paneled figures. Tailored for genomics, plotgardener allows users 12 | to visualize large complex genomic datasets and 13 | provides exquisite control over how plots are placed and arranged on 14 | a page. 15 | } 16 | \seealso{ 17 | Useful links: 18 | \itemize{ 19 | \item \url{https://phanstiellab.github.io/plotgardener} 20 | \item \url{https://github.com/PhanstielLab/plotgardener} 21 | } 22 | } 23 | \author{ 24 | \strong{Maintainer}: Nicole Kramer \email{nekramer@live.unc.edu} 25 | (\href{https://orcid.org/0000-0001-9617-9671}{ORCID}) 26 | 27 | Authors: 28 | \itemize{ 29 | \item Eric S. Davis \email{esdavis@live.unc.edu} 30 | (\href{https://orcid.org/0000-0003-4051-3217}{ORCID}) 31 | \item Craig Wenger \email{craig.wenger@gmail.com} 32 | (\href{https://orcid.org/0000-0002-7361-8456}{ORCID}) 33 | \item Douglas H. Phanstiel \email{douglas_phanstiel@med.unc.edu} 34 | [copyright holder] 35 | } 36 | 37 | Other contributors: 38 | \itemize{ 39 | \item Sarah Parker \email{sarmae@live.unc.edu} [contributor] 40 | \item Erika Deoudes \email{ed@erikadudes.com} [artist] 41 | \item Michael Love \email{milove@email.unc.edu} [contributor] 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /man/readBigwig.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/readBigwig.R 3 | \name{readBigwig} 4 | \alias{readBigwig} 5 | \title{Read a bigWig file and return it as a data frame} 6 | \usage{ 7 | readBigwig( 8 | file, 9 | chrom = NULL, 10 | chromstart = 1, 11 | chromend = .Machine$integer.max, 12 | strand = "*", 13 | params = NULL 14 | ) 15 | } 16 | \arguments{ 17 | \item{file}{A character value specifying the path to the bigwig file.} 18 | 19 | \item{chrom}{Chromosome of data as a string, if data for a specific 20 | chromosome is desired.} 21 | 22 | \item{chromstart}{Integer start position on chromosome.} 23 | 24 | \item{chromend}{Integer end position on chromosome.} 25 | 26 | \item{strand}{A character value specifying strand. 27 | Default value is \code{strand = "*"}. Options are: 28 | \itemize{ 29 | \item{\code{"+"}: }{Plus strand.} 30 | \item{\code{"-"}: }{Minus strand.} 31 | \item{\code{"*"}: }{Plus and minus strands.} 32 | }} 33 | 34 | \item{params}{An optional \link[plotgardener]{pgParams} object 35 | containing relevant function parameters.} 36 | } 37 | \value{ 38 | Returns a 6-column dataframe of bigwig information. 39 | } 40 | \description{ 41 | Read a bigWig file and return it as a data frame 42 | } 43 | \details{ 44 | This function does not work on Windows. 45 | } 46 | \examples{ 47 | if (.Platform$OS.type != "windows"){ 48 | bwFile <- system.file("extdata/test.bw", package="plotgardenerData") 49 | 50 | ## Read in entire file 51 | bwData <- readBigwig(file = bwFile) 52 | 53 | ## Read in specified region 54 | bwRegion <- readBigwig(file = bwFile, 55 | chrom = "chr2", 56 | chromstart = 1, 57 | chromend = 1500) 58 | } 59 | 60 | } 61 | \seealso{ 62 | \link[rtracklayer]{import.bw} 63 | } 64 | -------------------------------------------------------------------------------- /man/readCool.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/readCool.R 3 | \name{readCool} 4 | \alias{readCool} 5 | \title{Read a .(m)cool file and return Hi-C data as a dataframe} 6 | \usage{ 7 | readCool( 8 | file, 9 | chrom, 10 | chromstart = NULL, 11 | chromend = NULL, 12 | altchrom = NULL, 13 | altchromstart = NULL, 14 | altchromend = NULL, 15 | resolution = "auto", 16 | zrange = NULL, 17 | norm = "NONE", 18 | binChunkSize = 5e6, 19 | params = NULL, 20 | quiet = FALSE 21 | ) 22 | } 23 | \arguments{ 24 | \item{file}{A character value specifying the path to the .(m)cool file.} 25 | 26 | \item{chrom}{Chromosome of data, as a string.} 27 | 28 | \item{chromstart}{Integer start position on chromosome.} 29 | 30 | \item{chromend}{Integer end position on chromosome.} 31 | 32 | \item{altchrom}{Alternate chromosome for interchromosomal data, 33 | as a string.} 34 | 35 | \item{altchromstart}{Alternate chromosome integer start position 36 | for interchromosomal data.} 37 | 38 | \item{altchromend}{Alternate chromosome integer end position 39 | for interchromosomal data.} 40 | 41 | \item{resolution}{A numeric specifying the width of each pixel. 42 | "auto" will attempt to choose a resolution in basepairs based on 43 | the size of the region.} 44 | 45 | \item{zrange}{A numeric vector of length 2 specifying the range of 46 | interaction scores, where extreme values will be set to the max or min.} 47 | 48 | \item{norm}{Character value specifying hic data normalization method. 49 | This value must be found in the .(m)cool file. 50 | Default value is \code{norm = "NONE"}.} 51 | 52 | \item{binChunkSize}{A numeric specifying the number of bin indices to read 53 | from a file for a given region at a given resolution. If the total amount of 54 | data is larger than the \code{binChunkSize}, data will be read in multiple 55 | chunks. Default value is \code{binChunkSize = 5e6}.} 56 | 57 | \item{params}{An optional \link[plotgardener]{pgParams} object 58 | containing relevant function parameters.} 59 | 60 | \item{quiet}{A logical indicating whether or not to print messages.} 61 | } 62 | \value{ 63 | Returns a 3-column dataframe in sparse upper triangular 64 | format with the following columns: \code{chrom}, \code{altchrom}, 65 | \code{counts}. 66 | } 67 | \description{ 68 | Read a .(m)cool file and return Hi-C data as a dataframe 69 | } 70 | \examples{ 71 | 72 | ## .cool file 73 | coolFile <- file.path(tempdir(), "Rao2014-IMR90-MboI-allreps-filtered.1000kb.cool") 74 | download.file(url = "https://usgs2.osn.mghpcc.org/cooler01/examples/hg19/Rao2014-IMR90-MboI-allreps-filtered.1000kb.cool", 75 | destfile = coolFile, mode = "wb") 76 | 77 | ## Read in region `chr2:10000000-22000000` at 1000Kb cool file resolution 78 | coolData <- readCool(file = coolFile, chrom = "chr2", chromstart = 10000000, 79 | chromend = 22000000, 80 | resolution = 1000000) 81 | 82 | ## .mcool file 83 | mcoolFile <- file.path(tempdir(), "LEUK_HEK_PJA27_inter_30.mcool") 84 | download.file(url = "https://zenodo.org/records/10906240/files/LEUK_HEK_PJA27_inter_30.mcool?download=1", 85 | destfile = mcoolFile, mode = "wb") 86 | 87 | ## Read in region `chr2:1000000-5000000` at 100Kb resolution 88 | mcoolData_100Kb <- readCool(file = mcoolFile, chrom = "2", 89 | chromstart = 1000000, chromend = 5000000, 90 | resolution = 100000) 91 | 92 | ## Read in data for chr2 at 2500Kb resolution 93 | mcoolData_2500Kb <- readCool(file = mcoolFile, chrom = "2", 94 | resolution = 2500000) 95 | } 96 | \seealso{ 97 | \link[plotgardener]{readHic} 98 | } 99 | \author{ 100 | Sarah Parker, Nicole Kramer 101 | } 102 | -------------------------------------------------------------------------------- /man/readCoolBpResolutions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/readCool.R 3 | \name{readCoolBpResolutions} 4 | \alias{readCoolBpResolutions} 5 | \title{Read basepair resolutions from an .(m)cool file} 6 | \usage{ 7 | readCoolBpResolutions(file) 8 | } 9 | \arguments{ 10 | \item{file}{A character value specifying the path to the .(m)cool file} 11 | } 12 | \value{ 13 | Vector of basepair resolutions 14 | } 15 | \description{ 16 | Read basepair resolutions from an .(m)cool file 17 | } 18 | \author{ 19 | Sarah Parker 20 | } 21 | -------------------------------------------------------------------------------- /man/readCoolChroms.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/readCool.R 3 | \name{readCoolChroms} 4 | \alias{readCoolChroms} 5 | \title{Read chromosomes included in .(m)cool files} 6 | \usage{ 7 | readCoolChroms(file, resolution = NULL) 8 | } 9 | \arguments{ 10 | \item{file}{A character value specifying the path to the .(m)cool file} 11 | 12 | \item{resolution}{optional, specify which resolution(s) to read 13 | chromosomes from. Default is all resolutions in `file`.} 14 | } 15 | \value{ 16 | Data frame or list of data frames of chromosome names and lengths 17 | } 18 | \description{ 19 | Read chromosomes included in .(m)cool files 20 | } 21 | \author{ 22 | Sarah Parker, Nicole Kramer 23 | } 24 | -------------------------------------------------------------------------------- /man/readCoolNorms.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/readCool.R 3 | \name{readCoolNorms} 4 | \alias{readCoolNorms} 5 | \title{Read normalizations included in .(m)cool files} 6 | \usage{ 7 | readCoolNorms(file, resolution = NULL) 8 | } 9 | \arguments{ 10 | \item{file}{A character value specifying the path to the .(m)cool file} 11 | 12 | \item{resolution}{optional, specify which resolution(s) to read 13 | normalization types from. Default is all resolutions in `file`.} 14 | } 15 | \value{ 16 | A vector or list of vectors of available normalizations 17 | } 18 | \description{ 19 | Read normalizations included in .(m)cool files 20 | } 21 | \details{ 22 | The "BALANCE" normalization refers to applying the pre-calculated matrix 23 | balancing weights in the `weight` dataset of `file`, typically present 24 | in files created using cooler. VC is vanilla coverage, 25 | VC_SQRT is square root of vanilla coverage, 26 | and KR is Knight-Ruiz normalization. 27 | 28 | Please note that if using a file from HiC-Pro, ICE normalizations will come 29 | from files stored in a separate folder, and thus will not contain any 30 | normalizations explicitly called "ICE" or "BALANCE" since values are 31 | included already normalized. This normalization can be specified as "NONE". 32 | } 33 | \author{ 34 | Sarah Parker, Nicole Kramer 35 | } 36 | -------------------------------------------------------------------------------- /man/readHic.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/readHic.R 3 | \name{readHic} 4 | \alias{readHic} 5 | \title{Read a .hic file and return Hi-C data as a dataframe} 6 | \usage{ 7 | readHic( 8 | file, 9 | chrom, 10 | chromstart = NULL, 11 | chromend = NULL, 12 | altchrom = NULL, 13 | altchromstart = NULL, 14 | altchromend = NULL, 15 | assembly = "hg38", 16 | resolution = "auto", 17 | res_scale = "BP", 18 | zrange = NULL, 19 | norm = "KR", 20 | matrix = "observed", 21 | params = NULL, 22 | quiet = FALSE 23 | ) 24 | } 25 | \arguments{ 26 | \item{file}{A character value specifying the path to the .hic file.} 27 | 28 | \item{chrom}{Chromosome of data, as a string.} 29 | 30 | \item{chromstart}{Integer start position on chromosome.} 31 | 32 | \item{chromend}{Integer end position on chromosome.} 33 | 34 | \item{altchrom}{Alternate chromosome for interchromosomal data, 35 | as a string.} 36 | 37 | \item{altchromstart}{Alternate chromosome integer start position 38 | for interchromosomal data.} 39 | 40 | \item{altchromend}{Alternate chromosome integer end position 41 | for interchromosomal data.} 42 | 43 | \item{assembly}{Default genome assembly as a string or a 44 | \link[plotgardener]{assembly} object. 45 | Default value is \code{assembly = "hg38"}.} 46 | 47 | \item{resolution}{A numeric specifying the width of each pixel. 48 | "auto" will attempt to choose a resolution in basepairs based on 49 | the size of the region.} 50 | 51 | \item{res_scale}{A character value specifying the resolution scale. 52 | Default value is \code{res_scale = "BP"}. Options are: 53 | \itemize{ 54 | \item{\code{"BP"}: }{Base pairs.} 55 | \item{\code{"FRAG"}: }{Fragments.} 56 | }} 57 | 58 | \item{zrange}{A numeric vector of length 2 specifying the range of 59 | interaction scores, where extreme values will be set to the max or min.} 60 | 61 | \item{norm}{Character value specifying hic data normalization method. 62 | This value must be found in the .hic file. 63 | Default value is \code{norm = "KR"}.} 64 | 65 | \item{matrix}{Character value indicating the type of matrix to output. 66 | Default value is \code{matrix = "observed"}. Options are: 67 | \itemize{ 68 | \item{\code{"observed"}: }{Observed counts.} 69 | \item{\code{"oe"}: }{Observed/expected counts.} 70 | \item{\code{"log2oe"}: }{Log2 transformed observed/expected counts.} 71 | }} 72 | 73 | \item{params}{An optional \link[plotgardener]{pgParams} object 74 | containing relevant function parameters.} 75 | 76 | \item{quiet}{A logical indicating whether or not to print messages.} 77 | } 78 | \value{ 79 | Returns a 3-column dataframe in sparse upper triangular 80 | format with the following columns: \code{chrom}, \code{altchrom}, 81 | \code{counts}. 82 | } 83 | \description{ 84 | Read a .hic file and return Hi-C data as a dataframe 85 | } 86 | \examples{ 87 | hicFile <- system.file("extdata/test_chr22.hic", package="plotgardenerData") 88 | 89 | ## Read in data for all chr22 file at 2.5Mb bp resolution 90 | hicData <- readHic(file = hicFile, chrom = "22", 91 | assembly = "hg19", 92 | resolution = 2500000) 93 | 94 | ## Read in region `chr22:20000000-47500000` at 100 Kb resolution 95 | hicData10Kb <- readHic(file = hicFile, chrom = "22", 96 | chromstart = 20000000, chromend = 47500000, 97 | assembly = "hg19", 98 | resolution = 100000) 99 | 100 | } 101 | \seealso{ 102 | \link[strawr]{straw} 103 | } 104 | -------------------------------------------------------------------------------- /pkgdown/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://phanstiellab.github.io/plotgardener 2 | 3 | home: 4 | links: 5 | - text: View the publication 6 | href: https://doi.org/10.1093/bioinformatics/btac057 7 | 8 | template: 9 | params: 10 | bootswatch: lumen 11 | 12 | pkgdown: 13 | as_is: true 14 | 15 | authors: 16 | Nicole Kramer: 17 | href: https://github.com/nekramer 18 | Eric S. Davis: 19 | href: https://github.com/EricSDavis 20 | Craig Wenger: 21 | href: https://github.com/cwenger 22 | Sarah Parker: 23 | href: https://github.com/sarmapar 24 | Douglas H. Phanstiel: 25 | href: https://github.com/dphansti 26 | 27 | navbar: 28 | type: default 29 | left: 30 | - icon: fa-home fa-lg 31 | href: index.html 32 | - text: Our Philosophy 33 | href: articles/guides/our_philosophy.html 34 | - text: Introduction to plotgardener 35 | href: articles/introduction_to_plotgardener.html 36 | - text: Articles 37 | menu: 38 | - text: The plotgardener Page 39 | href: articles/guides/plotgardener_page.html 40 | - text: Reading Data for plotgardener 41 | href: articles/guides/reading_data_for_plotgardener.html 42 | - text: Plotting Multi-omic Data 43 | href: articles/guides/plotting_multiomic_data.html 44 | - text: Plot Annotations 45 | href: articles/guides/annotations.html 46 | - text: plotgardener Meta Functions 47 | href: articles/guides/plotgardener_meta_functions.html 48 | - text: Bioconductor Integration 49 | href: articles/guides/bioconductor_integration.html 50 | - text: Incorporating ggplots and other grid-based Bioconductor visualizations 51 | href: articles/guides/incorporating_ggplots.html 52 | - text: Ideograms and Shapes 53 | href: articles/guides/ideograms_and_shapes.html 54 | - text: Plot Aesthetics 55 | href: articles/guides/aesthetics.html 56 | - text: Reference 57 | href: reference/index.html 58 | right: 59 | - icon: fab fa-github fa-lg 60 | href: https://github.com/PhanstielLab/plotgardener 61 | 62 | reference: 63 | - title: "About plotgardener" 64 | contents: 65 | - plotgardener 66 | 67 | - title: "Page layout functions" 68 | contents: 69 | - starts_with("page") 70 | 71 | - title: "Reading functions" 72 | contents: 73 | - starts_with("read") 74 | 75 | - title: "Plotting functions" 76 | - subtitle: "Genomics" 77 | contents: 78 | - plotGenes 79 | - plotGenomeLabel 80 | - plotHicRectangle 81 | - plotHicSquare 82 | - plotHicTriangle 83 | - plotIdeogram 84 | - plotManhattan 85 | - plotPairs 86 | - plotPairsArches 87 | - plotRanges 88 | - plotSignal 89 | - plotMultiSignal 90 | - plotTranscripts 91 | - subtitle: "Shapes and Basic Elements" 92 | - contents: 93 | - plotCircle 94 | - plotLegend 95 | - plotPolygon 96 | - plotRaster 97 | - plotRect 98 | - plotSegments 99 | - plotText 100 | - subtitle: "External" 101 | - contents: 102 | - plotGG 103 | 104 | - title: "Annotation functions" 105 | contents: 106 | - starts_with("anno") 107 | 108 | - title: "Meta functions" 109 | contents: 110 | - assembly 111 | - defaultPackages 112 | - genomes 113 | - pgParams 114 | - c 115 | - colorby 116 | - mapColors 117 | - calcSignalRange 118 | 119 | figures: 120 | fig.height: 7 121 | fig.width: 8.2 122 | fig.asp: ~ 123 | dpi: 150 124 | 125 | 126 | -------------------------------------------------------------------------------- /pkgdown/extra.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | color: #65991F; 3 | } 4 | 5 | .version { 6 | background-color: #65991F; 7 | } 8 | 9 | .fa-home { 10 | color: #65991F; 11 | } -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/pkgdown/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/pkgdown/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhanstielLab/plotgardener/2bc0a3e9e4d4ea35bbc6f1c19dc0cc2a8d71c2ec/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.so 3 | *.dll 4 | -------------------------------------------------------------------------------- /src/RcppExports.cpp: -------------------------------------------------------------------------------- 1 | // Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | #include 5 | 6 | using namespace Rcpp; 7 | 8 | #ifdef RCPP_USE_GLOBAL_ROSTREAM 9 | Rcpp::Rostream& Rcpp::Rcout = Rcpp::Rcpp_cout_get(); 10 | Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get(); 11 | #endif 12 | 13 | // checkRow 14 | NumericMatrix checkRow(NumericMatrix x, int maxRows, int rowCol, double wig); 15 | RcppExport SEXP _plotgardener_checkRow(SEXP xSEXP, SEXP maxRowsSEXP, SEXP rowColSEXP, SEXP wigSEXP) { 16 | BEGIN_RCPP 17 | Rcpp::RObject rcpp_result_gen; 18 | Rcpp::RNGScope rcpp_rngScope_gen; 19 | Rcpp::traits::input_parameter< NumericMatrix >::type x(xSEXP); 20 | Rcpp::traits::input_parameter< int >::type maxRows(maxRowsSEXP); 21 | Rcpp::traits::input_parameter< int >::type rowCol(rowColSEXP); 22 | Rcpp::traits::input_parameter< double >::type wig(wigSEXP); 23 | rcpp_result_gen = Rcpp::wrap(checkRow(x, maxRows, rowCol, wig)); 24 | return rcpp_result_gen; 25 | END_RCPP 26 | } 27 | // rebinBigwig 28 | NumericVector rebinBigwig(DataFrame bigwig, DataFrame bins); 29 | RcppExport SEXP _plotgardener_rebinBigwig(SEXP bigwigSEXP, SEXP binsSEXP) { 30 | BEGIN_RCPP 31 | Rcpp::RObject rcpp_result_gen; 32 | Rcpp::RNGScope rcpp_rngScope_gen; 33 | Rcpp::traits::input_parameter< DataFrame >::type bigwig(bigwigSEXP); 34 | Rcpp::traits::input_parameter< DataFrame >::type bins(binsSEXP); 35 | rcpp_result_gen = Rcpp::wrap(rebinBigwig(bigwig, bins)); 36 | return rcpp_result_gen; 37 | END_RCPP 38 | } 39 | 40 | static const R_CallMethodDef CallEntries[] = { 41 | {"_plotgardener_checkRow", (DL_FUNC) &_plotgardener_checkRow, 4}, 42 | {"_plotgardener_rebinBigwig", (DL_FUNC) &_plotgardener_rebinBigwig, 2}, 43 | {NULL, NULL, 0} 44 | }; 45 | 46 | RcppExport void R_init_plotgardener(DllInfo *dll) { 47 | R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); 48 | R_useDynamicSymbols(dll, FALSE); 49 | } 50 | -------------------------------------------------------------------------------- /src/checkRow.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace Rcpp; 3 | 4 | int rowNum(NumericVector v, NumericMatrix x, int maxRows, int rowCol, double wig) { 5 | 6 | // genomic coord start and stop, incorporating wiggle (in bp) 7 | int start = std::min(v[0], v[1]) - wig; 8 | int stop = std::max(v[0], v[1]) + wig; 9 | 10 | // check every row value 11 | for (int j = 1; j <= maxRows; j++){ 12 | // initialize a row counter 13 | int rowCounter = 0; 14 | // go through dataframe to check for approriate row values 15 | int dfRows = x.nrow(); 16 | for (int row = 0; row < dfRows; row++){ 17 | NumericVector v = x(row,_); 18 | 19 | if (((v[rowCol] == j) & 20 | (((start >= v[0]) & (start <= v[1])) | 21 | ((stop >= v[0]) & (stop <= v[1])) | 22 | ((start <= v[0]) & (stop >= v[1]))))){ 23 | 24 | rowCounter++; 25 | } 26 | } 27 | 28 | if (rowCounter == 0){ 29 | 30 | return j; 31 | 32 | } 33 | 34 | } 35 | 36 | return 0; 37 | 38 | } 39 | 40 | 41 | // [[Rcpp::export]] 42 | NumericMatrix checkRow(NumericMatrix x, int maxRows, int rowCol, double wig){ 43 | 44 | // go through each row of the dataframe 45 | int dfRows = x.nrow(); 46 | for (int i = 0; i < dfRows; ++i){ 47 | // get the row 48 | NumericVector row = x(i,_); 49 | // determine its rownumber from rowNum function 50 | int rowNumber = rowNum(row, x, maxRows, rowCol, wig); 51 | // update whole dataframe with that value's rownumber 52 | x(i,rowCol) = rowNumber; 53 | } 54 | 55 | return x; 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/rebinBigwig.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace Rcpp; 4 | 5 | // [[Rcpp::export]] 6 | NumericVector rebinBigwig(DataFrame bigwig, DataFrame bins) 7 | { 8 | NumericVector bw_start = bigwig["start"]; 9 | NumericVector bw_end = bigwig["end"]; 10 | NumericVector bw_score = bigwig["score"]; 11 | NumericVector bins_start = bins["start"]; 12 | NumericVector bins_end = bins["end"]; 13 | NumericVector max_scores(bins.nrows()); 14 | int bw_i = 0, b_i = 0; 15 | while(bw_i < bigwig.nrows() && b_i < bins.nrows()) 16 | { 17 | if(bw_end[bw_i] < bins_start[b_i]) 18 | bw_i++; 19 | else if(bins_end[b_i] <= bw_start[bw_i]) 20 | b_i++; 21 | else 22 | { 23 | max_scores[b_i] = fmax(max_scores[b_i], bw_score[bw_i]); 24 | if(bw_end[bw_i] < bins_end[b_i]) 25 | bw_i++; 26 | else if(bins_end[b_i] <= bw_end[bw_i]) 27 | b_i++; 28 | else if(bw_end[bw_i] == bins_end[b_i]) 29 | { 30 | bw_i++; 31 | b_i++; 32 | } 33 | } 34 | } 35 | return max_scores; 36 | } 37 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(plotgardener) 3 | 4 | test_check("plotgardener") 5 | -------------------------------------------------------------------------------- /tests/testthat/test-assemblyFunctions.R: -------------------------------------------------------------------------------- 1 | test_that("chromDataAgreement", { 2 | library(plotgardenerData) 3 | ## Ranges 4 | data("IMR90_ChIP_CTCF_reads") 5 | ## match 6 | expect_silent(plotgardener:::chromDataAgreement(data = IMR90_ChIP_CTCF_reads, 7 | chrom = "chr21", 8 | type = "ranges")) 9 | ## don't match 10 | expect_warning(plotgardener:::chromDataAgreement(data = IMR90_ChIP_CTCF_reads, 11 | chrom = "21", 12 | type = "ranges")) 13 | ## Pairs 14 | data("IMR90_DNAloops_pairs") 15 | ## match 16 | expect_silent(plotgardener:::chromDataAgreement(data = IMR90_DNAloops_pairs, 17 | chrom = "chr21", 18 | type = "pairs")) 19 | ## don't match 20 | expect_warning(plotgardener:::chromDataAgreement(data = IMR90_DNAloops_pairs, 21 | chrom = "21", 22 | type = "pairs")) 23 | }) 24 | 25 | test_that("genomicScale", { 26 | 27 | ## Has TxDb and full chromosome xscale 28 | library("TxDb.Hsapiens.UCSC.hg19.knownGene") 29 | testObject <- list("chrom" = "chr1", 30 | "chromstart" = NULL, 31 | "chromend" = NULL, 32 | "assembly" = plotgardener:::parseAssembly("hg19")) 33 | testObjectInternal <- list() 34 | scale <- plotgardener:::genomicScale(object = testObject, 35 | objectInternal = testObjectInternal, 36 | plotType = "genes")[[2]]$xscale 37 | expect_equal(scale, c(1, 249250621)) 38 | 39 | ## Throws wrong chromosome warning 40 | testObject <- list("chrom" = "chrHello", 41 | "chromstart" = NULL, 42 | "chromend" = NULL, 43 | "assembly" = plotgardener:::parseAssembly("hg19")) 44 | expect_warning(plotgardener:::genomicScale(object = testObject, 45 | objectInternal = testObjectInternal, 46 | plotType = "genes")) 47 | scale2 <- suppressWarnings(plotgardener:::genomicScale(object = testObject, 48 | objectInternal = testObjectInternal, 49 | plotType = "genes"))[[2]]$xscale 50 | expect_equal(scale2, c(0, 1)) 51 | }) 52 | 53 | test_that("geneData", { 54 | 55 | ## TxDb and OrgDb gets data 56 | library("TxDb.Hsapiens.UCSC.hg19.knownGene") 57 | library("org.Hs.eg.db") 58 | testObject <- list("chrom" = "chr1", 59 | "assembly" = plotgardener:::parseAssembly("hg19")) 60 | testObjectInternal <- list() 61 | 62 | expect_silent(plotgardener:::geneData(object = testObject, 63 | objectInternal = testObjectInternal)) 64 | }) 65 | -------------------------------------------------------------------------------- /tests/testthat/test-colorby.R: -------------------------------------------------------------------------------- 1 | test_that("colorby object created", { 2 | object1 <- colorby(column = "foo") 3 | object2 <- colorby(column = "foo", range = c(0, 1)) 4 | 5 | expect_equal(class(object1), "colorby") 6 | expect_equal(class(object2), "colorby") 7 | }) 8 | 9 | test_that("mapped colors", { 10 | ## Numeric vector color mappings 11 | numVector <- c(1, 2, 3, 2, 1) 12 | colorVector <- mapColors(vector = numVector, 13 | palette = colorRampPalette(c("blue", "red", "black")), 14 | range = NULL) 15 | expect_setequal(colorVector, c("#0000FF", "#FF0000", "#050000", "#FF0000", 16 | "#0000FF")) 17 | colorVector <- mapColors(vector = numVector, 18 | palette = colorRampPalette(c("blue", "red", "black")), 19 | range = c(1, 2)) 20 | 21 | expect_setequal(colorVector, c("#0000FF", "#050000", "#050000", 22 | "#050000", "#0000FF")) 23 | 24 | 25 | ## Factor vector where levels are defaulted to: cat, dog, pig 26 | factVector <- factor(c("dog", "cat", "pig", "cat")) 27 | ## cat mapped to blue, dog mapped to red, pig mapped to black 28 | colorVector <- mapColors(vector = factVector, 29 | palette = colorRampPalette(c("blue", "red", "black"))) 30 | expect_mapequal(colorVector[levels(factVector)], c("dog" = "#FF0000", "cat" = "#0000FF", 31 | "pig" = "#000000")) 32 | 33 | ## Factor vector where levels are: dog, cat, pig 34 | factVector <- factor(c("dog", "cat", "pig", "cat")) 35 | levels(factVector) <- c("dog", "cat", "pig") 36 | ## dog mapped to blue, cat mapped to red, pig mapped to black 37 | colorVector <- mapColors(vector = factVector, 38 | palette = colorRampPalette(c("blue", "red", "black"))) 39 | expect_mapequal(colorVector[levels(factVector)], 40 | c("dog" = "#0000FF", "cat" = "#FF0000", "pig" = "#000000")) 41 | 42 | 43 | ## Subset of factor vector with four levels, but only three values present 44 | factVector <- factor(c("dog", "cat", "pig", "cat", "giraffe")) 45 | factVector <- factVector[1:4] 46 | # levels are cat, dog, giraffe, pig 47 | ## cat mapped to blue, dog mapped to red, giraffe mapped to black, pig mapped to yellow 48 | colorVector <- mapColors(vector = factVector, 49 | palette = colorRampPalette(c("blue", "red", "black", "yellow"))) 50 | expect_mapequal(colorVector[c("dog", "cat", "pig")], 51 | c("cat" = "#0000FF", "dog" = "#FF0000", "pig" = "#FFFF00")) 52 | 53 | ## Non-numeric, non-factor vector 54 | nonnumVector <- c("dog", "cat", "pig", "pig") 55 | # cat mapped to blue, dog mapped to red, pig mapped to black 56 | colorVector <- mapColors(vector = nonnumVector, 57 | palette = colorRampPalette(c("blue", "red", "black"))) 58 | expect_mapequal(colorVector[c("dog", "cat", "pig")], 59 | c("cat" = "#0000FF", "dog" = "#FF0000", "pig" = "#000000")) 60 | 61 | }) -------------------------------------------------------------------------------- /tests/testthat/test-hicFunctions.R: -------------------------------------------------------------------------------- 1 | test_that("adjust_resolution", { 2 | library(plotgardenerData) 3 | data("IMR90_HiC_10kb") 4 | ## Detect appropriate resolution from data 5 | expect_equal(plotgardener:::adjust_resolution(hic = IMR90_HiC_10kb, 6 | hicPlot = NULL)$resolution, 7 | 10000) 8 | ## Grab a resolution in a file 9 | hicFile <- system.file("extdata/test_chr22.hic", package="plotgardenerData") 10 | hic_plot <- list("chromstart" = 20000000, 11 | "chromend" = 47500000) 12 | expect_equal(plotgardener:::adjust_resolution(hic = hicFile, 13 | hicPlot = hic_plot)$resolution, 14 | 100000) 15 | 16 | ## Grab a close resolution to one in a file 17 | hic_plot <- list("chromstart" = 20000000, 18 | "chromend" = 40000000) 19 | expect_equal(plotgardener:::adjust_resolution(hic = hicFile, 20 | hicPlot = hic_plot)$resolution, 21 | 100000) 22 | 23 | }) 24 | 25 | test_that("hic_limit", { 26 | library(plotgardenerData) 27 | hicFile <- system.file("extdata/test_chr22.hic", package="plotgardenerData") 28 | 29 | ## Appropriate number of bins 30 | hic_plot <- list("chromstart" = 20000000, 31 | "chromend" = 47500000, 32 | "resolution" = 100000) 33 | expect_silent(plotgardener:::hic_limit(hic = hicFile, 34 | hicPlot = hic_plot)) 35 | 36 | ## Hic file and readjusts bin number 37 | hic_plot <- list("chromstart" = 20000000, 38 | "chromend" = 47500000, 39 | "resolution" = 5000) 40 | expect_warning(plotgardener:::hic_limit(hic = hicFile, 41 | hicPlot = hic_plot)) 42 | expect_equal(suppressWarnings(plotgardener:::hic_limit(hic = hicFile, 43 | hicPlot = hic_plot)$resolution), 44 | 100000) 45 | 46 | ## Data frame NA resolution 47 | data("IMR90_HiC_10kb") 48 | expect_warning(plotgardener:::hic_limit(hic = IMR90_HiC_10kb, 49 | hicPlot = hic_plot)) 50 | expect_equal(suppressWarnings(plotgardener:::hic_limit(hic = IMR90_HiC_10kb, 51 | hicPlot = hic_plot)$resolution), 52 | NA) 53 | }) 54 | 55 | test_that("set_zrange", { 56 | library(plotgardenerData) 57 | data("IMR90_HiC_10kb") 58 | ## already has a zrange 59 | hic_plot <- list("zrange" = c(0, 10)) 60 | 61 | expect_equal(plotgardener:::set_zrange(IMR90_HiC_10kb, 62 | hicPlot = hic_plot)$zrange, 63 | c(0, 10)) 64 | 65 | 66 | ## no zrange, multiple values 67 | hic_plot <- list("zrange" = NULL, "colorTrans" = "linear") 68 | expect_equal(plotgardener:::set_zrange(IMR90_HiC_10kb, 69 | hicPlot = hic_plot)$zrange, 70 | c(0, 70)) 71 | 72 | ## no zrange, only one value 73 | IMR90_HiC_10kb$counts <- 1 74 | expect_equal(plotgardener:::set_zrange(IMR90_HiC_10kb, 75 | hicPlot = hic_plot)$zrange, 76 | c(1, 1)) 77 | }) 78 | 79 | test_that("inherit_half", { 80 | 81 | ## square hic half , top 82 | library(plotgardenerData) 83 | data("IMR90_HiC_10kb") 84 | pageCreate(width = 3, height = 3, default.units = "inches") 85 | hicPlot <- suppressMessages(plotHicSquare( 86 | data = IMR90_HiC_10kb, resolution = 10000, 87 | zrange = c(0, 70), 88 | chrom = "chr21", 89 | chromstart = 28000000, chromend = 30300000, 90 | assembly = "hg19", 91 | half = "top", 92 | x = 0.5, y = 0.5, width = 2, height = 2, 93 | just = c("left", "top"), 94 | default.units = "inches" 95 | )) 96 | expect_equal(plotgardener:::inherit_half(hicPlot), 97 | "top") 98 | 99 | ## triangle hic half, always top 100 | pageCreate(width = 4, height = 2.5, default.units = "inches") 101 | 102 | ## Plot and place triangle Hi-C plot 103 | hicPlot <- suppressMessages(plotHicTriangle( 104 | data = IMR90_HiC_10kb, resolution = 10000, 105 | zrange = c(0, 70), 106 | chrom = "chr21", 107 | chromstart = 28000000, chromend = 30300000, 108 | assembly = "hg19", 109 | x = 2, y = 0.5, width = 3, height = 1.5, 110 | just = "top", default.units = "inches" 111 | )) 112 | hicPlot$half <- "testing" 113 | expect_equal(plotgardener:::inherit_half(hicPlot), 114 | "top") 115 | }) 116 | -------------------------------------------------------------------------------- /tests/testthat/test-pgParams.R: -------------------------------------------------------------------------------- 1 | test_that("pgParams object created", { 2 | object <- pgParams(chrom = "chr1") 3 | expect_equal(class(object), "pgParams") 4 | }) 5 | 6 | test_that("pgParams object concatenates", { 7 | object1 <- pgParams(chrom = "chr1") 8 | object2 <- pgParams(chromstart = 1000000) 9 | object3 <- pgParams(chrom = "chr1", chromstart = 1000000) 10 | 11 | expect_equal(class(c(object1, object2)), "pgParams") 12 | expect_equal(c(object1, object2), object3) 13 | expect_warning(c(object1, "gene")) 14 | }) 15 | 16 | test_that("pgParams parameter parsing", { 17 | 18 | testFun <- function(data, chrom, chromstart = NULL, chromend = NULL, 19 | assembly = "hg19", 20 | params = NULL, ...){ 21 | newObject <- plotgardener:::parseParams(params = params, 22 | defaultArgs = formals(eval(match.call()[[1]])), 23 | declaredArgs = lapply(match.call()[-1], eval.parent, 24 | n = 2), 25 | class = "test_object") 26 | return(newObject) 27 | } 28 | 29 | ## All default parameters 30 | expect_mapequal( 31 | testFun(), 32 | list(data = NULL, 33 | chrom = NULL, 34 | chromstart = NULL, 35 | chromend = NULL, 36 | assembly = "hg19" 37 | ) 38 | ) 39 | 40 | ## Parameter replaces default 41 | expect_mapequal( 42 | testFun(chromstart = 1000000), 43 | list(data = NULL, 44 | chrom = NULL, 45 | chromstart = 1000000, 46 | chromend = NULL, 47 | assembly = "hg19" 48 | ) 49 | ) 50 | 51 | ## pgParams replaces default 52 | params <- pgParams(assembly = "hg38") 53 | expect_mapequal( 54 | testFun(params = params), 55 | list(data = NULL, 56 | chrom = NULL, 57 | chromstart = NULL, 58 | chromend = NULL, 59 | assembly = "hg38" 60 | ) 61 | ) 62 | 63 | ## Input overrides pgParams 64 | expect_mapequal( 65 | testFun(params = params, assembly = "mm9"), 66 | list(data = NULL, 67 | chrom = NULL, 68 | chromstart = NULL, 69 | chromend = NULL, 70 | assembly = "mm9" 71 | ) 72 | ) 73 | 74 | ## Multiple replacements 75 | expect_mapequal( 76 | testFun(params = params, assembly = "mm9", chromstart = 1000000), 77 | list(data = NULL, 78 | chrom = NULL, 79 | chromstart = 1000000, 80 | chromend = NULL, 81 | assembly = "mm9" 82 | ) 83 | ) 84 | 85 | }) 86 | -------------------------------------------------------------------------------- /tests/testthat/test-placementFunctions.R: -------------------------------------------------------------------------------- 1 | test_that("convert_gpath", { 2 | 3 | testGrob <- rectGrob() 4 | ## Grob becomes a gpath 5 | expect_true(is(plotgardener:::convert_gpath(testGrob), "gPath")) 6 | }) 7 | 8 | test_that("check_placement", { 9 | 10 | testObject <- list("x" = NULL, 11 | "y" = NULL) 12 | 13 | attr(testObject, "plotted") <- FALSE 14 | ## doesn't check if not plotted 15 | expect_silent(plotgardener:::check_placement(testObject)) 16 | 17 | ## error one null x or y 18 | testObject <- list("x" = unit(3, "inches"), 19 | "y" = NULL) 20 | 21 | attr(testObject, "plotted") <- TRUE 22 | expect_error(plotgardener:::check_placement(testObject)) 23 | 24 | ## error for 0 width 25 | testObject <- list("x" = unit(2, "inches"), 26 | "y" = unit(0.5, "npc"), 27 | "width" = unit(3, "inches"), 28 | "height" = unit(0, "inches")) 29 | 30 | attr(testObject, "plotted") <- TRUE 31 | expect_error(plotgardener:::check_placement(testObject)) 32 | 33 | ## No errors with all checks 34 | pageCreate() 35 | testObject <- list("x" = unit(2, "inches"), 36 | "y" = unit(0.5, "npc"), 37 | "width" = unit(3, "inches"), 38 | "height" = unit(3, "inches")) 39 | attr(testObject, "plotted") <- TRUE 40 | expect_silent(plotgardener:::check_placement(testObject)) 41 | 42 | }) 43 | 44 | test_that("assignRows", { 45 | library(plotgardenerData) 46 | data("IMR90_ChIP_CTCF_reads") 47 | 48 | ## set seed 49 | set.seed(nrow(IMR90_ChIP_CTCF_reads)) 50 | 51 | IMR90_ChIP_CTCF_reads <- IMR90_ChIP_CTCF_reads[ 52 | which(IMR90_ChIP_CTCF_reads[, "chrom"] == "chr21" 53 | & IMR90_ChIP_CTCF_reads[, "start"] <= 54 | 29074000 & IMR90_ChIP_CTCF_reads[, "end"] >= 55 | 29073000), ] 56 | 57 | ## Message without limitLabel 58 | expect_warning(plotgardener:::assignRows(data = IMR90_ChIP_CTCF_reads[, c(2,3)], 59 | maxRows = 3, 60 | wiggle = 10, 61 | rowCol = 2, 62 | limitLabel = FALSE, 63 | gTree = NULL), 64 | regexp = "Not enough plotting space for all provided elements.") 65 | 66 | ## Message with limitLabel 67 | assign("pileup_grobs", gTree(), envir = pgEnv) 68 | expect_warning(plotgardener:::assignRows(data = IMR90_ChIP_CTCF_reads[, c(2,3)], 69 | maxRows = 3, 70 | wiggle = 10, 71 | rowCol = 2, 72 | limitLabel = TRUE, 73 | gTree = "pileup_grobs")) 74 | }) 75 | -------------------------------------------------------------------------------- /tests/testthat/test-signalFunctions.R: -------------------------------------------------------------------------------- 1 | test_that("signalRanges", { 2 | library(plotgardenerData) 3 | data("IMR90_ChIP_H3K27ac_signal") 4 | data("GM12878_ChIP_H3K27ac_signal") 5 | GM12878_ChIP_H3K27ac_signal[,"score"] <- 6 | GM12878_ChIP_H3K27ac_signal[,"score"] * -1 7 | 8 | region <- pgParams( 9 | chrom = "chr21", 10 | chromstart = 28000000, chromend = 30300000, 11 | assembly = "hg19") 12 | 13 | sig1 <- suppressMessages(plotSignal( 14 | data = IMR90_ChIP_H3K27ac_signal, params = region, range = c(0, 45))) 15 | 16 | expect_equal(sig1$range, c(0, 45)) 17 | 18 | sig2 <- suppressMessages(plotSignal( 19 | data = list(IMR90_ChIP_H3K27ac_signal, 20 | GM12878_ChIP_H3K27ac_signal), params = region, 21 | range = c(-45, 45) 22 | )) 23 | expect_equal(sig2$range, c(-45, 45)) 24 | 25 | }) 26 | 27 | test_that("plotSignalMessages", { 28 | 29 | library(plotgardenerData) 30 | data("IMR90_ChIP_H3K27ac_signal") 31 | data("GM12878_ChIP_H3K27ac_signal") 32 | GM12878_ChIP_H3K27ac_signal[,"score"] <- 33 | GM12878_ChIP_H3K27ac_signal[,"score"] * -1 34 | 35 | region <- pgParams( 36 | chrom = "chr21", 37 | chromstart = 28000000, chromend = 30300000, 38 | assembly = "hg19") 39 | 40 | # Positive data should have no warnings/errors 41 | expect_message(plotSignal(data = IMR90_ChIP_H3K27ac_signal, 42 | params = region)) 43 | expect_invisible(plotSignal(data = IMR90_ChIP_H3K27ac_signal, 44 | params = region)) 45 | 46 | # Negative data with negData = TRUE should have no warnings or errors 47 | expect_message(plotSignal(data = GM12878_ChIP_H3K27ac_signal, 48 | params = region, negData = TRUE)) 49 | 50 | # Negative data with negData = FALSE should throw warning 51 | expect_warning(plotSignal(data = GM12878_ChIP_H3K27ac_signal, 52 | params = region)) 53 | 54 | # Positive and negative data in proper order should have no warnings/errors 55 | expect_message(plotSignal(data = list(IMR90_ChIP_H3K27ac_signal, 56 | GM12878_ChIP_H3K27ac_signal), 57 | params = region)) 58 | 59 | # Positive and negative data in proper order should error 60 | expect_error(plotSignal(data = list(GM12878_ChIP_H3K27ac_signal, 61 | IMR90_ChIP_H3K27ac_signal), 62 | params = region)) 63 | 64 | }) -------------------------------------------------------------------------------- /tests/testthat/test-transcriptFilter.R: -------------------------------------------------------------------------------- 1 | library(TxDb.Hsapiens.UCSC.hg38.knownGene) 2 | library(plotgardener) 3 | 4 | test_that("plotTranscripts transcritFilter works", { 5 | 6 | txdb <- TxDb.Hsapiens.UCSC.hg38.knownGene 7 | 8 | tbg <- transcriptsBy(txdb, by="gene") 9 | gene <- tbg[["7168"]] 10 | range <- range(gene) 11 | 12 | par <- pgParams( 13 | chrom = as.character(seqnames(range)), 14 | chromstart = start(range)-1e4, chromend = end(range)+1e4, 15 | assembly = "hg38", just = c("left", "bottom") 16 | ) 17 | 18 | pageCreate(width = 5, height = 2, showGuides = TRUE) 19 | 20 | # highlight can be a subset of filter 21 | hilite <- data.frame(transcript=c("ENST00000559831.6","ENST00000288398.10"), color=c("blue","red")) 22 | filter <- c("ENST00000559831.6","ENST00000288398.10","ENST00000651344.1","ENST00000560975.5") 23 | 24 | # should only show 4 out of 44 total txps 25 | plotTranscripts( 26 | params = par, x = 0.5, y = 1.5, width = 4, height = 1.1, 27 | transcriptHighlight=hilite, transcriptFilter=filter 28 | ) 29 | 30 | }) 31 | -------------------------------------------------------------------------------- /vignettes/guides/bioconductor_integration.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Bioconductor Integration" 3 | output: 4 | rmarkdown::html_vignette 5 | vignette: > 6 | %\VignetteIndexEntry{Bioconductor Integration} 7 | %\VignetteEngine{knitr::rmarkdown} 8 | %\VignetteEncoding{UTF-8} 9 | --- 10 | 11 | ```{r setup, include=FALSE} 12 | knitr::opts_chunk$set( 13 | fig.align = "center", 14 | fig.width = 3, 15 | fig.height = 3, 16 | collapse = TRUE, 17 | comment = "#>", 18 | warning = FALSE, 19 | message = FALSE 20 | ) 21 | library(grid) 22 | library(plotgardener) 23 | ``` 24 | 25 | `plotgardener` is designed to be flexibly compatible with typical Bioconductor 26 | classes and libraries of genomic data to easily integrate genomic data 27 | analysis and visualization. In addition to handling various genomic file 28 | types and `R` objects, many `plotgardener` functions can also handle `GRanges` or 29 | `GInteractions` objects as input data. Furthermore, `plotgardener` does not hard-code 30 | any genomic assemblies and can utilize `TxDb`, `OrgDb`, and `BSgenome` objects 31 | for various genomic annotations, including gene and transcript structures 32 | and names, chromosome sizes, and nucleotide sequences. Furthermore, all cytoband 33 | data for ideogram plots is retrieved from the UCSC Genome Browser through 34 | `AnnotationHub`. For standard genomic assemblies (i.e. hg19, hg38, mm10), 35 | `plotgardener` uses a set of default packages that can be displayed by calling 36 | `defaultPackages()`: 37 | 38 | ```{r echo=TRUE, eval=TRUE} 39 | defaultPackages("hg38") 40 | defaultPackages("hg19") 41 | defaultPackages("mm10") 42 | ``` 43 | 44 | To see which assemblies have defaults within `plotgardener`, call `genomes()`: 45 | 46 | ```{r echo=TRUE, eval=TRUE} 47 | genomes() 48 | ``` 49 | 50 | `plotgardener` functions default to an "hg38" assembly, but can be customized 51 | with any of the other genomic assemblies included or a `assembly` object. 52 | To create custom genomic assemblies and combinations of `TxDb`, `orgDb`, and 53 | `BSgenome` packages for use in `plotgardener` functions, we can use the 54 | `assembly()` constructor. For example, we can create our own `TxDb` 55 | from the current human Ensembl release: 56 | 57 | ```{r eval=FALSE, echo=TRUE} 58 | library(GenomicFeatures) 59 | TxDb.Hsapiens.Ensembl.GrCh38.103 <- makeTxDbFromEnsembl( 60 | organism = 61 | "Homo sapiens" 62 | ) 63 | ``` 64 | 65 | We can now create a new `assembly` with this `TxDb` and combinations of 66 | other Bioconductor packages. The `Genome` parameter can is a string to name 67 | or describe this assembly. Since the `TxDb` is now from ENSEMBL, we will 68 | change the `gene.id` field to `"ENSEMBL"` to map gene IDs and symbols between 69 | our `TxDb` and `orgDb` objects. Most gene ID types can be found by calling 70 | `AnnotationDbi::keytypes()` on an `orgDb`. 71 | 72 | ```{r eval=FALSE, echo=TRUE} 73 | Ensembl38 <- assembly( 74 | Genome = "Ensembl.GRCh38.103", 75 | TxDb = TxDb.Hsapiens.Ensembl.GrCh38.103, 76 | OrgDb = "org.Hs.eg.db", 77 | BSgenome = "BSgenome.Hsapiens.NCBI.GRCh38", 78 | gene.id = "ENSEMBL", display.column = "SYMBOL" 79 | ) 80 | ``` 81 | 82 | This `assembly` object can now be easily passed into `plotgardener` functions 83 | through the `assembly` parameter to use custom genomic assembly configurations. 84 | 85 | `assembly` objects are especially handy for changing the type of gene or transcript label 86 | of our gene and transcript plots. The default `display.column = "SYMBOL"`, but we could 87 | change this value to other available `keytypes` in the `orgDb` we are using. 88 | For example, if we wanted to display the associated Ensembl IDs of an "hg19" 89 | `assembly` object, we would set `display.column = "ENSEMBL"`: 90 | 91 | ```{r bioc_01, echo=TRUE, fig.height=2.25, fig.width=5, message=FALSE} 92 | library(TxDb.Hsapiens.UCSC.hg19.knownGene) 93 | library(org.Hs.eg.db) 94 | new_hg19 <- assembly( 95 | Genome = "id_hg19", 96 | TxDb = "TxDb.Hsapiens.UCSC.hg19.knownGene", 97 | OrgDb = "org.Hs.eg.db", 98 | gene.id.column = "ENTREZID", 99 | display.column = "ENSEMBL" 100 | ) 101 | pageCreate( 102 | width = 5, height = 1.25, 103 | showGuides = FALSE, xgrid = 0, ygrid = 0 104 | ) 105 | genePlot <- plotGenes( 106 | chrom = "chr2", chromstart = 1000000, chromend = 20000000, 107 | assembly = new_hg19, 108 | x = 0.25, y = 0.25, width = 4.75, height = 1 109 | ) 110 | ``` 111 | 112 | ### Session Info 113 | ```{r} 114 | sessionInfo() 115 | ``` 116 | -------------------------------------------------------------------------------- /vignettes/guides/ideograms_and_shapes.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: Ideograms and Shapes 3 | output: rmarkdown::html_vignette 4 | vignette: > 5 | %\VignetteIndexEntry{Ideograms and Shapes} 6 | %\VignetteEngine{knitr::rmarkdown} 7 | %\VignetteEncoding{UTF-8} 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | knitr::opts_chunk$set( 12 | collapse = TRUE, 13 | comment = "#>", 14 | fig.align = "center", 15 | message = FALSE, 16 | warning = FALSE 17 | ) 18 | library(plotgardener) 19 | library(grid) 20 | library(plotgardenerData) 21 | ``` 22 | 23 | Beyond providing functions for plotting and arranging various genomic 24 | datasets, `plotgardener` also gives users the functionality to plot other elements 25 | within a `plotgardener` page layout: 26 | 27 | ## Ideograms 28 | 29 | In addition to a genomic axis label, it can also be useful to include an 30 | ideogram representation of a chromosome to give a broader context of the 31 | location of genomic data. UCSC Giemsa stain cytoband information for various 32 | genomic assemblies is retrieved from `AnnotationHub` for default assemblies, 33 | but users can also provide their own Giemsa stain information if they desire. 34 | 35 | Ideograms can be plotted both vertically and horizontally: 36 | ```{r ideogram_01, echo=TRUE, fig.height=5.25, fig.width=10.35, message=FALSE} 37 | library(AnnotationHub) 38 | library(TxDb.Hsapiens.UCSC.hg19.knownGene) 39 | library(GenomeInfoDb) 40 | 41 | ## Get sizes of chromosomes to scale their sizes 42 | tx_db <- TxDb.Hsapiens.UCSC.hg19.knownGene 43 | chromSizes <- GenomeInfoDb::seqlengths(tx_db) 44 | maxChromSize <- max(chromSizes) 45 | 46 | pageCreate( 47 | width = 8.35, height = 4.25, default.units = "inches", 48 | showGuides = FALSE, xgrid = 0, ygrid = 0 49 | ) 50 | xCoord <- 0.15 51 | for (chr in c(paste0("chr", seq(1, 22)), "chrX", "chrY")) { 52 | height <- (4 * chromSizes[[chr]]) / maxChromSize 53 | plotIdeogram( 54 | chrom = chr, assembly = "hg19", 55 | orientation = "v", 56 | x = xCoord, y = 4, 57 | width = 0.2, height = height, 58 | just = "bottom" 59 | ) 60 | plotText( 61 | label = gsub("chr", "", chr), 62 | x = xCoord, y = 4.1, fontsize = 10 63 | ) 64 | xCoord <- xCoord + 0.35 65 | } 66 | ``` 67 | 68 | ```{r ideogram_02, echo=TRUE, fig.height=.5, fig.width=8.25, message=FALSE} 69 | pageCreate( 70 | width = 6.25, height = 0.5, default.units = "inches", 71 | showGuides = FALSE, xgrid = 0, ygrid = 0 72 | ) 73 | 74 | plotIdeogram( 75 | chrom = "chr1", assembly = "hg19", 76 | orientation = "h", 77 | x = 0.25, y = unit(0.25, "npc"), width = 5.75, height = 0.3 78 | ) 79 | ``` 80 | 81 | The cytobands can also be hidden if a more minimal ideogram is preferred: 82 | 83 | ```{r eval=FALSE, echo=TRUE, message=FALSE} 84 | plotIdeogram( 85 | showBands = FALSE, 86 | chrom = "chr1", assembly = "hg19", 87 | orientation = "h", 88 | x = 0.25, y = unit(0.25, "npc"), width = 5.75, height = 0.3 89 | ) 90 | ``` 91 | 92 | ```{r ideogram_03, echo=FALSE, fig.height=.5, fig.width=8.25, message=FALSE} 93 | pageCreate( 94 | width = 6.25, height = 0.5, default.units = "inches", 95 | showGuides = FALSE, xgrid = 0, ygrid = 0 96 | ) 97 | 98 | plotIdeogram( 99 | showBands = FALSE, 100 | chrom = "chr1", assembly = "hg19", 101 | orientation = "h", 102 | x = 0.25, y = unit(0.25, "npc"), width = 5.75, height = 0.3 103 | ) 104 | ``` 105 | 106 | To highlight a specific genomic region on an ideogram, see the 107 | article [Plot Annotations](annotations.html#genomic-region-highlights-and-zooms-1). 108 | 109 | ## Images and basic shapes 110 | 111 | `plotgardener` also allows users to plot images and basic shapes and elements to 112 | further enhance and customize plot layouts. The functions `plotCircle()`, 113 | `plotPolygon()`, `plotRaster()`, `plotRect()`, `plotSegments()`, 114 | and `plotText()` provide an intuitive way to plot basic `grid` `grobs` 115 | without requiring any knowledge of `grid` graphics. 116 | 117 | For example, we can include `plotgardener`'s Gene the Gnome in our figures!: 118 | 119 | ```{r shapes, echo=TRUE, fig.height=7, fig.showtext=TRUE, fig.width=6} 120 | library(png) 121 | pg_type <- readPNG(system.file("images", 122 | "pg-wordmark.png", 123 | package = "plotgardener")) 124 | 125 | gene_gnome <- readPNG(system.file("images", 126 | "pg-gnome-hole-shadow.png", 127 | package = "plotgardener" )) 128 | 129 | pageCreate( 130 | width = 5, height = 6, default.units = "inches", 131 | showGuides = FALSE, xgrid = 0, ygrid = 0 132 | ) 133 | plotRaster( 134 | image = pg_type, 135 | x = 2.5, y = 0.25, width = 4, height = 1.5, just = "top" 136 | ) 137 | plotRaster( 138 | image = gene_gnome, 139 | x = 2.5, y = 1, width = 3.5, height = 3.5, just = "top" 140 | ) 141 | ``` 142 | 143 | For more detailed usage of basic shape functions, see the function-specific 144 | reference examples with `?function()` (e.g. `?plotCircle()`). 145 | 146 | ## Other grob objects 147 | 148 | We saw how to add `ggplots` and `ComplexHeatmaps` to `plotgardener` layouts 149 | in the vignette 150 | [Incorporating ggplots and other `grid`-based Bioconductor visualizations"](incorporating_ggplots.html) 151 | with the `plotGG()` function. Beyond customizing the coordinates and dimensions 152 | of `ggplots` and `grid`-based Bioconductor visualizations, `plotGG()` can also 153 | be used to incorporate other `grob` and `gtable` objects. Thus, `plotgardener` 154 | allows us to easily mix and arrange most kinds of plot objects for ultimate 155 | customization. 156 | 157 | ## Session Info 158 | ```{r} 159 | sessionInfo() 160 | ``` 161 | -------------------------------------------------------------------------------- /vignettes/guides/reading_data_for_plotgardener.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Reading Data for plotgardener" 3 | output: 4 | rmarkdown::html_vignette 5 | vignette: > 6 | %\VignetteIndexEntry{Reading Data for plotgardener} 7 | %\VignetteEngine{knitr::rmarkdown} 8 | %\VignetteEncoding{UTF-8} 9 | --- 10 | 11 | ```{r setup, include=FALSE} 12 | knitr::opts_chunk$set( 13 | fig.align = "center", 14 | fig.width = 3, 15 | fig.height = 3, 16 | collapse = TRUE, 17 | comment = "#>", 18 | warning = FALSE, 19 | message = FALSE 20 | ) 21 | library(grid) 22 | library(plotgardener) 23 | library(plotgardenerData) 24 | ``` 25 | 26 | `plotgardener` handles a wide array of genomic data types in various formats 27 | and file types. Not only does it work with `data.frames`, `data.tables`, 28 | `tibbles`, and Bioconductor `GRanges` and `GInteractions` objects, but 29 | it can also read in common genomic file types like BED, BEDPE, bigWig, 30 | and .hic files. While files can be read directly into `plotgardener` plotting 31 | functions, `plotgardener` also provides functions for reading in these large 32 | genomic data sets to work with them within the R environment: 33 | 34 | - `readBigwig()`: Read in entire bigWig files, or read in specific 35 | genomic regions or strands of bigWig data. Please note that this function does 36 | not work on Windows. 37 | ```{r eval=TRUE, echo=TRUE, message=FALSE} 38 | bwFile <- system.file("extdata/test.bw", package="plotgardenerData") 39 | 40 | ## Read in entire file 41 | bwFileData <- readBigwig(file = bwFile) 42 | 43 | ## Read in specified region 44 | bwRegion <- readBigwig(file = bwFile, 45 | chrom = "chr2", 46 | chromstart = 1, 47 | chromend = 1500) 48 | 49 | ## Read in specified region on "+" strand 50 | bwRegionPlus <- readBigwig(file = bwFile, 51 | chrom = "chr2", 52 | chromstart = 1, 53 | chromend = 1500, 54 | strand = "+") 55 | ``` 56 | 57 | The resulting file will contain `seqnames`, `start`, `end`, `width`, 58 | `strand`, and `score` columns: 59 | ```{r eval=TRUE, echo=TRUE} 60 | head(bwRegion) 61 | ``` 62 | 63 | - `readHic()`: Read in genomic regions of .hic files with various 64 | data resolutions and normalizations. 65 | ```{r eval=TRUE, echo=TRUE, message=FALSE} 66 | hicFile <- system.file("extdata/test_chr22.hic", package="plotgardenerData") 67 | 68 | hicDataChrom <- readHic(file = hicFile, 69 | chrom = "22", assembly = "hg19", 70 | resolution = 250000, res_scale = "BP", norm = "NONE" 71 | ) 72 | 73 | hicDataChromRegion <- readHic(file = hicFile, 74 | chrom = "22", assembly = "hg19", 75 | chromstart = 20000000, chromend = 47500000, 76 | resolution = 100000, res_scale = "BP", norm = "KR" 77 | ) 78 | 79 | ``` 80 | 81 | These data will be output in 3-column dataframe in sparse upper triangular 82 | matrix format: 83 | 84 | ```{r eval=TRUE, echo=TRUE} 85 | head(hicDataChromRegion) 86 | ``` 87 | 88 | It is also possible to use `readHic` for interchromosomal Hi-C data: 89 | 90 | ```{r eval=FALSE, echo=TRUE, message=FALSE} 91 | twoChroms <- readHic(file = "/path/to/hic", 92 | chrom = "chr1", altchrom = "chr2", 93 | resolution = 250000, res_scale = "BP" 94 | ) 95 | ``` 96 | 97 | For other filetypes, we recommend reading in files with `data.table` 98 | or `rtracklayer`. 99 | ```{r eval=FALSE, echo=TRUE, message=FALSE} 100 | library(data.table) 101 | data <- data.table::fread("/path/to/file") 102 | 103 | library(rtracklayer) 104 | data <- rtracklayer::import(con = "/path/to/file", format = "fileFormat") 105 | ``` 106 | 107 | ### Session Info 108 | ```{r} 109 | sessionInfo() 110 | ``` 111 | --------------------------------------------------------------------------------