biopipen 0.32.3__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 (117) hide show
  1. biopipen/__init__.py +1 -1
  2. biopipen/core/config.toml +6 -0
  3. biopipen/core/filters.py +35 -23
  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 +20 -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 -148
  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/MarkersFinder.R +273 -654
  59. biopipen/scripts/scrna/RadarPlots.R +73 -53
  60. biopipen/scripts/scrna/SCP-plot.R +15202 -0
  61. biopipen/scripts/scrna/ScVelo.py +0 -0
  62. biopipen/scripts/scrna/SeuratClusterStats-clustree.R +23 -31
  63. biopipen/scripts/scrna/SeuratClusterStats-dimplots.R +26 -54
  64. biopipen/scripts/scrna/SeuratClusterStats-features.R +85 -403
  65. biopipen/scripts/scrna/SeuratClusterStats-ngenes.R +32 -17
  66. biopipen/scripts/scrna/SeuratClusterStats-stats.R +45 -239
  67. biopipen/scripts/scrna/SeuratClusterStats.R +13 -19
  68. biopipen/scripts/scrna/SeuratMap2Ref.R +16 -12
  69. biopipen/scripts/scrna/SeuratPreparing.R +138 -81
  70. biopipen/scripts/scrna/SlingShot.R +71 -0
  71. biopipen/scripts/scrna/celltypist-wrapper.py +7 -6
  72. biopipen/scripts/snp/Plink2GTMat.py +26 -11
  73. biopipen/scripts/snp/PlinkFilter.py +7 -7
  74. biopipen/scripts/snp/PlinkFromVcf.py +8 -5
  75. biopipen/scripts/snp/PlinkSimulation.py +4 -4
  76. biopipen/scripts/snp/PlinkUpdateName.py +4 -4
  77. biopipen/scripts/stats/ChowTest.R +48 -22
  78. biopipen/scripts/tcgamaf/Maf2Vcf.py +2 -2
  79. biopipen/scripts/tcgamaf/MafAddChr.py +2 -2
  80. biopipen/scripts/tcr/ClonalStats.R +484 -0
  81. biopipen/scripts/tcr/ScRepLoading.R +127 -0
  82. biopipen/scripts/tcr/TCRDock.py +10 -6
  83. biopipen/scripts/tcr/vdjtools-patch.sh +1 -1
  84. biopipen/scripts/vcf/BcftoolsAnnotate.py +8 -8
  85. biopipen/scripts/vcf/BcftoolsFilter.py +3 -3
  86. biopipen/scripts/vcf/BcftoolsMerge.py +31 -0
  87. biopipen/scripts/vcf/BcftoolsSort.py +4 -4
  88. biopipen/scripts/vcf/BcftoolsView.py +5 -5
  89. biopipen/scripts/vcf/Vcf2Bed.py +2 -2
  90. biopipen/scripts/vcf/VcfAnno.py +11 -11
  91. biopipen/scripts/vcf/VcfDownSample.sh +22 -10
  92. biopipen/scripts/vcf/VcfFilter.py +5 -5
  93. biopipen/scripts/vcf/VcfFix.py +7 -7
  94. biopipen/scripts/vcf/VcfFix_utils.py +12 -3
  95. biopipen/scripts/vcf/VcfIndex.py +3 -3
  96. biopipen/scripts/vcf/VcfIntersect.py +3 -3
  97. biopipen/scripts/vcf/VcfLiftOver.sh +5 -0
  98. biopipen/scripts/vcf/VcfSplitSamples.py +4 -4
  99. biopipen/scripts/vcf/bcftools_utils.py +3 -3
  100. biopipen/scripts/web/Download.py +8 -4
  101. biopipen/scripts/web/DownloadList.py +5 -5
  102. biopipen/scripts/web/GCloudStorageDownloadBucket.py +5 -5
  103. biopipen/scripts/web/GCloudStorageDownloadFile.py +3 -3
  104. biopipen/scripts/web/gcloud_common.py +1 -1
  105. biopipen/utils/gsea.R +75 -35
  106. biopipen/utils/misc.R +205 -7
  107. biopipen/utils/misc.py +17 -8
  108. biopipen/utils/reference.py +11 -11
  109. biopipen/utils/repr.R +146 -0
  110. biopipen/utils/vcf.py +1 -1
  111. {biopipen-0.32.3.dist-info → biopipen-0.33.0.dist-info}/METADATA +8 -8
  112. {biopipen-0.32.3.dist-info → biopipen-0.33.0.dist-info}/RECORD +114 -105
  113. {biopipen-0.32.3.dist-info → biopipen-0.33.0.dist-info}/WHEEL +1 -1
  114. biopipen/scripts/scrna/SeuratClusterStats-hists.R +0 -144
  115. biopipen/scripts/scrna/SeuratPreparing-common.R +0 -467
  116. biopipen/scripts/scrna/SeuratPreparing-doublet_detection.R +0 -204
  117. {biopipen-0.32.3.dist-info → biopipen-0.33.0.dist-info}/entry_points.txt +0 -0
