Open mchimenti opened 6 years ago
Hi @mchimenti,
This is a mistake in the documentation (stating the result is a ggplot object, which it was in the previous iteration of this method; instead it is indeed a gtable object). It is intended to be printed directly to a device like this:
## Example: print plot to a PDF file
pdf('figure.pdf')
plot_transcript_heatmap(so, head(so_tab_wt_geno, n = 10)$target_id,
'tpm', cluster_transcripts = FALSE)
dev.off()
## Or if you want it to print to the console directly
plot_transcript_heatmap(so, head(so_tab_wt_geno, n = 10)$target_id,
'tpm', cluster_transcripts = FALSE)
## if you have stored the result as 'p',
## then using gridExtra::grid.arrange should print the plot to a device
p <- plot_transcript_heatmap(so, head(so_tab_wt_geno, n = 10)$target_id,
'tpm', cluster_transcripts = FALSE)
pdf('figure.pdf')
gridExtra::grid.arrange(p)
dev.off()
If this does not work, let me know. If it does work, we can update the documentation to correct the mistake and make it clear how to use the method to users. If you would prefer a ggplot2
object, Is there a use case where a gtable
object would not work?
Hi @mchimenti,
A further question: if you downgrade your version of R to before 3.4.3, do you still experience the same issue? Another user found this to be the case. If so, then this is a deeper issue with grid
and gridExtra
with later versions of R.
Another error I believe is related to this change: When I try to print both plot_transcript_heatmap() and plot_sample_heatmap() to a pdf (like in your first example), only the first plot will show up in the pdf. I did not have this issue with the previous version of Sleuth.
Hello:
I'm attempting to plot a transcript heatmap with:
p<- plot_transcript_heatmap(so, head(so_tab_wt_geno, n = 10)$target_id, 'tpm', cluster_transcripts = FALSE)
However, nothing is plotted and a "large gtable" object called 'p' is created.
Calls to "print(p)" do not work, neither does 'gridExtra::grid.arrange(p$gtable)'.
I can see from the plotting code on github that the function modifies the gtable and then is supposed to return the plot: https://github.com/pachterlab/sleuth/blob/master/R/plots.R } invisible(dev.off())
modify the column labels with the x_axis_angle
subtracting from 360 degrees to get it to align well without modifying
anything else
p$gtable$grobs[[3]]$rot <- 360 - x_axis_angle
this sends the graphic back
gridExtra::grid.arrange(p$gtable) }
But in my case, I do not get a plot back. Any help is appreciated!
Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages: [1] parallel stats4 stats graphics grDevices utils datasets methods base
other attached packages: [1] bindrcpp_0.2.2 dplyr_0.7.6 org.Hs.eg.db_3.5.0 AnnotationDbi_1.40.0 IRanges_2.12.0
[6] S4Vectors_0.16.0 Biobase_2.38.0 BiocGenerics_0.24.0 biomaRt_2.34.2 cowplot_0.9.2
[11] ggplot2_3.0.0 sleuth_0.30.0
loaded via a namespace (and not attached): [1] progress_1.1.2 tidyselect_0.2.4 purrr_0.2.5 reshape2_1.4.3 rhdf5_2.22.0 colorspace_1.3-2
[7] yaml_2.1.18 blob_1.1.1 XML_3.98-1.11 rlang_0.2.1 pillar_1.2.2 glue_1.2.0
[13] withr_2.1.2 DBI_1.0.0 bit64_0.9-7 RColorBrewer_1.1-2 matrixStats_0.53.1 bindr_0.1.1
[19] plyr_1.8.4 stringr_1.3.0 zlibbioc_1.24.0 munsell_0.4.3 gtable_0.2.0 devtools_1.13.5
[25] memoise_1.1.0 curl_3.2 Rcpp_0.12.17 scales_0.5.0 bit_1.1-12 gridExtra_2.3
[31] digest_0.6.15 stringi_1.2.3 grid_3.4.3 tools_3.4.3 bitops_1.0-6 magrittr_1.5
[37] lazyeval_0.2.1 RCurl_1.95-4.10 tibble_1.4.2 RSQLite_2.1.0 tidyr_0.8.1 pkgconfig_2.0.1
[43] pheatmap_1.0.10 data.table_1.11.4 prettyunits_1.0.2 assertthat_0.2.0 httr_1.3.1 R6_2.2.2
[49] compiler_3.4.3