Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graph2ppt connection error when exporting Seurat FeaturePlot in R 4.2 Rmarkdown #53

Open
JesseRop opened this issue Jan 25, 2023 · 3 comments
Labels

Comments

@JesseRop
Copy link

JesseRop commented Jan 25, 2023

Dear developer,

Many thanks for the great tool! Very handy.
I'll be grateful for your assistance with the issue below.

I updated my rstudio to the latest version and R to 4.2 and now not able to export getting the error
'Warning in .Internal(environment(fun)) :
closing unused connection 3 (/var/folders/9h/zbzv_b3j3wz2r6mdgw9s2p04000lw8/T//RtmpkTyPis/filee19561b44ad/raster-rId000002.png)
Warning: cannot open file '/var/folders/9h/zbzv_b3j3wz2r6mdgw9s2p04000lw8/T//RtmpkTyPis/filee197fc756a/raster-rId000002.png': No such file or directoryError in open.connection(con, "rb") : cannot open the connection'

I have tried making a reproducible example with the dataset loaded into pbmc found here ( https://cf.10xgenomics.com/samples/cell/pbmc3k/pbmc3k_filtered_gene_bc_matrices.tar.gz )

The code can be run in rmarkdown as below


title: "export trial"
output: html_document
date: "2023-01-25"

knitr::opts_chunk$set(echo = TRUE)
library(dplyr)
library(Seurat)
library(export)

# Load the PBMC dataset
pbmc.data <- Read10X(data.dir = "/Users/jr35/Google Drive/My Drive/PHD_documents/trial_datasets/filtered_gene_bc_matrices/hg19/")
# Initialize the Seurat object with the raw (non-normalized data).
pbmc <- CreateSeuratObject(counts = pbmc.data, project = "pbmc3k", min.cells = 3, min.features = 200)

pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000)

pbmc <- ScaleData(pbmc)
pbmc <- RunPCA(pbmc, features = VariableFeatures(object = pbmc))

pbmc <- FindNeighbors(pbmc, dims = 1:10)
pbmc <- FindClusters(pbmc, resolution = 0.5)

pbmc <- RunUMAP(pbmc, dims = 1:10)

Plotting and exporting

FeaturePlot(pbmc, features = "CCR7", dims = c(1,2), pt.size = 1.5, label = T, label.size = 5, repel = T) 
graph2ppt(file = '/Users/jr35/Google Drive/My Drive/PHD_documents/test_exp.ppt')

The output of session info is below

sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.6.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/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] gdtools_0.3.0      export_0.3.0       patchwork_1.1.2    SeuratObject_4.1.3 Seurat_4.3.0       dplyr_1.0.10      

loaded via a namespace (and not attached):
  [1] utf8_1.2.2                  spatstat.explore_3.0-5      reticulate_1.27             tidyselect_1.2.0           
  [5] RSQLite_2.2.20              AnnotationDbi_1.60.0        htmlwidgets_1.6.1           grid_4.2.2                 
  [9] BiocParallel_1.32.5         Rtsne_0.16                  scatterpie_0.1.8            munsell_0.5.0              
 [13] codetools_0.2-18            ica_1.0-3                   future_1.30.0               miniUI_0.1.1.1             
 [17] withr_2.5.0                 spatstat.random_3.1-3       colorspace_2.1-0            GOSemSim_2.24.0            
 [21] progressr_0.13.0            Biobase_2.58.0              uuid_1.1-0                  knitr_1.42                 
 [25] rstudioapi_0.14             stats4_4.2.2                SingleCellExperiment_1.20.0 ROCR_1.0-11                
 [29] officer_0.5.1               tensor_1.5                  DOSE_3.25.0.002             listenv_0.9.0              
 [33] labeling_0.4.2              MatrixGenerics_1.10.0       GenomeInfoDbData_1.2.9      polyclip_1.10-4            
 [37] bit64_4.0.5                 farver_2.1.1                pheatmap_1.0.12             downloader_0.4             
 [41] treeio_1.22.0               parallelly_1.34.0           vctrs_0.5.2                 generics_0.1.3             
 [45] gson_0.0.9                  xfun_0.36                   qpdf_1.3.0                  R6_2.5.1                   
 [49] GenomeInfoDb_1.34.6         graphlayouts_0.8.4          bitops_1.0-7                spatstat.utils_3.0-1       
 [53] cachem_1.0.6                reshape_0.8.9               fgsea_1.24.0                gridGraphics_0.5-1         
 [57] DelayedArray_0.24.0         assertthat_0.2.1            promises_1.2.0.1            scales_1.2.1               
 [61] ggraph_2.1.0                enrichplot_1.19.1.991       gtable_0.3.1                globals_0.16.2             
 [65] goftest_1.2-3               tidygraph_1.2.2             rlang_1.0.6                 systemfonts_1.0.4          
 [69] splines_4.2.2               lazyeval_0.2.2              broom_1.0.3                 spatstat.geom_3.0-5        
 [73] rgl_1.0.1                   yaml_2.3.7                  reshape2_1.4.4              abind_1.4-5                
 [77] backports_1.4.1             httpuv_1.6.8                qvalue_2.30.0               clusterProfiler_4.7.0      
 [81] tools_4.2.2                 ggplotify_0.1.0             ggplot2_3.4.0               ellipsis_0.3.2             
 [85] RColorBrewer_1.1-3          BiocGenerics_0.44.0         stargazer_5.2.3             ggridges_0.5.4             
 [89] devEMF_4.2                  Rcpp_1.0.10                 plyr_1.8.8                  base64enc_0.1-3            
 [93] zlibbioc_1.44.0             purrr_1.0.1                 RCurl_1.98-1.9              openssl_2.0.5              
 [97] deldir_1.0-6                pbapply_1.7-0               viridis_0.6.2               cowplot_1.1.1              
