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")

Change the type of Dandelion plot

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")

methy$color <- rep(list(c(3, 5)), length(methy))
methy$score2 <- (max(methy$score) - methy$score)/m
legends <- list(list(labels=c("s1", "s2"), fill=c(3, 5)))
dandelion.plot(methy, features, ranges=gr, type="pie", legend=legends)

Change the number of dandelions

## 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)

Add y-axis (yaxis)

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')

Session Info

sessionInfo()

R version 4.2.1 (2022-06-23) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.5 LTS

Matrix products: default BLAS: /home/biocbuild/bbs-3.16-bioc/R/lib/libRblas.so LAPACK: /home/biocbuild/bbs-3.16-bioc/R/lib/libRlapack.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB LC_COLLATE=C
[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

attached base packages: [1] grid stats4 stats graphics grDevices utils datasets [8] methods base

other attached packages: [1] httr_1.4.4
[2] VariantAnnotation_1.44.0
[3] Rsamtools_2.14.0
[4] Biostrings_2.66.0
[5] XVector_0.38.0
[6] SummarizedExperiment_1.28.0
[7] MatrixGenerics_1.10.0
[8] matrixStats_0.62.0
[9] org.Hs.eg.db_3.16.0
[10] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 [11] GenomicFeatures_1.50.0
[12] AnnotationDbi_1.60.0
[13] Biobase_2.58.0
[14] Gviz_1.42.0
[15] rtracklayer_1.58.0
[16] trackViewer_1.34.0
[17] Rcpp_1.0.9
[18] GenomicRanges_1.50.0
[19] GenomeInfoDb_1.34.0
[20] IRanges_2.32.0
[21] S4Vectors_0.36.0
[22] BiocGenerics_0.44.0

loaded via a namespace (and not attached): [1] colorspace_2.0-3 rjson_0.2.21 deldir_1.0-6
[4] ellipsis_0.3.2 biovizBase_1.46.0 htmlTable_2.4.1
[7] base64enc_0.1-3 dichromat_2.0-0.1 rstudioapi_0.14
[10] bit64_4.0.5 fansi_1.0.3 xml2_1.3.3
[13] codetools_0.2-18 splines_4.2.1 cachem_1.0.6
[16] knitr_1.40 Formula_1.2-4 jsonlite_1.8.3
[19] cluster_2.1.4 dbplyr_2.2.1 png_0.1-7
[22] grImport_0.9-5 graph_1.76.0 BiocManager_1.30.19
[25] compiler_4.2.1 backports_1.4.1 lazyeval_0.2.2
[28] assertthat_0.2.1 Matrix_1.5-1 fastmap_1.1.0
[31] cli_3.4.1 htmltools_0.5.3 prettyunits_1.1.1
[34] tools_4.2.1 gtable_0.3.1 glue_1.6.2
[37] GenomeInfoDbData_1.2.9 dplyr_1.0.10 rappdirs_0.3.3
[40] jquerylib_0.1.4 rhdf5filters_1.10.0 vctrs_0.5.0
[43] xfun_0.34 stringr_1.4.1 lifecycle_1.0.3
[46] ensembldb_2.22.0 restfulr_0.0.15 InteractionSet_1.26.0
[49] XML_3.99-0.12 zlibbioc_1.44.0 scales_1.2.1
[52] BiocStyle_2.26.0 BSgenome_1.66.0 ProtGenerics_1.30.0
[55] hms_1.1.2 parallel_4.2.1 rhdf5_2.42.0
[58] AnnotationFilter_1.22.0 RColorBrewer_1.1-3 yaml_2.3.6
[61] curl_4.3.3 memoise_2.0.1 gridExtra_2.3
[64] ggplot2_3.3.6 sass_0.4.2 biomaRt_2.54.0
[67] rpart_4.1.19 latticeExtra_0.6-30 stringi_1.7.8
[70] RSQLite_2.2.18 highr_0.9 BiocIO_1.8.0
[73] plotrix_3.8-2 checkmate_2.1.0 filelock_1.0.2
[76] BiocParallel_1.32.0 rlang_1.0.6 pkgconfig_2.0.3
[79] bitops_1.0-7 evaluate_0.17 lattice_0.20-45
[82] Rhdf5lib_1.20.0 GenomicAlignments_1.34.0 htmlwidgets_1.5.4
[85] bit_4.0.4 tidyselect_1.2.0 magrittr_2.0.3
[88] R6_2.5.1 generics_0.1.3 Hmisc_4.7-1
[91] DelayedArray_0.24.0 DBI_1.1.3 pillar_1.8.1
[94] foreign_0.8-83 survival_3.4-0 KEGGREST_1.38.0
[97] RCurl_1.98-1.9 nnet_7.3-18 tibble_3.1.8
[100] crayon_1.5.2 interp_1.1-3 utf8_1.2.2
[103] BiocFileCache_2.6.0 rmarkdown_2.17 jpeg_0.1-9
[106] progress_1.2.2 data.table_1.14.4 Rgraphviz_2.42.0
[109] blob_1.2.3 digest_0.6.30 munsell_0.5.0
[112] bslib_0.4.0