-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Thanks a lot for this wonderful tool, but I think there's an issue with the plotMultiSignal() function, especially with the range argument. I want to plot multiple signals but in two separate sections of the graph, for example -
In this example I wish to set the scale for both the plots from the human genome and the chimp genome to c(0,250), although it seems to work for the upper plot the second plot still gets scaled based on the optimising code. Upon inspection of the source code for the function you can find here -
plotgardener/R/plotMultiSignal.R
Line 331 in 4471ff0
| range <- calcSignalRange(data = signal, |
The range is set by the function irrespective of whether the range parameter was passed explicitly during call. So the range is always determined by the code and not by the user. I'm also not sure if the range param is processed and stored in the multisigInternal object that is created in this step -
plotgardener/R/plotMultiSignal.R
Line 276 in 4471ff0
| multisigInternal <- parseParams( |
If indeed the argument is saved in the multisigInternal object, a simple fix could be something like
if (is.null(multisigInternal$range)) {
range <- calcSignalRange(data = signal,
chrom = multisigInternal$chrom,
chromstart = multisigInternal$chromstart,
chromend = multisigInternal$chromend,
assembly = multisigInternal$assembly,
negData = multisigInternal$negData)
} else {
range <- multisigInternal$range
}
where we can simply add a check to see if range=NULL which is the default value or it contains a user input and process the rest of the code as usual. Please let me know if this can fixed, or if I'm completely misreading the usage and doing something wrong.
Here's the section of my script where I call the plotMultiSignal() function -
## Plot multiple signals
multisignal <- plotMultiSignal(sp1_signalList, chrom = sp1$chr1[i],
chromstart = min(sp1[i,c("x1","x2","y1","y2")]) - pad_flank,
chromend = max(sp1[i,c("x1","x2","y1","y2")]) + pad_flank,
linecolor = c(rep(c("black"),2)),
range = c(0,250), scale = TRUE,
label = c("Sample A", "Sample B"),
assembly = sp1_id, x = 2.5, y = 3.5,
width = 4.62, height = 1.5, default.units = "inches",
gapdistance = 0.05, just = c("center", "top"))
## Label Plot
plotText(paste0(sp1_id," Genome"), fontsize = 12, x = 2.5, y = 5.225, just = "center", fontface = "italic")
plotSegments(0, 5.4, 5, 5.4, lwd = 2, lty = 2)
# Plots for loops in second species
## Label Plot
plotText(paste0(sp2_id," Genome"), fontsize = 12, x = 2.5, y = 5.575, just = "center", fontface = "italic")
## Plot multiple signals
multisignal <- plotMultiSignal(sp2_signalList, chrom = sp2$chr1[i],
chromstart = min(sp2[i,c("x1","x2","y1","y2")]) - pad_flank,
chromend = max(sp2[i,c("x1","x2","y1","y2")]) + pad_flank,
linecolor = c(rep(c("red"),2)),
range = c(0,250), scale = TRUE,
label = c("Sample C", "Sample D"),
assembly = sp2_id, x = 2.5, y = 5.65,
width = 4.62, height = 1.5, default.units = "inches",
gapdistance = 0.05, just = c("center", "top"))
Here's my session info -
> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 20.04.6 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=pl_PL.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=pl_PL.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=pl_PL.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=pl_PL.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Warsaw
tzcode source: system (glibc)
attached base packages:
[1] grid parallel tools stats4 stats graphics grDevices utils datasets methods base
other attached packages:
[1] BSgenome_1.72.0 BiocIO_1.14.0 Biostrings_2.72.1 XVector_0.44.0
[5] plyranges_1.24.0 org.Hs.eg.db_3.19.1 TxDb.Hsapiens.UCSC.hg38.knownGene_3.18.0 EBImage_4.46.0
[9] fftwtools_0.9-11 LSD_4.1-0 colorspace_2.1-0 GenomicFeatures_1.56.0
[13] Gviz_1.48.0 st_1.2.7 sda_1.3.8 fdrtool_1.2.17
[17] corpcor_1.6.10 entropy_1.3.1 smoothmest_0.1-3 MASS_7.3-61
[21] genefilter_1.86.0 geneplotter_1.82.0 annotate_1.82.0 XML_3.99-0.17
[25] AnnotationDbi_1.66.0 lattice_0.22-6 Biobase_2.64.0 locfit_1.5-9.10
[29] plyr_1.8.9 ggrepel_0.9.5 Matrix_1.7-0 gtools_3.9.5
[33] microbenchmark_1.4.10 stringi_1.8.4 doParallel_1.0.17 iterators_1.0.14
[37] foreach_1.5.2 RColorBrewer_1.1-3 plotgardener_1.10.2 rtracklayer_1.64.0
[41] data.table_1.15.4 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1
[45] dplyr_1.1.4 purrr_1.0.2 readr_2.1.5 tidyr_1.3.1
[49] tibble_3.2.1 ggplot2_3.5.1 tidyverse_2.0.0 GenomicRanges_1.56.1
[53] GenomeInfoDb_1.40.1 IRanges_2.38.1 S4Vectors_0.42.1 BiocGenerics_0.50.0
loaded via a namespace (and not attached):
[1] splines_4.4.1 bitops_1.0-7 ggplotify_0.1.2 filelock_1.0.3 rpart_4.1.23 lifecycle_1.0.4
[7] httr2_1.0.1 ensembldb_2.28.0 backports_1.5.0 magrittr_2.0.3 Hmisc_5.1-3 rmarkdown_2.27
[13] yaml_2.3.9 DBI_1.2.3 abind_1.4-5 zlibbioc_1.50.0 AnnotationFilter_1.28.0 biovizBase_1.52.0
[19] RCurl_1.98-1.14 yulab.utils_0.1.4 nnet_7.3-19 VariantAnnotation_1.50.0 rappdirs_0.3.3 GenomeInfoDbData_1.2.12
[25] codetools_0.2-20 DelayedArray_0.30.1 xml2_1.3.6 tidyselect_1.2.1 UCSC.utils_1.0.0 matrixStats_1.3.0
[31] BiocFileCache_2.12.0 base64enc_0.1-3 GenomicAlignments_1.40.0 jsonlite_1.8.8 Formula_1.2-5 survival_3.7-0
[37] progress_1.2.3 strawr_0.0.91 Rcpp_1.0.12 glue_1.7.0 gridExtra_2.3 SparseArray_1.4.8
[43] xfun_0.45 MatrixGenerics_1.16.0 withr_3.0.0 fastmap_1.2.0 latticeExtra_0.6-30 fansi_1.0.6
[49] digest_0.6.36 timechange_0.3.0 R6_2.5.1 gridGraphics_0.5-1 jpeg_0.1-10 dichromat_2.0-0.1
[55] biomaRt_2.60.1 RSQLite_2.3.7 utf8_1.2.4 generics_0.1.3 prettyunits_1.2.0 httr_1.4.7
[61] htmlwidgets_1.6.4 S4Arrays_1.4.1 pkgconfig_2.0.3 gtable_0.3.5 blob_1.2.4 htmltools_0.5.8.1
[67] ProtGenerics_1.36.0 scales_1.3.0 png_0.1-8 knitr_1.48 rstudioapi_0.16.0 tzdb_0.4.0
[73] rjson_0.2.21 checkmate_2.3.1 curl_5.2.1 cachem_1.1.0 foreign_0.8-87 restfulr_0.0.15
[79] pillar_1.9.0 vctrs_0.6.5 dbplyr_2.5.0 xtable_1.8-4 cluster_2.1.6 htmlTable_2.4.2
[85] evaluate_0.24.0 cli_3.6.3 compiler_4.4.1 Rsamtools_2.20.0 rlang_1.1.4 crayon_1.5.3
[91] interp_1.1-6 fs_1.6.4 deldir_2.0-4 BiocParallel_1.38.0 munsell_0.5.1 tiff_0.1-12
[97] lazyeval_0.2.2 pacman_0.5.1 hms_1.1.3 bit64_4.0.5 KEGGREST_1.44.1 SummarizedExperiment_1.34.0
[103] memoise_2.0.1 bit_4.0.5