biopipen 0.33.0__py3-none-any.whl → 0.34.0__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 (150) hide show
  1. biopipen/__init__.py +1 -1
  2. biopipen/core/filters.py +10 -183
  3. biopipen/core/proc.py +5 -3
  4. biopipen/core/testing.py +8 -1
  5. biopipen/ns/bam.py +40 -4
  6. biopipen/ns/cnv.py +1 -1
  7. biopipen/ns/cnvkit.py +1 -1
  8. biopipen/ns/delim.py +1 -1
  9. biopipen/ns/gsea.py +63 -37
  10. biopipen/ns/misc.py +38 -0
  11. biopipen/ns/plot.py +8 -0
  12. biopipen/ns/scrna.py +307 -288
  13. biopipen/ns/scrna_metabolic_landscape.py +207 -366
  14. biopipen/ns/tcr.py +165 -97
  15. biopipen/reports/bam/CNVpytor.svelte +4 -9
  16. biopipen/reports/cnvkit/CNVkitDiagram.svelte +1 -1
  17. biopipen/reports/cnvkit/CNVkitHeatmap.svelte +1 -1
  18. biopipen/reports/cnvkit/CNVkitScatter.svelte +1 -1
  19. biopipen/reports/{delim/SampleInfo.svelte → common.svelte} +2 -3
  20. biopipen/reports/scrna/DimPlots.svelte +1 -1
  21. biopipen/reports/scrna_metabolic_landscape/MetabolicFeatures.svelte +51 -22
  22. biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayActivity.svelte +46 -42
  23. biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayHeterogeneity.svelte +63 -6
  24. biopipen/reports/snp/PlinkCallRate.svelte +2 -2
  25. biopipen/reports/snp/PlinkFreq.svelte +1 -1
  26. biopipen/reports/snp/PlinkHWE.svelte +1 -1
  27. biopipen/reports/snp/PlinkHet.svelte +1 -1
  28. biopipen/reports/snp/PlinkIBD.svelte +1 -1
  29. biopipen/reports/tcr/CDR3AAPhyschem.svelte +1 -1
  30. biopipen/scripts/bam/CNAClinic.R +41 -6
  31. biopipen/scripts/bam/CNVpytor.py +2 -1
  32. biopipen/scripts/bam/ControlFREEC.py +2 -3
  33. biopipen/scripts/bam/SamtoolsView.py +33 -0
  34. biopipen/scripts/cnv/AneuploidyScore.R +25 -13
  35. biopipen/scripts/cnv/AneuploidyScoreSummary.R +218 -163
  36. biopipen/scripts/cnv/TMADScore.R +4 -4
  37. biopipen/scripts/cnv/TMADScoreSummary.R +51 -84
  38. biopipen/scripts/cnvkit/CNVkitGuessBaits.py +3 -3
  39. biopipen/scripts/cnvkit/CNVkitHeatmap.py +3 -3
  40. biopipen/scripts/cnvkit/CNVkitReference.py +3 -3
  41. biopipen/scripts/delim/RowsBinder.R +1 -1
  42. biopipen/scripts/delim/SampleInfo.R +14 -2
  43. biopipen/scripts/gene/GeneNameConversion.R +14 -12
  44. biopipen/scripts/gsea/Enrichr.R +2 -2
  45. biopipen/scripts/gsea/FGSEA.R +184 -50
  46. biopipen/scripts/gsea/PreRank.R +3 -3
  47. biopipen/scripts/misc/Plot.R +80 -0
  48. biopipen/scripts/plot/VennDiagram.R +2 -2
  49. biopipen/scripts/protein/ProdigySummary.R +34 -27
  50. biopipen/scripts/regulatory/MotifAffinityTest.R +11 -9
  51. biopipen/scripts/regulatory/MotifAffinityTest_AtSNP.R +5 -5
  52. biopipen/scripts/regulatory/MotifAffinityTest_MotifBreakR.R +4 -4
  53. biopipen/scripts/regulatory/VariantMotifPlot.R +10 -8
  54. biopipen/scripts/regulatory/motifs-common.R +10 -9
  55. biopipen/scripts/rnaseq/Simulation-ESCO.R +14 -11
  56. biopipen/scripts/rnaseq/Simulation-RUVcorr.R +7 -4
  57. biopipen/scripts/rnaseq/Simulation.R +0 -2
  58. biopipen/scripts/rnaseq/UnitConversion.R +6 -5
  59. biopipen/scripts/scrna/AnnData2Seurat.R +25 -73
  60. biopipen/scripts/scrna/CellCellCommunication.py +1 -1
  61. biopipen/scripts/scrna/CellCellCommunicationPlots.R +51 -168
  62. biopipen/scripts/scrna/CellTypeAnnotation-celltypist.R +99 -150
  63. biopipen/scripts/scrna/CellTypeAnnotation-direct.R +11 -9
  64. biopipen/scripts/scrna/CellTypeAnnotation-hitype.R +12 -9
  65. biopipen/scripts/scrna/CellTypeAnnotation-sccatch.R +14 -11
  66. biopipen/scripts/scrna/CellTypeAnnotation-sctype.R +19 -16
  67. biopipen/scripts/scrna/CellTypeAnnotation.R +10 -2
  68. biopipen/scripts/scrna/CellsDistribution.R +1 -1
  69. biopipen/scripts/scrna/ExprImputation-alra.R +87 -11
  70. biopipen/scripts/scrna/ExprImputation-rmagic.R +247 -21
  71. biopipen/scripts/scrna/ExprImputation-scimpute.R +8 -5
  72. biopipen/scripts/scrna/LoomTo10X.R +51 -0
  73. biopipen/scripts/scrna/MarkersFinder.R +348 -217
  74. biopipen/scripts/scrna/MetaMarkers.R +3 -3
  75. biopipen/scripts/scrna/ModuleScoreCalculator.R +14 -13
  76. biopipen/scripts/scrna/RadarPlots.R +1 -1
  77. biopipen/scripts/scrna/ScFGSEA.R +157 -75
  78. biopipen/scripts/scrna/ScSimulation.R +11 -10
  79. biopipen/scripts/scrna/ScVelo.py +605 -0
  80. biopipen/scripts/scrna/Seurat2AnnData.R +2 -3
  81. biopipen/scripts/scrna/SeuratClusterStats-clustree.R +1 -1
  82. biopipen/scripts/scrna/SeuratClusterStats-features.R +39 -30
  83. biopipen/scripts/scrna/SeuratClusterStats-ngenes.R +56 -65
  84. biopipen/scripts/scrna/SeuratClusterStats-stats.R +4 -4
  85. biopipen/scripts/scrna/SeuratClusterStats.R +9 -6
  86. biopipen/scripts/scrna/SeuratClustering.R +31 -48
  87. biopipen/scripts/scrna/SeuratLoading.R +2 -2
  88. biopipen/scripts/scrna/SeuratMap2Ref.R +66 -367
  89. biopipen/scripts/scrna/SeuratMetadataMutater.R +5 -7
  90. biopipen/scripts/scrna/SeuratPreparing.R +76 -24
  91. biopipen/scripts/scrna/SeuratSubClustering.R +46 -185
  92. biopipen/scripts/scrna/{SlingShot.R → Slingshot.R} +12 -16
  93. biopipen/scripts/scrna/Subset10X.R +2 -2
  94. biopipen/scripts/scrna/TopExpressingGenes.R +141 -184
  95. biopipen/scripts/scrna/celltypist-wrapper.py +6 -4
  96. biopipen/scripts/scrna/seurat_anndata_conversion.py +81 -0
  97. biopipen/scripts/scrna_metabolic_landscape/MetabolicFeatures.R +429 -123
  98. biopipen/scripts/scrna_metabolic_landscape/MetabolicPathwayActivity.R +346 -245
  99. biopipen/scripts/scrna_metabolic_landscape/MetabolicPathwayHeterogeneity.R +182 -173
  100. biopipen/scripts/snp/MatrixEQTL.R +39 -20
  101. biopipen/scripts/snp/PlinkCallRate.R +43 -34
  102. biopipen/scripts/snp/PlinkFreq.R +34 -41
  103. biopipen/scripts/snp/PlinkHWE.R +23 -18
  104. biopipen/scripts/snp/PlinkHet.R +26 -22
  105. biopipen/scripts/snp/PlinkIBD.R +30 -34
  106. biopipen/scripts/stats/ChowTest.R +9 -8
  107. biopipen/scripts/stats/DiffCoexpr.R +13 -11
  108. biopipen/scripts/stats/LiquidAssoc.R +7 -8
  109. biopipen/scripts/stats/Mediation.R +8 -8
  110. biopipen/scripts/stats/MetaPvalue.R +11 -13
  111. biopipen/scripts/stats/MetaPvalue1.R +6 -5
  112. biopipen/scripts/tcr/CDR3AAPhyschem.R +105 -164
  113. biopipen/scripts/tcr/ClonalStats.R +5 -4
  114. biopipen/scripts/tcr/CloneResidency.R +3 -3
  115. biopipen/scripts/tcr/CloneSizeQQPlot.R +2 -2
  116. biopipen/scripts/tcr/Immunarch2VDJtools.R +2 -2
  117. biopipen/scripts/tcr/ImmunarchFilter.R +3 -3
  118. biopipen/scripts/tcr/ImmunarchLoading.R +5 -5
  119. biopipen/scripts/tcr/ScRepCombiningExpression.R +39 -0
  120. biopipen/scripts/tcr/ScRepLoading.R +114 -92
  121. biopipen/scripts/tcr/TCRClusterStats.R +2 -2
  122. biopipen/scripts/tcr/TCRClustering.R +86 -97
  123. biopipen/scripts/tcr/TESSA.R +65 -115
  124. biopipen/scripts/tcr/VJUsage.R +5 -5
  125. biopipen/scripts/vcf/TruvariBenchSummary.R +15 -11
  126. biopipen/utils/common_docstrs.py +66 -63
  127. biopipen/utils/reporter.py +177 -0
  128. {biopipen-0.33.0.dist-info → biopipen-0.34.0.dist-info}/METADATA +2 -1
  129. {biopipen-0.33.0.dist-info → biopipen-0.34.0.dist-info}/RECORD +131 -144
  130. {biopipen-0.33.0.dist-info → biopipen-0.34.0.dist-info}/WHEEL +1 -1
  131. biopipen/reports/scrna/CellCellCommunicationPlots.svelte +0 -14
  132. biopipen/reports/scrna/SeuratClusterStats.svelte +0 -16
  133. biopipen/reports/scrna/SeuratMap2Ref.svelte +0 -37
  134. biopipen/reports/scrna/SeuratPreparing.svelte +0 -15
  135. biopipen/reports/scrna_metabolic_landscape/MetabolicFeaturesIntraSubset.svelte +0 -28
  136. biopipen/reports/utils/gsea.liq +0 -110
  137. biopipen/scripts/scrna/CellTypeAnnotation-common.R +0 -10
  138. biopipen/scripts/scrna/SeuratClustering-common.R +0 -213
  139. biopipen/scripts/scrna_metabolic_landscape/MetabolicFeaturesIntraSubset.R +0 -193
  140. biopipen/utils/caching.R +0 -44
  141. biopipen/utils/gene.R +0 -95
  142. biopipen/utils/gsea.R +0 -329
  143. biopipen/utils/io.R +0 -20
  144. biopipen/utils/misc.R +0 -602
  145. biopipen/utils/mutate_helpers.R +0 -581
  146. biopipen/utils/plot.R +0 -209
  147. biopipen/utils/repr.R +0 -146
  148. biopipen/utils/rnaseq.R +0 -48
  149. biopipen/utils/single_cell.R +0 -207
  150. {biopipen-0.33.0.dist-info → biopipen-0.34.0.dist-info}/entry_points.txt +0 -0
