biopipen 0.32.1__py3-none-any.whl → 0.32.3__py3-none-any.whl

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.

Potentially problematic release.


This version of biopipen might be problematic. Click here for more details.

Files changed (37) hide show
  1. biopipen/__init__.py +1 -1
  2. biopipen/core/filters.py +45 -6
  3. biopipen/reports/utils/misc.liq +6 -4
  4. biopipen/scripts/delim/SampleInfo.R +10 -1
  5. biopipen/scripts/scrna/CellsDistribution.R +31 -6
  6. biopipen/scripts/scrna/MarkersFinder.R +67 -16
  7. biopipen/scripts/scrna/MetaMarkers.R +16 -7
  8. biopipen/scripts/scrna/RadarPlots.R +22 -2
  9. biopipen/scripts/scrna/SeuratClusterStats-clustree.R +7 -1
  10. biopipen/scripts/scrna/SeuratClusterStats-dimplots.R +9 -2
  11. biopipen/scripts/scrna/SeuratClusterStats-features.R +21 -3
  12. biopipen/scripts/scrna/SeuratClusterStats-hists.R +7 -2
  13. biopipen/scripts/scrna/SeuratClusterStats-ngenes.R +6 -1
  14. biopipen/scripts/scrna/SeuratClusterStats-stats.R +13 -2
  15. biopipen/scripts/scrna/SeuratMap2Ref.R +7 -1
  16. biopipen/scripts/scrna/SeuratPreparing-common.R +15 -0
  17. biopipen/scripts/scrna/SeuratPreparing-doublet_detection.R +6 -3
  18. biopipen/scripts/scrna/TopExpressingGenes.R +9 -7
  19. biopipen/scripts/tcr/CDR3AAPhyschem.R +12 -2
  20. biopipen/scripts/tcr/CloneResidency.R +23 -5
  21. biopipen/scripts/tcr/Immunarch-basic.R +8 -1
  22. biopipen/scripts/tcr/Immunarch-clonality.R +5 -0
  23. biopipen/scripts/tcr/Immunarch-diversity.R +25 -4
  24. biopipen/scripts/tcr/Immunarch-geneusage.R +15 -1
  25. biopipen/scripts/tcr/Immunarch-kmer.R +14 -1
  26. biopipen/scripts/tcr/Immunarch-overlap.R +15 -1
  27. biopipen/scripts/tcr/Immunarch-spectratyping.R +10 -1
  28. biopipen/scripts/tcr/Immunarch-tracking.R +6 -0
  29. biopipen/scripts/tcr/Immunarch-vjjunc.R +33 -0
  30. biopipen/scripts/tcr/TCRClusterStats.R +24 -7
  31. biopipen/scripts/tcr/TESSA.R +6 -1
  32. biopipen/utils/gsea.R +21 -7
  33. biopipen/utils/plot.R +53 -17
  34. {biopipen-0.32.1.dist-info → biopipen-0.32.3.dist-info}/METADATA +2 -2
  35. {biopipen-0.32.1.dist-info → biopipen-0.32.3.dist-info}/RECORD +37 -37
  36. {biopipen-0.32.1.dist-info → biopipen-0.32.3.dist-info}/WHEEL +1 -1
  37. {biopipen-0.32.1.dist-info → biopipen-0.32.3.dist-info}/entry_points.txt +0 -0
biopipen/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.32.1"
1
+ __version__ = "0.32.3"
biopipen/core/filters.py CHANGED
@@ -15,7 +15,7 @@ filtermanager = FilterManager()
15
15
  @filtermanager.register
