biopipen 0.34.5__py3-none-any.whl → 0.34.7__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.

biopipen/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.34.5"
1
+ __version__ = "0.34.7"
biopipen/ns/tcr.py CHANGED
@@ -1682,6 +1682,10 @@ class ScRepLoading(Proc):
1682
1682
  type (choice): The type of the data to load.
1683
1683
  - TCR: T cell receptor data
1684
1684
  - BCR: B cell receptor data
1685
+ - auto: Automatically detect the type from the metadata.
1686
+ If `auto` is selected, the type will be determined by the presence of
1687
+ `TCRData` or `BCRData` columns in the metadata. If both columns are
1688
+ present, `TCR` will be selected by default.
1685
1689
  combineTCR (type=json): The extra arguments for `scRepertoire::combineTCR`
1686
1690
  function.
1687
1691
  See also <https://www.borch.dev/uploads/screpertoire/reference/combinetcr>
@@ -1721,13 +1725,12 @@ class ScRepLoading(Proc):
1721
1725
  output = "outfile:file:{{in.metafile | stem}}.scRep.qs"
1722
1726
  lang = config.lang.rscript
1723
1727
  envs = {
1724
- "type": "TCR", # or BCR
1728
+ "type": "auto", # or TCR/BCR
1725
1729
  "combineTCR": {"samples": True},
1726
1730
  "combineBCR": {"samples": True},
1727
1731
  "exclude": ["BCRData", "TCRData", "RNAData"],
1728
1732
  "format": None,
1729
1733
  "tmpdir": config.path.tmpdir,
1730
-
1731
1734
  }
1732
1735
  script = "file://../scripts/tcr/ScRepLoading.R"
1733
1736
 
@@ -1750,7 +1753,7 @@ class ScRepCombiningExpression(Proc):
1750
1753
  Output:
1751
1754
  outfile: The `Seurat` object with the TCR/BCR data combined
1752
1755
  In addition to the meta columns added by
1753
- `scRepertoire::combineExpression()`, a new column `TCR_Presence` will be
1756
+ `scRepertoire::combineExpression()`, a new column `VDJ_Presence` will be
1754
1757
  added to the metadata. It indicates whether the cell has a TCR/BCR
1755
1758
  sequence or not. The value is `TRUE` if the cell has a TCR/BCR sequence,
1756
1759
  and `FALSE` otherwise.
@@ -111,7 +111,7 @@ if (file.exists(celltypist_outfile) &&
111
111
  command <- paste(command, "-v")
112
112
  }
113
113
  log$info("Running celltypist:")
114
- log$debug("- {command}")
114
+ print("- {command}")
115
115
  rc <- system(command)