@@ -1,4 +1,5 @@
1
1
  {{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
2
+ {{ biopipen_dir | joinpaths: "utils", "repr.R" | source_r }}
2
3
 
3
4
  library(Seurat)
4
5
  library(rlang)
@@ -8,6 +9,8 @@ library(tibble)
8
9
  library(ggplot2)
9
10
  library(ggradar)
10
11
  library(ggprism)
12
+ library(glue)
13
+ library(gglogger)
11
14
 
12
15
  # input/output
13
16
  srtfile = {{in.srtobj | r}}
@@ -192,40 +195,46 @@ do_radarplot <- function(info, case, counts) {
192
195
  }
193
196
 
194
197
  # Plot
195
- plotfile = file.path(info$casedir, "plot.png")
196
- plotfile_pdf = file.path(info$casedir, "plot.pdf")
197
198
  if (!is.null(case$colors) && length(case$colors) == 1 && case$colors == "biopipen") {
198
199
  colors = pal_biopipen()(nrow(rdr_data))
199
200
  } else if (!is.null(case$colors) && length(case$colors) > 0) {
200
201
  colors = trimws(unlist(strsplit(case$colors, ",")))
201
202
  }
203
+
204
+ plotdf <- rdr_data %>%
205
+ as.data.frame() %>%
206
+ rownames_to_column("group") %>%
207
+ mutate(group = factor(group, levels = rownames(rdr_data)))
208
+
202
209
  p = ggradar(
203
- rdr_data %>%
204
- as.data.frame() %>%
205
- rownames_to_column("group") %>%
206
- mutate(group = factor(group, levels = rownames(rdr_data))),
210
+ plotdf,
207
211
  values.radar = paste0(breaks, "%"),
208
212
  grid.min = breaks[1] / 100,
209
213
  grid.mid = breaks[2] / 100,
210
214
  grid.max = breaks[3] / 100,
211
215
  group.colours = colors
212
216
  )
213
- png(
214
- plotfile,
215
- width = case$devpars$width,
216
- height = case$devpars$height,
217
- res = case$devpars$res
217
+ prefix <- file.path(info$casedir, "plot")
218
+ save_plot(p, prefix, case$devpars)
219
+
220
+ code_file <- paste0(prefix, ".R")
221
+ code = glue(
222
+ "library(ggradar)
223
+
224
+ plotdf <- {repr(plotdf)}
225
+ breaks <- {repr(breaks)}
226
+ colors <- {repr(colors)}
227
+
228
+ ggradar(
229
+ plotdf,
230
+ values.radar = paste0(breaks, '%'),
231
+ grid.min = breaks[1] / 100,
232
+ grid.mid = breaks[2] / 100,
233
+ grid.max = breaks[3] / 100,
234
+ group.colours = colors
235
+ )"
218
236
  )
219
- print(p)
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()
237
+ writeLines(code, code_file)
229
238
  }
230
239
 
231
240
  do_barplot_and_tests <- function(info, case, counts) {
@@ -275,43 +284,42 @@ do_barplot_and_tests <- function(info, case, counts) {
275
284
  rowwise() %>%
276
285
  mutate(mean_sd1 = max(.mean - .sd, 0), mean_sd2 = .mean + .sd)
277
286
 
287
+ if (!is.null(case$colors) && length(case$colors) == 1 && case$colors == "biopipen") {
288
+ colors <- pal_biopipen(.8)(length(unique(plotdata[[case$by]])))
289
+ } else if (!is.null(case$colors) && length(case$colors) > 0) {
290
+ colors <- trimws(unlist(strsplit(case$colors, ",")))
291
+ }
292
+
278
293
  # Plot the barplot
279
- plotfile = file.path(info$casedir, "barplot.png")
280
- plotfile_pdf = file.path(info$casedir, "barplot.pdf")
281
294
  p = ggplot(plotdata, aes(x = !!sym(case$ident), y = .mean, fill = !!sym(case$by))) +
282
- geom_bar(stat = "identity", position = "dodge") +
295
+ geom_bar(stat = "identity", position = "dodge", color = "#333333") +
283
296
  geom_errorbar(
284
297
  aes(ymin = mean_sd1, ymax = mean_sd2),
285
- width = 0.4,
286
- linewidth = 0.8,
298
+ width = 0.2,
299
+ alpha = 0.5,
300
+ linewidth = 0.6,
287
301
  position = position_dodge(0.9),
288
302
  color = "#333333"
289
303
  ) +
290
- theme_prism(axis_text_angle = 90) +
291
- ylab("Fraction of cells")
292
-
293
- if (!is.null(case$colors) && length(case$colors) == 1 && case$colors == "biopipen") {
294
- p <- p + scale_fill_biopipen(.8)
295
- } else if (!is.null(case$colors) && length(case$colors) > 0) {
296
- p <- p + scale_fill_manual(values = trimws(unlist(strsplit(case$colors, ","))))
297
- }
298
-
299
- png(
300
- plotfile,
301
- width = case$bar_devpars$width,
302
- height = case$bar_devpars$height,
303
- res = case$bar_devpars$res
304
- )
305
- print(p)
306
- dev.off()
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()
304
+ theme_prism(axis_text_angle = 45) +
305
+ ylab("Fraction of cells") +
306
+ scale_fill_manual(values = colors)
307
+
308
+ prefix = file.path(info$casedir, "barplot")
309
+ save_plot(p, prefix, case$bar_devpars)
310
+ neat_case <- list(by = case$by, ident = case$ident)
311
+ save_plotcode(
312
+ p,
313
+ setup = c(
314
+ 'library(rlang)',
315
+ 'library(ggplot2)',
316
+ 'library(ggprism)',
317
+ '',
318
+ 'load("data.RData")',
319
+ 'case <- neat_case'
320
+ ),
321
+ prefix,
322
+ "plotdata", "neat_case", "colors")
315
323
 
316
324
  # Do the tests in each cluster between groups on .frac
317
325
  bys <- bardata %>% pull(!!sym(case$by)) %>% unique()
@@ -367,7 +375,12 @@ add_case_report = function(info, breakdown, test) {
367
375
  list(
368
376
  kind = "image",
369
377
  src = file.path(info$casedir, "plot.png"),
370
- download = file.path(info$casedir, "plot.pdf")
378
+ download = list(
379
+ file.path(info$casedir, "plot.pdf"),
380
+ list(
381
+ src = file.path(info$casedir, "plot.R"),
382
+ tip = "Download the code used to reproduce the plot",
383
+ icon = "Code"))
371
384
  )
372
385
  )
373
386
  ),
@@ -401,7 +414,14 @@ add_case_report = function(info, breakdown, test) {
401
414
  list(
402
415
  kind = "image",
403
416
  src = file.path(info$casedir, "barplot.png"),
404
- download = file.path(info$casedir, "barplot.pdf")
417
+ download = list(
418
+ file.path(info$casedir, "barplot.pdf"),
419
+ list(
420
+ src = file.path(info$casedir, "barplot.code.zip"),
421
+ tip = "Download the code used to reproduce the plot",
422
+ icon = "Code"
423
+ )
424
+ )
405
425
  )
406
426
  )
407
427
  ))