jpquast / ggplate

Create Layout Plots of Biological Culture Plates and Microplates
https://jpquast.github.io/ggplate/
Other
90 stars 6 forks source link

Missing Letter Row Labels #20

Closed Marie269 closed 4 months ago

Marie269 commented 4 months ago

I love this package! Thank you so much for providing it!

I still learning all the ins & outs of how to customize the plots, however I do seem to be having an issue with the row labels ("A", "B", "C", etc.) not showing up. The column labels show up just fine & I've tried with both my data as well as provided data sets and can't seem to figure it out. Any suggestions on how to add these?

Here is my code:

plate_plot( data = well_data, position = WELL.LABEL, value = Chord_Ratio_SD, plate_size = 384, plate_type = "square", title = "Test Data 6/10/24", colour = c( "#000004FF", "#51127CFF", "#B63679FF", "#FB8861FF", "#FCFDBFFF")) +

Aesthetic additions to graph

theme(plot.background = element_rect(fill = "gray8")) + theme(panel.background = element_rect(fill = "gray8")) + theme(legend.background = element_rect(fill = "gray8")) + theme(text= element_text(family="serif", face="bold", color="white"))

Screenshot 2024-06-10 at 5 34 25 PM
jpquast commented 4 months ago

@Marie269 thanks for posting the issue!

I have tried to run the code you provided with the continuous 384 well example dataset and I have row names. So I guess your input is the problem. Could you maybe provide your well_data? You can run dput(well_data) and paste the output.

library(ggplate)
#> 📊 Welcome to ggplate version 0.0.1! 📈
#>                             
#> 🖍 Have fun plotting your data! 💻
library(ggplot2)

plate_plot(
  data = data_continuous_384,
  position = well,
  value = Value,
  plate_size = 384,
  plate_type = "square",
  title = "Test Data 6/10/24",
  colour = c(
    "#000004FF",
    "#51127CFF",
    "#B63679FF",
    "#FB8861FF",
    "#FCFDBFFF")) +
  #Aesthetic additions to graph
  theme(plot.background = element_rect(fill = "gray8")) +
  theme(panel.background = element_rect(fill = "gray8")) +
  theme(legend.background = element_rect(fill = "gray8")) +
  theme(text= element_text(family="serif", face="bold", color="white"))

Created on 2024-06-11 with reprex v2.0.2

Marie269 commented 4 months ago

I don't think it's my dataset. I tried in a different R project using the continuous 384 well example dataset and got the same result:

Input: library(ggplot2) library(ggplate)

plate_plot( data = data_continuous_384, position = well, value = Value, plate_size = 384, plate_type = "square",

Can add limits to standardize gradient

limits = c(0,0.3),

Change title to plate name & data

title = "Test Data 6/10/24", colour = c("#FF0000", "#FF5500", "#FFAA00", "#FFFF00", "#FFFF80"))

dput(data_continuous_384)

Output:

