biopipen 0.32.1__py3-none-any.whl → 0.33.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 (134) hide show
  1. biopipen/__init__.py +1 -1
  2. biopipen/core/config.toml +6 -0
  3. biopipen/core/filters.py +77 -26
  4. biopipen/core/testing.py +6 -1
  5. biopipen/ns/bam.py +39 -0
  6. biopipen/ns/cellranger.py +5 -0
  7. biopipen/ns/cellranger_pipeline.py +2 -2
  8. biopipen/ns/cnvkit_pipeline.py +4 -1
  9. biopipen/ns/delim.py +33 -27
  10. biopipen/ns/protein.py +99 -0
  11. biopipen/ns/scrna.py +411 -250
  12. biopipen/ns/snp.py +16 -3
  13. biopipen/ns/tcr.py +125 -1
  14. biopipen/ns/vcf.py +34 -0
  15. biopipen/ns/web.py +5 -1
  16. biopipen/reports/scrna/SeuratClusterStats.svelte +1 -1
  17. biopipen/reports/scrna/SeuratMap2Ref.svelte +15 -2
  18. biopipen/reports/tcr/ClonalStats.svelte +15 -0
  19. biopipen/reports/utils/misc.liq +22 -7
  20. biopipen/scripts/bam/BamMerge.py +2 -2
  21. biopipen/scripts/bam/BamSampling.py +4 -4
  22. biopipen/scripts/bam/BamSort.py +141 -0
  23. biopipen/scripts/bam/BamSplitChroms.py +10 -10
  24. biopipen/scripts/bam/BamSubsetByBed.py +3 -3
  25. biopipen/scripts/bam/CNVpytor.py +10 -10
  26. biopipen/scripts/bam/ControlFREEC.py +11 -11
  27. biopipen/scripts/bed/Bed2Vcf.py +5 -5
  28. biopipen/scripts/bed/BedConsensus.py +5 -5
  29. biopipen/scripts/bed/BedLiftOver.sh +6 -4
  30. biopipen/scripts/bed/BedtoolsIntersect.py +4 -4
  31. biopipen/scripts/bed/BedtoolsMakeWindows.py +3 -3
  32. biopipen/scripts/bed/BedtoolsMerge.py +4 -4
  33. biopipen/scripts/cellranger/CellRangerCount.py +20 -9
  34. biopipen/scripts/cellranger/CellRangerSummary.R +20 -29
  35. biopipen/scripts/cellranger/CellRangerVdj.py +8 -8
  36. biopipen/scripts/cnvkit/CNVkitAccess.py +6 -6
  37. biopipen/scripts/cnvkit/CNVkitAutobin.py +25 -18
  38. biopipen/scripts/cnvkit/CNVkitBatch.py +5 -5
  39. biopipen/scripts/cnvkit/CNVkitCall.py +3 -3
  40. biopipen/scripts/cnvkit/CNVkitCoverage.py +2 -2
  41. biopipen/scripts/cnvkit/CNVkitDiagram.py +5 -5
  42. biopipen/scripts/cnvkit/CNVkitFix.py +3 -3
  43. biopipen/scripts/cnvkit/CNVkitGuessBaits.py +9 -5
  44. biopipen/scripts/cnvkit/CNVkitHeatmap.py +4 -4
  45. biopipen/scripts/cnvkit/CNVkitReference.py +2 -2
  46. biopipen/scripts/cnvkit/CNVkitScatter.py +5 -5
  47. biopipen/scripts/cnvkit/CNVkitSegment.py +5 -5
  48. biopipen/scripts/cnvkit/guess_baits.py +166 -93
  49. biopipen/scripts/delim/SampleInfo.R +85 -139
  50. biopipen/scripts/misc/Config2File.py +2 -2
  51. biopipen/scripts/misc/Str2File.py +2 -2
  52. biopipen/scripts/protein/MMCIF2PDB.py +33 -0
  53. biopipen/scripts/protein/PDB2Fasta.py +60 -0
  54. biopipen/scripts/protein/Prodigy.py +4 -4
  55. biopipen/scripts/protein/RMSD.py +178 -0
  56. biopipen/scripts/regulatory/MotifScan.py +8 -8
  57. biopipen/scripts/scrna/CellCellCommunication.py +59 -22
  58. biopipen/scripts/scrna/CellsDistribution.R +31 -6
  59. biopipen/scripts/scrna/MarkersFinder.R +272 -602
  60. biopipen/scripts/scrna/MetaMarkers.R +16 -7
  61. biopipen/scripts/scrna/RadarPlots.R +75 -35
  62. biopipen/scripts/scrna/SCP-plot.R +15202 -0
  63. biopipen/scripts/scrna/ScVelo.py +0 -0
  64. biopipen/scripts/scrna/SeuratClusterStats-clustree.R +23 -25
  65. biopipen/scripts/scrna/SeuratClusterStats-dimplots.R +26 -47
  66. biopipen/scripts/scrna/SeuratClusterStats-features.R +85 -385
  67. biopipen/scripts/scrna/SeuratClusterStats-ngenes.R +33 -13
  68. biopipen/scripts/scrna/SeuratClusterStats-stats.R +45 -228
  69. biopipen/scripts/scrna/SeuratClusterStats.R +13 -19
  70. biopipen/scripts/scrna/SeuratMap2Ref.R +16 -6
  71. biopipen/scripts/scrna/SeuratPreparing.R +138 -81
  72. biopipen/scripts/scrna/SlingShot.R +71 -0
  73. biopipen/scripts/scrna/TopExpressingGenes.R +9 -7
  74. biopipen/scripts/scrna/celltypist-wrapper.py +7 -6
  75. biopipen/scripts/snp/Plink2GTMat.py +26 -11
  76. biopipen/scripts/snp/PlinkFilter.py +7 -7
  77. biopipen/scripts/snp/PlinkFromVcf.py +8 -5
  78. biopipen/scripts/snp/PlinkSimulation.py +4 -4
  79. biopipen/scripts/snp/PlinkUpdateName.py +4 -4
  80. biopipen/scripts/stats/ChowTest.R +48 -22
  81. biopipen/scripts/tcgamaf/Maf2Vcf.py +2 -2
  82. biopipen/scripts/tcgamaf/MafAddChr.py +2 -2
  83. biopipen/scripts/tcr/CDR3AAPhyschem.R +12 -2
  84. biopipen/scripts/tcr/ClonalStats.R +484 -0
  85. biopipen/scripts/tcr/CloneResidency.R +23 -5
  86. biopipen/scripts/tcr/Immunarch-basic.R +8 -1
  87. biopipen/scripts/tcr/Immunarch-clonality.R +5 -0
  88. biopipen/scripts/tcr/Immunarch-diversity.R +25 -4
  89. biopipen/scripts/tcr/Immunarch-geneusage.R +15 -1
  90. biopipen/scripts/tcr/Immunarch-kmer.R +14 -1
  91. biopipen/scripts/tcr/Immunarch-overlap.R +15 -1
  92. biopipen/scripts/tcr/Immunarch-spectratyping.R +10 -1
  93. biopipen/scripts/tcr/Immunarch-tracking.R +6 -0
  94. biopipen/scripts/tcr/Immunarch-vjjunc.R +33 -0
  95. biopipen/scripts/tcr/ScRepLoading.R +127 -0
  96. biopipen/scripts/tcr/TCRClusterStats.R +24 -7
  97. biopipen/scripts/tcr/TCRDock.py +10 -6
  98. biopipen/scripts/tcr/TESSA.R +6 -1
  99. biopipen/scripts/tcr/vdjtools-patch.sh +1 -1
  100. biopipen/scripts/vcf/BcftoolsAnnotate.py +8 -8
  101. biopipen/scripts/vcf/BcftoolsFilter.py +3 -3
  102. biopipen/scripts/vcf/BcftoolsMerge.py +31 -0
  103. biopipen/scripts/vcf/BcftoolsSort.py +4 -4
  104. biopipen/scripts/vcf/BcftoolsView.py +5 -5
  105. biopipen/scripts/vcf/Vcf2Bed.py +2 -2
  106. biopipen/scripts/vcf/VcfAnno.py +11 -11
  107. biopipen/scripts/vcf/VcfDownSample.sh +22 -10
  108. biopipen/scripts/vcf/VcfFilter.py +5 -5
  109. biopipen/scripts/vcf/VcfFix.py +7 -7
  110. biopipen/scripts/vcf/VcfFix_utils.py +12 -3
  111. biopipen/scripts/vcf/VcfIndex.py +3 -3
  112. biopipen/scripts/vcf/VcfIntersect.py +3 -3
  113. biopipen/scripts/vcf/VcfLiftOver.sh +5 -0
  114. biopipen/scripts/vcf/VcfSplitSamples.py +4 -4
  115. biopipen/scripts/vcf/bcftools_utils.py +3 -3
  116. biopipen/scripts/web/Download.py +8 -4
  117. biopipen/scripts/web/DownloadList.py +5 -5
  118. biopipen/scripts/web/GCloudStorageDownloadBucket.py +5 -5
  119. biopipen/scripts/web/GCloudStorageDownloadFile.py +3 -3
  120. biopipen/scripts/web/gcloud_common.py +1 -1
  121. biopipen/utils/gsea.R +96 -42
  122. biopipen/utils/misc.R +205 -7
  123. biopipen/utils/misc.py +17 -8
  124. biopipen/utils/plot.R +53 -17
  125. biopipen/utils/reference.py +11 -11
  126. biopipen/utils/repr.R +146 -0
  127. biopipen/utils/vcf.py +1 -1
  128. {biopipen-0.32.1.dist-info → biopipen-0.33.0.dist-info}/METADATA +9 -9
  129. {biopipen-0.32.1.dist-info → biopipen-0.33.0.dist-info}/RECORD +131 -122
  130. {biopipen-0.32.1.dist-info → biopipen-0.33.0.dist-info}/WHEEL +1 -1
  131. biopipen/scripts/scrna/SeuratClusterStats-hists.R +0 -139
  132. biopipen/scripts/scrna/SeuratPreparing-common.R +0 -452
  133. biopipen/scripts/scrna/SeuratPreparing-doublet_detection.R +0 -201
  134. {biopipen-0.32.1.dist-info → biopipen-0.33.0.dist-info}/entry_points.txt +0 -0
