talgalili / heatmaply

Interactive Heat Maps for R Using plotly
377 stars 73 forks source link

Warning: unable to load shared object R_X11.so #196

Closed gtollefson closed 5 years ago

gtollefson commented 5 years ago

I receive the following warning when running the heatmaply() plotting function using heatmaply version 0.15.3 on R version 3.4.3 (2017-11-30) on MacOS High Sierra. The code works and the plot is produced without error. However, I am implementing heatmaply in a command line tool we're developing and as a result the printed output is messy.

Does this warning need to be displayed? If so, is there a way for me to include code to suppress this warning from being printed?

Warning message: In doTryCatch(return(expr), name, parentenv, handler) : unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so': dlopen(/Library/Frameworks/R.framework/Resources/modules//R_X11.so, 6): Library not loaded: /opt/X11/lib/libSM.6.dylib Referenced from: /Library/Frameworks/R.framework/Resources/modules//R_X11.so Reason: image not found

I believe the warning is triggered because heatmaply looks for XQuartz to be installed but it is not installed on current Mac OSX. Manually installing XQuartz has been reported to solve the issue here [https://github.com/RevolutionAnalytics/RRO/issues/312] . However as heatmaply will be installed as a dependency of our command line tool, ideally heatmaply would install onto Mac OS without additional manual installation.

alanocallaghan commented 5 years ago

You can use suppressWarnings to not print warnings, though unfortunately it catches all warnings. I don't have access to a Mac so this might be hard to test but I can have a look later. This isn't something I'm aware of so would prefer to prevent it outright

gtollefson commented 5 years ago

Thanks for your reply @Alanocallaghan. I will plan to use suppressWarnings if necessary, but preventing it outright would be great! Please let me know how I can help test.

talgalili commented 5 years ago

I just installed a fresh copy of heatmaply from CRAN on my mac at work, and couldn't reproduce the issue. For reference:

> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.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] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] heatmaply_0.15.2  viridis_0.4.1     viridisLite_0.2.0 plotly_4.7.1      ggplot2_2.2.1    

loaded via a namespace (and not attached):
 [1] httr_1.3.1          tidyr_0.8.0         jsonlite_1.5        foreach_1.4.4       gtools_3.5.0        shiny_1.0.5         assertthat_0.2.0   
 [8] stats4_3.4.3        yaml_2.1.16         robustbase_0.92-8   pillar_1.1.0        lattice_0.20-35     glue_1.2.0          digest_0.6.13      
[15] RColorBrewer_1.1-2  colorspace_1.3-2    htmltools_0.3.6     httpuv_1.3.5        plyr_1.8.4          pkgconfig_2.0.1     purrr_0.2.4        
[22] xtable_1.8-2        mvtnorm_1.0-6       scales_0.5.0        webshot_0.5.1       gdata_2.18.0        whisker_0.3-2       tibble_1.4.2       
[29] nnet_7.3-12         lazyeval_0.2.1      magrittr_1.5        mime_0.5            mclust_5.4          MASS_7.3-47         gplots_3.0.1       
[36] class_7.3-14        Cairo_1.5-9         tools_3.4.3         registry_0.5        data.table_1.10.4-3 trimcluster_0.1-2   stringr_1.3.0      
[43] kernlab_0.9-25      munsell_0.4.3       cluster_2.0.6       fpc_2.1-10          bindrcpp_0.2        compiler_3.4.3      caTools_1.17.1     
[50] rlang_0.2.0         grid_3.4.3          iterators_1.0.9     htmlwidgets_1.0     crosstalk_1.0.0     bitops_1.0-6        labeling_0.3       
[57] gtable_0.2.0        codetools_0.2-15    flexmix_2.3-14      TSP_1.1-6           reshape2_1.4.3      R6_2.2.2            seriation_1.2-3    
[64] gridExtra_2.3       prabclus_2.2-6      dplyr_0.7.4         bindr_0.1           KernSmooth_2.23-15  dendextend_1.6.0    modeltools_0.2-21  
[71] stringi_1.1.7       Rcpp_0.12.16        gclus_1.3.1         DEoptimR_1.0-8      diptest_0.75-7     
talgalili commented 5 years ago

mmm, update: I see I already have XQuartz installed on my system. So is it required to have it installed for heatmaply to work properly on Mac, or does it run properly without it? @gtollefson - can you see which command is triggering the warning?

alanocallaghan commented 5 years ago

can you see which command is triggering the warning?

You can test this easily by setting options(warn=2) (this converts warnings to errors - reset using options(warn=0)).

Also, are you using Microsoft R Open (given the related issue was specific to RRO)?

gtollefson commented 5 years ago

Thanks for looking into this @Alanocallaghan and @talgalili. I am not using MRO - I'm using the following version:

R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

@talgalili the function runs fine without XQuartz and produces the plot I would expect. Also, it only produces the warning on the first time running the function in a session.

Interestingly, I do not get the error/warning message when I set options(warn=2) but does trigger the warning I run without setting this. Since setting warn=2 isn't working, I ran line by line to find the command and it looks like the error message comes from heatmaply(x).

I've pasted the output from loading heatmaply (which produces two warnings) and the warning when I run the heatmaply() function.

library(heatmaply)
Loading required package: plotly
Loading required package: ggplot2

Attaching package: ‘plotly’

The following object is masked from ‘package:ggplot2’:

    last_plot

The following object is masked from ‘package:stats’:

    filter

The following object is masked from ‘package:graphics’:

    layout

Loading required package: viridis
Loading required package: viridisLite

======================
Welcome to heatmaply version 0.15.3

Type citation('heatmaply') for how to cite the package.
Type ?heatmaply for the main documentation.

The github page is: https://github.com/talgalili/heatmaply/
Please submit your suggestions and bug-reports at: https://github.com/talgalili/heatmaply/issues
Or contact: <tal.galili@gmail.com>
======================

Warning messages:
1: package ‘ggplot2’ was built under R version 3.4.4 
2: package ‘viridis’ was built under R version 3.4.4 

heatmaply(gt_num_array_1)
Warning message:
In doTryCatch(return(expr), name, parentenv, handler) :
  unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so':
  dlopen(/Library/Frameworks/R.framework/Resources/modules//R_X11.so, 6): Library not loaded: /opt/X11/lib/libSM.6.dylib
  Referenced from: /Library/Frameworks/R.framework/Resources/modules//R_X11.so
  Reason: image not found
alanocallaghan commented 5 years ago

Can you post what this returns in your R shell? .Platform$GUI

alanocallaghan commented 5 years ago

Also, could you try adding the argument plot_method="plotly" to your call to heatmaply, and then check if the warning still occurs?

gtollefson commented 5 years ago

Can you post what this returns in your R shell? .Platform$GUI Returns:

[1] "X11"

gtollefson commented 5 years ago

Also, could you try adding the argument plot_method="plotly" to your call to heatmaply, and then check if the warning still occurs?

The warning does not occur when I add this argument to the heatmaply() function.

alanocallaghan commented 5 years ago

Okay I think I know the issue! Great.

alanocallaghan commented 5 years ago

If you run this line, does it reproduce the warning?

grDevices::png()
gtollefson commented 5 years ago

If you run this line, does it reproduce the warning?

grDevices::png()

When I run this line alone in the R shell it does not reproduce the warning.

gtollefson commented 5 years ago

When I run this line alone in the R shell it does not reproduce the warning.

On Wed, Dec 19, 2018 at 11:56 AM Alanocallaghan notifications@github.com wrote:

If you run this line, does it reproduce the warning?

grDevices::png()

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/talgalili/heatmaply/issues/196#issuecomment-448667529, or mute the thread https://github.com/notifications/unsubscribe-auth/AfcN7NmNaZUU9bXP4wxzUpS5ev2WHuocks5u6m_TgaJpZM4ZYyqY .

alanocallaghan commented 5 years ago

Hmm, curious. How about grDevices::jpeg()?

alanocallaghan commented 5 years ago

Or grDevices::dev.list()

gtollefson commented 5 years ago

@Alanocallaghan grDevices::jpeg() produces nothing but grDevices::dev.list()returns NULL.

alanocallaghan commented 5 years ago

No warnings? Hmm, I really thought the problem might be with ggplotly. How about the following:

library(plotly)
p <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species, shape=Species)) + 
    geom_point(size=6, alpha=0.6)
ggplotly(p)
gtollefson commented 5 years ago

@Alanocallaghan this returns the following output (including several warnings) and plots correctly.

> library(plotly)
Loading required package: ggplot2
p <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species, shape=Species)) + 
    geom_point(size=6, alpha=0.6)
ggplotly(p)

Attaching package: ‘plotly’

The following object is masked from ‘package:ggplot2’:

    last_plot

The following object is masked from ‘package:stats’:

    filter

The following object is masked from ‘package:graphics’:

    layout

Warning message:
package ‘ggplot2’ was built under R version 3.4.4 
> p <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species, shape=Species)) + 
+     geom_point(size=6, alpha=0.6)
> ggplotly(p)
alanocallaghan commented 5 years ago

I only see one warning there, and not the relevant one! Quite confusing.

btw, the "package ‘X’ was built under R version 3.4.4" warnings can be fixed by re-installing package X.

talgalili commented 5 years ago

This bug seems not updated (not reproducible?!). Can we close this issue?

alanocallaghan commented 5 years ago

Couldn't get to the bottom of this, and it didn't affect output, so yep