Nik-Zainal-Group / signature.tools.lib

R package containing useful functions for mutational signature analysis
Other
80 stars 26 forks source link

SignatureFit_withBootstrap_Analysis plot issue #14

Closed jorisvdhaar closed 2 years ago

jorisvdhaar commented 4 years ago

Hi,

I have used your signature.tools.lib package successfully in the past and was very happy with the results. However, now (a couple of months later), it throws an error (see below). In the mean time, I may have done some updates/upgrades, but I am not sure which.

The error seems to be about the plotting dimensions of grDevices::jpeg. I suspect that within the package the size of the plot is specified in pixels, whereas grDevices::jpeg interprets it as inches, leading to an enormous plot.

Do you have a workaround here? For example, could you provide an update in which you specify the units of the plot dimensions? Alternatively, a way to disable plotting would also be perfect.

Cheers, Joris

CODE: subs_fit_res <- SignatureFit_withBootstrap_Analysis(outdir = "/tmp/signatures_Nik_Zainal/", cat = SNV_catalogues, signature_data_matrix = COSMIC30_subs_signatures, type_of_mutations = "subs",nboot = 100,nparallel = 8)

OUTPUT: Bootstrap Signature Fits loaded from file Error in grDevices::jpeg(..., res = dpi, units = "in") : unable to start device 'jpeg' In addition: Warning message: In grDevices::jpeg(..., res = dpi, units = "in") : cairo error 'invalid value (typically too big) for the size of the input (surface, pattern, etc.)'

sessionInfo()

R version 3.6.1 (2019-07-05) Platform: x86_64-conda_cos6-linux-gnu (64-bit) Running under: Ubuntu 16.04.6 LTS

Matrix products: default BLAS/LAPACK: /home/j.vd.haar/anaconda3/lib/R/lib/libRblas.so

locale: [1] en_US.UTF-8

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

other attached packages: [1] signature.tools.lib_0.0.0.9000

loaded via a namespace (and not attached): [1] Rcpp_1.0.1
[2] compiler_3.6.1
[3] pillar_1.3.1
[4] GenomeInfoDb_1.22.0
[5] XVector_0.26.0
[6] bitops_1.0-6
[7] iterators_1.0.12
[8] tools_3.6.1
[9] zlibbioc_1.32.0
[10] lifecycle_0.2.0
[11] tibble_2.1.1
[12] gtable_0.3.0
[13] BSgenome_1.54.0
[14] lattice_0.20-38
[15] pkgconfig_2.0.2
[16] rlang_0.4.5
[17] Matrix_1.2-17
[18] foreach_1.4.8
[19] DelayedArray_0.12.1
[20] parallel_3.6.1
[21] GenomeInfoDbData_1.2.2
[22] dplyr_0.8.5
[23] rtracklayer_1.46.0
[24] Biostrings_2.52.0
[25] S4Vectors_0.24.1
[26] IRanges_2.20.1
[27] tidyselect_0.2.5
[28] stats4_3.6.1
[29] grid_3.6.1
[30] glue_1.3.1
[31] Biobase_2.46.0
[32] R6_2.4.0
[33] XML_3.98-1.20
[34] BiocParallel_1.20.0
[35] purrr_0.3.2
[36] magrittr_1.5
[37] ggplot2_3.3.0
[38] Rsamtools_2.0.3
[39] scales_1.1.0
[40] codetools_0.2-16
[41] matrixStats_0.55.0
[42] GenomicAlignments_1.22.1
[43] BiocGenerics_0.32.0
[44] GenomicRanges_1.38.0
[45] assertthat_0.2.1
[46] SummarizedExperiment_1.16.0
[47] BSgenome.Hsapiens.1000genomes.hs37d5_0.99.1 [48] colorspace_1.4-1
[49] RCurl_1.95-4.12
[50] doParallel_1.0.15
[51] munsell_0.5.0
[52] crayon_1.3.4

andreadega commented 4 years ago

Hi there,

Not sure what the error is about, probably you are right that the plot dimensions are not ok, and in fact we should add more plotting options to this function, or at least have a try catch that allows the function to continue even when a plot doesn't work for whatever reason.

In the meanwhile, you should be able to run the signature fit with bootstrap without plotting, all the data will be returned using the function SignatureFit_withBootstrap. This function is called internally by SignatureFit_withBootstrap_Analysis, which is just a wrapper that produces the plots, as explained in the README page.

jorisvdhaar commented 4 years ago

Ah, I missed that option. It is working perfect now, thank you! Cheers, Joris

andreadega commented 4 years ago

Thanks no problem,

I will reopen this issue just for us as a reminder that we need to fix this error message.

annahoge commented 3 years ago

I get this error, too, with both plotRearrSignatures() used for plotting catalogues, and the plot of all sample rearrangement signature exposures made by SignatureFit_withBootstrap_Analysis(). I don't get the error when running with 192 or fewer samples, but do when running with 208+. plotRearrSignatures() sometimes works when the output file is pdf instead of jpg.

andreadega commented 3 years ago

Thanks for the feedback. I believe this is a problem of the size of the plot (height/width), which scales with the number of samples, but breaks the plotting when the samples are too many. I think a solution will be to divide the samples into multiple plots/pages, something like 100 samples for each page.

Indeed the pdf format seems less affected by this issue.

andreadega commented 3 years ago

While I haven't yet fixed the plots in the SignatureFit_withBootstrap_Analysis() function, I have updated the plotSubsSignatures and plotRearrSignatures functions. It is now possible to specify how many samples max per page (default is 100) and also how many columns to use in the plot.

andreadega commented 2 years ago

The function SignatureFit_withBootstrap_Analysis is now a legacy function, and the new Fit and plotFitResults functions provide improved plotting that should not have the issues mentined above.