uclahs-cds / package-BoutrosLab-plotting-general

Functions to Create Publication-Quality Plots
https://uclahs-cds.github.io/package-BoutrosLab-plotting-general
11 stars 4 forks source link

Italic doesn't work #26

Open RoniHaas opened 2 years ago

RoniHaas commented 2 years ago

Hey @dan-knight ,

I am trying to use expression(italic(''something to print)), but for some reason, the italic is being ignored. When I use for example expression(bold(''something to print)), that works fine.

As an example:

create.dotmap(
    main = expression(italic('Weird')),
    x = dot.df.sig[,names(l2fc.combined.data)],
    bg.data = -log10(dot.df.sig[,names(p.adj.df.chosen)]),
    spot.size.function = spot.size,
    at = c(0, -log10(0.05), -log10(0.01), -log10(0.001), -log10(0.0001), -log10(0.00001),
           -log10(0.0000000001), -log10(min(dot.df.sig[,names(p.adj.df.chosen)], na.rm = TRUE))),
    colour.scheme =  c('white', 'lightgrey', 'grey70', 'grey55', 'grey35', 'grey20',
                       'black'),
    spot.colour.function = colour.function,
    total.colours = 3,
    height = 7,
    width = 10,
    yaxis.cex = 1,
    xaxis.cex = 1,
    key = dot.key,
    bg.alpha = 1,
    key.top = 2,
    key.ylab.padding = 2,
    right.padding = 18,
    resolution = 300,
    yaxis.lab =  row.names(dot.df.sig),
    xaxis.lab = sub(
        names(dot.df.sig[,names(l2fc.combined.data)]),
        replacement = ' vs ',
        pattern = 'vs'
        ),
    xaxis.tck = 0,
    yaxis.tck = 0,
    bottom.padding = 2,
    filename = paste0(
        config.file$Output,
        'radioresistance/',
        'paper_figures/',
        generate.filename(
           project.stem = 'for_key_dot',
            file.core = 'log',
            extension = 'png'
           )
        )
    );

The figure I get is that (the title is not italicized):

2022-06-27_for_key_dot_log

RoniHaas commented 2 years ago

Thanks to the great help from @jmlivingstone, we realized that the issue occurs in certain environments.

We both tried this code that Julie wrote:

library(BoutrosLab.plotting.general);
library(BoutrosLab.utilities);

set.seed(12345);

simple.data <- data.frame(
    x = rnorm(800),
    y = rnorm(800)
    );

create.scatterplot(
    formula = y ~ x,
    data = simple.data,
    file = generate.filename('BPG', 'italics_test', 'png'),
    xlab.label = expression(italic('Weird') * underline('Weird')),
    xaxis.cex = 1,
    yaxis.cex = 1,
    ylab.label = expression(italic('bold')),
    main = expression(italic('italics font')),
    main.cex = 1,
    resolution = 200
    );

set.seed(12345);

dot.simple.data <- data.frame(
    'A' = runif(n = 15, min = -1, max = 1),
    'B' = runif(n = 15, min = -1, max = 1),
    'C' = runif(n = 15, min = -1, max = 1),
    'D' = runif(n = 15, min = -1, max = 1),
    'E' = runif(n = 15, min = -1, max = 1)
    );

create.dotmap(
    x = dot.simple.data,
    file = generate.filename('BPG', 'italics_test_dot', 'png'),
    xlab.label = expression(italic('Weird') * underline('Weird')),
    xaxis.cex = 1,
    yaxis.cex = 1,
    ylab.label = expression(italic('bold')),
    main = expression(italic('italics font')),
    main.cex = 1,
    resolution = 200
    );

I ran this locally and received non-italicized title and axis labels. E.g.: 2022-07-14_BPG_italics_test

For Julie, everything worked fine! E.g.: 2022-07-14_BPG_italics_test

Here is Julie's save.session.profile, using her r-environment on Slurm:

### Memory #########################################################################################
          used (Mb) gc trigger (Mb) max used (Mb)
Ncells  540147 28.9    1237274 66.1  1022636 54.7
Vcells 1065805  8.2    8388608 64.0  1863731 14.3

### Time ###########################################################################################
   user  system elapsed 
 14.418   1.162 814.800 

### Full list of objects ###########################################################################
                  Type  Size PrettySize Rows Columns
simple.data data.frame 13648    13.3 Kb  800       2

### Session Info ###################################################################################
R version 4.1.1 (2021-08-10)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /shared/home/jlivingstone/miniconda3/envs/r_env/lib/libopenblasp-r0.3.17.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] BoutrosLab.utilities_1.9.10       BoutrosLab.plotting.general_7.0.3
[3] hexbin_1.28.2                     cluster_2.1.3                    
[5] latticeExtra_0.6-29               lattice_0.20-45                  

loaded via a namespace (and not attached):
 [1] png_0.1-7          class_7.3-20       MASS_7.3-57        gtable_0.3.0      
 [5] e1071_1.7-11       RColorBrewer_1.1-3 tools_4.1.1        jpeg_0.1-9        
 [9] proxy_0.4-27       compiler_4.1.1     gridExtra_2.3  `

Here is mine:

### Memory #########################################################################################
          used (Mb) gc trigger  (Mb) limit (Mb) max used (Mb)
Ncells 1063573 56.9    2174794 116.2         NA  1393408 74.5
Vcells 2500936 19.1    8388608  64.0      16384  4280194 32.7

### Time ###########################################################################################
     user    system   elapsed 
  171.496    95.726 83538.929 

### Full list of objects ###########################################################################
                      Type  Size PrettySize Rows Columns
simple.data     data.frame 13648    13.3 Kb  800       2
dot.simple.data data.frame  1864     1.8 Kb   15       5

### Session Info ###################################################################################
R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
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] grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] BoutrosLab.utilities_1.9.10       BoutrosLab.plotting.general_7.0.3 hexbin_1.28.2                    
[4] cluster_2.1.3                     latticeExtra_0.6-29               lattice_0.20-45                  

loaded via a namespace (and not attached):
 [1] png_0.1-7          class_7.3-20       MASS_7.3-57        gtable_0.3.0       e1071_1.7-11       RColorBrewer_1.1-3 tools_4.2.0       
 [8] jpeg_0.1-9         proxy_0.4-27       compiler_4.2.0     gridExtra_2.3     

I hope that helps!

lydiayliu commented 2 years ago

As a follow up to this, I have never been able to get BOTH italic and bold to work on the same piece of text. There is an option called bolditalic() in R, but has anybody had success with it?

RoniHaas commented 2 years ago

As a follow up to this, I have never been able to get BOTH italic and bold to work on the same piece of text. There is an option called bolditalic() in R, but has anybody had success with it?

I am using bolditalic() on Slurm, and it works well in my r environment: For example, see the vs in the x axis 2022-07-20_drivers_GSEA-merged-all

But locally it is not working for me (same as for just italic). I still don't know what is the source for this variation.

lydiayliu commented 2 years ago

Thank you! It might be the same issue for me then, it has never worked for me locally (but I have gotten bold and italic) to work. Guess using the cluster will be the answer.