@@ -1,251 +1,68 @@
1
1
  # Loaded variables: srtfile, outdir, srtobj
2
2
  library(circlize)
3
3
 
4
- # stats_defaults = {{envs.stats_defaults | r: todot="-"}}
5
- # stats = {{envs.stats | r: todot="-", skip=1}}
6
- log_info("stats:")
4
+ log$info("stats:")
7
5
 
8
- odir = file.path(outdir, "stats")
6
+ odir <- file.path(outdir, "stats")
9
7
  dir.create(odir, recursive=TRUE, showWarnings=FALSE)
10
8
 
11
- do_one_stats = function(name) {
12
- log_info("- Case: {name}")
9
+ do_one_stats <- function(name) {
10
+ log$info("- Case: {name}")
13
11
 
14
- case = list_update(stats_defaults, stats[[name]])
15
- case$devpars = list_update(stats_defaults$devpars, case$devpars)
16
- case$pie_devpars = list_update(stats_defaults$pie_devpars, case$pie_devpars)
17
- case$circos_devpars = list_update(stats_defaults$circos_devpars, case$circos_devpars)
18
- if (isTRUE(case$pie) && !is.null(case$group.by)) {
19
- stop(paste0(name, ": pie charts are not supported for group-by"))
20
- }
21
- if (isTRUE(case$transpose) && is.null(case$group.by)) {
22
- stop(paste0(name, ": transpose is only supported for group-by"))
23
- }
24
-
25
- figfile = file.path(odir, paste0(slugify(name), ".bar.png"))
26
- piefile = file.path(odir, paste0(slugify(name), ".pie.png"))
27
- circosfile = file.path(odir, paste0(slugify(name), ".circos.png"))
28
- samtablefile = file.path(odir, paste0(slugify(name), ".bysample.txt"))
29
- tablefile = file.path(odir, paste0(slugify(name), ".txt"))
30
-
31
- df_cells = srtobj@meta.data %>% drop_na(!!sym(case$ident))
32
- if (!is.null(case$subset)) {
33
- df_cells = df_cells %>% filter(!!rlang::parse_expr(case$subset))
34
- }
12
+ case <- list_update(stats_defaults, stats[[name]])
13
+ extract_vars(case, "devpars", "more_formats", "save_code", "save_data", "subset")
35
14
 
36
- select_cols = unique(c(case$ident, case$group.by, case$split.by))
37
- if (!is.null(case$split.by)) {
38
- plot_df = do_call(rbind, lapply(group_split(
39
- df_cells %>% select(all_of(select_cols)),
40
- !!!syms(case$split.by)
41
- ), function(df) {
42
- out <- df %>% group_by(!!!syms(select_cols)) %>% summarise(.n = n(), .groups = "drop")
43
- if (!is.null(case$group.by) && case$frac != "none") {
44
- if (case$frac == "all") {
45
- out <- out %>% mutate(.frac = .n / sum(.n))
46
- } else if (case$frac == "group") {
47
- out <- out %>% group_by(!!sym(case$group.by)) %>% mutate(.frac = .n / sum(.n))
48
- } else { # case$frac == "ident" or "cluster"
49
- out <- out %>% group_by(!!sym(case$ident)) %>% mutate(.frac = .n / sum(.n))
50
- }
51
- }
52
- out
53
- }))
54
- } else if (!is.null(case$group.by) && case$frac != "none") { # no split.by
55
- plot_df <- df_cells %>%
56
- select(all_of(select_cols)) %>%
57
- group_by(!!!syms(select_cols)) %>%
58
- summarise(.n = n(), .groups = "drop")
59
- if (case$frac == "all") {
60
- plot_df = plot_df %>% mutate(.frac = .n / sum(.n))
61
- } else if (case$frac == "group") {
62
- plot_df = plot_df %>% group_by(!!sym(case$group.by)) %>% mutate(.frac = .n / sum(.n))
63
- } else { # case$frac == "ident" or "cluster"
64
- plot_df = plot_df %>% group_by(!!sym(case$ident)) %>% mutate(.frac = .n / sum(.n))
65
- }
15
+ if (!is.null(subset)) {
16
+ case$object <- srtobj %>% filter(!!parse_expr(subset))
66
17
  } else {
67
- plot_df <- df_cells %>%
68
- select(all_of(select_cols)) %>%
69
- group_by(!!!syms(select_cols)) %>%
70
- summarise(.n = n(), .groups = "drop")
71
-
72
- if (case$frac != "none") {
73
- plot_df <- plot_df %>% mutate(.frac = .n / sum(.n))
74
- }
18
+ case$object <- srtobj
75
19
  }
76
20
 
77
- write.table(plot_df, tablefile, sep="\t", quote=FALSE, row.names=FALSE)
78
-
79
- ngroups = ifelse(is.null(case$group.by), 1, length(unique(plot_df[[case$group.by]])))
80
- nidents = length(unique(plot_df[[case$ident]]))
81
- bar_position = ifelse(case$position == "auto", ifelse(ngroups > 5, "stack", "dodge"), case$position)
82
- p = plot_df %>%
83
- ggplot(aes(
84
- x=!!sym(ifelse(case$transpose, case$group.by, case$ident)),
85
- y=if (case$frac != "none") .frac else .n,
86
- fill=!!sym(ifelse(is.null(case$group.by) || isTRUE(case$transpose), case$ident, case$group.by))
87
- )) +
88
- geom_bar(stat="identity", position=bar_position, alpha=.8) +
89
- theme_prism(axis_text_angle = 90) +
90
- scale_fill_biopipen() +
91
- ylab(ifelse(case$frac != "none", "Fraction of cells", "Number of cells"))
92
-
93
- if (!is.null(case$split.by)) {
94
- p = p + facet_wrap(case$split.by)
95
- }
96
-
97
- png(figfile, width=case$devpars$width, height=case$devpars$height, res=case$devpars$res)
98
- print(p)
99
- dev.off()
100
-
101
- add_report(
102
- list(
103
- kind = "descr",
104
- content = paste0(
105
- "Plots showing the ",
106
- ifelse(case$frac != "none", "number/faction", "number"),
107
- " of cells per cluster",
108
- ifelse(
109
- is.null(case$group.by),
110
- "",
111
- paste0(", by ", paste0(case$group.by, collapse = ", "))
112
- )
113
- )
114
- ),
115
- h1 = name
116
- )
117
-
118
- add_report(
119
- list(
120
- name = "Bar Plot",
121
- contents = list(list(kind = "image", src = figfile))
122
- ),
123
- h1 = name,
124
- ui = "tabs"
125
- )
126
- if (isTRUE(case$table)) {
127
- add_report(
128
- list(
129
- name = "Table",
130
- contents = list(list(kind = "table", src = tablefile))
131
- ),
132
- h1 = name,
133
- ui = "tabs"
134
- )
21
+ info <- case_info(name, odir, is_dir = FALSE, create = TRUE)
22
+ p <- do_call(gglogger::register(CellStatPlot), case)
23
+ save_plot(p, info$prefix, devpars, formats = c("png", more_formats))
24
+ if (save_code) {
25
+ save_plotcode(p, info$prefix,
26
+ setup = c("library(scplotter)", "load('data.RData')", "invisible(list2env('case'))"),
27
+ "case",
28
+ auto_data_setup = FALSE)
135
29
  }
136
30
 
137
- if (isTRUE(case$pie)) {
138
- p_pie = plot_df %>%
139
- arrange(!!sym(case$ident)) %>%
140
- ggplot(aes(x="", y=.n, fill=!!sym(case$ident))) +
141
- geom_bar(stat="identity", width=1, alpha=.8, position = position_stack(reverse = TRUE)) +
142
- coord_polar("y", start=0) +
143
- scale_fill_biopipen() +
144
- guides(fill = guide_legend(title = case$ident)) +
145
- theme_void() +
146
- geom_label(
147
- if (case$frac != "none")
148
- aes(label=sprintf("%.1f%%", .frac * 100))
149
- else
150
- aes(label=.n),
151
- position = position_stack(vjust = 0.5),
152
- color="#333333",
153
- fill="#EEEEEE",
154
- size=5
155
- )
156
-
157
- if (!is.null(case$split.by)) {
158
- p_pie = p_pie + facet_wrap(case$split.by)
31
+ if (save_data) {
32
+ if (!inherits(p$data, "data.frame") && !inherits(p$data, "matrix")) {
33
+ stop("'save_data = TRUE' is not supported for plot_type: ", case$plot_type)
159
34
  }
160
-
161
- png(piefile, width=case$pie_devpars$width, height=case$pie_devpars$height, res=case$pie_devpars$res)
162
- print(p_pie)
163
- dev.off()
164
-
165
- add_report(
35
+ write.table(p$data, paste0(info$prefix, ".data.txt"), sep="\t", quote=FALSE, row.names=FALSE)
36
+ reporter$add2(
166
37
  list(
167
- name = "Pie Chart",
168
- contents = list(list(kind = "image", src = piefile))
38
+ name = "Plot",
39
+ contents = list(
40
+ reporter$image(
41
+ info$prefix, more_formats, save_code, kind = "image")
42
+ )
169
43
  ),
170
- h1 = name,
171
- ui = "tabs"
172
- )
173
- }
174
-
175
- if (isTRUE(case$circos)) {
176
- if (is.null(case$group.by)) {
177
- stop(paste0(name, ": circos plots require a group-by"))
178
- }
179
- if (isTRUE(case$transpose)) {
180
- circos_df <- plot_df %>%
181
- select(from=!!sym(case$ident), to=!!sym(case$group.by), value=.n)
182
- } else {
183
- circos_df <- plot_df %>%
184
- select(from=!!sym(case$group.by), to=!!sym(case$ident), value=.n)
185
- }
186
- groups <- if (is.factor(circos_df$from)) {
187
- levels(circos_df$from)
188
- } else {
189
- unique(circos_df$from)
190
- }
191
- idents <- if (is.factor(circos_df$to)) {
192
- levels(circos_df$to)
193
- } else {
194
- unique(circos_df$to)
195
- }
196
- grid_cols <- pal_biopipen()(length(idents))
197
- names(grid_cols) <- idents
198
- gcols <- rep("#565656", length(groups))
199
- names(gcols) <- groups
200
- grid_cols <- c(grid_cols, gcols)
201
- link_cols <- grid_cols[circos_df$to]
202
-
203
- png(
204
- circosfile,
205
- width=case$circos_devpars$width,
206
- height=case$circos_devpars$height,
207
- res=case$circos_devpars$res
208
- )
209
- circos.clear()
210
- if (!isTRUE(case$circos_labels_rot)) {
211
- chordDiagram(
212
- circos_df,
213
- grid.col = grid_cols,
214
- col = link_cols,
215
- direction = 1,
216
- direction.type = c("diffHeight", "arrows"),
217
- link.arr.type = "big.arrow"
218
- )
219
- } else {
220
- chordDiagram(
221
- circos_df,
222
- grid.col = grid_cols,
223
- col = link_cols,
224
- direction = 1,
225
- annotationTrack = "grid",
226
- direction.type = c("diffHeight", "arrows"),
227
- link.arr.type = "big.arrow",
228
- preAllocateTracks = list(track.height = max(strwidth(unlist(dimnames(circos_df)))))
229
- )
230
- circos.track(track.index = 1, panel.fun = function(x, y) {
231
- circos.text(
232
- CELL_META$xcenter, CELL_META$ylim[1],
233
- CELL_META$sector.index,
234
- facing = "clockwise",
235
- niceFacing = TRUE,
236
- adj = c(0, 0.5))
237
- }, bg.border = NA) # here set bg.border to NA is important
238
- }
239
- dev.off()
240
-
241
- add_report(
242
44
  list(
243
- name = "Circos plot",
244
- contents = list(list(kind = "image", src = circosfile))
45
+ name = "Data",
46
+ contents = list(
47
+ list(
48
+ kind = "descr",
49
+ content = "Data used directly for the plot"
50
+ ),
51
+ list(
52
+ kind = "table",
53
+ src = paste0(info$prefix, ".data.txt"),
54
+ data = list(nrows = 100)
55
+ )
56
+ )
245
57
  ),
246
- h1 = name,
58
+ hs = c(info$section, info$name),
247
59
  ui = "tabs"
248
60
  )
61
+ } else {
62
+ reporter$add2(
63
+ reporter$image(info$prefix, more_formats, save_code, kind = "image"),
64
+ hs = c(info$section, info$name)
65
+ )
249
66
  }
250
67
  }
251
68
 
@@ -1,35 +1,34 @@
1
- {{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
2
- {{ biopipen_dir | joinpaths: "utils", "mutate_helpers.R" | source_r }}
3
- {{ biopipen_dir | joinpaths: "utils", "plot.R" | source_r }}
4
-
5
1
  library(Seurat)
6
2
  library(rlang)
7
3
  library(dplyr)
8
4
  library(tidyr)
9
5
  library(tibble)
10
- library(ggprism)
11
- library(ggrepel)
6
+ library(forcats)
12
7
  library(tidyseurat)
13
- library(circlize)
14
- library(ComplexHeatmap)
8
+ library(gglogger)
9
+ library(scplotter)
10
+ library(biopipen.utils)
11
+
12
+ log <- get_logger()
13
+ reporter <- get_reporter()
15
14
 
16
15
  srtfile <- {{in.srtobj | r}}
17
16
  outdir <- {{out.outdir | r}}
18
17
  joboutdir <- {{job.outdir | r}}
19
18
  mutaters <- {{envs.mutaters | r}}
20
19
 
21
- log_info("Loading Seurat object ...")
20
+ log$info("Loading Seurat object ...")
22
21
  srtobj = readRDS(srtfile)
23
22
 
24
- log_info("Applying mutaters if any ...")
23
+ log$info("Applying mutaters if any ...")
25
24
  if (!is.null(mutaters) && length(mutaters) > 0) {
26
25
  srtobj@meta.data = srtobj@meta.data %>%
27
26
  mutate(!!!lapply(mutaters, parse_expr))
28
27
  }
29
28
 
30
29
  ############## clustree ##############
31
- clustrees_defaults <- {{envs.clustrees_defaults | r}}
32
- clustrees <- {{envs.clustrees | r}}
30
+ clustrees_defaults <- {{envs.clustrees_defaults | r: todot="-"}}
31
+ clustrees <- {{envs.clustrees | r: todot="-", skip=1}}
33
32
  {{ biopipen_dir | joinpaths: "scripts", "scrna", "SeuratClusterStats-clustree.R" | source_r }}
34
33
 
35
34
  ############## stats ##############
@@ -37,11 +36,6 @@ stats_defaults = {{envs.stats_defaults | r: todot="-"}}
37
36
  stats = {{envs.stats | r: todot="-", skip=1}}
38
37
  {{ biopipen_dir | joinpaths: "scripts", "scrna", "SeuratClusterStats-stats.R" | source_r }}
39
38
 
40
- ############## hists ##############
41
- hists_defaults <- {{envs.hists_defaults | r: todot="-"}}
42
- hists <- {{envs.hists | r: todot="-", skip=1}}
43
- {{ biopipen_dir | joinpaths: "scripts", "scrna", "SeuratClusterStats-hists.R" | source_r }}
44
-
45
39
  ############## ngenes ##############
46
40
  ngenes_defaults <- {{envs.ngenes_defaults | r: todot="-"}}
47
41
  ngenes <- {{envs.ngenes | r: todot="-", skip=1}}
@@ -50,11 +44,11 @@ ngenes <- {{envs.ngenes | r: todot="-", skip=1}}
50
44
  ############## features ##############
51
45
  features_defaults = {{envs.features_defaults | r: todot="-"}}
52
46
  features = {{envs.features | r: todot="-", skip=1}}
53
- {{ biopipen_dir | joinpaths: "scripts", "scrna", "SeuratClusterStats-features.R" | source_r }}
47
+ {{ biopipen_dir | joinpaths: "scripts", "scrna", "SeuratClusterStats-features.R" | source_r: chdir = False }}
54
48
 
55
49
  ############## dimplots ##############
56
50
  dimplots_defaults = {{envs.dimplots_defaults | r: todot="-"}}
57
51
  dimplots = {{envs.dimplots | r: todot="-", skip=1}}
58
52
  {{ biopipen_dir | joinpaths: "scripts", "scrna", "SeuratClusterStats-dimplots.R" | source_r }}
59
53
 
60
- save_report(joboutdir)
54
+ reporter$save(joboutdir)
@@ -6,8 +6,11 @@ library(SeuratDisk)
6
6
  library(rlang)
7
7
  library(dplyr)
8
8
  library(tidyr)
9
+ library(ggplot2)
10
+ library(ggprism)
9
11
 
10
12
  set.seed(8525)
13
+ theme_set(theme_prism())
11
14
 
12
15
  sobjfile = {{in.sobjfile | r}}
13
16
  outfile = {{out.outfile | r}}
@@ -346,8 +349,16 @@ saveRDS(sobj, file = outfile)
346
349
  # ############################
347
350
  # Some plots
348
351
  # ############################
352
+ log_info("- Plotting mapping score ...")
353
+ p <- FeaturePlot(
354
+ object = sobj,
355
+ reduction = "ref.umap",
356
+ features = "mapping.score",
357
+ cols = c("white", "blue"),
358
+ pt.size = 0.5
359
+ ) + ggtitle("Mapping score for query cells")
360
+ save_plot(p, file.path(outdir, "mapping_score"), list(width = 800, height = 600, res = 100))
349
361
 
350
- # # Plot the UMAP
351
362
  log_info("- Plotting for transferred data ...")
352
363
  ref.reduction = mapquery_args$reduction.model %||% "wnn.umap"
353
364
  for (qname in names(mapquery_args$refdata)) {
@@ -358,8 +369,7 @@ for (qname in names(mapquery_args$refdata)) {
358
369
  next
359
370
  }
360
371
 
361
- log_info(" Plotting transferred data: {qname} -> {rname}")
362
-
372
+ log_info(" UMAP for transferred data: {qname} -> {rname}")
363
373
  ref_p <- DimPlot(
364
374
  object = reference,
365
375
  reduction = ref.reduction,
@@ -378,9 +388,9 @@ for (qname in names(mapquery_args$refdata)) {
378
388
  repel = TRUE,
379
389
  ) + NoLegend()
380
390
 
381
- png(file.path(outdir, paste0("UMAPs-", slugify(qname), ".png")), width = 1500, height = 700, res = 100)
382
- print(ref_p | query_p)
383
- dev.off()
391
+ p <- ref_p | query_p
392
+ prefix <- file.path(outdir, paste0("UMAPs-", slugify(qname)))
393
+ save_plot(p, prefix, list(width = 1500, height = 700, res = 100))
384
394
 
385
395
  # summarize the stats
386
396
  log_info(" Summarizing stats: {qname} -> {rname}")