biopipen 0.34.14__py3-none-any.whl → 0.34.16__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.14"
1
+ __version__ = "0.34.16"
biopipen/ns/scrna.py CHANGED
@@ -96,6 +96,8 @@ class SeuratPreparing(Proc):
96
96
  `RNAData` to assign the path of the data to the samples
97
97
  The path will be read by `Read10X()` from `Seurat`, or the path
98
98
  to the h5 file that can be read by `Read10X_h5()` from `Seurat`.
99
+ It can also be an RDS or qs2 file containing a `Seurat` object.
100
+ Note that it must has a column named `Sample` in the meta.data to specify the sample names.
99
101
 
100
102
  Output:
101
103
  outfile: The qs2 file with the Seurat object with all samples integrated.
@@ -111,11 +113,11 @@ class SeuratPreparing(Proc):
111
113
  min_cells (type=int): The minimum number of cells that a gene must be
112
114
  expressed in to be kept. This is used in `Seurat::CreateSeuratObject()`.
113
115
  Futher QC (`envs.cell_qc`, `envs.gene_qc`) will be performed after this.
114
- It doesn't work when data is loaded from loom files.
116
+ It doesn't work when data is loaded from loom files or RDS/qs2 files.
115
117
  min_features (type=int): The minimum number of features that a cell must
116
118
  express to be kept. This is used in `Seurat::CreateSeuratObject()`.
117
119
  Futher QC (`envs.cell_qc`, `envs.gene_qc`) will be performed after this.
118
- It doesn't work when data is loaded from loom files.
120
+ It doesn't work when data is loaded from loom files or RDS/qs2 files.
119
121
  cell_qc: Filter expression to filter cells, using
120
122
  `tidyrseurat::filter()`.
121
123
  It can also be a dictionary of expressions, where the names of the list are
@@ -607,7 +609,7 @@ class SeuratClusterStats(Proc):
607
609
  `ActivationScore` in the metadata.
608
610
  You may also specify the literal order of the clusters by a list of strings (at least two).
609
611
  - subset: An expression to subset the cells, will be passed to `tidyrseurat::filter()`.
610
- - devpars (ns): The device parameters for the plots. Does not work for `table`.
612
+ - devpars (ns): The device parameters for the plots.
611
613
  - res (type=int): The resolution of the plots.
612
614
  - height (type=int): The height of the plots.
613
615
  - width (type=int): The width of the plots.
@@ -600,6 +600,28 @@ run_case <- function(name) {
600
600
 
601
601
  if (length(allenrich_plots) > 0 && !is.null(enriches) && nrow(enriches) > 0) {
602
602
  log$info("- Visualizing all enrichments together ...")
603
+ # add other metadata columns if any by mapping groupname
604
+ # only add the metadata columns from object if there is a single value mapped
605
+ metacols <- srtobj@meta.data %>% group_by(!!sym(each)) %>%
606
+ summarize(across(everything(), ~ n_distinct(.) == 1), .groups = "keep") %>%
607
+ select(where(~ all(. == TRUE))) %>%
608
+ colnames()
609
+
610
+ if (length(metacols) > 1) {
611
+ metadf <- srtobj@meta.data[, metacols, drop = FALSE] %>%
612
+ distinct(!!sym(each), .keep_all = TRUE)
613
+
614
+ for (col in setdiff(metacols, each)) {
615
+ if (col %in% colnames(enriches)) {
616
+ warning("Column name conflict: {col}, adding with suffix '_meta'", immediate. = TRUE)
617
+ metadf[[paste0(col, "_meta")]] <- metadf[[col]]
618
+ metadf[[col]] <- NULL
619
+ }
620
+ }
621
+
622
+ enriches <- left_join(enriches, metadf, by = each)
623
+ }
624
+
603
625
  process_allenriches(enriches, allenrich_plots, name, each)
604
626
  }
605
627
  }