[101] S4Vectors_0.36.1            zoo_1.8-11                  SummarizedExperiment_1.28.0 ggrepel_0.9.2              
[105] cluster_2.1.4               crul_1.3                    magrittr_2.0.3              data.table_1.14.6          
[109] scattermore_0.8             openxlsx_4.2.5.1            flextable_0.8.4             lmtest_0.9-40              
[113] RANN_2.6.1                  fitdistrplus_1.1-8          matrixStats_0.63.0          mime_0.12                  
[117] evaluate_0.20               xtable_1.8-4                HDO.db_0.99.1               readxl_1.4.1               
[121] IRanges_2.32.0              gridExtra_2.3               compiler_4.2.2              tibble_3.1.8               
[125] shadowtext_0.1.2            KernSmooth_2.23-20          crayon_1.5.2                htmltools_0.5.4            
[129] ggfun_0.0.9                 later_1.3.0                 tidyr_1.3.0                 aplot_0.1.9                
[133] DBI_1.1.3                   tweenr_2.0.2                MASS_7.3-58.2               Matrix_1.5-3               
[137] cli_3.6.0                   parallel_4.2.2              igraph_1.3.5                GenomicRanges_1.50.2       
[141] pkgconfig_2.0.3             sp_1.6-0                    plotly_4.10.1               spatstat.sparse_3.0-0      
[145] xml2_1.3.3                  ggtree_3.6.2                XVector_0.38.0              rvg_0.3.2                  
[149] yulab.utils_0.0.6           stringr_1.5.0               digest_0.6.31               sctransform_0.3.5          
[153] RcppAnnoy_0.0.20            httpcode_0.3.0              spatstat.data_3.0-0         Biostrings_2.66.0          
[157] rmarkdown_2.20              cellranger_1.1.0            leiden_0.4.3                fastmatch_1.1-3            
[161] tidytree_0.4.2              uwot_0.1.14                 curl_5.0.0                  shiny_1.7.4                
[165] lifecycle_1.0.3             nlme_3.1-161                jsonlite_1.8.4              askpass_1.1                
[169] viridisLite_0.4.1           fansi_1.0.4                 pillar_1.8.1                lattice_0.20-45            
[173] GGally_2.1.2                KEGGREST_1.38.0             fastmap_1.1.0               httr_1.4.4                 
[177] survival_3.5-0              GO.db_3.16.0                glue_1.6.2                  zip_2.2.2                  
[181] png_0.1-8                   bit_4.0.5                   ggforce_0.4.1               stringi_1.7.12             
[185] blob_1.2.3                  gfonts_0.2.0                pdftools_3.3.2              memoise_2.0.1              
[189] irlba_2.3.5.1               future.apply_1.10.0         ape_5.6-2                  

@JesseRop JesseRop changed the title graph2ppt error when exporting Seurat FeaturePlot "open.connection(con, "rb") : cannot open the connection" graph2ppt connection error when exporting Seurat FeaturePlot in R 4.2 Rmarkdown Jan 25, 2023
@tomwenseleers
Copy link
Owner

Hmm thanks for the bug report.
I can confirm that

library(Seurat)
data("pbmc_small")
pl = FeaturePlot(object = pbmc_small, features = 'PC_1')
graph2ppt(x=pl, file="./test.pptx", width=7, height=5)

also produces the error

Error in open.connection(con, "rb") : cannot open the connection
In addition: Warning message:
In open.connection(con, "rb") :
  cannot open file 'C:\Users\bherr\AppData\Local\Temp\RtmpCQqwZP\file1f6849f02517/raster-rId000002.png': No such file or directory

for me - haven't figured out yet where that is coming from...

graph2doc(x=pl, file="./test.docx", width=7, height=5)
does seem to work though, if that's of any help...

Will try to look a bit further where this is coming from...

@xjin15
Copy link

xjin15 commented Feb 4, 2023

I have the similar problem, and I have just updated all my R CRAN packages 3 hours ago. But I found that the ggplot object (like plots made through ggsurvplot() and ggplot2() function ) works fine, but the plotsI build through dotplot() function using the enrichr package for enrichment analysis got the error. I hope my experience will help to find the bug.

> ggsurvplot(fit, data = lung)
> export::graph2ppt(file = './output/test.pptx',append=T)
Exported graph as ./output/test.pptx
> ggplot(df, aes(gp, y)) +
+   geom_point()
> export::graph2ppt(file = './output/test.pptx',append=T)
Exported graph as ./output/test.pptx
> dotplot(Case_go)
> export::graph2ppt(file = './output/test.pptx',append=T)
Error in open.connection(con, "rb") : cannot open the connection
In addition: Warning message:
In open.connection(con, "rb") :
  cannot open file 'C:\Users\JinXing\AppData\Local\Temp\RtmpMTp2kQ\file2bb8508d12e7/raster-rId000002.png': No such file or directory

@Liqyao
Copy link

Liqyao commented Mar 27, 2023

Help!!! I also suffered the same problem.

Error in open.connection(con, "rb") : cannot open the connection
In addition: Warning message:
In open.connection(con, "rb") :
cannot open file 'C:\Users\yaolq\AppData\Local\Temp\Rtmpu4jUEU\filecf8430fca3/raster-rId000002.png': No such file or directory

Hope some can find the solutions, really thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants