biopipen 0.34.1__py3-none-any.whl → 0.34.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 (32) hide show
  1. biopipen/__init__.py +1 -1
  2. biopipen/ns/scrna.py +259 -34
  3. biopipen/ns/scrna_metabolic_landscape.py +1 -1
  4. biopipen/ns/tcr.py +9 -4
  5. biopipen/reports/scrna_metabolic_landscape/MetabolicFeatures.svelte +12 -3
  6. biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayActivity.svelte +12 -3
  7. biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayHeterogeneity.svelte +12 -3
  8. biopipen/scripts/scrna/CellTypeAnnotation-celltypist.R +3 -10
  9. biopipen/scripts/scrna/MarkersFinder.R +34 -28
  10. biopipen/scripts/scrna/PseudoBulkDEG.R +592 -0
  11. biopipen/scripts/scrna/ScFGSEA.R +35 -35
  12. biopipen/scripts/scrna/SeuratClusterStats-clustree.R +16 -0
  13. biopipen/scripts/scrna/SeuratClusterStats-dimplots.R +1 -1
  14. biopipen/scripts/scrna/SeuratClusterStats-features.R +29 -6
  15. biopipen/scripts/scrna/SeuratClusterStats-stats.R +29 -1
  16. biopipen/scripts/scrna/SeuratClusterStats.R +1 -0
  17. biopipen/scripts/scrna/TopExpressingGenes.R +6 -6
  18. biopipen/scripts/scrna/celltypist-wrapper.py +2 -0
  19. biopipen/scripts/scrna_metabolic_landscape/MetabolicFeatures.R +9 -3
  20. biopipen/scripts/scrna_metabolic_landscape/MetabolicPathwayActivity.R +2 -2
  21. biopipen/scripts/scrna_metabolic_landscape/MetabolicPathwayHeterogeneity.R +1 -0
  22. biopipen/scripts/tcr/GIANA/GIANA4.py +2 -4
  23. biopipen/scripts/tcr/ScRepCombiningExpression.R +3 -2
  24. biopipen/scripts/tcr/ScRepLoading.R +7 -2
  25. biopipen/scripts/tcr/TCRClustering.R +9 -23
  26. biopipen/scripts/tcr/TESSA.R +4 -2
  27. {biopipen-0.34.1.dist-info → biopipen-0.34.3.dist-info}/METADATA +1 -1
  28. {biopipen-0.34.1.dist-info → biopipen-0.34.3.dist-info}/RECORD +30 -31
  29. biopipen/reports/scrna/TopExpressingGenes.svelte +0 -17
  30. biopipen/scripts/scrna/SCP-plot.R +0 -15202
  31. {biopipen-0.34.1.dist-info → biopipen-0.34.3.dist-info}/WHEEL +0 -0
  32. {biopipen-0.34.1.dist-info → biopipen-0.34.3.dist-info}/entry_points.txt +0 -0
@@ -1,6 +1,7 @@
1
1
  library(rlang)
2
2
  library(dplyr)
3
3
  library(Seurat)
4
+ library(tidyseurat)
4
5
  library(plotthis)
5
6
  library(biopipen.utils)
6
7
 
@@ -13,9 +14,9 @@ joboutdir <- {{ job.outdir | r }}
13
14
 
14
15
  ncores <- {{ envs.ncores | int }}
15
16
  mutaters <- {{ envs.mutaters | r }}
16
- group.by <- {{ envs["group-by"] | r }}
17
- ident.1 <- {{ envs["ident-1"] | r }}
18
- ident.2 <- {{ envs["ident-2"] | r }}
17
+ group_by <- {{ envs.group_by | default: envs["group-by"] | default: None | r }}
18
+ ident_1 <- {{ envs.ident_1 | default: envs["ident-1"] | default: None | r }}
19
+ ident_2 <- {{ envs.ident_2 | default: envs["ident-2"] | default: None | r }}
19
20
  each <- {{ envs.each | r }}
20
21
  dbs <- {{ envs.dbs | r }}
21
22
  sigmarkers <- {{ envs.sigmarkers | r }}
