galaaz 2.1.7 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +63 -58
  4. data/blogs/galaaz_ggplot/galaaz_ggplot.log +59 -68
  5. data/blogs/galaaz_ggplot/galaaz_ggplot.md +91 -84
  6. data/blogs/galaaz_ggplot/galaaz_ggplot.tex +125 -94
  7. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/midwest_rb.png +0 -0
  8. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/scatter_plot_rb.png +0 -0
  9. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/midwest_rb.png +0 -0
  10. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/scatter_plot_rb.png +0 -0
  11. data/blogs/gknit/gknit.Rmd +33 -28
  12. data/blogs/gknit/gknit.md +47 -42
  13. data/blogs/gknit/gknit.tex +1368 -0
  14. data/blogs/gknit/gknit_files/figure-html/bubble-1.png +0 -0
  15. data/blogs/gknit/gknit_files/figure-html/diverging_bar.png +0 -0
  16. data/blogs/gknit/gknit_files/figure-latex/bubble-1.png +0 -0
  17. data/blogs/gknit/gknit_files/gknit_files/figure-latex/bubble-1.png +0 -0
  18. data/blogs/manual/manual.Rmd +129 -60
  19. data/blogs/manual/manual.log +289 -545
  20. data/blogs/manual/manual.md +551 -467
  21. data/blogs/manual/manual.tex +1059 -485
  22. data/blogs/manual/manual_files/figure-html/bubble-1.png +0 -0
  23. data/blogs/manual/manual_files/figure-latex/bubble-1.png +0 -0
  24. data/blogs/manual/manual_files/figure-markdown_github/bubble-1.png +0 -0
  25. data/blogs/manual/manual_files/figure-markdown_github/diverging_bar.png +0 -0
  26. data/blogs/manual/manual_files/manual_files/figure-latex/bubble-1.png +0 -0
  27. data/blogs/nse_dplyr/nse_dplyr.Rmd +28 -7
  28. data/blogs/nse_dplyr/nse_dplyr.log +49 -153
  29. data/blogs/nse_dplyr/nse_dplyr.md +676 -705
  30. data/blogs/nse_dplyr/nse_dplyr.tex +1589 -0
  31. data/blogs/oh_my/oh_my.Rmd +193 -55
  32. data/blogs/oh_my/oh_my.log +265 -95
  33. data/blogs/oh_my/oh_my.md +236 -95
  34. data/blogs/oh_my/oh_my.tex +1976 -68
  35. data/blogs/ruby_plot/ruby_plot.Rmd +42 -34
  36. data/blogs/ruby_plot/ruby_plot.log +101 -99
  37. data/blogs/ruby_plot/ruby_plot.md +52 -46
  38. data/blogs/ruby_plot/ruby_plot.tex +134 -102
  39. data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.png +0 -0
  40. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.png +0 -0
  41. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.png +0 -0
  42. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.png +0 -0
  43. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.png +0 -0
  44. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png +0 -0
  45. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png +0 -0
  46. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.png +0 -0
  47. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.png +0 -0
  48. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png +0 -0
  49. data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png +0 -0
  50. data/blogs/ruby_plot/ruby_plot_files/figure-latex/dose_len.png +0 -0
  51. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_delivery.png +0 -0
  52. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_dose.png +0 -0
  53. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color.png +0 -0
  54. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color2.png +0 -0
  55. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_decorations.png +0 -0
  56. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
  57. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_points.png +0 -0
  58. data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_box_plot.png +0 -0
  59. data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
  60. data/blogs/ruby_plot/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
  61. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/dose_len.png +0 -0
  62. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facet_by_delivery.png +0 -0
  63. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facet_by_dose.png +0 -0
  64. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_by_delivery_color.png +0 -0
  65. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_by_delivery_color2.png +0 -0
  66. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_with_decorations.png +0 -0
  67. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
  68. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_with_points.png +0 -0
  69. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/final_box_plot.png +0 -0
  70. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
  71. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
  72. data/lib/galaaz/cli.rb +51 -10
  73. data/script/omarchy/README.md +1 -1
  74. data/script/omarchy/galaaz-guide.sh +1 -1
  75. data/sty/galaaz.sty +22 -0
  76. data/version.rb +1 -1
  77. metadata +19 -1
