biopipen 0.32.0__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 (39) hide show
  1. biopipen/__init__.py +1 -1
  2. biopipen/core/filters.py +45 -6
  3. biopipen/reports/scrna/TopExpressingGenes.svelte +1 -1
  4. biopipen/reports/utils/misc.liq +6 -4
  5. biopipen/scripts/delim/SampleInfo.R +10 -1
  6. biopipen/scripts/scrna/CellsDistribution.R +31 -6
  7. biopipen/scripts/scrna/MarkersFinder.R +67 -16
  8. biopipen/scripts/scrna/MetaMarkers.R +16 -7
  9. biopipen/scripts/scrna/RadarPlots.R +22 -2
  10. biopipen/scripts/scrna/ScFGSEA.R +1 -1
  11. biopipen/scripts/scrna/SeuratClusterStats-clustree.R +7 -1
  12. biopipen/scripts/scrna/SeuratClusterStats-dimplots.R +9 -2
  13. biopipen/scripts/scrna/SeuratClusterStats-features.R +22 -4
  14. biopipen/scripts/scrna/SeuratClusterStats-hists.R +7 -2
  15. biopipen/scripts/scrna/SeuratClusterStats-ngenes.R +6 -1
  16. biopipen/scripts/scrna/SeuratClusterStats-stats.R +13 -2
  17. biopipen/scripts/scrna/SeuratMap2Ref.R +7 -1
  18. biopipen/scripts/scrna/SeuratPreparing-common.R +21 -6
  19. biopipen/scripts/scrna/SeuratPreparing-doublet_detection.R +6 -3
  20. biopipen/scripts/scrna/TopExpressingGenes.R +9 -7
  21. biopipen/scripts/tcr/CDR3AAPhyschem.R +12 -2
  22. biopipen/scripts/tcr/CloneResidency.R +23 -5
  23. biopipen/scripts/tcr/Immunarch-basic.R +8 -1
  24. biopipen/scripts/tcr/Immunarch-clonality.R +5 -0
  25. biopipen/scripts/tcr/Immunarch-diversity.R +25 -4
  26. biopipen/scripts/tcr/Immunarch-geneusage.R +15 -1
  27. biopipen/scripts/tcr/Immunarch-kmer.R +14 -1
  28. biopipen/scripts/tcr/Immunarch-overlap.R +15 -1
  29. biopipen/scripts/tcr/Immunarch-spectratyping.R +10 -1
  30. biopipen/scripts/tcr/Immunarch-tracking.R +6 -0
  31. biopipen/scripts/tcr/Immunarch-vjjunc.R +33 -0
  32. biopipen/scripts/tcr/TCRClusterStats.R +24 -7
  33. biopipen/scripts/tcr/TESSA.R +6 -1
  34. biopipen/utils/gsea.R +21 -7
  35. biopipen/utils/plot.R +53 -17
  36. {biopipen-0.32.0.dist-info → biopipen-0.32.3.dist-info}/METADATA +3 -2
  37. {biopipen-0.32.0.dist-info → biopipen-0.32.3.dist-info}/RECORD +39 -39
  38. {biopipen-0.32.0.dist-info → biopipen-0.32.3.dist-info}/WHEEL +1 -1
  39. {biopipen-0.32.0.dist-info → biopipen-0.32.3.dist-info}/entry_points.txt +0 -0
@@ -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
  }