@@ -75,9 +76,9 @@ overlaps <- lapply(overlaps, function(x) {
75
76
  })
76
77
 
77
78
  defaults <- list(
78
- group.by = group.by,
79
- ident.1 = ident.1,
80
- ident.2 = ident.2,
79
+ group_by = group_by,
80
+ ident_1 = ident_1,
81
+ ident_2 = ident_2,
81
82
  dbs = dbs,
82
83
  sigmarkers = sigmarkers,
83
84
  enrich_style = enrich_style,
@@ -104,17 +105,17 @@ log$info("Expanding cases ...")
104
105
  post_casing <- function(name, case) {
105
106
  outcases <- list()
106
107
 
107
- case$group.by <- case$group.by %||% "Identity"
108
+ case$group_by <- case$group_by %||% "Identity"
108
109
 
109
110
  if (is.null(case$each) || is.na(case$each) || nchar(case$each) == 0 || isFALSE(each)) {
110
111
  # single cases, no need to expand
111
- if (length(case$ident.1) > 0 && length(case$overlaps) > 0) {
112
+ if (length(case$ident_1) > 0 && length(case$overlaps) > 0) {
112
113
  stop("Cannot perform 'overlaps' with a single comparison (ident-1 is set) in case '", name, "'")
113
114
  }
114
- if (length(case$ident.1) > 0 && length(case$allmarker_plots) > 0) {
115
+ if (length(case$ident_1) > 0 && length(case$allmarker_plots) > 0) {
115
116
  stop("Cannot perform 'allmarker_plots' with a single comparison (ident-1 is set) in case '", name, "'")
116
117
  }
117
- if (length(case$ident.1) > 0 && length(case$allenrich_plots) > 0) {
118
+ if (length(case$ident_1) > 0 && length(case$allenrich_plots) > 0) {
118
119
  stop("Cannot perform 'allenrich_plots' with a single comparison (ident-1 is set) in case '", name, "'")
119
120
  }
120
121
 
@@ -158,8 +159,8 @@ post_casing <- function(name, case) {
158
159
  srtobj@meta.data %>%
159
160
  pull(case$each) %>% na.omit() %>% unique() %>% as.vector()
160
161
  }
161
- if (length(case$overlaps) > 0 && is.null(case$ident.1)) {
162
- stop("Cannot perform 'overlaps' analysis with 'each' and without 'ident.1' in case '", name, "'")
162
+ if (length(case$overlaps) > 0 && is.null(case$ident_1)) {
163
+ stop("Cannot perform 'overlaps' analysis with 'each' and without 'ident_1' in case '", name, "'")
163
164
  }
164
165
 
165
166
  if (length(cases) == 0 && name == "Marker Discovery") {
@@ -173,6 +174,7 @@ post_casing <- function(name, case) {
173
174
  newcase$original_case <- name
174
175
  newcase$each_name <- case$each
175
176
  newcase$each <- each
177
+ newcase$original_subset <- case$subset
176
178
 
177
179
  if (!is.null(case$subset)) {
178
180
  newcase$subset <- paste0(case$subset, " & ", bQuote(case$each), " == '", each, "'")
@@ -443,7 +445,7 @@ process_allenriches <- function(enriches, plotcases, casename, groupname) {
443
445
  }
444
446
 
445
447
  process_overlaps <- function(markers, ovcases, casename, groupname) {
446
- name <- paste0(casename, "::", paste0(groupname, ": Overlaps"))
448
+ name <- paste0(casename, "::", paste0(groupname, " (Overlaps)"))
447
449
  info <- case_info(name, outdir, create = TRUE)
448
450
 
449
451
  for (plotname in names(ovcases)) {
@@ -510,7 +512,7 @@ run_case <- function(name) {
510
512
  case <- extract_vars(
511
513
  case,
512
514
  "dbs", "sigmarkers", "allmarker_plots", "allenrich_plots", "marker_plots", "enrich_plots",
513
- "overlaps", "original_case", "markers", "enriches", "each_name", "each", "enrich_style",
515
+ "overlaps", "original_case", "markers", "enriches", "each_name", "each", "enrich_style", "original_subset",
514
516
  allow_nonexisting = TRUE
515
517
  )
516
518
 
@@ -535,10 +537,14 @@ run_case <- function(name) {
535
537
 
536
538
  if (length(allmarker_plots) > 0) {
537
539
  log$info("- Visualizing all markers together ...")
538
- attr(markers, "object") <- srtobj
539
- attr(markers, "group.by") <- each
540
- attr(markers, "ident.1") <- NULL
541
- attr(markers, "ident.2") <- NULL
540
+ if (is.null(original_subset)) {
541
+ attr(markers, "object") <- srtobj
542
+ } else {
543
+ attr(markers, "object") <- filter(srtobj, !!parse_expr(original_subset))
544
+ }
545
+ attr(markers, "group_by") <- each
546
+ attr(markers, "ident_1") <- NULL
547
+ attr(markers, "ident_2") <- NULL
542
548
  process_allmarkers(markers, allmarker_plots, name, each)
543
549
  }
544
550
 
@@ -579,16 +585,16 @@ run_case <- function(name) {
579
585
  case$object <- NULL
580
586
  gc()
581
587
 
582
- if (is.null(case$ident.1)) {
583
- all_idents <- unique(as.character(markers[[case$group.by]]))
588
+ if (is.null(case$ident_1)) {
589
+ all_idents <- unique(as.character(markers[[case$group_by]]))
584
590
  enriches <- list()
585
591
  for (ident in all_idents) {
586
- log$info("- {case$group.by}: {ident} ...")
587
- ident_markers <- markers[markers[[case$group.by]] == ident, , drop = TRUE]
588
- casename <- paste0(name, "::", paste0(case$group.by, ": ", ident))
592
+ log$info("- {case$group_by}: {ident} ...")
593
+ ident_markers <- markers[markers[[case$group_by]] == ident, , drop = TRUE]
594
+ casename <- paste0(name, "::", paste0(case$group_by, ": ", ident))
589
595
  info <- case_info(casename, outdir, create = TRUE)
590
596
 
591
- attr(ident_markers, "ident.1") <- ident
597
+ attr(ident_markers, "ident_1") <- ident
592
598
  enrich <- process_markers(ident_markers, info = info, case = list(
593
599
  dbs = dbs,
594
600
  sigmarkers = sigmarkers,
@@ -603,17 +609,17 @@ run_case <- function(name) {
603
609
 
604
610
  if (length(allmarker_plots) > 0) {
605
611
  log$info("- Visualizing all markers together ...")
606
- process_allmarkers(markers, allmarker_plots, name, case$group.by)
612
+ process_allmarkers(markers, allmarker_plots, name, case$group_by)
607
613
  }
608
614
 
609
615
  if (length(overlaps) > 0) {
610
616
  log$info("- Visualizing overlaps between subcases ...")
611
- process_overlaps(markers, overlaps, name, case$group.by)
617
+ process_overlaps(markers, overlaps, name, case$group_by)
612
618
  }
613
619
 
614
620
  if (length(allenrich_plots) > 0) {
615
621
  log$info("- Visualizing all enrichments together ...")
616
- process_allenriches(enriches, allenrich_plots, name, case$group.by)
622
+ process_allenriches(enriches, allenrich_plots, name, case$group_by)
617
623
  }
618
624
  } else {
619
625
  info <- case_info(name, outdir, create = TRUE)
@@ -624,7 +630,7 @@ run_case <- function(name) {
624
630
  marker_plots = marker_plots,
625
631
  enrich_plots = enrich_plots,
626
632
  error = case$error,
627
- ident = if (is.null(case$ident.2)) case$ident.1 else paste0(case$ident.1, " vs ", case$ident.2)
633
+ ident = if (is.null(case$ident_2)) case$ident_1 else paste0(case$ident_1, " vs ", case$ident_2)
628
634
  ))
629
635
 
630
636
  if (!is.null(original_case) && !is.null(cases[[original_case]])) {