@@ -25,10 +25,12 @@ fontsize: 11pt
25
25
  ---
26
26
 
27
27
  ```{ruby setup, echo=FALSE}
28
- # Bridge default is 60s; some chunks (Arrow, large dplyr pipes) need more.
28
+ # Bridge default 60s; Arrow/dplyr pipes may need more.
29
29
  ENV['GALAAZ_BRIDGE_TIMEOUT_SEC'] ||= '300'
30
+ # Writable jobs dir for R::Job demos when knitting (avoid Permission denied).
31
+ ENV['GALAAZ_JOBS_DIR'] ||= File.join(Dir.tmpdir, 'galaaz_jobs_manual')
30
32
 
31
- R.options(crayon__enabled: false)
33
+ R.options(crayon__enabled: false, width: 70)
32
34
  R.install_and_loads('kableExtra')
33
35
  ```
34
36
 
@@ -126,15 +128,20 @@ JRuby (`bin/galaaz_jruby_env.inc.sh` / `lib/galaaz_jruby.rb`). **`bin/galaaz-jru
126
128
 
127
129
  ```{r bin-tables-helper, echo=FALSE}
128
130
  bin_tbl <- function(df) {
129
- k <- knitr::kable(df, row.names = FALSE, booktabs = TRUE, linesep = "",
130
- col.names = c("Script", "Role", "2.0?"))
131
+ k <- knitr::kable(
132
+ df, row.names = FALSE, booktabs = TRUE, linesep = "",
133
+ col.names = c("Script", "Role", "2.0?"))
131
134
  if (knitr::is_latex_output()) {
132
- k <- kableExtra::kable_styling(k, font_size = 9, latex_options = "scale_down")
135
+ k <- kableExtra::kable_styling(
136
+ k, font_size = 9, latex_options = "scale_down")
133
137
  k <- kableExtra::column_spec(k, 1, width = "2.5cm")
134
138
  k <- kableExtra::column_spec(k, 2, width = "9.5cm")
135
139
  k <- kableExtra::column_spec(k, 3, width = "2.8cm")
136
140
  } else {
137
- k <- kableExtra::kable_styling(k, bootstrap_options = c("striped", "condensed"), full_width = TRUE)
141
+ k <- kableExtra::kable_styling(
142
+ k,
143
+ bootstrap_options = c("striped", "condensed"),
144
+ full_width = TRUE)
138
145
  }
139
146
  k
140
147
  }