@@ -14,6 +14,7 @@ do_one_ngenes <- function(name) {
14
14
  case$devpars <- list_update(ngenes_defaults$devpars, case$devpars)
15
15
 
16
16
  figfile = file.path(odir, paste0(slugify(name), ".boxplot.png"))
17
+ figfile_pdf = file.path(odir, paste0(slugify(name), ".boxplot.pdf"))
17
18
 
18
19
  if (!is.null(case$subset)) {
19
20
  sobj <- srtobj %>% filter(!!rlang::parse_expr(case$subset))
@@ -49,6 +50,10 @@ do_one_ngenes <- function(name) {
49
50
  print(p)
50
51
  dev.off()
51
52
 
53
+ pdf(figfile_pdf, width=case$devpars$width / case$devpars$res, height=case$devpars$height / case$devpars$res)
54
+ print(p)
55
+ dev.off()
56
+
52
57
  add_report(
53
58
  list(
54
59
  kind = "descr",
@@ -62,7 +67,7 @@ do_one_ngenes <- function(name) {
62
67
  )
63
68
  )
64
69
  ),
65
- list(kind = "image", src = figfile),
70
+ list(kind = "image", src = figfile, download = figfile_pdf),
66
71
  h1 = name
67
72
  )
68
73
  }
@@ -23,8 +23,11 @@ do_one_stats = function(name) {
23
23
  }
24
24
 
25
25
  figfile = file.path(odir, paste0(slugify(name), ".bar.png"))
26
+ figfile_pdf = file.path(odir, paste0(slugify(name), ".bar.pdf"))
26
27
  piefile = file.path(odir, paste0(slugify(name), ".pie.png"))
28
+ piefile_pdf = file.path(odir, paste0(slugify(name), ".pie.pdf"))
27
29
  circosfile = file.path(odir, paste0(slugify(name), ".circos.png"))
30
+ circosfile_pdf = file.path(odir, paste0(slugify(name), ".circos.pdf"))
28
31
  samtablefile = file.path(odir, paste0(slugify(name), ".bysample.txt"))
29
32
  tablefile = file.path(odir, paste0(slugify(name), ".txt"))
30
33
 
@@ -98,6 +101,10 @@ do_one_stats = function(name) {
98
101
  print(p)
99
102
  dev.off()
100
103
 
104
+ pdf(figfile_pdf, width=case$devpars$width / case$devpars$res, height=case$devpars$height / case$devpars$res)
105
+ print(p)
106
+ dev.off()
107
+
101
108
  add_report(
102
109
  list(
103
110
  kind = "descr",
@@ -118,7 +125,7 @@ do_one_stats = function(name) {
118
125
  add_report(
119
126
  list(
120
127
  name = "Bar Plot",
121
- contents = list(list(kind = "image", src = figfile))
128
+ contents = list(list(kind = "image", src = figfile, download = figfile_pdf))
122
129
  ),
123
130
  h1 = name,
124
131
  ui = "tabs"
@@ -162,10 +169,14 @@ do_one_stats = function(name) {
162
169
  print(p_pie)
163
170
  dev.off()
164
171
 
172
+ pdf(piefile_pdf, width=case$pie_devpars$width / case$pie_devpars$res, height=case$pie_devpars$height / case$pie_devpars$res)
173
+ print(p_pie)
174
+ dev.off()
175
+
165
176
  add_report(
166
177
  list(
167
178
  name = "Pie Chart",
168
- contents = list(list(kind = "image", src = piefile))
179
+ contents = list(list(kind = "image", src = piefile, download = piefile_pdf))
169
180
  ),
170
181
  h1 = name,
171
182
  ui = "tabs"
@@ -378,7 +378,13 @@ for (qname in names(mapquery_args$refdata)) {
378
378
  repel = TRUE,
379
379
  ) + NoLegend()
380
380
 
381
- png(file.path(outdir, paste0("UMAPs-", slugify(qname), ".png")), width = 1500, height = 700, res = 100)
381
+ plotfile <- file.path(outdir, paste0("UMAPs-", slugify(qname), ".png"))
382
+ png(plotfile, width = 1500, height = 700, res = 100)
383
+ print(ref_p | query_p)
384
+ dev.off()
385
+
386
+ plotfile_pdf <- file.path(outdir, paste0("UMAPs-", slugify(qname), ".pdf"))
387
+ pdf(plotfile_pdf, width = 15, height = 7)
382
388
  print(ref_p | query_p)
383
389
  dev.off()
384
390
 
@@ -35,10 +35,10 @@ rename_files = function(e, sample, path) {
35
35
  perform_cell_qc <- function(sobj, per_sample = FALSE) {
36
36
  log_prefix <- ifelse(per_sample, " ", "- ")
37
37
  log_info("{log_prefix}Adding metadata for QC ...")
38
- sobj$percent.mt <- PercentageFeatureSet(sobj, pattern = "^MT-")
39
- sobj$percent.ribo <- PercentageFeatureSet(sobj, pattern = "^RP[SL]")
40
- sobj$percent.hb <- PercentageFeatureSet(sobj, pattern = "^HB[^(P)]")
41
- sobj$percent.plat <- PercentageFeatureSet(sobj, pattern = "PECAM1|PF4")
38
+ sobj$percent.mt <- PercentageFeatureSet(sobj, pattern = "^MT-|^Mt-|^mt-")
39
+ sobj$percent.ribo <- PercentageFeatureSet(sobj, pattern = "^RP[SL]|^Rp[sl]")
40
+ sobj$percent.hb <- PercentageFeatureSet(sobj, pattern = "^HB[^P]|^Hb[^p]")
41
+ sobj$percent.plat <- PercentageFeatureSet(sobj, pattern = "PECAM1|PF4|Pecam1|Pf4")
42
42
 
43
43
  if (is.null(envs$cell_qc) || length(envs$cell_qc) == 0) {
44
44
  log_warn("{log_prefix}No cell QC criteria is provided. All cells will be kept.")
@@ -97,10 +97,19 @@ report_cell_qc = function(ngenes) {
97
97
  print(vln_p)
98
98
  dev.off()
99
99
 
100
+ vlnplot_pdf = file.path(plotsdir, paste0(slugify(feat), ".vln.pdf"))
101
+ pdf(
102
+ vlnplot_pdf,
103
+ width = (800 + length(samples) * 15) / 100, height = 600 / 100
104
+ )
105
+ print(vln_p)
106
+ dev.off()
107
+
100
108
  add_report(
101
109
  list(
102
110
  src = vlnplot,
103
111
  name = feat,
112
+ download = vlnplot_pdf,
104
113
  descr = paste0("Distribution of ", feat, " for each sample.")
105
114
  ),
106
115
  h1 = "Violin Plots",
@@ -135,10 +144,16 @@ report_cell_qc = function(ngenes) {
135
144
  print(scat_p)
136
145
  dev.off()
137
146
 
147
+ scatfile_pdf = file.path(plotsdir, paste0(slugify(feat), "-nCount_RNA.scatter.pdf"))
148
+ pdf(scatfile_pdf, width = 8, height = 6)
149
+ print(scat_p)
150
+ dev.off()
151
+
138
152
  add_report(
139
153
  list(
140
154
  src = scatfile,
141
155
  name = paste0(feat, " vs nCount_RNA"),
156
+ download = scatfile_pdf,
142
157
  descr = paste0("Scatter plot for ", feat, " against nCount_RNA")
143
158
  ),
144
159
  h1 = "Scatter Plots",
@@ -210,7 +225,7 @@ load_sample = function(sample) {
210
225
 
211
226
  if (isTRUE(envs$cell_qc_per_sample)) {
212
227
  log_info("- Perform cell QC for sample: {sample} ...")
213
- obj = perform_cell_qc(obj, TRUE)
228
+ obj = perform_cell_qc(obj, per_sample = TRUE)
214
229
  }
215
230
 
216
231
  if (isTRUE(envs$use_sct)) {
@@ -287,7 +302,7 @@ run_cell_qc <- function(sobj) {
287
302
 
288
303
  if (!envs$cell_qc_per_sample) {
289
304
  log_info("Performing cell QC ...")
290
- sobj = perform_cell_qc(sobj)
305
+ sobj = perform_cell_qc(sobj, per_sample = FALSE)
291
306
  }
292
307
 
293
308
  cached$data <- list(sobj = sobj, cell_qc_df = cell_qc_df)
@@ -158,6 +158,7 @@ plot_dd <- function(sobj, dd, detector) {
158
158
  sobj, group.by = paste0(detector, "_DropletType"), order = "doublet",
159
159
  cols = c("#333333", "#FF3333"), pt.size = 0.8, alpha = 0.5)
160
160
  ggsave(dimp, filename = file.path(plotsdir, paste0(detector, "_dimplot.png")))
161
+ ggsave(dimp, filename = file.path(plotsdir, paste0(detector, "_dimplot.pdf")))
161
162
  }
162
163
 
163
164
  filter_dd <- function(sobj, dd, detector) {
@@ -184,15 +185,17 @@ report_dd <- function(detector) {
184
185
 
185
186
  if (detector == "DoubletFinder") {
186
187
  add_report(
187
- list(name = "pK vs BCmetric", src = file.path(plotsdir, "pK_BCmetric.png")),
188
- list(name = "Dimension Reduction Plot", src = file.path(plotsdir, "DoubletFinder_dimplot.png")),
188
+ list(name = "pK vs BCmetric", src = file.path(plotsdir, "DoubletFinder_pK_BCmetric.png")),
189
+ list(name = "Dimension Reduction Plot", src = file.path(plotsdir, "DoubletFinder_dimplot.png"),
190
+ download = file.path(plotsdir, "DoubletFinder_dimplot.pdf")),
189
191
  ui = "table_of_images",
190
192
  h1 = "DoubletFinder Results",
191
193
  h2 = "Plots"
192
194
  )
193
195
  } else {
194
196
  add_report(
195
- list(name = "Dimension Reduction Plot",src = file.path(plotsdir, "scDblFinder_dimplot.png")),
197
+ list(name = "Dimension Reduction Plot", src = file.path(plotsdir, "scDblFinder_dimplot.png"),
198
+ download = file.path(plotsdir, "scDblFinder_dimplot.pdf")),
196
199
  ui = "table_of_images",
197
200
  h1 = "scDblFinder Results",
198
201
  h2 = "Plots"
@@ -161,14 +161,16 @@ do_enrich <- function(expr, odir) {
161
161
  next
162
162
  }
163
163
 
164
- png(
165
- file.path(odir, paste0("Enrichr-", db, ".png")),
166
- res = 100, height = 1000, width = 1000
167
- )
168
- print(
169
- plotEnrich(enriched[[db]], showTerms = 20, title = db) +
164
+ enrich_p <- plotEnrich(enriched[[db]], showTerms = 20, title = db) +
170
165
  theme_prism()
171
- )
166
+ enrich_plot <- file.path(odir, paste0("Enrichr-", db, ".png"))
167
+ png(enrich_plot, res = 100, height = 1000, width = 1000)
168
+ print(enrich_p)
169
+ dev.off()
170
+
171
+ enrich_plot_pdf <- file.path(odir, paste0("Enrichr-", db, ".pdf"))
172
+ pdf(enrich_plot_pdf, height = 10, width = 10)
173
+ print(enrich_p)
172
174
  dev.off()
173
175
  }
174
176
  }
@@ -385,6 +385,10 @@ do_one_subset = function(s) {
385
385
  print(g)
386
386
  dev.off()
387
387
 
388
+ pdf(file.path(odir, "estimated_coefficients.pdf"), width=10, height=10)
389
+ print(g)
390
+ dev.off()
391
+
388
392
  add_report(
389
393
  list(
390
394
  kind = "descr",
@@ -408,7 +412,8 @@ do_one_subset = function(s) {
408
412
  contents = list(
409
413
  list(
410
414
  kind = "image",
411
- src = file.path(odir, "estimated_coefficients.png")
415
+ src = file.path(odir, "estimated_coefficients.png"),
416
+ download = file.path(odir, "estimated_coefficients.pdf")
412
417
  )
413
418
  )
414
419
  ),
@@ -465,6 +470,10 @@ do_one_subset = function(s) {
465
470
  print(g)
466
471
  dev.off()
467
472
 
473
+ pdf(file.path(odir, "distribution.pdf"), width=10, height=10)
474
+ print(g)
475
+ dev.off()
476
+
468
477
  add_report(
469
478
  list(
470
479
  kind = "table_image",
@@ -473,7 +482,8 @@ do_one_subset = function(s) {
473
482
  "then scaled to have a mean of 0 and a variance of 1. ",
474
483
  "Horizontal lines depict the mean for each population"
475
484
  ),
476
- src = file.path(odir, "distribution.png")
485
+ src = file.path(odir, "distribution.png"),
486
+ download = file.path(odir, "distribution.pdf")
477
487
  ),
478
488
  h1 = ifelse(
479
489
  is.null(s),
@@ -500,10 +500,16 @@ handle_subject <- function(i, subjects, casename, case) {
500
500
  print(scatter_p)
501
501
  dev.off()
502
502
 
503
+ scatter_pdf <- gsub(".png$", ".pdf", scatter_png)
504
+ pdf(scatter_pdf, width = 10, height = 8)
505
+ print(scatter_p)
506
+ dev.off()
507
+
503
508
  add_report(
504
509
  list(
505
510
  name = paste0(subject, " (", pair[1], " - ", pair[2], ")"),
506
- src = scatter_png
511
+ src = scatter_png,
512
+ download = scatter_pdf
507
513
  ),
508
514
  h1 = h$h1,
509
515
  h2 = h$h2,
@@ -515,13 +521,19 @@ handle_subject <- function(i, subjects, casename, case) {
515
521
  # upset/venn
516
522
  venn_dir <- file.path(casedir, "venn")
517
523
  venn_png <- file.path(venn_dir, paste0("venn_", slugify(subject), ".png"))
524
+ venn_pdf <- gsub(".png$", ".pdf", venn_png)
525
+ p <- plot_venndg(counts, groups, singletons)
518
526
  png(venn_png, res = 100, height = 600, width = 800)
519
- print(plot_venndg(counts, groups, singletons))
527
+ print(p)
528
+ dev.off()
529
+
530
+ pdf(venn_pdf, width = 8, height = 6)
531
+ print(p)
520
532
  dev.off()
521
533
 
522
534
  h <- headings(case$section, casename, "Overlapping Clones (Venn Diagram)")
523
535
  add_report(
524
- list(src = venn_png, name = subject),
536
+ list(src = venn_png, name = subject, download = venn_pdf),
525
537
  h1 = h$h1,
526
538
  h2 = h$h2,
527
539
  h3 = h$h3,
@@ -530,13 +542,19 @@ handle_subject <- function(i, subjects, casename, case) {
530
542
 
531
543
  upset_dir <- file.path(casedir, "upset")
532
544
  upset_png <- file.path(upset_dir, paste0("upset_", slugify(subject), ".png"))
545
+ upset_pdf <- gsub(".png$", ".pdf", upset_png)
546
+ p <- plot_upset(counts, singletons, case$upset_ymax, case$upset_trans)
533
547
  png(upset_png, res = 100, height = 600, width = 800)
534
- print(plot_upset(counts, singletons, case$upset_ymax, case$upset_trans))
548
+ print(p)
549
+ dev.off()
550
+
551
+ pdf(upset_pdf, width = 8, height = 6)
552
+ print(p)
535
553
  dev.off()
536
554
 
537
555
  h <- headings(case$section, casename, "Overlapping Clones (UpSet Plots)")
538
556
  add_report(
539
- list(src = upset_png, name = subject),
557
+ list(src = upset_png, name = subject, download = upset_pdf),
540
558
  h1 = h$h1,
541
559
  h2 = h$h2,
542
560
  h3 = h$h3,
@@ -63,15 +63,22 @@ do_one_case_basic = function(name, case, method) {
63
63
  } else {
64
64
  p = vis(exp, .by = case$by, .meta = d$meta)
65
65
  }
66
+
66
67
  ofig = file.path(odir, paste0(name, ".png"))
67
68
  png(ofig, width = case$devpars$width, height = case$devpars$height, res = case$devpars$res)
68
69
  print(p + scale_fill_biopipen())
69
70
  dev.off()
70
71
 
72
+ ofig_pdf = file.path(odir, paste0(name, ".pdf"))
73
+ pdf(ofig_pdf, width = case$devpars$width / case$devpars$res, height = case$devpars$height / case$devpars$res)
74
+ print(p + scale_fill_biopipen())
75
+ dev.off()
76
+
71
77
  add_report(
72
78
  list(
73
79
  src = ofig,
74
- name = if (name == "DEFAULT") NULL else name
80
+ name = if (name == "DEFAULT") NULL else name,
81
+ download = ofig_pdf
75
82
  ),
76
83
  h1 = "Exploratory Analysis",
77
84
  h2 = switch(method,
@@ -78,6 +78,11 @@ do_one_case_clonality = function(name, case, method) {
78
78
  print(p)
79
79
  dev.off()
80
80
 
81
+ ofig_pdf = file.path(odir, paste0(name, ".pdf"))
82
+ pdf(ofig_pdf, width = case$devpars$width / case$devpars$res, height = case$devpars$height / case$devpars$res)
83
+ print(p)
84
+ dev.off()
85
+
81
86
  add_report(
82
87
  list(
83
88
  src = ofig,
@@ -353,7 +353,14 @@ run_general = function(casename, d, case, ddir, value_col = "Value") {
353
353
  width = width * case$ncol
354
354
  }
355
355
  }
356
- png(file.path(ddir, "diversity.png"), width = width, height = height, res = res)
356
+
357
+ div_plot = file.path(ddir, "diversity.png")
358
+ png(div_plot, width = width, height = height, res = res)
359
+ print(p)
360
+ dev.off()
361
+
362
+ div_plot_pdf = file.path(ddir, "diversity.pdf")
363
+ pdf(div_plot_pdf, width = width / res, height = height / res)
357
364
  print(p)
358
365
  dev.off()
359
366
 
@@ -407,7 +414,7 @@ run_general = function(casename, d, case, ddir, value_col = "Value") {
407
414
  add_report(
408
415
  list(
409
416
  name = "Diversity Plot",
410
- contents = list(list(kind = "image", src = file.path(ddir, "diversity.png")))
417
+ contents = list(list(kind = "image", src = div_plot, download = div_plot_pdf))
411
418
  ),
412
419
  list(
413
420
  name = "Diversity Table",
@@ -559,6 +566,10 @@ run_raref_single = function(d, case, ddir, suffix = "", save_p = TRUE) {
559
566
  png(file.path(ddir, "raref.png"), width = devpars$width, height = devpars$height, res = devpars$res)
560
567
  print(p)
561
568
  dev.off()
569
+
570
+ pdf(file.path(ddir, "raref.pdf"), width = devpars$width / devpars$res, height = devpars$height / devpars$res)
571
+ print(p)
572
+ dev.off()
562
573
  } else {
563
574
  return (list(p = p, width = devpars$width))
564
575
  }
@@ -628,6 +639,14 @@ run_raref_multi = function(d, case, ddir) {
628
639
  )
629
640
  print(p)
630
641
  dev.off()
642
+
643
+ pdf(
644
+ file.path(ddir, paste0("raref-", slugify(case$separate_by), ".pdf")),
645
+ width = width / res,
646
+ height = height / res
647
+ )
648
+ print(p)
649
+ dev.off()
631
650
  }
632
651
 
633
652
  # Run the diversity estimation for one case
@@ -673,7 +692,8 @@ run_div_case = function(casename) {
673
692
  add_report(
674
693
  list(
675
694
  kind = "image",
676
- src = file.path(ddir, paste0("raref-", slugify(case$separate_by), ".png"))
695
+ src = file.path(ddir, paste0("raref-", slugify(case$separate_by), ".png")),
696
+ download = file.path(ddir, paste0("raref-", slugify(case$separate_by), ".pdf"))
677
697
  ),
678
698
  h1 = "Rarefraction",
679
699
  h2 = casename
@@ -683,7 +703,8 @@ run_div_case = function(casename) {
683
703
  add_report(
684
704
  list(
685
705
  kind = "image",
686
- src = file.path(ddir, "raref.png")
706
+ src = file.path(ddir, "raref.png"),
707
+ download = file.path(ddir, "raref.pdf")
687
708
  ),
688
709
  h1 = "Rarefraction",
689
710
  h2 = casename
@@ -126,10 +126,16 @@ do_one_case_geneusage = function(name, case, gu_dir) {
126
126
  print(p + scale_fill_biopipen())
127
127
  dev.off()
128
128
 
129
+ ofig_pdf = file.path(odir, paste0(name, ".pdf"))
130
+ pdf(ofig_pdf, width = case$devpars$width / case$devpars$res, height = case$devpars$height / case$devpars$res)
131
+ print(p + scale_fill_biopipen())
132
+ dev.off()
133
+
129
134
  add_report(
130
135
  list(
131
136
  kind = "table_image",
132
137
  src = ofig,
138
+ download = ofig_pdf,
133
139
  descr = paste0(
134
140
  "Distribution of known gene segments following the ",
135
141
  '<a href="http://www.imgt.org/IMGTrepertoire/LocusGenes/" target="_blank">IMGT</a> ',
@@ -165,15 +171,23 @@ do_one_case_geneusage = function(name, case, gu_dir) {
165
171
  ap = do_call(vis, avis_args)
166
172
  if (aname == "DEFAULT") {
167
173
  aofig = file.path(odir, paste0(name, "-analysis.png"))
174
+ aofig_pdf = file.path(odir, paste0(name, "-analysis.pdf"))
168
175
  } else {
169
176
  aofig = file.path(odir, paste0(name, "-", aname, "-analysis.png"))
177
+ aofig_pdf = file.path(odir, paste0(name, "-", aname, "-analysis.pdf"))
170
178
  }
171
179
  png(aofig, width = case$analyses$cases[[aname]]$devpars$width, height = case$analyses$cases[[aname]]$devpars$height, res = case$analyses$cases[[aname]]$devpars$res)
172
180
  print(ap)
173
181
  dev.off()
174
182
 
183
+ pdf(aofig_pdf,
184
+ width = case$analyses$cases[[aname]]$devpars$width / case$analyses$cases[[aname]]$devpars$res,
185
+ height = case$analyses$cases[[aname]]$devpars$height / case$analyses$cases[[aname]]$devpars$res)
186
+ print(ap)
187
+ dev.off()
188
+
175
189
  add_report(
176
- list(src = aofig, name = aname),
190
+ list(src = aofig, name = aname, download = aofig_pdf),
177
191
  h1 = "Gene Usage",
178
192
  h2 = ifelse(name == "DEFAULT", "#", name),
179
193
  h3 = "Gene Usage Analysis",
@@ -105,6 +105,11 @@ do_one_case_kmer = function(name, case, kmer_dir) {
105
105
  print(p)
106
106
  dev.off()
107
107
 
108
+ ofig_pdf = file.path(odir, "Allsamples.pdf")
109
+ pdf(ofig_pdf, width = case$devpars$width / case$devpars$res, height = case$devpars$height / case$devpars$res)
110
+ print(p)
111
+ dev.off()
112
+
108
113
  add_report(
109
114
  list(
110
115
  kind = "descr",
@@ -116,7 +121,7 @@ do_one_case_kmer = function(name, case, kmer_dir) {
116
121
  )
117
122
 
118
123
  add_report(
119
- list(kind = "image", src = ofig),
124
+ list(kind = "image", src = ofig, download = ofig_pdf),
120
125
  h1 = "Kmer and sequence motif analysis",
121
126
  h2 = ifelse(name == "DEFAULT", "#", name),
122
127
  h3 = "Kmer sequence occurrences"
@@ -150,9 +155,17 @@ do_one_case_kmer = function(name, case, kmer_dir) {
150
155
  print(ap)
151
156
  dev.off()
152
157
 
158
+ aofig_pdf = gsub(".png$", ".pdf", aofig)
159
+ pdf(aofig_pdf,
160
+ width = case$profiles$cases[[aname]]$devpars$width / case$profiles$cases[[aname]]$devpars$res,
161
+ height = case$profiles$cases[[aname]]$devpars$height / case$profiles$cases[[aname]]$devpars$res)
162
+ print(ap)
163
+ dev.off()
164
+
153
165
  add_report(
154
166
  list(
155
167
  src = aofig,
168
+ download = aofig_pdf,
156
169
  name = paste0(sample, ifelse(aname == "DEFAULT", "", paste0(" - ", aname)))
157
170
  ),
158
171
  h1 = "Kmer and sequence motif analysis",
@@ -138,10 +138,16 @@ do_one_case_overlap = function(name, case, ov_dir) {
138
138
  print(p)
139
139
  dev.off()
140
140
 
141
+ ofig_pdf = file.path(odir, paste0(name, ".pdf"))
142
+ pdf(ofig_pdf, width = case$devpars$width / case$devpars$res, height = case$devpars$height / case$devpars$res)
143
+ print(p)
144
+ dev.off()
145
+
141
146
  add_report(
142
147
  list(
143
148
  kind = "table_image",
144
149
  src = ofig,
150
+ download = ofig_pdf,
145
151
  descr = paste0(
146
152
  "Repertoire overlap is the most common approach to measure repertoire similarity, ",
147
153
  "using method <code>", case$method, "</code>, ",
@@ -179,15 +185,23 @@ do_one_case_overlap = function(name, case, ov_dir) {
179
185
  ap = do_call(vis, avis_args)
180
186
  if (aname == "DEFAULT") {
181
187
  aofig = file.path(odir, paste0(name, "-analysis.png"))
188
+ aofig_pdf = file.path(odir, paste0(name, "-analysis.pdf"))
182
189
  } else {
183
190
  aofig = file.path(odir, paste0(name, "-", aname, "-analysis.png"))
191
+ aofig_pdf = file.path(odir, paste0(name, "-", aname, "-analysis.pdf"))
184
192
  }
185
193
  png(aofig, width = case$analyses$cases[[aname]]$devpars$width, height = case$analyses$cases[[aname]]$devpars$height, res = case$analyses$cases[[aname]]$devpars$res)
186
194
  print(ap)
187
195
  dev.off()
188
196
 
197
+ pdf(aofig_pdf,
198
+ width = case$analyses$cases[[aname]]$devpars$width / case$analyses$cases[[aname]]$devpars$res,
199
+ height = case$analyses$cases[[aname]]$devpars$height / case$analyses$cases[[aname]]$devpars$res)
200
+ print(ap)
201
+ dev.off()
202
+
189
203
  add_report(
190
- list(src = aofig, name = aname),
204
+ list(src = aofig, name = aname, download = aofig_pdf),
191
205
  h1 = "Repertoire Overlaps",
192
206
  h2 = ifelse(name == "DEFAULT", "#", name),
193
207
  h3 = "Repertoire Overlap Analysis",
@@ -69,8 +69,17 @@ do_one_case_spectratyping = function(name, case, spect_dir) {
69
69
  print(vis(spec_obj))
70
70
  dev.off()
71
71
 
72
+ spectfile_pdf = file.path(odir, paste0(slugify(sample), ".spect.pdf"))
73
+ pdf(
74
+ spectfile_pdf,
75
+ width = case$devpars$width / case$devpars$res,
76
+ height = case$devpars$height / case$devpars$res
77
+ )
78
+ print(vis(spec_obj))
79
+ dev.off()
80
+
72
81
  add_report(
73
- list(src = spectfile, name = sample),
82
+ list(src = spectfile, name = sample, download = spectfile_pdf),
74
83
  h1 = "Spectratyping",
75
84
  h2 = name,
76
85
  ui = "table_of_images"
@@ -88,6 +88,11 @@ run_tracking_case = function(casename) {
88
88
  print(vis(imm_tracking))
89
89
  dev.off()
90
90
 
91
+ tracking_pdf = file.path(tracking_dir, paste0(slugify(casename), ".pdf"))
92
+ pdf(tracking_pdf, height=10, width=6 + 1.5 * length(subjects))
93
+ print(vis(imm_tracking))
94
+ dev.off()
95
+
91
96
  add_report(
92
97
  list(
93
98
  kind = "descr",
@@ -105,6 +110,7 @@ run_tracking_case = function(casename) {
105
110
  add_report(
106
111
  list(
107
112
  src = tracking_png,
113
+ download = tracking_pdf,
108
114
  name = if (casename == "DEFAULT") NULL else casename
109
115
  ),
110
116
  h1 = "Tracking of clonotypes",
@@ -110,7 +110,40 @@ do_one_case_vjjunc <- function(name, case) {
110
110
  }, bg.border = NA) # here set bg.border to NA is important
111
111
  dev.off()
112
112
 
113
+ # figfile_pdf <- file.path(odir, paste0(slugify(by_name), ".pdf"))
114
+ # png(figfile_pdf, width = case$devpars$width / case$devpars$res, height = case$devpars$height / case$devpars$res)
115
+ # circos.clear()
116
+ # tryCatch({
117
+ # chordDiagram(
118
+ # gsd,
119
+ # annotationTrack = c("grid", "axis"),
120
+ # preAllocateTracks = list(track.height = 0.25)
121
+ # )
122
+ # }, error = function(e) {
123
+ # log_warn("Error encountered: {e$message}, setting gap.after ...")
124
+ # circos.par(gap.after = c(rep(1, nrow(gsd) - 1), 5, rep(1, nrow(gsd) - 1), 5))
125
+ # chordDiagram(
126
+ # gsd,
127
+ # annotationTrack = c("grid", "axis"),
128
+ # preAllocateTracks = list(track.height = 0.25)
129
+ # )
130
+
131
+ # })
132
+ # circos.track(track.index = 1, panel.fun = function(x, y) {
133
+ # circos.text(
134
+ # CELL_META$xcenter,
135
+ # CELL_META$ylim[1],
136
+ # CELL_META$sector.index,
137
+ # cex = .8,
138
+ # facing = "clockwise",
139
+ # niceFacing = TRUE,
140
+ # adj = c(-0.2, 0.5)
141
+ # )
142
+ # }, bg.border = NA) # here set bg.border to NA is important
143
+ # dev.off()
144
+
113
145
  add_report(
146
+ # list(src = figfile, name = by_name, download = figfile_pdf),
114
147
  list(src = figfile, name = by_name),
115
148
  h1 = "V-J Junction Circos Plots",
116
149
  h2 = ifelse(name == "DEFAULT", "#" , name),