@@ -659,6 +681,29 @@ run_case <- function(name) {
659
681
 
660
682
  if (length(allenrich_plots) > 0) {
661
683
  log$info("- Visualizing all enrichments together ...")
684
+ # add other metadata columns if any by mapping groupname
685
+ # only add the metadata columns from object if there is a single value mapped
686
+ metacols <- subobj@meta.data %>% group_by(!!sym(case$group_by)) %>%
687
+ summarize(across(everything(), ~ n_distinct(.) == 1), .groups = "keep") %>%
688
+ select(where(~ all(. == TRUE))) %>%
689
+ colnames()
690
+
691
+ if (length(metacols) > 1) {
692
+ metadf <- subobj@meta.data[, metacols, drop = FALSE] %>%
693
+ distinct(!!sym(case$group_by), .keep_all = TRUE)
694
+
695
+ for (col in setdiff(metacols, case$group_by)) {
696
+ if (col %in% colnames(enriches[[1]])) {
697
+ warning("Column name conflict: {col}, adding with suffix '_meta'", immediate. = TRUE)
698
+ metadf[[paste0(col, "_meta")]] <- metadf[[col]]
699
+ metadf[[col]] <- NULL
700
+ }
701
+ }
702
+
703
+ for (ne in names(enriches)) {
704
+ enriches[[ne]] <- left_join(enriches[[ne]], metadf, by = case$group_by)
705
+ }
706
+ }
662
707
  process_allenriches(enriches, allenrich_plots, name, case$group_by)
663
708
  }
664
709
  } else {
@@ -38,19 +38,27 @@ reporter$add(
38
38
  h1 = "Filters and QC"
39
39
  )
40
40
 
41
- metadata <- read.table(
42
- metafile,
43
- header = TRUE,
44
- row.names = NULL,
45
- sep = "\t",
46
- check.names = FALSE
47
- )
41
+ metadata <- tryCatch({
42
+ log$debug("Trying to read Seurat object from metafile ...")
43
+ read_obj(metafile)
44
+ }, error = function(e) {
45
+ log$debug("Failed to read Seurat object from metafile: {e$message}")
46
+ log$debug("Reading metafile as a table (sample info) ...")
47
+ read.table(
48
+ metafile,
49
+ header = TRUE,
50
+ row.names = NULL,
51
+ sep = "\t",
52
+ check.names = FALSE
53
+ )
54
+ })
55
+ is_seurat <- inherits(metadata, "Seurat")
48
56
 
49
- meta_cols = colnames(metadata)
57
+ meta_cols <- if (is_seurat) colnames(metadata@meta.data) else colnames(metadata)
50
58
  if (!"Sample" %in% meta_cols) {
51
- stop("Error: Column `Sample` is not found in metafile.")
59
+ stop("Error: Column `Sample` is not found in ", ifelse(is_seurat, "Seurat object's meta.data.", "metafile."))
52
60
  }
53
- if (!"RNAData" %in% meta_cols) {
61
+ if (!"RNAData" %in% meta_cols && !is_seurat) {
54
62
  stop("Error: Column `RNAData` is not found in metafile.")
55
63
  }
56
64
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: biopipen
3
- Version: 0.34.14
3
+ Version: 0.34.16
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=EumHAzPCe3UipaK_9iqfQf47_8LP5jWSnXBVUZmzQTA,24
1
+ biopipen/__init__.py,sha256=Ej0aenQBQvcrsqY3gHfGZPfKtKcKEskpGj0mMmPo81k,24
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
@@ -22,7 +22,7 @@ biopipen/ns/plot.py,sha256=N41_izb6zi-XArUly5WhLebapNXbTNSgGlOCCwtrDlY,18282
22
22
  biopipen/ns/protein.py,sha256=YJtlKoHI2p5yHdxKeQnNtm5QrbxDGOq1UXOdt_7tlTs,6391
23
23
  biopipen/ns/regulatory.py,sha256=WlnX_R8jEFyxCjk8mru5Qu5iCQJLzjMWiWGoc3gygzc,16221
24
24
  biopipen/ns/rnaseq.py,sha256=bKAa6friFWof4yDTWZQahm1MS-lrdetO1GqDKdfxXYc,7708
25
- biopipen/ns/scrna.py,sha256=yWG6oQ1XXzhr-GYOouiC_4aEwmi7XS8RW265XWsoqhw,145722
25
+ biopipen/ns/scrna.py,sha256=HlR0eGaOOKXVIk9fcQYduMfdK1ith7OHfq38s9C55z8,145909
26
26
  biopipen/ns/scrna_metabolic_landscape.py,sha256=EwLMrsj_pTqvyAgtHLoishjQxCg_j8n5OofuTofUph0,22096
27
27
  biopipen/ns/snp.py,sha256=iXWrw7Lmhf4_ct57HGT7JGTClCXUD4sZ2FzOgsC2pTg,28123
28
28
  biopipen/ns/stats.py,sha256=DlPyK5Vsg6ZEkV9SDS3aAw21eXzvOHgqeZDkXPhg7go,20509
@@ -155,7 +155,7 @@ 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=nz18T_70ni9sfoFYp8weQMCiojphF61l5yHe9f_gOSM,26320
158
+ biopipen/scripts/scrna/MarkersFinder.R,sha256=SBh3cA2WZQIlZTysAlU-U9knzO9gU0XW-yi8mk2iJG4,28588
159
159
  biopipen/scripts/scrna/MetaMarkers.R,sha256=BgYaWYEj6obwqaZaDWqNPtxb1IEEAnXAeBE0Ji9PvBA,12426
160
160
  biopipen/scripts/scrna/ModuleScoreCalculator.R,sha256=_mvo35a-wk5miUb_kMIVwvKK0b6InRa1NKtN8zznGwk,4457
161
161
  biopipen/scripts/scrna/PseudoBulkDEG.R,sha256=IuM4hl-KHZ5aaaTqZeylw4b1ZenMZaY4qobD5qxAlHs,25199
@@ -176,7 +176,7 @@ biopipen/scripts/scrna/SeuratFilter.R,sha256=BrYK0MLdaTtQvInMaQsmOt7oH_hlks0M1zy
176
176
  biopipen/scripts/scrna/SeuratLoading.R,sha256=23KAgsj0-XZhOOdUlLrb3r17St4LzZq230UlfIjLn_E,892
177
177
  biopipen/scripts/scrna/SeuratMap2Ref.R,sha256=bSk-GPe5jZl6QGiNN7VrD7oAlbLjg9Vo5-t6ua28dyM,3631
178
178
  biopipen/scripts/scrna/SeuratMetadataMutater.R,sha256=22Kh9G3awSOvyeFZk5I8Sgg-fbu4gClAvHf_wJOxWnU,1020
179
- biopipen/scripts/scrna/SeuratPreparing.R,sha256=5mWDYwVBCncj_z3U8LGZ9xCQnax0gQJpEyGPZ7NykXk,8313
179
+ biopipen/scripts/scrna/SeuratPreparing.R,sha256=T5BwpSLUnGDuUQsIBv9G8e9OBAODuJu8o1ZkvFO8p6k,8762
180
180
  biopipen/scripts/scrna/SeuratSplit.R,sha256=vdK11V39_Uo_NaOh76QWCtxObGaEr5Ynxqq0hTiSvsU,754
181
181
  biopipen/scripts/scrna/SeuratSubClustering.R,sha256=bsBzhzSsdqOy3aqNu_Cbx7qtRI7PDLnWRhUpoo8uvSw,1628
182
182
  biopipen/scripts/scrna/SeuratSubset.R,sha256=yVA11NVE2FSSw-DhxQcJRapns0tNNHdyDYi5epO6SKM,1776
@@ -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.14.dist-info/METADATA,sha256=uIS3ZdJr3bVM1TspZIe2NmoVavOa_XGKe4qsuRk7gdw,1027
288
- biopipen-0.34.14.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
289
- biopipen-0.34.14.dist-info/entry_points.txt,sha256=BYqHGBQJxyFDNLYqgH64ycI5PYwnlqwYcCFsMvJgzAU,653
290
- biopipen-0.34.14.dist-info/RECORD,,
287
+ biopipen-0.34.16.dist-info/METADATA,sha256=01g2zsm_S0SAqFkTHB5oIFDYxSc1WkBLH4zdBr0FNcA,1027
288
+ biopipen-0.34.16.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
289
+ biopipen-0.34.16.dist-info/entry_points.txt,sha256=BYqHGBQJxyFDNLYqgH64ycI5PYwnlqwYcCFsMvJgzAU,653
290
+ biopipen-0.34.16.dist-info/RECORD,,