@@ -1,87 +1,39 @@
1
- {{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
2
-
3
1
  library(rlang)
4
2
  library(Seurat)
5
- library(hdf5r)
6
- library(SeuratDisk)
3
+ library(scplotter)
4
+ library(biopipen.utils)
7
5
 
8
6
  adfile <- {{in.adfile | r}}
9
7
  outfile <- {{out.outfile | r}}
10
8
  dotplot_check <- {{envs.dotplot_check | r}}
11
9
  outdir <- dirname(outfile)
12
10
  assay <- {{envs.assay | r}}
13
- outtype <- {{envs.outtype | r}}
14
-
15
- if (outtype == "rds") {
16
- h5seurat_file <- file.path(
17
- outdir,
18
- paste0(tools::file_path_sans_ext(basename(outfile)), ".h5seurat")
19
- )
20
- } else if (outtype == "h5seurat") {
21
- h5seurat_file <- outfile
22
- } else {
23
- stop("Unknown output file type: ", outtype)
24
- }
25
11
 
26
- if (file.exists(h5seurat_file) && (file.mtime(h5seurat_file) < file.mtime(adfile))) {
27
- file.remove(h5seurat_file)
28
- }
12
+ log <- get_logger()
29
13
 
30
- if (!file.exists(h5seurat_file)) {
31
- log_info("Converting to H5Seurat file ...")
32
- Convert(adfile, dest = h5seurat_file, assay = assay, overwrite = TRUE)
33
- } else {
34
- log_info("Using existing H5Seurat file ...")
35
- }
14
+ ConvertAnnDataToSeurat(adfile, outfile = outfile, assay = assay, log = log)
36
15
 
37
- if (outtype == "rds") {
38
- log_info("Converting to RDS file ...")
39
- # Fix Missing required datasets 'levels' and 'values'
40
- # https://github.com/mojaveazure/seurat-disk/issues/109#issuecomment-1722394184
41
- f <- H5File$new(h5seurat_file, "r+")
42
- groups <- f$ls(recursive = TRUE)
16
+ if (!isFALSE(dotplot_check)) {
17
+ log$info("Reading Seurat object ...")
18
+ sobj <- read_obj(outfile)
43
19
 
44
- for (name in groups$name[grepl("/categories$", groups$name)]) {
45
- valuenames <- levelnames <- codenames <- strsplit(name, "/")[[1]]
46
- valuenames[length(valuenames)] <- "values"
47
- valuenames <- paste(valuenames, collapse = "/")
48
- levelnames[length(levelnames)] <- "levels"
49
- levelnames <- paste(levelnames, collapse = "/")
50
- codenames[length(codenames)] <- "codes"
51
- codenames <- paste(codenames, collapse = "/")
52
- if (!f$exists(codenames)) {
53
- # No codes, skip
54
- next
55
- }
56
-
57
- if (!f$exists(levelnames)) {
58
- f[[levelnames]] <- f[[name]]
59
- }
60
-
61
- if (!f$exists(valuenames)) {
62
- f[[valuenames]] <- f[[codenames]]
63
- grp <- f[[valuenames]]
64
- grp$write(args = list(1:grp$dims), value = grp$read() + 1)
65
- }
20
+ log$info("Checking dotplot ...")
21
+ dotfig <- file.path(outdir, "dotplot.png")
22
+ if (isTRUE(dotplot_check)) {
23
+ vobj <- FindVariableFeatures(
24
+ sobj, selection.method = "vst", nfeatures = 2000)
25
+ dotplot_check <- head(VariableFeatures(vobj), 10)
26
+ } else if (is.character(dotplot_check)) {
27
+ dotplot_check <- trimws(strsplit(dotplot_check, ",")[[1]])
66
28
  }
67
- f$close_all()
68
- # end
69
-
70
- sobj <- LoadH5Seurat(h5seurat_file, assays = assay)
71
- if (!isFALSE(dotplot_check)) {
72
- log_info("Checking dotplot ...")
73
- dotfig <- file.path(outdir, "dotplot.png")
74
- if (isTRUE(dotplot_check)) {
75
- vobj <- FindVariableFeatures(
76
- sobj, selection.method = "vst", nfeatures = 2000)
77
- dotplot_check <- head(VariableFeatures(vobj), 10)
78
- } else if (is.character(dotplot_check)) {
79
- dotplot_check <- trimws(strsplit(dotplot_check, ",")[[1]])
80
- }
81
- png(dotfig, width = 800, height = 800, res = 70)
82
- p <- DotPlot(sobj, features = dotplot_check, assay = assay)
83
- print(p)
84
- dev.off()
85
- }
86
- saveRDS(sobj, outfile)
29
+ p <- FeatureStatPlot(
30
+ sobj, features = dotplot_check, plot_type = "dot",
31
+ assay = assay
32
+ )
33
+ res = 70
34
+ height <- attr(p, "height") * res
35
+ width <- attr(p, "width") * res
36
+ png(dotfig, width = width, height = height, res = res)
37
+ print(p)
38
+ dev.off()
87
39
  }
@@ -40,7 +40,7 @@ if subset_using == "auto":
40
40
  subset_using = "python" if subset and "[" in subset else "r"
41
41
  split_by = envs.pop("split_by")
42
42
 
43
- if sobjfile.suffix.lower() == ".rds" or sobjfile.suffix.lower() == ".h5seurat":
43
+ if sobjfile.suffix.lower() in (".rds", ".qs", "qs2"):
44
44
  logger.info("Converting the Seurat object to h5ad ...")
45
45
 
46
46
  annfile = outfile.parent / f"{sobjfile.stem}.h5ad"
@@ -1,191 +1,74 @@
1
- {{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
2
1
  library(rlang)
3
2
  library(dplyr)
4
- library(ggplot2)
5
- library(CCPlotR)
6
- {{ biopipen_dir | joinpaths: "scripts", "scrna", "CCPlotR-patch.R" | source_r }}
3
+ library(scplotter)
4
+ library(biopipen.utils)
7
5
 
8
6
  cccfile <- {{ in.cccfile | r }}
9
- expfile <- {{ in.expfile | r }}
10
7
  outdir <- {{ out.outdir | r }}
11
8
  joboutdir <- {{ job.outdir | r }}
12
- score_col <- {{ envs.score_col | r }}
13
- subset <- {{ envs.subset | r }}
14
- cases <- {{ envs.cases | r }}
9
+ envs <- {{ envs | r }}
10
+ envs <- extract_vars(
11
+ envs,
12
+ "magnitude", "specificity", "devpars", "subset", "cases", "more_formats", "descr"
13
+ )
15
14
 
16
15
  ccc <- read.table(cccfile, header=TRUE, sep="\t", check.names = FALSE)
17
- if (!is.null(subset)) {
18
- ccc <- ccc %>% dplyr::filter(!!parse_expr(subset))
19
- }
20
- if (ncol(ccc) > 10) {
21
- # from CellCellCommunication
22
- if (!is.null(expfile)) {
23
- log_warn("in.cccfile is from CellCellCommunication, in.expfile will be ignored")
24
- }
25
- if (is.null(score_col)) {
26
- stop("'envs.score_col' is required for CellCellCommunication output")
27
- }
28
- if (!score_col %in% colnames(ccc)) {
29
- stop(paste("Score column", score_col, "not found in the in.cccfile"))
30
- }
31
- # compose the expression data frame
32
- exp <- data.frame(
33
- cell_type = c(ccc$source, ccc$target),
34
- gene = c(ccc$ligand, ccc$receptor),
35
- mean_exp = c(ccc$ligand_trimean, ccc$receptor_trimean)
36
- ) %>% distinct()
37
- ccc <- ccc %>% select(
38
- source, target,
39
- ligand, receptor,
40
- !!sym(score_col)
41
- ) %>% rename(score = !!sym(score_col))
42
- } else {
43
- if (!is.null(expfile)) {
44
- exp <- read.table(expfile, header=TRUE, sep="\t", check.names = FALSE)
45
- }
46
- }
47
16
 
48
- if (length(cases) == 0) {
49
- stop("No cases provided.")
17
+ if (length(ccc) == 0) {
18
+ stop("No data found in the input file: ", cccfile)
50
19
  }
51
20
 
52
- .get_default_devpars <- function(kind, nrows, ncols = NULL) {
53
- if (kind == "arrow") {
54
- list(
55
- res = 100,
56
- width = 600,
57
- height = 50 + nrows * 20
58
- )
59
- } else if (kind == "circos") {
60
- list(
61
- res = 100,
62
- width = 800,
63
- height = 800
64
- )
65
- } else if (kind == "dotplot") {
66
- list(
67
- res = 100,
68
- width = 120 + ncols * 60,
69
- height = 300 + nrows * 40
70
- )
71
- } else if (kind == "heatmap") {
72
- list(
73
- res = 100,
74
- width = 120 + ncols * 60,
75
- height = 300 + ncols * 40
76
- )
77
- } else if (kind == "network") {
78
- list(
79
- res = 100,
80
- width = 1200,
81
- height = 1200
82
- )
83
- } else if (kind == "sigmoid") {
84
- list(
85
- res = 100,
86
- width = max(800, ncols * 200),
87
- height = 100 + nrows * 60
88
- )
89
- }
90
- }
21
+ defaults <- list(
22
+ magnitude = NULL,
23
+ specificity = NULL,
24
+ subset = subset,
25
+ descr = descr,
26
+ more_formats = more_formats,
27
+ devpars = list(res = 100)
28
+ )
91
29
 
92
- images <- lapply(names(cases), function(name) {
93
- log_info("- Case: ", name, " ...")
94
- case <- cases[[name]]
30
+ cases <- expand_cases(cases, defaults)
31
+ log <- get_logger()
32
+ reporter <- get_reporter()
95
33
 
96
- kind <- match.arg(case$kind, c("arrow", "circos", "dotplot", "heatmap", "network", "sigmoid"))
97
- fun <- get(paste0("cc_", kind))
98
- case$kind <- NULL
34
+ do_case <- function(name) {
35
+ log$info("- Case: {name}")
36
+ case <- cases[[name]]
37
+ info <- case_info(name, outdir, is_dir = FALSE)
38
+ case <- extract_vars(case, "subset", "devpars", "more_formats", "descr")
99
39
 
100
- gg <- NULL
101
- if (kind == "arrow") {
102
- cell_types <- case$cell_types
103
- if (is.null(cell_types) || length(cell_types) != 2) {
104
- stop("'case.cell_types' is required and must be a vector of length 2")
105
- }
106
- n_ligand <- length(unique(ccc[ccc$source == cell_types[1], "ligand"]))
107
- n_receptor <- length(unique(ccc[ccc$target == cell_types[2], "receptor"]))
108
- default_devpars <- .get_default_devpars(kind, nrows = max(n_ligand, n_receptor))
109
- } else if (kind == "circos") {
110
- nrows <- length(unique(c(ccc$source, ccc$target)))
111
- default_devpars <- .get_default_devpars(kind, nrows = nrows)
112
- } else if (kind == "dotplot" || kind == "heatmap") {
113
- nrows <- length(unique(ccc$source))
114
- ncols <- length(unique(ccc$target))
115
- default_devpars <- .get_default_devpars(kind, nrows = nrows, ncols = ncols)
116
- if (
117
- (kind == "heatmap" && (is.null(case$option) || case$option != "B")) ||
118
- (kind == "dotplot" && (is.null(case$option) || case$option != "B"))) {
119
- gg <- theme(axis.text.x = element_text(angle = 90, hjust = 1))
120
- }
121
- } else if (kind == "network") {
122
- nrows <- length(unique(c(ccc$source, ccc$target)))
123
- ncols <- length(unique(c(ccc$ligand, ccc$receptor)))
124
- default_devpars <- .get_default_devpars(kind, nrows = nrows, ncols = ncols)
125
- gg <- theme(plot.margin = margin(c(50, 50, 50, 50), "pt"))
126
- } else if (kind == "sigmoid") {
127
- nrows <- (case$n_top_ints %||% 20) / 2 # approx
128
- ncols <- length(unique(c(ccc$source, ccc$target))) / 2
129
- default_devpars <- .get_default_devpars(kind, nrows = nrows, ncols = ncols)
40
+ case$data <- ccc
41
+ if (!is.null(case$subset)) {
42
+ case$data <- ccc %>% dplyr::filter(!!parse_expr(case$subset))
130
43
  }
131
- devpars <- case$devpars %||% default_devpars
132
- devpars$res <- devpars$res %||% default_devpars$res
133
- devpars$width <- devpars$width %||% default_devpars$width
134
- devpars$height <- devpars$height %||% default_devpars$height
135
- case$devpars <- NULL
136
-
137
- section <- case$section
138
- case$section <- NULL
139
-
140
- case$cc_df <- ccc
141
- if ("exp_df" %in% names(formals(fun))) {
142
- case$exp_df <- exp
44
+ if (is.null(case$magnitude)) {
45
+ case$magnitude <- NULL
46
+ }
47
+ if (is.null(case$specificity)) {
48
+ case$specificity <- NULL
143
49
  }
144
- outpath <- file.path(outdir, paste0(slugify(name), ".png"))
145
- png(outpath, width=devpars$width, height=devpars$height, res=devpars$res)
146
- p <- do_call(fun, case)
147
- if (!is.null(gg)) { p <- p + gg }
148
- print(p)
149
- dev.off()
50
+ p <- do_call(scplotter::CCCPlot, case)
51
+ save_plot(
52
+ p, info$prefix,
53
+ devpars = devpars, formats = unique(c("png", more_formats))
54
+ )
150
55
 
151
- list(
152
- section = section,
56
+ report <- list(
153
57
  kind = "table_image",
154
- src = outpath,
155
- name = name
58
+ src = paste0(info$prefix, ".png"),
59
+ download = list(),
60
+ descr = html_escape(descr),
61
+ name = html_escape(info$name)
156
62
  )
157
- })
158
-
159
- section_images = list()
160
- for (image in images) {
161
- section <- image$section
162
- image$section <- NULL
163
- if (is.null(section)) {
164
- section = "DEFAULT"
63
+ exformats <- setdiff(more_formats, "png")
64
+ if (length(exformats) > 0) {
65
+ report$download <- lapply(exformats, function(fmt) {
66
+ paste0(info$prefix, ".", fmt)
67
+ })
165
68
  }
166
- if (!section %in% names(section_images)) {
167
- section_images[[section]] = list()
168
- }
169
- section_images[[section]][[length(section_images[[section]]) + 1]] = image
69
+ reporter$add2(report, hs = c(info$section, info$name), ui = "table_of_images:2")
170
70
  }
171
71
 
172
- if (length(section_images) == 1 && names(section_images)[1] == "DEFAULT") {
173
- add_report(
174
- section_images,
175
- h1 = "Cell-Cell Communication Plots",
176
- ui = "table_of_images"
177
- )
178
- } else {
179
- for (section in names(section_images)) {
180
- imgplots = section_images[[section]]
181
- add_report(
182
- list(
183
- ui = "table_of_images",
184
- contents = imgplots
185
- ),
186
- h1 = section
187
- )
188
- }
189
- }
72
+ sapply(names(cases), do_case)
190
73
 
191
- save_report(joboutdir)
74
+ reporter$save(joboutdir)