16
16
  def dict_to_cli_args(
17
17
  dic: Mapping[str, Any],
18
- exclude: List[str] = None,
18
+ exclude: List[str] | None = None,
19
19
  prefix: str | None = None,
20
20
  sep: str | None = " ",
21
21
  dup_key: bool = True,
@@ -118,7 +118,7 @@ def dict_to_cli_args(
118
118
  def r(
119
119
  obj: Any,
120
120
  ignoreintkey: bool = True,
121
- todot: str = None,
121
+ todot: str | None = None,
122
122
  sortkeys: bool = False,
123
123
  skip: int = 0,
124
124
  _i: int = 0,
@@ -271,9 +271,22 @@ def _render_fgsea(
271
271
  "title": "Plot",
272
272
  "ui": "flat",
273
273
  "contents": [
274
+ {
275
+ "kind": "descr",
276
+ "content": (
277
+ "This table presents a comprehensive summary of the "
278
+ "top enriched pathways derived from the fgsea. "
279
+ "Each row corresponds to a pathway, and the gene ranks "
280
+ "are shown based on the ranking metric used in the "
281
+ "analysis. The enrichment score, p-value, and adjusted "
282
+ "p-value are also provided to assess the significance "
283
+ "of the enrichment."
284
+ )
285
+ },
274
286
  {
275
287
  "kind": "image",
276
288
  "src": str(Path(cont["dir"]).joinpath("gsea_table.png")),
289
+ "download": str(Path(cont["dir"]).joinpath("gsea_table.pdf"))
277
290
  }
278
291
  ],
279
292
  },
@@ -281,6 +294,19 @@ def _render_fgsea(
281
294
  "title": "Table",
282
295
  "ui": "flat",
283
296
  "contents": [
297
+ {
298
+ "kind": "descr",
299
+ "content": (
300
+ "This plot represents the GSEA results for a specified "
301
+ "gene set, illustrating the distribution and impact of "
302
+ "the gene set along the ranked list of genes. "
303
+ "The running enrichment score curve shows the "
304
+ "cumulative enrichment score as genes from the input "
305
+ "list are encountered. Positive peaks on the curve "
306
+ "indicate regions where members of the gene set are "
307
+ "predominantly found."
308
+ )
309
+ },
284
310
  {
285
311
  "kind": "table",
286
312
  "src": str(Path(cont["dir"]).joinpath("fgsea.txt")),
@@ -297,6 +323,7 @@ def _render_fgsea(
297
323
  "contents": [
298
324
  {
299
325
  "src": str(Path(cont["dir"]) / f"fgsea_{slug}.png"),
326
+ "download": str(Path(cont["dir"]) / f"fgsea_{slug}.pdf"),
300
327
  "title": pw,
301
328
  }
302
329
  for pw, slug in pathways
@@ -304,7 +331,7 @@ def _render_fgsea(
304
331
  },
305
332
  ]
306
333
 
307
- return render_ui(components, "accordion", job, level)
334
+ return render_ui(components, "accordion", job, level) # type: ignore
308
335
 
309
336
 
310
337
  @register_component("pdf")
@@ -359,11 +386,23 @@ def _render_enrichr(
359
386
  "title": "Plot",
360
387
  "ui": "flat",
361
388
  "contents": [
389
+ {
390
+ "kind": "descr",
391
+ "content": (
392
+ "The enrichment analysis results of the top "
393
+ "biological pathways associated with the input "
394
+ "gene set. Each bar represents a pathway, "
395
+ "with the length of the bar indicating the "
396
+ "number of input genes overlapping with genes "
397
+ "in that pathway. The color intensity of the "
398
+ "bars reflects the statistical significance of "
399
+ "the enrichment (p-value). "
400
+ )
401
+ },
362
402
  {
363
403
  "kind": "image",
364
- "src": str(
365
- Path(cont["dir"]).joinpath(f"Enrichr-{db}.png")
366
- ),
404
+ "src": str(enrichr_plot),
405
+ "download": str(enrichr_plot.with_suffix(".pdf")),
367
406
  }
368
407
  ],
369
408
  },
@@ -43,10 +43,12 @@ import { Image } from "$libs";
43
43
  {{ caps[i] }}
44
44
  </div>
45
45
  {% endif %}
46
- <Image
47
- style="max-width: 90%"
48
- src={{src | quote}}
49
- />
46
+ {% if src | replace: ".png", ".pdf" | exists %}
47
+ <Image style="max-width: 90%" src={{src | quote}}
48
+ download={{src | replace: ".png", ".pdf" | quote}} />
49
+ {% else %}
50
+ <Image style="max-width: 90%" src={{src | quote}} />
51
+ {% endif %}
50
52
  </td>
51
53
  {% endif %}
52
54
  {% endfor %}
@@ -186,6 +186,15 @@ for (name in names(stats)) {
186
186
  print(p)
187
187
  dev.off()
188
188
 
189
+ plotfile_pdf <- file.path(outdir, paste0(name, ".pdf"))
190
+ pdf(
191
+ plotfile_pdf,
192
+ width = stat$devpars$width / stat$devpars$res,
193
+ height = stat$devpars$height / stat$devpars$res
194
+ )
195
+ print(p)
196
+ dev.off()
197
+
189
198
  by_desc <- ifelse(is.null(stat$by), "", paste0(" by ", stat$by))
190
199
  descr <- ifelse(
191
200
  is_continuous,
@@ -193,7 +202,7 @@ for (name in names(stats)) {
193
202
  paste0("The number of ", stat$on, by_desc)
194
203
  )
195
204
  add_report(
196
- list(kind = "table_image", src = plotfile, name = name, descr = descr),
205
+ list(kind = "table_image", src = plotfile, name = name, descr = descr, download = plotfile_pdf),
197
206
  h1 = "Statistics",
198
207
  ui = "table_of_images:2"
199
208
  )
@@ -368,9 +368,17 @@ do_case <- function(name, case) {
368
368
  width <- devpars$width %||% (400 + 120 + 100 * ngroups)
369
369
  # group_by names
370
370
  height <- devpars$height %||% (120 + 100 * cells_rows)
371
+
372
+ p <- wrap_plots(piecharts, ncol = 1, guides = "collect")
373
+
371
374
  piefile <- file.path(info$casedir, paste0(info$case_slug, ".png"))
372
375
  png(piefile, res = res, width = width, height = height)
373
- print(wrap_plots(piecharts, ncol = 1, guides = "collect"))
376
+ print(p)
377
+ dev.off()
378
+
379
+ piefile_pdf <- file.path(info$casedir, paste0(info$case_slug, ".pdf"))
380
+ pdf(piefile_pdf, width = width / res, height = height / res)
381
+ print(p)
374
382
  dev.off()
375
383
 
376
384
  log_info(" Plotting and saving heatmap ...")
@@ -411,7 +419,6 @@ do_case <- function(name, case) {
411
419
  hm_res <- hm_devpars$res %||% 100
412
420
  hm_width <- hm_devpars$width %||% (600 + 15 * length(unique(meta$seurat_clusters)) + extra_width)
413
421
  hm_height <- hm_devpars$height %||% (450 + 15 * cells_rows + extra_height)
414
- png(hmfile, res = hm_res, width = hm_width, height = hm_height)
415
422
  hm <- Heatmap(
416
423
  as.matrix(hmdata),
417
424
  name = "Size",
@@ -430,6 +437,12 @@ do_case <- function(name, case) {
430
437
  right_annotation = row_ha,
431
438
  top_annotation = ha
432
439
  )
440
+ png(hmfile, res = hm_res, width = hm_width, height = hm_height)
441
+ print(hm)
442
+ dev.off()
443
+
444
+ hmfile_pdf <- gsub(".png$", ".pdf", hmfile)
445
+ pdf(hmfile_pdf, width = hm_width / hm_res, height = hm_height / hm_res)
433
446
  print(hm)
434
447
  dev.off()
435
448
 
@@ -454,11 +467,11 @@ do_case <- function(name, case) {
454
467
  add_report(
455
468
  list(
456
469
  name = "Pie Charts",
457
- contents = list(list(kind = "image", src = piefile))
470
+ contents = list(list(kind = "image", src = piefile, download = piefile_pdf))
458
471
  ),
459
472
  list(
460
473
  name = "Heatmap",
461
- contents = list(list(src = hmfile, kind = "image"))
474
+ contents = list(list(src = hmfile, kind = "image", download = hmfile_pdf))
462
475
  ),
463
476
  list(
464
477
  name = "Distribution Table",
@@ -493,25 +506,37 @@ do_overlap <- function(section) {
493
506
  print(venn_p)
494
507
  dev.off()
495
508
 
509
+ venn_plot_pdf <- gsub(".png$", ".pdf", venn_plot)
510
+ pdf(venn_plot_pdf, width = 10, height = 6)
511
+ print(venn_p)
512
+ dev.off()
513
+
496
514
  upset_plot <- file.path(sec_dir, "upset.png")
497
515
  upset_p <- upset(fromList(overlap_cases))
498
516
  png(upset_plot, res = 100, width = 800, height = 600)
499
517
  print(upset_p)
500
518
  dev.off()
501
519
 
520
+ upset_plot_pdf <- gsub(".png$", ".pdf", upset_plot)
521
+ pdf(upset_plot_pdf, width = 8, height = 6)
522
+ print(upset_p)
523
+ dev.off()
524
+
502
525
  add_report(
503
526
  list(
504
527
  name = "Venn Plot",
505
528
  contents = list(list(
506
529
  kind = "image",
507
- src = venn_plot
530
+ src = venn_plot,
531
+ download = venn_plot_pdf
508
532
  ))
509
533
  ),
510
534
  list(
511
535
  name = "UpSet Plot",
512
536
  contents = list(list(
513
537
  kind = "image",
514
- src = upset_plot
538
+ src = upset_plot,
539
+ download = upset_plot_pdf
515
540
  ))
516
541
  ),
517
542
  h1 = "Overlapping Groups",
@@ -208,6 +208,11 @@ plot_volcano = function(markers, volfile, sig, volgenes) {
208
208
  png(volfile, res = 100, height = 1200, width = 900)
209
209
  print(p_vol)
210
210
  dev.off()
211
+
212
+ volfile_pdf <- gsub(".png$", ".pdf", volfile)
213
+ pdf(volfile_pdf, width = 9, height = 12)
214
+ print(p_vol)
215
+ dev.off()
211
216
  }
212
217
 
213
218
  # Do enrichment analysis for a case using Enrichr
@@ -256,14 +261,16 @@ do_enrich <- function(info, markers, sig, volgenes) {
256
261
  log_warn(" No enrichment found for case: {info$casename} - {db}")
257
262
  next
258
263
  }
259
- png(
260
- file.path(info$casedir, paste0("Enrichr-", db, ".png")),
261
- res = 100, height = 1000, width = 1000
262
- )
263
- print(
264
- plotEnrich(enriched[[db]], showTerms = 20, title = db) +
264
+ enrich_p <- plotEnrich(enriched[[db]], showTerms = 20, title = db) +
265
265
  theme_prism()
266
- )
266
+ enrich_plot <- file.path(info$casedir, paste0("Enrichr-", db, ".png"))
267
+ png(enrich_plot, res = 100, height = 1000, width = 1000)
268
+ print(enrich_p)
269
+ dev.off()
270
+
271
+ enrich_plot_pdf <- gsub(".png$", ".pdf", enrich_plot)
272
+ pdf(enrich_plot_pdf, width = 10, height = 10)
273
+ print(enrich_p)
267
274
  dev.off()
268
275
  }
269
276
  }
@@ -287,13 +294,17 @@ do_dotplot <- function(info, siggenes, dotplot, args) {
287
294
  dotplot_height <- dotplot_devpars$height %||% 600
288
295
  dotplot_res <- dotplot_devpars$res %||% 100
289
296
  dotplot_file <- file.path(info$casedir, "dotplot.png")
290
- png(dotplot_file, res = dotplot_res, width = dotplot_height, height = dotplot_width)
291
- # rotate x axis labels
292
- print(
293
- do_call(DotPlot, dotplot) +
297
+ dot_p <- do_call(DotPlot, dotplot) +
294
298
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
295
299
  coord_flip()
296
- )
300
+ png(dotplot_file, res = dotplot_res, width = dotplot_height, height = dotplot_width)
301
+ # rotate x axis labels
302
+ print(dot_p)
303
+ dev.off()
304
+
305
+ dotplot_file_pdf <- gsub(".png$", ".pdf", dotplot_file)
306
+ pdf(dotplot_file_pdf, width = dotplot_height / dotplot_res, height = dotplot_width / dotplot_res)
307
+ print(dot_p)
297
308
  dev.off()
298
309
  }
299
310
 
@@ -336,9 +347,19 @@ add_case_report <- function(info, sigmarkers, siggenes) {
336
347
  title = "Volcano Plot",
337
348
  ui = "flat",
338
349
  contents = list(
350
+ list(
351
+ kind = "descr",
352
+ content = paste0(
353
+ "The volcano plot is generated using ggplot2. ",
354
+ "The significant markers are highlighted in blue and red, ",
355
+ "indicating up-regulated and down-regulated genes, respectively. ",
356
+ "The non-significant genes are shown in grey. "
357
+ )
358
+ ),
339
359
  list(
340
360
  kind = "img",
341
- src = file.path(info$casedir, "volcano.png")
361
+ src = file.path(info$casedir, "volcano.png"),
362
+ download = file.path(info$casedir, "volcano.pdf")
342
363
  )
343
364
  )
344
365
  ),
@@ -346,9 +367,21 @@ add_case_report <- function(info, sigmarkers, siggenes) {
346
367
  title = "Dot Plot",
347
368
  ui = "flat",
348
369
  contents = list(
370
+ list(
371
+ kind = "descr",
372
+ content = paste0(
373
+ "The dot plot is generated using Seurat's DotPlot function. ",
374
+ "The top significant markers are used as input. ",
375
+ "The sizes of the dots are proportional to the percentage of cells ",
376
+ "expressing the gene in each group. ",
377
+ "The colors of the dots are proportional to the average expression ",
378
+ "of the gene in each group. "
379
+ )
380
+ ),
349
381
  list(
350
382
  kind = "img",
351
- src = file.path(info$casedir, "dotplot.png")
383
+ src = file.path(info$casedir, "dotplot.png"),
384
+ download = file.path(info$casedir, "dotplot.pdf")
352
385
  )
353
386
  )
354
387
  ),
@@ -613,6 +646,14 @@ do_overlap <- function(section) {
613
646
  do.call(png, ov_args$venn$devpars)
614
647
  print(venn_p)
615
648
  dev.off()
649
+
650
+ venn_plot_pdf <- file.path(ov_dir, "venn.pdf")
651
+ pdf(
652
+ venn_plot_pdf,
653
+ width = ov_args$venn$devpars$width / ov_args$venn$devpars$res,
654
+ height = ov_args$venn$devpars$height / ov_args$venn$devpars$res)
655
+ print(venn_p)
656
+ dev.off()
616
657
  }
617
658
 
618
659
  df_markers <- fromList(ov_cases)
@@ -654,6 +695,14 @@ do_overlap <- function(section) {
654
695
  do.call(png, ov_args$upset$devpars)
655
696
  print(upset_p)
656
697
  dev.off()
698
+
699
+ upset_plot_pdf <- file.path(ov_dir, "upset.pdf")
700
+ pdf(
701
+ upset_plot_pdf,
702
+ width = ov_args$upset$devpars$width / ov_args$upset$devpars$res,
703
+ height = ov_args$upset$devpars$height / ov_args$upset$devpars$res)
704
+ print(upset_p)
705
+ dev.off()
657
706
  }
658
707
 
659
708
  add_report(
@@ -663,7 +712,8 @@ do_overlap <- function(section) {
663
712
  contents = list(
664
713
  list(
665
714
  kind = "img",
666
- src = file.path(ov_dir, "venn.png")
715
+ src = file.path(ov_dir, "venn.png"),
716
+ download = file.path(ov_dir, "venn.pdf")
667
717
  )
668
718
  )
669
719
  ),
@@ -673,7 +723,8 @@ do_overlap <- function(section) {
673
723
  contents = list(
674
724
  list(
675
725
  kind = "img",
676
- src = file.path(ov_dir, "upset.png")
726
+ src = file.path(ov_dir, "upset.png"),
727
+ download = file.path(ov_dir, "upset.pdf")
677
728
  )
678
729
  )
679
730
  ),
@@ -171,14 +171,17 @@ do_enrich <- function(info, markers, sig) {
171
171
  next
172
172
  }
173
173
 
174
- png(
175
- file.path(info$casedir, paste0("Enrichr-", db, ".png")),
176
- res = 100, height = 600, width = 800
177
- )
178
- print(
179
- plotEnrich(enriched[[db]], showTerms = 20, title = db) +
174
+ p <- plotEnrich(enriched[[db]], showTerms = 20, title = db) +
180
175
  theme_prism()
181
- )
176
+
177
+ plotfile <- file.path(info$casedir, paste0("Enrichr-", db, ".png"))
178
+ png(plotfile, res = 100, height = 600, width = 800)
179
+ print(p)
180
+ dev.off()
181
+
182
+ plotfile_pdf <- gsub(".png$", ".pdf", plotfile)
183
+ pdf(plotfile_pdf, height = 6, width = 8)
184
+ print(p)
182
185
  dev.off()
183
186
  }
184
187
  }
@@ -292,9 +295,15 @@ do_case <- function(casename) {
292
295
  print(p)
293
296
  dev.off()
294
297
 
298
+ outfile_pdf <- gsub(".png$", ".pdf", outfile)
299
+ pdf(outfile_pdf, height = 6, width = 8)
300
+ print(p)
301
+ dev.off()
302
+
295
303
  geneplots[[length(geneplots) + 1]] <- list(
296
304
  kind = "table_image",
297
305
  src = outfile,
306
+ download = outfile_pdf,
298
307
  name = gene
299
308
  )
300
309
  }
@@ -193,6 +193,7 @@ do_radarplot <- function(info, case, counts) {
193
193
 
194
194
  # Plot
195
195
  plotfile = file.path(info$casedir, "plot.png")
196
+ plotfile_pdf = file.path(info$casedir, "plot.pdf")
196
197
  if (!is.null(case$colors) && length(case$colors) == 1 && case$colors == "biopipen") {
197
198
  colors = pal_biopipen()(nrow(rdr_data))
198
199
  } else if (!is.null(case$colors) && length(case$colors) > 0) {
@@ -217,6 +218,14 @@ do_radarplot <- function(info, case, counts) {
217
218
  )
218
219
  print(p)
219
220
  dev.off()
221
+
222
+ pdf(
223
+ plotfile_pdf,
224
+ width = case$devpars$width / case$devpars$res,
225
+ height = case$devpars$height / case$devpars$res
226
+ )
227
+ print(p)
228
+ dev.off()
220
229
  }
221
230
 
222
231
  do_barplot_and_tests <- function(info, case, counts) {
@@ -268,6 +277,7 @@ do_barplot_and_tests <- function(info, case, counts) {
268
277
 
269
278
  # Plot the barplot
270
279
  plotfile = file.path(info$casedir, "barplot.png")
280
+ plotfile_pdf = file.path(info$casedir, "barplot.pdf")
271
281
  p = ggplot(plotdata, aes(x = !!sym(case$ident), y = .mean, fill = !!sym(case$by))) +
272
282
  geom_bar(stat = "identity", position = "dodge") +
273
283
  geom_errorbar(
@@ -295,6 +305,14 @@ do_barplot_and_tests <- function(info, case, counts) {
295
305
  print(p)
296
306
  dev.off()
297
307
 
308
+ pdf(
309
+ plotfile_pdf,
310
+ width = case$bar_devpars$width / case$bar_devpars$res,
311
+ height = case$bar_devpars$height / case$bar_devpars$res
312
+ )
313
+ print(p)
314
+ dev.off()
315
+
298
316
  # Do the tests in each cluster between groups on .frac
299
317
  bys <- bardata %>% pull(!!sym(case$by)) %>% unique()
300
318
  if (!is.null(case$test) && test != "none") {
@@ -348,7 +366,8 @@ add_case_report = function(info, breakdown, test) {
348
366
  contents = list(
349
367
  list(
350
368
  kind = "image",
351
- src = file.path(info$casedir, "plot.png")
369
+ src = file.path(info$casedir, "plot.png"),
370
+ download = file.path(info$casedir, "plot.pdf")
352
371
  )
353
372
  )
354
373
  ),
@@ -381,7 +400,8 @@ add_case_report = function(info, breakdown, test) {
381
400
  contents = list(
382
401
  list(
383
402
  kind = "image",
384
- src = file.path(info$casedir, "barplot.png")
403
+ src = file.path(info$casedir, "barplot.png"),
404
+ download = file.path(info$casedir, "barplot.pdf")
385
405
  )
386
406
  )
387
407
  ))
@@ -46,9 +46,14 @@ if (
46
46
  command <- srtobj@commands[[paste0("FindClusters.", prefix)]] %||%
47
47
  (if(prefix == "seurat_clusters") srtobj@commands$FindClusters else NULL)
48
48
 
49
+ p <- do_call(clustree, case)
49
50
  clustree_file <- file.path(odir, paste0(prefix, ".clustree.png"))
50
51
  png(clustree_file, width = devpars$width, height = devpars$height, res = devpars$res)
51
- p <- do_call(clustree, case)
52
+ print(p)
53
+ dev.off()
54
+
55
+ clustree_file_pdf <- file.path(odir, paste0(prefix, ".clustree.pdf"))
56
+ pdf(clustree_file_pdf, width = devpars$width / devpars$res, height = devpars$height / devpars$res)
52
57
  print(p)
53
58
  dev.off()
54
59
 
@@ -62,6 +67,7 @@ if (
62
67
  reports[[length(reports) + 1]] <- list(
63
68
  kind = "table_image",
64
69
  src = clustree_file,
70
+ download = clustree_file_pdf,
65
71
  name = name,
66
72
  descr = paste0("Resolutions: ", paste(resolution, collapse = ", "), "; resolution used: ", resolution_used)
67
73
  )
@@ -49,9 +49,15 @@ do_one_dimplot = function(name) {
49
49
 
50
50
  if (case$reduction %in% c("dim", "auto")) { case$reduction = NULL }
51
51
  case$na_group <- NULL
52
+
53
+ p = do_call(DimPlot, case)
52
54
  figfile = file.path(odir, paste0(slugify(name), ".dim.png"))
53
55
  png(figfile, width=devpars$width, height=devpars$height, res=devpars$res)
54
- p = do_call(DimPlot, case)
56
+ print(p)
57
+ dev.off()
58
+
59
+ figfile_pdf = file.path(odir, paste0(slugify(name), ".dim.pdf"))
60
+ pdf(figfile_pdf, width=devpars$width / devpars$res, height=devpars$height / devpars$res)
55
61
  print(p)
56
62
  dev.off()
57
63
 
@@ -62,7 +68,8 @@ do_one_dimplot = function(name) {
62
68
  ),
63
69
  list(
64
70
  kind = "image",
65
- src = figfile
71
+ src = figfile,
72
+ download = figfile_pdf
66
73
  ),
67
74
  h1 = name
68
75
  )
@@ -224,6 +224,7 @@ do_one_features = function(name) {
224
224
 
225
225
  if (kind == "bar") {
226
226
  figfile <- file.path(odir, paste0(slugify(name), ".bar.png"))
227
+ figfile_pdf <- file.path(odir, paste0(slugify(name), ".bar.pdf"))
227
228
  genes <- rownames(GetAssayData(case$object))
228
229
  genes <- genes[sapply(genes, function(x) grepl(x, case$features))]
229
230
  if (length(genes) == 0) {
@@ -265,6 +266,10 @@ do_one_features = function(name) {
265
266
  print(p)
266
267
  dev.off()
267
268
 
269
+ pdf(figfile_pdf, width = devpars$width / devpars$res, height = devpars$height / devpars$res)
270
+ print(p)
271
+ dev.off()
272
+
268
273
  add_report(
269
274
  list(
270
275
  kind = "descr",
@@ -272,7 +277,8 @@ do_one_features = function(name) {
272
277
  ),
273
278
  list(
274
279
  kind = "image",
275
- src = figfile
280
+ src = figfile,
281
+ download = figfile_pdf
276
282
  ),
277
283
  h1 = ifelse(is.null(section), name, section),
278
284
  h2 = ifelse(is.null(section), "#", name)
@@ -284,6 +290,7 @@ do_one_features = function(name) {
284
290
  case$features = .get_features(case$features)
285
291
  if (kind == "avgheatmap") {
286
292
  figfile <- file.path(odir, paste0(slugify(name), ".avgheatmap.png"))
293
+ figfile_pdf <- file.path(odir, paste0(slugify(name), ".avgheatmap.pdf"))
287
294
  assay <- assay %||% DefaultAssay(object)
288
295
  layer <- layer %||% ifelse("scale.data" %in% Layers(object, assay = assay), "scale.data", "data")
289
296
 
@@ -353,6 +360,10 @@ do_one_features = function(name) {
353
360
  print(p)
354
361
  dev.off()
355
362
 
363
+ pdf(figfile_pdf, width = devpars$width / devpars$res, height = devpars$height / devpars$res)
364
+ print(p)
365
+ dev.off()
366
+
356
367
  add_report(
357
368
  list(
358
369
  kind = "descr",
@@ -360,7 +371,8 @@ do_one_features = function(name) {
360
371
  ),
361
372
  list(
362
373
  kind = "image",
363
- src = figfile
374
+ src = figfile,
375
+ download = figfile_pdf
364
376
  ),
365
377
  h1 = ifelse(is.null(section), name, section),
366
378
  h2 = ifelse(is.null(section), "#", name)
@@ -430,6 +442,11 @@ do_one_features = function(name) {
430
442
  })
431
443
  dev.off()
432
444
 
445
+ figfile_pdf = gsub(".png$", ".pdf", figfile)
446
+ pdf(figfile_pdf, width=devpars$width / devpars$res, height=devpars$height / devpars$res)
447
+ print(p)
448
+ dev.off()
449
+
433
450
  add_report(
434
451
  list(
435
452
  kind = "descr",
@@ -437,7 +454,8 @@ do_one_features = function(name) {
437
454
  ),
438
455
  list(
439
456
  kind = "image",
440
- src = figfile
457
+ src = figfile,
458
+ download = figfile_pdf
441
459
  ),
442
460
  h1 = ifelse(is.null(section), name, section),
443
461
  h2 = ifelse(is.null(section), "#", name)
@@ -6,6 +6,7 @@ log_info("hists:")
6
6
 
7
7
  do_one_hists <- function(m, case, odir, h1, each = NULL) {
8
8
  ofile <- file.path(odir, paste0(slugify(h1), ifelse(is.null(each), "", paste0("-", slugify(each))), ".png"))
9
+ ofile_pdf <- gsub(".png$", ".pdf", ofile)
9
10
 
10
11
  p <- ggplot(m, aes(x=!!sym(case$x))) +
11
12
  geom_histogram(
@@ -42,16 +43,20 @@ do_one_hists <- function(m, case, odir, h1, each = NULL) {
42
43
  print(p)
43
44
  dev.off()
44
45
 
46
+ pdf(ofile_pdf, width=devpars$width / devpars$res, height=devpars$height / devpars$res)
47
+ print(p)
48
+ dev.off()
49
+
45
50
  # Add report
46
51
  if (!is.null(each)) {
47
52
  add_report(
48
- list(src = ofile, descr = first(m[[case$each]])),
53
+ list(src = ofile, descr = first(m[[case$each]]), download = ofile_pdf),
49
54
  h1 = h1,
50
55
  ui = "table_of_images"
51
56
  )
52
57
  } else {
53
58
  add_report(
54
- list(kind = "image", src = ofile),
59
+ list(kind = "image", src = ofile, download = ofile_pdf),
55
60
  h1 = h1
56
61
  )
57
62
  }