dput(data_continuous_384) structure(list(Value = c(1.98, 0.7, 0.61, 0.12, 0.27, 0.67, 0.47, 0.37, 0.04, 0.65, 1.16, 1.91, 0.68, 1.1, 0.07, 0.11, 0.14, 1.2, 0.57, 1.67, 0.24, 0.14, 0.52, 0.69, 1.17, 0.19, 0.3, 0.32, 0.44, 0.24, 0.7, 0.35, 0.49, 0.29, 0.76, 0.01, 0.5, 0.53, 1.41, 1.59, 0.17, 0.15, 0.04, 0.84, 1.53, 1.3, 0.41, 0.17, 0.51, 0.7, 0.63, 1.08, 1.06, 1.19, 0.81, 0.32, 1.23, 0.9, 2.34, 0.15, 0.33, 0.79, 0.28, 0.12, 0.94, 1.8, 0.55, 1.43, 0.49, 0, 0.34, 0.59, 0.7, 0.31, 0.9, 3.23, 0.45, 0.38, 0.81, 0.58, 0.15, 0.52, 0.47, 0.51, 1.83, 0.46, 0.71, 1.25, 1.29, 0.1, 0.5, 2.24, 0.35, 0.68, 0.43, 0.82, 0.2, 0.76, 0.66, 0.25, 0.66, 0.67, 0.32, 0.95, 1.55, 0.55, 0.52, 1.43, 2.65, 0.54, 2.15, 0.74, 1.41, 0.8, 1.06, 1.76, 0.02, 0.85, 1.3, 2.86, 0.54, 1.84, 2.27, 0.03, 1.14, 0.3, 0.85, 0.18, 0.56, 0.09, 2.32, 1.29, 0.58, 0.01, 0.28, 1.22, 0.27, 0.23, 1.1, 1.11, 1.06, 0.35, 0.65, 0.95, 2.86, 1.11, 1.17, 0.59, 0.37, 1.83, 0.25, 1.01, 0.65, 1.14, 0.56, 0.31, 1.45, 0.92, 0.53, 1.92, 0.41, 0.7, 1.17, 0.04, 0.84, 0.23, 0.02, 0.62, 0.79, 0.03, 0.29, 0.06, 1.48, 0.67, 1.55, 0.02, 0.14, 0.27, 0.78, 0.05, 0.84, 1.23, 1.13, 0.81, 0.33, 1.3, 0.75, 2.23, 0.01, 0.03, 0.57, 0.7, 0.49, 1.11, 0.66, 0.41, 1.22, 0.95, 0.13, 0.65, 0.02, 1.62, 0.23, 2.25, 1.22, 0.04, 0.6, 0.74, 2.06, 1.05, 1.21, 0.51, 1.04, 0.2, 1.13, 1.07, 2.17, 0.42, 2.92, 1.1, 0.26, 2.05, 0.99, 0.5, 0.5, 0.21, 1.59, 0.61, 0.98, 0.42, 0.56, 0.61, 0.36, 1.94, 1.69, 0.73, 0.36, 0.2, 1.85, 0.3, 0.5, 0.4, 0.68, 0.71, 0.41, 0.65, 0.18, 1.61, 1.58, 0.82, 0.55, 1.51, 0.32, 0.9, 0.14, 1.61, 1.41, 1.27, 0.42, 1.73, 0.87, 0.71, 0.2, 0.11, 0.62, 1.49, 0.68, 0.72, 0.98, 0.81, 1.77, 0.45, 0.03, 0.05, 1.89, 0.23, 1.51, 0.42, 1.24, 1.64, 1.37, 0.89, 0.23, 0.98, 2.7, 0.27, 0.6, 0.72, 0.97, 1.61, 0.19, 0.25, 0.35, 0.99, 0.62, 0.76, 0.72, 0.33, 0.88, 0.04, 0.21, 0.15, 0.37, 0.73, 0.41, 0.29, 3.2, 1.22, 0.49, 1.64, 0.64, 1.39, 0.16, 0.42, 0.32, 1.36, 0.16, 0.01, 1.66, 1.47, 1.08, 0.96, 0.11, 0.84, 1.6, 1.46, 0.11, 1.27, 0.76, 1.41, 2.73, 0.71, 0.43, 0.44, 1.39, 0.85, 2.08, 0.42, 0.27, 0.4, 1.76, 0.32, 1.81, 0.44, 0.95, 1.14, 1.95, 0.13, 3.4, 1.12, 0.17, 0.02, 0.65, 0.89, 0.84, 0.11, 1.31, 1.19, 1.13, 0.29, 0.49, 0.15, 0.93, 0.26, 0.34, 1.01, 1.18, 0.42, 1.13, 0.1, 0.93, 0.28, 0.78, 0.52, 0.66, 0.49, 1.47, 0.27, 0.67, 1.78, 1.47, 0.28, 1.14, 1.33), well = c("A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "A16", "A17", "A18", "A19", "A20", "A21", "A22", "A23", "A24", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "B10", "B11", "B12", "B13", "B14", "B15", "B16", "B17", "B18", "B19", "B20", "B21", "B22", "B23", "B24", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "C10", "C11", "C12", "C13", "C14", "C15", "C16", "C17", "C18", "C19", "C20", "C21", "C22", "C23", "C24", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9", "D10", "D11", "D12", "D13", "D14", "D15", "D16", "D17", "D18", "D19", "D20", "D21", "D22", "D23", "D24", "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8", "E9", "E10", "E11", "E12", "E13", "E14", "E15", "E16", "E17", "E18", "E19", "E20", "E21", "E22", "E23", "E24", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", "G1", "G2", "G3", "G4", "G5", "G6", "G7", "G8", "G9", "G10", "G11", "G12", "G13", "G14", "G15", "G16", "G17", "G18", "G19", "G20", "G21", "G22", "G23", "G24", "H1", "H2", "H3", "H4", "H5", "H6", "H7", "H8", "H9", "H10", "H11", "H12", "H13", "H14", "H15", "H16", "H17", "H18", "H19", "H20", "H21", "H22", "H23", "H24", "I1", "I2", "I3", "I4", "I5", "I6", "I7", "I8", "I9", "I10", "I11", "I12", "I13", "I14", "I15", "I16", "I17", "I18", "I19", "I20", "I21", "I22", "I23", "I24", "J1", "J2", "J3", "J4", "J5", "J6", "J7", "J8", "J9", "J10", "J11", "J12", "J13", "J14", "J15", "J16", "J17", "J18", "J19", "J20", "J21", "J22", "J23", "J24", "K1", "K2", "K3", "K4", "K5", "K6", "K7", "K8", "K9", "K10", "K11", "K12", "K13", "K14", "K15", "K16", "K17", "K18", "K19", "K20", "K21", "K22", "K23", "K24", "L1", "L2", "L3", "L4", "L5", "L6", "L7", "L8", "L9", "L10", "L11", "L12", "L13", "L14", "L15", "L16", "L17", "L18", "L19", "L20", "L21", "L22", "L23", "L24", "M1", "M2", "M3", "M4", "M5", "M6", "M7", "M8", "M9", "M10", "M11", "M12", "M13", "M14", "M15", "M16", "M17", "M18", "M19", "M20", "M21", "M22", "M23", "M24", "N1", "N2", "N3", "N4", "N5", "N6", "N7", "N8", "N9", "N10", "N11", "N12", "N13", "N14", "N15", "N16", "N17", "N18", "N19", "N20", "N21", "N22", "N23", "N24", "O1", "O2", "O3", "O4", "O5", "O6", "O7", "O8", "O9", "O10", "O11", "O12", "O13", "O14", "O15", "O16", "O17", "O18", "O19", "O20", "O21", "O22", "O23", "O24", "P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10", "P11", "P12", "P13", "P14", "P15", "P16", "P17", "P18", "P19", "P20", "P21", "P22", "P23", "P24")), row.names = c(NA, -384L), class = c("tbl_df", "tbl", "data.frame"))

Screenshot 2024-06-11 at 1 05 40 PM
Marie269 commented 4 months ago

Also, I had installed the package through CRAN, but tried un-installing & re-installing through devtools & got the same result.

jpquast commented 4 months ago

I can still not reproduce the problem. So I assume it might be some problem with other package versions or the some environment variables. Can you copy the code I posted above and then run: reprex::reprex(). This creates a reproducible example in a new environment with the code you had in the clipboard. After running this the output is automatically copied into the clipboard and you just need to paste into the GitHub reply.

It would also help if you paste the result of sessionInfo().

RachaelMurray commented 4 months ago

Hello @jpquast ! I'm having the same issue as @Marie269. I just ran your code using reprex::reprex() and I still cannot see the row letters.

Here is my sessionInfo() if this will help!

R version 4.4.0 (2024-04-24 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale: [1] LC_COLLATE=English_United Kingdom.utf8 LC_CTYPE=English_United Kingdom.utf8
[3] LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.utf8

time zone: Europe/London tzcode source: internal

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

other attached packages: [1] viridis_0.6.5 viridisLite_0.4.2 stringr_1.5.1 grafify_4.0.1 readr_2.1.5 tidyqpcr_1.0
[7] tibble_3.2.1 ggplot2_3.5.1 dplyr_1.1.4 ggplate_0.1.1

loaded via a namespace (and not attached): [1] gtable_0.3.5 xfun_0.43 htmlwidgets_1.6.4 processx_3.8.4 lattice_0.22-6
[6] callr_3.7.6 numDeriv_2016.8-1.1 tzdb_0.4.0 ps_1.7.6 vctrs_0.6.5
[11] tools_4.4.0 generics_0.1.3 fansi_1.0.6 cluster_2.1.6 pkgconfig_2.0.3
[16] Matrix_1.7-0 data.table_1.15.4 checkmate_2.3.1 assertthat_0.2.1 lifecycle_1.0.4
[21] compiler_4.4.0 farver_2.1.1 munsell_0.5.1 lmerTest_3.1-3 carData_3.0-5
[26] htmltools_0.5.8.1 yaml_2.3.8 htmlTable_2.4.2 Formula_1.2-5 nloptr_2.0.3
[31] pillar_1.9.0 car_3.1-2 tidyr_1.3.1 MASS_7.3-60.2 Hmisc_5.1-3
[36] rpart_4.1.23 boot_1.3-30 abind_1.4-5 nlme_3.1-164 tidyselect_1.2.1
[41] digest_0.6.35 mvtnorm_1.2-5 stringi_1.8.4 purrr_1.0.2 forcats_1.0.0
[46] splines_4.4.0 fastmap_1.1.1 grid_4.4.0 colorspace_2.1-0 cli_3.6.2
[51] magrittr_2.0.3 patchwork_1.2.0 base64enc_0.1-3 utf8_1.2.4 clipr_0.8.0
[56] foreign_0.8-86 withr_3.0.0 scales_1.3.0 backports_1.5.0 estimability_1.5.1 [61] rmarkdown_2.26 emmeans_1.10.2 nnet_7.3-19 lme4_1.1-35.3 gridExtra_2.3
[66] hms_1.1.3 evaluate_0.23 knitr_1.46 mgcv_1.9-1 rlang_1.1.3
[71] Rcpp_1.0.12 xtable_1.8-4 glue_1.7.0 reprex_2.1.0 minqa_1.2.7
[76] rstudioapi_0.16.0 R6_2.5.1 fs_1.6.4

Marie269 commented 4 months ago

Hello @jpquast, here is the output following reprex::reprex()

``` r
reprex::reprex()
#> ℹ Non-interactive session, setting `html_preview = FALSE`.
#> CLIPR_ALLOW has not been set, so clipr will not run interactively
#> Error in switch(where, expr = stringify_expression(x_expr), clipboard = ingest_clipboard(), : EXPR must be a length 1 vector

Created on 2024-06-12 with reprex v2.1.0



    #> Error: attempt to use zero-length variable name

<sup>Created on 2024-06-12 with [reprex v2.1.0](https://reprex.tidyverse.org)</sup>

And here is the session info:

> sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.5

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.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
 [1] ggplate_0.1.1   lubridate_1.9.3 forcats_1.0.0  
 [4] stringr_1.5.1   dplyr_1.1.4     purrr_1.0.2    
 [7] readr_2.1.5     tidyr_1.3.1     tibble_3.2.1   
[10] ggplot2_3.5.1   tidyverse_2.0.0

loaded via a namespace (and not attached):
 [1] styler_1.10.3     utf8_1.2.4        generics_0.1.3   
 [4] stringi_1.8.4     hms_1.1.3         digest_0.6.35    
 [7] magrittr_2.0.3    evaluate_0.23     grid_4.4.0       
[10] timechange_0.3.0  pkgload_1.3.4     fastmap_1.1.1    
[13] R.oo_1.26.0       R.cache_0.16.0    R.utils_2.12.3   
[16] processx_3.8.4    ps_1.7.6          fansi_1.0.6      
[19] scales_1.3.0      cli_3.6.2         rlang_1.1.4      
[22] R.methodsS3_1.8.2 munsell_0.5.1     reprex_2.1.0     
[25] withr_3.0.0       yaml_2.3.8        tools_4.4.0      
[28] tzdb_0.4.0        colorspace_2.1-0  vctrs_0.6.5      
[31] R6_2.5.1          lifecycle_1.0.4   fs_1.6.4         
[34] pkgconfig_2.0.3   callr_3.7.6       clipr_0.8.0      
[37] pillar_1.9.0      gtable_0.3.5      glue_1.7.0       
[40] xfun_0.43         tidyselect_1.2.1  rstudioapi_0.16.0
[43] knitr_1.46        farver_2.1.2      htmltools_0.5.8.1
[46] rmarkdown_2.26    labeling_0.4.3    compiler_4.4.0   
jpquast commented 4 months ago

Thank you both! It was the new version of ggplot2 that caused the issue. I fixed the bug. You can reinstall it from GitHub and it should work correctly. The fix will also be on CRAN soon.

Marie269 commented 4 months ago

Hello @jpquast ,

Installing the new version fixed the issue with the row labels! However, it caused something to go wrong with the data positioning. All of the data ended up inverted (The data for row A shows up on row P, etc).

Screenshot 2024-06-14 at 11 50 16 AM

Here is my input data:

dput(well_data) structure(list(WELL.LABEL = structure(1:12, levels = c("B - 10", "B - 2", "B - 4", "B - 6", "C - 10", "C - 2", "C - 4", "C - 6", "D - 10", "D - 2", "D - 4", "D - 6"), class = "factor"), Row = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L), levels = c("B", "C", "D"), class = "factor"), Column = c(10L, 2L, 4L, 6L, 10L, 2L, 4L, 6L, 10L, 2L, 4L, 6L), Chord_Ratio_SD = c(0.0104104145780509, 0.0881314570115311, 0.156043283958191, 0.000455062899882333, 0.00104601173792502, 0.0929370677885526, 0.106230602250418, 0.00214980996192313, 0.000597060754835863, 0.220211504296801, 0.2154958433828, 0.00887161854808691 ), Motile = c("N", "Y", "Y", "N", "N", "Y", "Y", "N", "N", "Y", "Y", "N")), class = c("grouped_df", "tbl_df", "tbl", "data.frame" ), row.names = c(NA, -12L), groups = structure(list(WELL.LABEL = structure(1:12, levels = c("B - 10", "B - 2", "B - 4", "B - 6", "C - 10", "C - 2", "C - 4", "C - 6", "D - 10", "D - 2", "D - 4", "D - 6"), class = "factor"), Row = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L), levels = c("B", "C", "D"), class = "factor"), .rows = structure(list(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L), ptype = integer(0), class = c("vctrs_list_of", "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame" ), row.names = c(NA, -12L), .drop = TRUE))

And reprex:

reprex::reprex()
#> ℹ Non-interactive session, setting `html_preview = FALSE`.
#> CLIPR_ALLOW has not been set, so clipr will not run interactively
#> Error in switch(where, expr = stringify_expression(x_expr), clipboard = ingest_clipboard(), : EXPR must be a length 1 vector

Created on 2024-06-14 with reprex v2.1.0

And session info:

sessionInfo() R version 4.4.0 (2024-04-24) Platform: aarch64-apple-darwin20 Running under: macOS Sonoma 14.5

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.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Chicago tzcode source: internal

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

other attached packages: [1] ggplate_0.1.2 lubridate_1.9.3 forcats_1.0.0
[4] stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2
[7] readr_2.1.5 tidyr_1.3.1 tibble_3.2.1
[10] ggplot2_3.5.1 tidyverse_2.0.0

loaded via a namespace (and not attached): [1] styler_1.10.3 utf8_1.2.4 generics_0.1.3
[4] stringi_1.8.4 hms_1.1.3 digest_0.6.35
[7] magrittr_2.0.3 evaluate_0.23 grid_4.4.0
[10] timechange_0.3.0 fastmap_1.1.1 R.oo_1.26.0
[13] R.cache_0.16.0 processx_3.8.4 R.utils_2.12.3
[16] ps_1.7.6 fansi_1.0.6 scales_1.3.0
[19] cli_3.6.2 rlang_1.1.4 R.methodsS3_1.8.2 [22] munsell_0.5.1 reprex_2.1.0 yaml_2.3.8
[25] withr_3.0.0 tools_4.4.0 tzdb_0.4.0
[28] colorspace_2.1-0 vctrs_0.6.5 R6_2.5.1
[31] lifecycle_1.0.4 fs_1.6.4 callr_3.7.6
[34] pkgconfig_2.0.3 clipr_0.8.0 pillar_1.9.0
[37] gtable_0.3.5 glue_1.7.0 xfun_0.43
[40] tidyselect_1.2.1 rstudioapi_0.16.0 knitr_1.46
[43] farver_2.1.2 htmltools_0.5.8.1 rmarkdown_2.26
[46] labeling_0.4.3 compiler_4.4.0

So sorry for the trouble!

jpquast commented 4 months ago

@Marie269 you are right, I didn't notice that. Thanks for spotting this! I have fixed the row swap now and you can install the new version from GitHub.