@@ -142,11 +149,13 @@ bin_tbl <- function(df) {
142
149
 
143
150
  ```{r bin-tables-bootstrap, echo=FALSE}
144
151
  df_boot <- data.frame(
145
- Script = c("galaaz-bootstrap", "galaaz-jruby", "galaaz_jruby_env.inc.sh", "install-tinytex"),
152
+ Script = c(
153
+ "galaaz-bootstrap", "galaaz-jruby",
154
+ "galaaz_jruby_env.inc.sh", "install-tinytex"),
146
155
  Role = c(
147
- "WSL2 helper: Docker checks; optional TinyTeX or poppler for gKnit PDF.",
148
- "JRuby with repo lib/ on LOAD_PATH and required JVM flags (e.g. Arrow).",
149
- "Sourced by bash wrappers; sets GALAAZ_REQUIRED_JRUBY_J_ARGS.",
156
+ "WSL2 helper: Docker checks; optional TinyTeX/poppler.",
157
+ "JRuby with repo lib/ on LOAD_PATH and JVM flags.",
158
+ "Sourced by bash wrappers; sets JRUBY_J_ARGS.",
150
159
  "Install TinyTeX for PDF output."
151
160
  ),
152
161
  X2 = c("Yes*", "Yes", "Yes†", "Yes"),
@@ -189,7 +198,7 @@ df_gk <- data.frame(
189
198
  Script = c("gknit", "gknit-draft", "gknit-draft.rb", "gknit_Rscript"),
190
199
  Role = c(
191
200
  "Knit .Rmd via JRuby and R Markdown render.",
192
- "Drafts from rticles-style templates; wrapper still uses legacy polyglot ruby.",
201
+ "Drafts from rticles templates; legacy polyglot wrapper.",
193
202
  "Ruby entry: GKnit.draft (use with JRuby + LOAD_PATH).",
194
203
  "Polyglot Rscript launcher; hard-coded LOAD_PATH sample."
195
204
  ),
@@ -207,10 +216,12 @@ Prefer **`galaaz-jruby`** for **`gknit-draft`** workflows until that wrapper mat
207
216
 
208
217
  ```{r bin-tables-tests, echo=FALSE}
209
218
  df_ts <- data.frame(
210
- Script = c("run_rspec", "run_all_rspec", "run_slow_rspec", "run_old_rspec", "run_rspec_subset"),
219
+ Script = c(
220
+ "run_rspec", "run_all_rspec", "run_slow_rspec",
221
+ "run_old_rspec", "run_rspec_subset"),
211
222
  Role = c(
212
223
  "Top-level specs/*_spec.rb with spec_helper (see docs/testing.md).",
213
- "Compile ext/new_bridge; run specs/ and new_bridge_specs/ together.",
224
+ "Compile ext/new_bridge; run specs/ and new_bridge_specs/.",
214
225
  "Suites under slow-specs/ (read script header for spec_helper).",
215
226
  "Legacy suites under old_specs/.",
216
227
  "Numbered subset 1–18 (Documentation/Spec_Subsets.md)."
@@ -227,7 +238,7 @@ bin_tbl(df_ts)
227
238
  df_ot <- data.frame(
228
239
  Script = c("grun", "gstudio_irb.rb / gstudio_pry.rb"),
229
240
  Role = c(
230
- "Graal-era launcher: polyglot ruby with --jvm. Use galaaz-jruby -S instead.",
241
+ "Graal-era launcher: polyglot ruby --jvm; prefer galaaz-jruby.",
231
242
  "Loaded by gstudio; not meant to be run standalone."
232
243
  ),
233
244
  X2 = c("No", "Yes"),
@@ -268,8 +279,9 @@ The supported install is **`gem install` + compile the gatekeeper**. You do not
268
279
  4. Compile the native gatekeeper from the installed gem:
269
280
 
270
281
  ```
271
- gem_dir="$(ruby -e "puts Gem::Specification.find_by_name('galaaz').full_gem_path")"
272
- # under JRuby: gem_dir="$(jruby -e "puts Gem::Specification.find_by_name('galaaz').full_gem_path")"
282
+ gem_dir="$(ruby -e \
283
+ "puts Gem::Specification.find_by_name('galaaz').full_gem_path")"
284
+ # under JRuby: use jruby -e instead of ruby -e
273
285
  make -C "${gem_dir}/ext/new_bridge" all
274
286
  ```
275
287
 
@@ -290,9 +302,10 @@ A **table of all `bin/` scripts** (bootstrap, Ruby launcher, gstudio, gknit, tes
290
302
  wrapper that forces JRuby.
291
303
 
292
304
  A **gstudio** try image with Galaaz already installed is available for both engines:
293
- **JRuby** — `docker run --rm -it ghcr.io/rbotafogo/galaaz-try:gstudio` (or
294
- `./docker/try-gstudio/run.sh` from a checkout); **CRuby** —
295
- `docker run --rm -it ghcr.io/rbotafogo/galaaz-try:cruby` (or `./docker/try-cruby/run.sh`).
305
+ **JRuby** — `docker run --rm -it ghcr.io/rbotafogo/galaaz-try:gstudio`
306
+ (or `./docker/try-gstudio/run.sh` from a checkout); **CRuby** —
307
+ `docker run --rm -it ghcr.io/rbotafogo/galaaz-try:cruby`
308
+ (or `./docker/try-cruby/run.sh`).
296
309
  Maintainers can prove a RubyGems install on a throwaway Ubuntu machine (no repo inside
297
310
  the container) with `./docker/cold-install/run.sh published-specs` (JRuby) or
298
311
  `./docker/cold-install-cruby/run.sh published-specs` (CRuby).
@@ -331,7 +344,8 @@ WSL integration is enabled for the distro where Galaaz is installed.
331
344
  vec = R.c(1, 2, 3, 4)
332
345
  puts vec
333
346
 
334
- # R.foo(...) calls an R *function*. Datasets are objects — fetch with ~:
347
+ # R.foo(...) calls an R *function*. Datasets are objects — fetch with
348
+ # ~:
335
349
  df = ~R[:mtcars]
336
350
  puts R.summary(df)
337
351
  ```
@@ -425,9 +439,11 @@ completion = Queue.new
425
439
 
426
440
  R.eval_r_async('({ Sys.sleep(0.3); 42L })', timeout: nil) do |result|
427
441
  if result.ok?
428
- puts "[completion] R finished; eval_r-style value: #{result.value.inspect}"
442
+ puts "[completion] R finished; value: " +
443
+ "#{result.value.inspect}"
429
444
  else
430
- puts "[completion] R/bridge error: #{result.error.class}: #{result.error.message}"
445
+ puts "[completion] R/bridge error: " +
446
+ "#{result.error.class}: #{result.error.message}"
431
447
  end
432
448
  completion.push(:done)
433
449
  end
@@ -466,7 +482,8 @@ finishes** (default: no wall-clock limit). Optional limit: `GALAAZ_INSTALL_TIMEO
466
482
  Only one install runs at a time (`install.lock`).
467
483
 
468
484
  ```{ruby r_job_install_note, eval=FALSE}
469
- # May take a long time the first time (e.g. caret); the bridge is not used for compile.
485
+ # May take a long time the first time (e.g. caret); the bridge is not
486
+ # used for compile.
470
487
  R.install_and_loads 'caret'
471
488
  ```
472
489
 
@@ -476,19 +493,26 @@ Prefer the **block** form (like `File.open`): await the child, yield the job, re
476
493
  block’s value. Without a block, the methods still await by default and return the `Job`.
477
494
 
478
495
  ```{ruby r_job_eval_block}
479
- coef = R::Job.eval(<<~R) { |job| job.load_rds }
480
- fit <- lm(mpg ~ wt, data = mtcars)
481
- saveRDS(unname(coef(fit)), result_path)
482
- R
483
- puts coef
496
+ begin
497
+ coef = R::Job.eval(<<~R) { |job| job.load_rds }
498
+ fit <- lm(mpg ~ wt, data = mtcars)
499
+ saveRDS(unname(coef(fit)), result_path)
500
+ R
501
+ puts coef
502
+ rescue => e
503
+ puts e.class.to_s
504
+ e.message.to_s.scan(/.{1,68}/).each { |line| puts line }
505
+ end
484
506
  ```
485
507
 
486
508
  ```{ruby r_job_eval_no_block, eval=FALSE}
487
- # Without a block: awaits (wait: true is the default) and returns the Job
509
+ # Without a block: awaits (wait: true is the default) and returns the
510
+ # Job
488
511
  job = R::Job.eval(code)
489
512
  job = R::Job.eval(code, wait: false) # start only; call job.wait later
490
513
 
491
- # Script file; trailing args → commandArgs(trailingOnly=TRUE) in the child
514
+ # Script file; trailing args → commandArgs(trailingOnly=TRUE) in the
515
+ # child
492
516
  res = R::Job.script('train.R', '5') { |job| job.load_rds }
493
517
  ```
494
518
 
@@ -520,7 +544,8 @@ extension paths on JRuby, or deployment extras you do not need). A minimal app a
520
544
 
521
545
  ```bash
522
546
  cd /home/rbotafogo/desenv_linux
523
- jruby -S rails new hedi --skip-git --minimal --skip-kamal --skip-solid --skip-active-record
547
+ jruby -S rails new hedi --skip-git --minimal \
548
+ --skip-kamal --skip-solid --skip-active-record
524
549
  ```
525
550
 
526
551
  Then install gems:
@@ -558,7 +583,8 @@ A direct smoke test from Rails runner:
558
583
 
559
584
  ```bash
560
585
  cd /home/rbotafogo/desenv_linux/hedi
561
- jruby -S bundle exec rails runner "puts R.eval('sum(c(1,2,3,4,5))').inspect"
586
+ jruby -S bundle exec rails runner \
587
+ "puts R.eval('sum(c(1,2,3,4,5))').inspect"
562
588
  ```
563
589
 
564
590
  Expected output:
@@ -1028,7 +1054,9 @@ a linear regression line (method = "lm") for every manufacturer.
1028
1054
  library(ggplot2)
1029
1055
  data(mpg, package="ggplot2")
1030
1056
 
1031
- mpg_select <- mpg[mpg$manufacturer %in% c("audi", "ford", "honda", "hyundai"), ]
1057
+ mpg_select <- mpg[
1058
+ mpg$manufacturer %in% c("audi", "ford", "honda", "hyundai"),
1059
+ ]
1032
1060
 
1033
1061
  # Scatterplot
1034
1062
  theme_set(theme_bw()) # pre-set the bw theme.
@@ -1096,7 +1124,8 @@ with the 'rb' engine. The following chunk specification will
1096
1124
  create and inline Ruby text:
1097
1125
 
1098
1126
  ````
1099
- This is some text with inline Ruby accessing variable 'b' which has value:
1127
+ This is some text with inline Ruby accessing
1128
+ variable 'b' which has value:
1100
1129
  ```{rb puts "```{rb puts b}\n```"}
1101
1130
  ```
1102
1131
  and is followed by some other text!
@@ -1347,14 +1376,16 @@ templates for the following journals with the respective template name:
1347
1376
  In order to create a document with one of those templates, use the following command:
1348
1377
 
1349
1378
  ```
1350
- gknit-draft --filename <my_document> --template <template> --package <package>
1351
- --create_dir
1379
+ gknit-draft --filename <my_document> \
1380
+ --template <template> --package <package> \
1381
+ --create_dir
1352
1382
  ```
1353
1383
  So, in order to create a template for writing an R Journal, use:
1354
1384
 
1355
1385
  ```
1356
- gknit-draft --filename my_r_article --template rjournal_article --package rticles
1357
- --create_dir
1386
+ gknit-draft --filename my_r_article \
1387
+ --template rjournal_article --package rticles \
1388
+ --create_dir
1358
1389
  ```
1359
1390
 
1360
1391
  # Accessing R variables
@@ -1411,7 +1442,10 @@ Data frames will later be more carefully described. In R, the method used to cr
1411
1442
  data frame is 'data.frame', in Galaaz we use 'data\_\_frame'.
1412
1443
 
1413
1444
  ```{ruby typeof_integer}
1414
- df = R.data__frame(typeof: vec.typeof, mode: vec.mode, storage__mode: vec.storage__mode)
1445
+ df = R.data__frame(
1446
+ typeof: vec.typeof,
1447
+ mode: vec.mode,
1448
+ storage__mode: vec.storage__mode)
1415
1449
  puts df
1416
1450
  ```
1417
1451
 
@@ -1426,7 +1460,10 @@ puts vec
1426
1460
  ```
1427
1461
 
1428
1462
  ```{ruby typeof_float}
1429
- df = R.data__frame(typeof: vec.typeof, mode: vec.mode, storage__mode: vec.storage__mode)
1463
+ df = R.data__frame(
1464
+ typeof: vec.typeof,
1465
+ mode: vec.mode,
1466
+ storage__mode: vec.storage__mode)
1430
1467
  outputs df.kable.kable_styling
1431
1468
  ```
1432
1469
 
@@ -2120,8 +2157,12 @@ when experimenting locally.
2120
2157
 
2121
2158
  ```{ruby arrow_pipeline_example, message=FALSE, warning=FALSE}
2122
2159
  # Scaled-down version of slow-specs/arrow_large_pipeline_spec.rb.
2123
- unless R::Support.eval("requireNamespace('arrow', quietly=TRUE) && requireNamespace('dplyr', quietly=TRUE)") == true
2124
- puts '(Skip: need arrow + dplyr in R; use bin/galaaz-jruby outside gKnit.)'
2160
+ arrow_ok = R::Support.eval(
2161
+ "requireNamespace('arrow', quietly=TRUE) && " +
2162
+ "requireNamespace('dplyr', quietly=TRUE)")
2163
+ unless arrow_ok == true
2164
+ puts '(Skip: need arrow + dplyr in R; ' +
2165
+ 'use bin/galaaz-jruby outside gKnit.)'
2125
2166
  else
2126
2167
  thread_count = 4
2127
2168
  rows_per_thread = 500
@@ -2164,7 +2205,9 @@ else
2164
2205
 
2165
2206
  total_n = 0
2166
2207
  (1..(out.nrow >> 0)).each { |i| total_n += (out[['n']][i] >> 0) }
2167
- puts "Sum of group counts n (should equal #{thread_count * rows_per_thread}): #{total_n}"
2208
+ puts "Sum of group counts n " +
2209
+ "(should equal #{thread_count * rows_per_thread}): " +
2210
+ "#{total_n}"
2168
2211
  end
2169
2212
  ```
2170
2213
 
@@ -2201,8 +2244,10 @@ The script **`examples/bioconductor_deseq2_airway/deseq2_airway_galaaz.rb`** is
2201
2244
  version in the repository. Run it from the **Galaaz repository root** with either engine, for example:
2202
2245
 
2203
2246
  ```text
2204
- bin/galaaz-ruby examples/bioconductor_deseq2_airway/deseq2_airway_galaaz.rb
2205
- # or: bin/galaaz-jruby examples/bioconductor_deseq2_airway/deseq2_airway_galaaz.rb
2247
+ bin/galaaz-ruby \
2248
+ examples/bioconductor_deseq2_airway/deseq2_airway_galaaz.rb
2249
+ # or: bin/galaaz-jruby \
2250
+ # examples/bioconductor_deseq2_airway/deseq2_airway_galaaz.rb
2206
2251
  ```
2207
2252
 
2208
2253
  The workflow in Ruby mirrors a standard DESeq2 vignette:
@@ -2229,7 +2274,8 @@ Below is the full listing (same as the file in the repository). It is **not** ex
2229
2274
  manual is knitted, because **DESeq2** is heavy and may be absent on the build machine.
2230
2275
 
2231
2276
  ```{ruby deseq2_airway_full_listing, eval=FALSE}
2232
- # Canonical script: examples/bioconductor_deseq2_airway/deseq2_airway_galaaz.rb
2277
+ # Canonical script:
2278
+ # examples/bioconductor_deseq2_airway/deseq2_airway_galaaz.rb
2233
2279
  # Run: bin/galaaz-ruby examples/.../deseq2_airway_galaaz.rb (repo root).
2234
2280
 
2235
2281
  require 'galaaz'
@@ -2256,7 +2302,8 @@ puts "Samples: #{R.ncol(dds)}"
2256
2302
  puts "Genes after prefilter: #{R.nrow(dds)}"
2257
2303
  puts "Result rows: #{R.nrow(res)}"
2258
2304
  puts "Result columns: #{R.colnames(res)}"
2259
- puts "Significant genes (padj < 0.05): #{R.sum(res.padj < 0.05, na__rm: true)}"
2305
+ puts "Significant genes (padj < 0.05): " +
2306
+ "#{R.sum(res.padj < 0.05, na__rm: true)}"
2260
2307
 
2261
2308
  res_ordered = res[R.order(res.padj), :all]
2262
2309
  puts R.head(R.as__data__frame(res_ordered), 10)
@@ -2271,8 +2318,12 @@ If **DESeq2** and **airway** are installed, the next chunk loads the data and pr
2271
2318
  preview (it does **not** run **`DESeq`** so the manual knits quickly).
2272
2319
 
2273
2320
  ```{ruby deseq2_airway_smoke, message=FALSE, warning=FALSE}
2274
- unless R::Support.eval("requireNamespace('DESeq2', quietly=TRUE) && requireNamespace('airway', quietly=TRUE)")
2275
- puts '(Skip: install DESeq2 and airway via BiocManager in R to run the full example.)'
2321
+ deseq_ok = R::Support.eval(
2322
+ "requireNamespace('DESeq2', quietly=TRUE) && " +
2323
+ "requireNamespace('airway', quietly=TRUE)")
2324
+ unless deseq_ok
2325
+ puts '(Skip: install DESeq2 and airway via ' +
2326
+ 'BiocManager in R for the full example.)'
2276
2327
  else
2277
2328
  R.library('DESeq2')
2278
2329
  R.library('airway')
@@ -2350,13 +2401,17 @@ but in this graph we want the bars to be horizontally laid so we add 'coord\_fli
2350
2401
  ```{ruby diverging_bar, fig.width = 9.1, fig.height = 6.5}
2351
2402
  require 'ggplot'
2352
2403
 
2353
- puts mtcars.ggplot(E.aes(x: :car_name, y: :mpg_z, label: :mpg_z)) +
2354
- R.geom_bar(E.aes(fill: :mpg_type), stat: 'identity', width: 0.5) +
2355
- R.scale_fill_manual(name: 'Mileage',
2356
- labels: R.c('Above Average', 'Below Average'),
2357
- values: R.c('above': '#00ba38', 'below': '#f8766d')) +
2404
+ puts mtcars.ggplot(
2405
+ E.aes(x: :car_name, y: :mpg_z, label: :mpg_z)) +
2406
+ R.geom_bar(E.aes(fill: :mpg_type),
2407
+ stat: 'identity', width: 0.5) +
2408
+ R.scale_fill_manual(
2409
+ name: 'Mileage',
2410
+ labels: R.c('Above Average', 'Below Average'),
2411
+ values: R.c('above': '#00ba38',
2412
+ 'below': '#f8766d')) +
2358
2413
  R.labs(subtitle: "Normalised mileage from 'mtcars'",
2359
- title: "Diverging Bars") +
2414
+ title: "Diverging Bars") +
2360
2415
  R.coord_flip
2361
2416
  ```
2362
2417
 
@@ -2448,7 +2503,8 @@ In Galaaz the method mutate_y below will work fine and will never fail silently.
2448
2503
 
2449
2504
  ```{ruby mutate_y, warning=FALSE}
2450
2505
  def mutate_y(df)
2451
- # Mutate column names are Ruby kwargs (y: …). Use .assign only for R `<-` expressions.
2506
+ # Column names are Ruby kwargs (y: …).
2507
+ # Use .assign only for R `<-` expressions.
2452
2508
  df.mutate(y: R[:a] + R[:x])
2453
2509
  end
2454
2510
  ```
@@ -2465,7 +2521,12 @@ definition of 'mutate\_y' above:
2465
2521
 
2466
2522
  ```{ruby call_mutate_y, warning = FALSE}
2467
2523
  a = 10
2468
- mutate_y(df1)
2524
+ begin
2525
+ mutate_y(df1)
2526
+ rescue => e
2527
+ puts e.class.to_s
2528
+ e.message.to_s.scan(/.{1,68}/).each { |line| puts line }
2529
+ end
2469
2530
  ```
2470
2531
  ## Different expressions
2471
2532
 
@@ -2736,11 +2797,19 @@ def grouped_mean(data, grouping_variables, value_variables)
2736
2797
  data.
2737
2798
  group_by_at(grouping_variables).
2738
2799
  mutate(count: E.n).
2739
- summarise_at(E.c(value_variables, "count"), ~R[:mean], na__rm: true).
2740
- rename_at(value_variables, E.funs(E.paste0("mean_", value_variables)))
2800
+ summarise_at(
2801
+ E.c(value_variables, "count"),
2802
+ ~R[:mean],
2803
+ na__rm: true).
2804
+ rename_at(
2805
+ value_variables,
2806
+ E.funs(E.paste0("mean_", value_variables)))
2741
2807
  end
2742
2808
 
2743
- puts grouped_mean((~R[:starwars]), "eye_color", E.c("mass", "birth_year"))
2809
+ puts grouped_mean(
2810
+ (~R[:starwars]),
2811
+ "eye_color",
2812
+ E.c("mass", "birth_year"))
2744
2813
  ```
2745
2814
 
2746
2815
  The examples above cover programmatic dplyr with string column names and `_at` helpers. The same