dandelionPlot.Rmd
Abstract
Visualize high dense methylation or mutation data along with annotation as track layers via Dandelion Plot.
Sometimes, there are as many as hundreds of SNPs invoved in one gene. Dandelion plot can be used to depict such dense SNPs. Please note that the height of the dandelion indicates the desity of the SNPs.
library(trackViewer)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
library(org.Hs.eg.db)
library(rtracklayer)
methy <- import(system.file("extdata", "methy.bed", package="trackViewer"), "BED")
gr <- GRanges("chr22", IRanges(50968014, 50970514, names="TYMP"))
trs <- geneModelFromTxdb(TxDb.Hsapiens.UCSC.hg19.knownGene,
org.Hs.eg.db,
gr=gr)
features <- c(range(trs[[1]]$dat), range(trs[[5]]$dat))
names(features) <- c(trs[[1]]$name, trs[[5]]$name)
features$fill <- c("lightblue", "mistyrose")
features$height <- c(.02, .04)
dandelion.plot(methy, features, ranges=gr, type="pin")
There are one more type for dandelion plot, i.e., type “fan”. The area of the fan indicates the percentage of methylation or rate of mutation.
methy$color <- 3
methy$border <- "gray"
## Score info is required and the score must be a number in [0, 1]
m <- max(methy$score)
methy$score <- methy$score/m
dandelion.plot(methy, features, ranges=gr, type="fan")
## Less dandelions
dandelion.plot(methy, features, ranges=gr, type="circle", maxgaps=1/10)
## More dandelions
dandelion.plot(methy, features, ranges=gr, type="circle", maxgaps=1/100)
Users can also specify the maximum distance between neighboring dandelions by setting the maxgaps as a GRanges object.
maxgaps <- tile(gr, n = 10)[[1]]
dandelion.plot(methy, features, ranges=gr, type="circle", maxgaps=maxgaps)
Set yaxis to TRUE to add y-axis, and set
heightMethod
=mean
to use the mean score as the
height.
dandelion.plot(methy, features, ranges=gr, type="pie",
maxgaps=1/100, yaxis = TRUE, heightMethod = mean,
ylab='mean of methy scores')
yaxis = c(0, 0.5, 1)
dandelion.plot(methy, features, ranges=gr, type="pie",
maxgaps=1/100, yaxis = yaxis, heightMethod = mean,
ylab='mean of methy scores')
R version 4.4.1 (2024-06-14) Platform: x86_64-pc-linux-gnu Running under: Ubuntu 22.04.4 LTS
Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0
locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: Etc/UTC tzcode source: system (glibc)
attached base packages: [1] grid stats4 stats graphics grDevices utils datasets [8] methods base
other attached packages: [1] httr_1.4.7
[2] VariantAnnotation_1.51.0
[3] Rsamtools_2.21.1
[4] Biostrings_2.73.1
[5] XVector_0.45.0
[6] SummarizedExperiment_1.35.1
[7] MatrixGenerics_1.17.0
[8] matrixStats_1.4.0
[9] org.Hs.eg.db_3.19.1
[10] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 [11]
GenomicFeatures_1.57.0
[12] AnnotationDbi_1.67.0
[13] Biobase_2.65.1
[14] rtracklayer_1.65.0
[15] trackViewer_1.41.6
[16] GenomicRanges_1.57.1
[17] GenomeInfoDb_1.41.1
[18] IRanges_2.39.2
[19] S4Vectors_0.43.2
[20] BiocGenerics_0.51.1
loaded via a namespace (and not attached): [1] strawr_0.0.92
RColorBrewer_1.1-3 rstudioapi_0.16.0
[4] jsonlite_1.8.8 magrittr_2.0.3 rmarkdown_2.28
[7] fs_1.6.4 BiocIO_1.15.2 zlibbioc_1.51.1
[10] ragg_1.3.2 vctrs_0.6.5 memoise_2.0.1
[13] RCurl_1.98-1.16 base64enc_0.1-3 htmltools_0.5.8.1
[16] S4Arrays_1.5.7 progress_1.2.3 curl_5.2.2
[19] Rhdf5lib_1.27.0 rhdf5_2.49.0 SparseArray_1.5.31
[22] Formula_1.2-5 sass_0.4.9 bslib_0.8.0
[25] htmlwidgets_1.6.4 desc_1.4.3 Gviz_1.49.0
[28] httr2_1.0.3 cachem_1.1.0 GenomicAlignments_1.41.0 [31]
lifecycle_1.0.4 pkgconfig_2.0.3 Matrix_1.7-0
[34] R6_2.5.1 fastmap_1.2.0 GenomeInfoDbData_1.2.12 [37] digest_0.6.37
colorspace_2.1-1 textshaping_0.4.0
[40] Hmisc_5.1-3 RSQLite_2.3.7 filelock_1.0.3
[43] fansi_1.0.6 abind_1.4-5 compiler_4.4.1
[46] bit64_4.0.5 htmlTable_2.4.3 backports_1.5.0
[49] BiocParallel_1.39.0 DBI_1.2.3 highr_0.11
[52] biomaRt_2.61.3 rappdirs_0.3.3 DelayedArray_0.31.11
[55] rjson_0.2.22 tools_4.4.1 foreign_0.8-87
[58] nnet_7.3-19 glue_1.7.0 InteractionSet_1.33.0
[61] restfulr_0.0.15 rhdf5filters_1.17.0 checkmate_2.3.2
[64] cluster_2.1.6 generics_0.1.3 gtable_0.3.5
[67] BSgenome_1.73.0 ensembldb_2.29.1 data.table_1.16.0
[70] hms_1.1.3 xml2_1.3.6 utf8_1.2.4
[73] pillar_1.9.0 stringr_1.5.1 dplyr_1.1.4
[76] BiocFileCache_2.13.0 lattice_0.22-6 deldir_2.0-4
[79] bit_4.0.5 biovizBase_1.53.0 tidyselect_1.2.1
[82] knitr_1.48 gridExtra_2.3 ProtGenerics_1.37.1
[85] xfun_0.47 stringi_1.8.4 UCSC.utils_1.1.0
[88] lazyeval_0.2.2 yaml_2.3.10 evaluate_0.24.0
[91] codetools_0.2-20 interp_1.1-6 tibble_3.2.1
[94] BiocManager_1.30.25 cli_3.6.3 rpart_4.1.23
[97] systemfonts_1.1.0 munsell_0.5.1 jquerylib_0.1.4
[100] Rcpp_1.0.13 dichromat_2.0-0.1 grImport_0.9-7
[103] dbplyr_2.5.0 png_0.1-8 XML_3.99-0.17
[106] parallel_4.4.1 pkgdown_2.1.0 ggplot2_3.5.1
[109] blob_1.2.4 prettyunits_1.2.0 latticeExtra_0.6-30
[112] jpeg_0.1-10 AnnotationFilter_1.29.0 bitops_1.0-8
[115] txdbmaker_1.1.1 scales_1.3.0 crayon_1.5.3
[118] BiocStyle_2.33.1 rlang_1.1.4 KEGGREST_1.45.1