116
116
  if (rc != 0) {
117
117
  stop("Failed to run celltypist. Check the job.stderr file to see the error message.")
@@ -165,10 +165,12 @@ post_casing <- function(name, case) {
165
165
 
166
166
  if (length(cases) == 0 && name == "Marker Discovery") {
167
167
  name <- case$each
168
+ } else {
169
+ name <- paste0(name, " (", case$each, ")")
168
170
  }
169
171
 
170
172
  for (each in eachs) {
171
- newname <- paste0(name, " - ", each)
173
+ newname <- paste0(name, "::", each)
172
174
  newcase <- case
173
175
 
174
176
  newcase$original_case <- name
@@ -131,12 +131,14 @@ expand_each <- function(name, case) {
131
131
 
132
132
  if (length(cases) == 0 && name == "DEG Analysis") {
133
133
  name <- case$each
134
+ } else {
135
+ name <- paste0(name, " (", case$each, ")")
134
136
  }
135
137
 
136
138
  case$aggregate_by <- unique(c(case$aggregate_by, case$group_by, case$paired_by, case$each))
137
139
 
138
140
  for (each in eachs) {
139
- newname <- paste0(case$each, "::", each)
141
+ newname <- paste0(name, "::", each)
140
142
  newcase <- case
141
143
 
142
144
  newcase$original_case <- name
@@ -212,7 +214,52 @@ process_markers <- function(markers, info, case) {
212
214
  # markers <- markers %>%
213
215
  # mutate(gene = as.character(gene)) %>%
214
216
  # arrange(p_val_adj, desc(abs(avg_log2FC)))
217
+
218
+ empty <- if (case$enrich_style == "enrichr") {
219
+ data.frame(
220
+ Database = character(0),
221
+ Term = character(0),
222
+ Overlap = character(0),
223
+ P.value = numeric(0),
224
+ Adjusted.P.value = numeric(0),
225
+ Odds.Ratio = numeric(0),
226
+ Combined.Score = numeric(0),
227
+ Genes = character(0),
228
+ Rank = numeric(0)
229
+ )
230
+ } else { # clusterProfiler
231
+ data.frame(
232
+ ID = character(0),
233
+ Description = character(0),
234
+ GeneRatio = character(0),
235
+ BgRatio = character(0),
236
+ Count = integer(0),
237
+ pvalue = numeric(0),
238
+ p.adjust = numeric(0),
239
+ qvalue = numeric(0),
240
+ geneID = character(0),
241
+ Database = character(0)
242
+ )
243
+ }
244
+ if (is.null(markers) || nrow(markers) == 0) {
245
+ if (case$error) {
246
+ stop("Error: No markers found in case '", info$name, "'.")
247
+ } else {
248
+ log$warn("! Warning: No markers found in case '", info$name, "'.")
249
+ reporter$add2(
250
+ list(
251
+ name = "Warning",
252
+ contents = list(list(kind = "error", content = "No markers found.", kind_ = "warning"))),
253
+ hs = c(info$section, info$name),
254
+ hs2 = "DEG Analysis",
255
+ ui = "tabs"
256
+ )
257
+ return(empty)
258
+ }
259
+ }
215
260
  markers$gene <- as.character(markers$gene)
261
+ markers$p_val_adj <- as.numeric(markers$p_val_adj)
262
+ markers$log2FC <- as.numeric(markers$log2FC)
216
263
  markers <- markers[order(markers$p_val_adj, -abs(markers$log2FC)), ]
217
264
 
218
265
  # Save markers
@@ -287,7 +334,7 @@ process_markers <- function(markers, info, case) {
287
334
  stop("Error: Not enough significant DEGs with '", case$sigmarkers, "' in case '", info$name, "' found (< 5) for enrichment analysis.")
288
335
  } else {
289
336
  message <- paste0("Not enough significant DEGs with '", case$sigmarkers, "' found (< 5) for enrichment analysis.")
290
- log$warn(" ! Error: {message}")
337
+ log$warn("! Error: {message}")
291
338
  reporter$add2(
292
339
  list(
293
340
  name = "Warning",
@@ -345,7 +392,7 @@ process_markers <- function(markers, info, case) {
345
392
  if (case$error) {
346
393
  stop("Error: ", e$message)
347
394
  } else {
348
- log$warn(" ! Error: {e$message}")
395
+ log$warn("! Error: {e$message}")
349
396
  reporter$add2(
350
397
  list(
351
398
  name = "Warning",
@@ -478,6 +525,7 @@ process_overlaps <- function(markers, ovcases, casename, groupname) {
478
525
 
479
526
  run_case <- function(name) {
480
527
  case <- cases[[name]]
528
+ log$info("----------------------------------------")
481
529
  log$info("Case: {name} ...")
482
530
 
483
531
  case <- extract_vars(
@@ -558,16 +606,35 @@ run_case <- function(name) {
558
606
  return(invisible())
559
607
  }
560
608
 
609
+ info <- case_info(name, outdir, create = TRUE)
561
610
  exprs <- AggregateExpressionPseudobulk(
562
611
  srtobj, aggregate_by = aggregate_by, layer = layer, assay = assay,
563
612
  subset = subset, log = log
564
613
  )
565
- markers <- RunDEGAnalysis(
566
- exprs, group_by = group_by, ident_1 = ident_1, ident_2 = ident_2,
567
- paired_by = paired_by, tool = tool, log = log
614
+ markers <- tryCatch(
615
+ {
616
+ RunDEGAnalysis(
617
+ exprs, group_by = group_by, ident_1 = ident_1, ident_2 = ident_2,
618
+ paired_by = paired_by, tool = tool, log = log
619
+ )
620
+ }, error = function(e) {
621
+ if (error) {
622
+ stop("Error: ", e$message)
623
+ } else {
624
+ log$warn("! Error: {e$message}")
625
+ reporter$add2(
626
+ list(
627
+ name = "Warning",
628
+ contents = list(list(kind = "error", content = e$message, kind_ = "warning"))),
629
+ hs = c(info$section, info$name),
630
+ hs2 = "DEG Analysis",
631
+ ui = "tabs"
632
+ )
633
+ return(invisible())
634
+ }
635
+ }
568
636
  )
569
637
 
570
- info <- case_info(name, outdir, create = TRUE)
571
638
  enrich <- process_markers(markers, info = info, case = list(
572
639
  dbs = dbs,
573
640
  sigmarkers = sigmarkers,
@@ -83,10 +83,12 @@ expand_each <- function(name, case) {
83
83
 
84
84
  if (length(cases) == 0 && name == "GSEA") {
85
85
  name <- case$each
86
+ } else {
87
+ name <- paste0(name, " (", case$each, ")")
86
88
  }
87
89
 
88
90
  for (each in eachs) {
89
- newname <- paste0(case$each, "::", each)
91
+ newname <- paste0(name, "::", each)
90
92
  newcase <- case
91
93
 
92
94
  newcase$original_case <- paste0(name, " (all ", case$each,")")
@@ -34,7 +34,7 @@ obj <- combineExpression(
34
34
  cloneSize = unlist(cloneSize),
35
35
  addLabel = addLabel
36
36
  )
37
- obj$TCR_Presence <- !is.na(obj$CTaa)
37
+ obj$VDJ_Presence <- !is.na(obj$CTaa)
38
38
 
39
39
  log$info("Saving combined object ...")
40
40
  save_obj(obj, outfile)
@@ -21,6 +21,18 @@ log <- get_logger()
21
21
 
22
22
  log$info("Loading metadata ...")
23
23
  metadata <- read.table(metafile, header = TRUE, sep = "\t", row.names = NULL, check.names = FALSE)
24
+ if (type == "AUTO") {
25
+ if ("TCRData" %in% colnames(metadata) && "BCRData" %in% colnames(metadata)) {
26
+ log$warn("Both TCRData and BCRData columns found in metadata. Defaulting to TCR.")
27
+ type <- "TCR"
28
+ } else if ("TCRData" %in% colnames(metadata)) {
29
+ type <- "TCR"
30
+ } else if ("BCRData" %in% colnames(metadata)) {
31
+ type <- "BCR"
32
+ } else {
33
+ stop("Error: Neither TCRData nor BCRData column found in metadata.")
34
+ }
35
+ }
24
36
 
25
37
  data_column <- ifelse(type == "TCR", "TCRData", "BCRData")
26
38
  combine_fn <- ifelse(type == "TCR", combineTCR, combineBCR)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: biopipen
3
- Version: 0.34.5
3
+ Version: 0.34.7
4
4
  Summary: Bioinformatics processes/pipelines that can be run from `pipen run`
5
5
  License: MIT
6
6
  Author: pwwang
@@ -1,4 +1,4 @@
1
- biopipen/__init__.py,sha256=h8CbBrHmMIAi56YuHk8Y6QbCUJtGFC7bwBFj8VtTAR8,23
1
+ biopipen/__init__.py,sha256=vVRUKRt0zUNKxfGQQE5WrQiVWQ-bg4UrgyEGX7LclcA,23
2
2
  biopipen/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  biopipen/core/config.py,sha256=edK5xnDhM8j27srDzsxubi934NMrglLoKrdcC8qsEPk,1069
4
4
  biopipen/core/config.toml,sha256=lZV_vbYWk6uqm19ZWJcsZCcSNqAdIfN2fOfamzxZpg4,2148
@@ -27,7 +27,7 @@ biopipen/ns/scrna_metabolic_landscape.py,sha256=EwLMrsj_pTqvyAgtHLoishjQxCg_j8n5
27
27
  biopipen/ns/snp.py,sha256=iXWrw7Lmhf4_ct57HGT7JGTClCXUD4sZ2FzOgsC2pTg,28123
28
28
  biopipen/ns/stats.py,sha256=DlPyK5Vsg6ZEkV9SDS3aAw21eXzvOHgqeZDkXPhg7go,20509
29
29
  biopipen/ns/tcgamaf.py,sha256=AFbUJIxiMSvsVY3RcHgjRFuMnNh2DG3Mr5slLNEyz6o,1455
30
- biopipen/ns/tcr.py,sha256=urx0RomtzhyEtE0V8r3mpNUEMSZCXJ8T6C_I1TSShSY,99373
30
+ biopipen/ns/tcr.py,sha256=XvhbZcVzdJYCjGe61G_EitdRpZyDnyDsaMNPlyH5590,99676
31
31
  biopipen/ns/vcf.py,sha256=zjOH2qiSJsHACLmBqV-Tew-mn-peZgvYLAWjTLh7uTI,23823
32
32
  biopipen/ns/web.py,sha256=8VY4Xsb8UrzS4IkGUX_84GQP1JG6NcTZrV7f9tA1tUI,5458
33
33
  biopipen/reports/bam/CNAClinic.svelte,sha256=D4IxQcgDCPQZMbXog-aZP5iJEQTK2N4i0C60e_iXyfs,213
@@ -142,7 +142,7 @@ biopipen/scripts/scrna/AnnData2Seurat.R,sha256=wc5PDbK9TkuJtoXXxF4W1ODylWhyfKWd3
142
142
  biopipen/scripts/scrna/CCPlotR-patch.R,sha256=KpB8fwacBaWaUNjIidcLUkMShLjS4Gq9UY8LUgIITB0,8369
143
143
  biopipen/scripts/scrna/CellCellCommunication.py,sha256=Wg0uFSo0Yt0wq6UT1TBodyK8GtWQXGv7hXRfM665paU,4354
144
144
  biopipen/scripts/scrna/CellCellCommunicationPlots.R,sha256=4l2EJVd1y94Nfry8fuRL9OSF6AhS8PGBekimpRUu3s8,1919
145
- biopipen/scripts/scrna/CellTypeAnnotation-celltypist.R,sha256=AlNx0vBKqvpQ83yfNUbU4taJ8CUyz63iXzumZcw-PBc,6968
145
+ biopipen/scripts/scrna/CellTypeAnnotation-celltypist.R,sha256=CwYR8WWQMf8r7V2CTalG4kxdKnYMtyhpJBe9zP2sQWA,6964
146
146
  biopipen/scripts/scrna/CellTypeAnnotation-direct.R,sha256=w3CKRUA9NZfC3TFbU8I35L4XJ6MtVaWX-VnV7ScZlBI,2196
147
147
  biopipen/scripts/scrna/CellTypeAnnotation-hitype.R,sha256=vvjhxin4aoA9heecey0dpr6ofirybygY3ApjgtQW89Y,2094
148
148
  biopipen/scripts/scrna/CellTypeAnnotation-sccatch.R,sha256=xxB4K1MzBSNQnDxa44s5ExeU67MbncOBf8lGFr7RvwQ,1870
@@ -155,13 +155,13 @@ biopipen/scripts/scrna/ExprImputation-rmagic.R,sha256=ePgbMZ_3bKbeUrjsMdkdtBM_MS
155
155
  biopipen/scripts/scrna/ExprImputation-scimpute.R,sha256=MI_bYfvCDKJsuGntUxfx_-NdrssBoQgL95-DGwJVE5s,1191
156
156
  biopipen/scripts/scrna/ExprImputation.R,sha256=GcdZJpkDpq88hRQjtLZY5-byp8V43stEFm5T-pQbU6A,319
157
157
  biopipen/scripts/scrna/LoomTo10X.R,sha256=c6F0p1udsL5UOlb84-53K5BsjSDWkdFyYTt5NQmlIec,1059
158
- biopipen/scripts/scrna/MarkersFinder.R,sha256=P6BgseCrXTeJR8X52hzD16qBUuCeHmPc96h5pKE_-qY,24207
158
+ biopipen/scripts/scrna/MarkersFinder.R,sha256=A-YCJ2WogU2QR8PqVn71lXCP63Vq1sMyAAIhqZYYawg,24278
159
159
  biopipen/scripts/scrna/MetaMarkers.R,sha256=BgYaWYEj6obwqaZaDWqNPtxb1IEEAnXAeBE0Ji9PvBA,12426
160
160
  biopipen/scripts/scrna/ModuleScoreCalculator.R,sha256=-tByCPk7i070LynAb0z2ANeRxr1QqiKP0dfrJm52jH4,4198
161
- biopipen/scripts/scrna/PseudoBulkDEG.R,sha256=32Hd3x2WyTFv175Os4bxf6goAcIq7QN8m1i7i7emnMI,22308
161
+ biopipen/scripts/scrna/PseudoBulkDEG.R,sha256=Y5OuVCaIIppBqMxxXM3HpJQk5kA42wSgbBBIC1Rr1s0,24608
162
162
  biopipen/scripts/scrna/RadarPlots.R,sha256=Kn1E-hpczuujpgNjR8MqeIIVN-S3PbpmfcKWGKcNCVY,14546
163
163
  biopipen/scripts/scrna/SCImpute.R,sha256=dSJOHhmJ3x_72LBRXT72dbCti5oiB85CJ-OjWtqONbk,2958
164
- biopipen/scripts/scrna/ScFGSEA.R,sha256=Cbr1RE4jD3CbR7K4Y1XWKfcqiqhZmzATCKEd3ysCnCc,11517
164
+ biopipen/scripts/scrna/ScFGSEA.R,sha256=EyRbsH5d1daIxtOHjYz24Udmv1PhV0nUC9HqEtzRnpE,11584
165
165
  biopipen/scripts/scrna/ScSimulation.R,sha256=q0-dXD9px1cApc_TxGmR-OdNHE8W1VSVWfSI57B96bo,1697
166
166
  biopipen/scripts/scrna/ScVelo.py,sha256=SPUZFgZW1Zhw-bnjJo98RK0vpuNFODQ8Q3eTguNc84k,21359
167
167
  biopipen/scripts/scrna/Seurat2AnnData.R,sha256=F8g5n2CqX4-KBggxd8ittz8TejYuqqNLMudAHdFt1QM,184
@@ -234,8 +234,8 @@ biopipen/scripts/tcr/ImmunarchFilter.R,sha256=-en-zi0ZB1JjuqhPlaEAN8YvHrELZNJ1V7
234
234
  biopipen/scripts/tcr/ImmunarchLoading.R,sha256=u3o2aag_7cZ17HA8RxpN58wvrII0Uh-q6FY6dA8MWeQ,5756
235
235
  biopipen/scripts/tcr/ImmunarchSplitIdents.R,sha256=FGCeGV0uSmFU91lKkldUAeV4A2m3hHw5X4GNi8ffGzI,1873
236
236
  biopipen/scripts/tcr/SampleDiversity.R,sha256=oipN4-2nQZe8bYjI0lZ0SvZ7T8GZ_FWkpkobi1cwmWE,2664
237
- biopipen/scripts/tcr/ScRepCombiningExpression.R,sha256=TwnlUWG9isSl7H1VqhFLbWlVSdDwFRVSszqbnShH_E0,1011
238
- biopipen/scripts/tcr/ScRepLoading.R,sha256=FORXYfeTitFr9EtfJrv2A-2GeWG-WKDBBANeeT9ejds,5269
237
+ biopipen/scripts/tcr/ScRepCombiningExpression.R,sha256=sYn6BEUB53Z3pF7IAjYpewGYBvVBwzJqoAOPpcAxzQo,1011
238
+ biopipen/scripts/tcr/ScRepLoading.R,sha256=COdY7KotlYemq4LDJT3d08NlzOzRwrDUTrNUdt4P66A,5732
239
239
  biopipen/scripts/tcr/TCRClusterStats.R,sha256=ns3S95DVDBuhSe1YgTZ1OksbfBgREO2Tnp1d4QzbTw0,13530
240
240
  biopipen/scripts/tcr/TCRClustering.R,sha256=K01qYLNhXrMmPb3TJE504lpRXnfizUNZ5q75nL7dxBg,9152
241
241
  biopipen/scripts/tcr/TCRDock.py,sha256=Oyw27k6vr0pnJ0w1-lrk5b6sZ_IOf6TmbhSxQae-3Q8,3148
@@ -284,7 +284,7 @@ biopipen/utils/misc.py,sha256=pDZ-INWVNqHuXYvcjmu8KqNAigkh2lsHy0BxX44CPvc,4048
284
284
  biopipen/utils/reference.py,sha256=Oc6IlA1giLxymAuI7DO-IQLHQ7-DbsWzOQE86oTDfMU,5955
285
285
  biopipen/utils/reporter.py,sha256=VwLl6xyVDWnGY7NEXyqBlkW8expKJoNQ5iTyZSELf5c,4922
286
286
  biopipen/utils/vcf.py,sha256=MmMbAtLUcKPp02jUdk9TzuET2gWSeoWn7xgoOXFysK0,9393
287
- biopipen-0.34.5.dist-info/METADATA,sha256=WmREdhe4-vouw0NWeH63QRdWDg_I8lWvhhcxK0QoKeA,975
288
- biopipen-0.34.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
289
- biopipen-0.34.5.dist-info/entry_points.txt,sha256=BYqHGBQJxyFDNLYqgH64ycI5PYwnlqwYcCFsMvJgzAU,653
290
- biopipen-0.34.5.dist-info/RECORD,,
287
+ biopipen-0.34.7.dist-info/METADATA,sha256=uR3Q2oygeFSoT96Lp0wQGCcigCJGaIyzbYzdJ2wlWVw,975
288
+ biopipen-0.34.7.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
289
+ biopipen-0.34.7.dist-info/entry_points.txt,sha256=BYqHGBQJxyFDNLYqgH64ycI5PYwnlqwYcCFsMvJgzAU,653
290
+ biopipen-0.34.7.dist-info/RECORD,,