Stacked density plots not working in for loop (graphical device crashing?)
Entering edit mode
Last seen 4.2 years ago

Hi all,

Im trying to make a for loop that makes stacked Density plots per patient.
I made 2 variables Minimum and Maximum in which i determine the minimum and maximum row number of a sample. Which gives me a range.

Doesnt't work (gives me empty plots)
for(i in 1:length(gs)){
png(paste0(Unique_subjects[2],"CD4 CD45 tailgate, ref side left .png") )
plotGate(x = gs[c(Minimum[i]:Maximum[i])], "/stable/nonDebris/Lymphocytes/Singlets/Live/CD3NonDump/CD3+/CD4+/BV786.A+" , xbin = 0 , type = "densityplot", stack = TRUE)

Works partialy (i need an extra often)
png(paste0(Unique_subjects[2],"CD4 CD45 tailgate, ref side left .png") )
plotGate(x = gs[c(Minimum[1]:Maximum[1])], "/stable/nonDebris/Lymphocytes/Singlets/Live/CD3NonDump/CD3+/CD4+/BV786.A+" , xbin = 0 , type = "densityplot", stack = TRUE)

Works normal:
for(i in 1:length(gs)){
  png(filename = paste0("Output/Plots/",gs[[i]]@name,"_.png"),width =40,height = 40,res = 120,units = "cm")
  plotGate(gs[[i]],"/stable/nonDebris/Lymphocytes/Singlets/Live/CD3NonDump/CD3+/CD4+/BV786.A+" , default.y="SSC.A",margin=F,smooth=F,merge=T,digits=4,bool=F, type = "densityplot" , showHidden = FALSE,xbins=0, sample.ratio=1,sample.minsize=10000)

The fact that only the stacked density plots gives me this problem, makes me think it has to do specifically with this functionality.
Because sometimes i need to shut the graphical device another time and otherwise i get empty plots. Makes me think the Graphical Devices crashes.
Below i have shown which software versions and packages i am using.

Would anyone have any idea why i am getting empty plots while making stacked density plots?


I am using
Rstudio 1.0.153

loaded via a namespace (and not attached):
  [1] readxl_1.0.0        changepoint_2.2.2   spam_2.1-4          lazyeval_0.2.1      sp_1.2-7            RPMG_2.2-1         
  [7] digest_0.6.12       htmltools_0.3.6     rsconnect_0.8.8     magrittr_1.5        memoise_1.1.0       Rwave_2.4-5        
 [13] ks_1.10.7           matrixStats_0.52.2  R.utils_2.6.0       MCMCpack_1.4-2      colorspace_1.3-2    blob_1.1.1         
 [19] rrcov_1.4-3         haven_1.1.1         jsonlite_1.5        hexbin_1.27.1       graph_1.54.0        bindr_0.1.1        
 [25] zoo_1.8-0           glue_1.2.0          gtable_0.2.0        zlibbioc_1.22.0     MatrixModels_0.4-1  car_3.0-0          
 [31] IDPmisc_1.1.17      Rgraphviz_2.20.0    BiocGenerics_0.22.1 DEoptimR_1.0-8      maps_3.3.0          abind_1.4-5        
 [37] SparseM_1.77        scales_0.5.0        mvtnorm_1.0-6       multicool_0.1-10    DBI_0.8             Rcpp_0.12.16       
 [43] xtable_1.8-2        clue_0.3-54         foreign_0.8-69      bit_1.1-12          RSEIS_3.7-4         dotCall64_0.9-04   
 [49] stats4_3.4.4        htmlwidgets_1.0     FNN_1.1             gplots_3.0.1        RColorBrewer_1.1-2  pkgconfig_2.0.1    
 [55] XML_3.98-1.10       R.methodsS3_1.7.1   GEOmap_2.4-0        tidyselect_0.2.4    rlang_0.2.0         munsell_0.4.3      
 [61] cellranger_1.1.0    tools_3.4.4         splancs_2.01-40     stringr_1.2.0       mcmc_0.9-5          knitr_1.20         
 [67] bit64_0.9-7         robustbase_0.92-8   rgl_0.98.1          caTools_1.17.1      purrr_0.2.4         packrat_0.4.9-1    
 [73] RBGL_1.52.0         mime_0.5            quantreg_5.35       R.oo_1.21.0         compiler_3.4.4      curl_3.2           
 [79] tibble_1.4.2        pcaPP_1.9-73        stringi_1.1.7       forcats_0.3.0       fields_9.6          pillar_1.2.1       
 [85] data.table_1.10.4-3 bitops_1.0-6        corpcor_1.6.9       httpuv_1.3.6.2      R6_2.2.2            latticeExtra_0.6-28
 [91] KernSmooth_2.23-15  gridExtra_2.3       RFOC_3.4-3          rio_0.5.10          codetools_0.2-15    MASS_7.3-49        
 [97] gtools_3.5.0        assertthat_0.2.0    chron_2.3-52        MBA_0.0-9           mnormt_1.5-5        grid_3.4.4         
[103] coda_0.19-1         misc3d_0.8-4        carData_3.0-1       Biobase_2.36.2     

densityplot stacked for loop • 714 views
Entering edit mode
Last seen 4.2 years ago

I have not recieved a reaction yet, so i will bump this topic :)

Entering edit mode

Hmm, please consider that people are more likely to be able to give a meaningful response if you followed the posting guide and did your homework. In particular,

  • can you please try with the up-to-date version of R and install up-to-date versions of all required packages  from scratch?
  • can you produce a small self-contained example?
  • proper session info (incl. operating system) after running the small example on a fresh session of R

Thank you for considering.


Login before adding your answer.

Traffic: 412 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6