biopipen 0.7.0__py3-none-any.whl → 0.8.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 (65) hide show
  1. biopipen/__init__.py +1 -1
  2. biopipen/core/config.py +0 -5
  3. biopipen/core/config.toml +4 -4
  4. biopipen/core/defaults.py +3 -3
  5. biopipen/core/filters.py +1 -0
  6. biopipen/core/proc.py +1 -3
  7. biopipen/core/testing.py +1 -2
  8. biopipen/ns/bam.py +10 -14
  9. biopipen/ns/bcftools.py +37 -7
  10. biopipen/ns/bed.py +9 -16
  11. biopipen/ns/cnv.py +8 -11
  12. biopipen/ns/cnvkit.py +32 -59
  13. biopipen/ns/cnvkit_pipeline.py +266 -310
  14. biopipen/ns/csv.py +0 -2
  15. biopipen/ns/gene.py +0 -1
  16. biopipen/ns/gsea.py +4 -10
  17. biopipen/ns/misc.py +0 -5
  18. biopipen/ns/plot.py +2 -4
  19. biopipen/ns/rnaseq.py +0 -1
  20. biopipen/ns/scrna.py +78 -120
  21. biopipen/ns/scrna_metabolic_landscape.py +306 -348
  22. biopipen/ns/tcgamaf.py +52 -0
  23. biopipen/ns/tcr.py +5 -15
  24. biopipen/ns/vcf.py +52 -34
  25. biopipen/ns/web.py +8 -19
  26. biopipen/reports/bam/CNAClinic.svelte +1 -1
  27. biopipen/reports/bam/CNVpytor.svelte +2 -2
  28. biopipen/reports/bam/ControlFREEC.svelte +1 -1
  29. biopipen/reports/cnv/AneuploidyScore.svelte +2 -2
  30. biopipen/reports/cnv/AneuploidyScoreSummary.svelte +1 -1
  31. biopipen/reports/cnvkit/CNVkitDiagram.svelte +1 -1
  32. biopipen/reports/cnvkit/CNVkitHeatmap.svelte +1 -1
  33. biopipen/reports/cnvkit/CNVkitScatter.svelte +1 -1
  34. biopipen/reports/gsea/FGSEA.svelte +1 -1
  35. biopipen/reports/gsea/GSEA.svelte +2 -2
  36. biopipen/reports/scrna/CellsDistribution.svelte +1 -1
  37. biopipen/reports/scrna/DimPlots.svelte +1 -1
  38. biopipen/reports/scrna/GeneExpressionInvistigation.svelte +1 -1
  39. biopipen/reports/scrna/MarkersFinder.svelte +42 -39
  40. biopipen/reports/scrna/ScFGSEA.svelte +3 -3
  41. biopipen/reports/scrna/SeuratClusterStats.svelte +3 -3
  42. biopipen/reports/scrna/SeuratPreparing.svelte +2 -2
  43. biopipen/reports/scrna_metabolic_landscape/MetabolicFeaturesIntraSubsets.svelte +2 -2
  44. biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayActivity.svelte +1 -1
  45. biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayHeterogeneity.svelte +1 -1
  46. biopipen/reports/tcr/CloneResidency.svelte +4 -4
  47. biopipen/reports/tcr/Immunarch.svelte +2 -2
  48. biopipen/reports/tcr/SampleDiversity.svelte +2 -2
  49. biopipen/reports/tcr/TCRClusteringStats.svelte +3 -3
  50. biopipen/reports/tcr/VJUsage.svelte +1 -1
  51. biopipen/reports/utils/gsea.liq +1 -1
  52. biopipen/reports/utils/misc.liq +1 -1
  53. biopipen/reports/vcf/TruvariBenchSummary.svelte +1 -1
  54. biopipen/reports/vcf/TruvariConsistency.svelte +3 -3
  55. biopipen/scripts/bcftools/BcftoolsSort.py +19 -0
  56. biopipen/scripts/scrna/MarkersFinder.R +73 -35
  57. biopipen/scripts/tcgamaf/Maf2Vcf.py +22 -0
  58. biopipen/scripts/tcgamaf/MafAddChr.py +14 -0
  59. biopipen/scripts/tcgamaf/maf2vcf.pl +427 -0
  60. biopipen/scripts/vcf/VcfAnno.py +26 -0
  61. biopipen/scripts/vcf/VcfFix_utils.py +3 -2
  62. {biopipen-0.7.0.dist-info → biopipen-0.8.0.dist-info}/METADATA +7 -8
  63. {biopipen-0.7.0.dist-info → biopipen-0.8.0.dist-info}/RECORD +65 -59
  64. {biopipen-0.7.0.dist-info → biopipen-0.8.0.dist-info}/WHEEL +1 -1
  65. {biopipen-0.7.0.dist-info → biopipen-0.8.0.dist-info}/entry_points.txt +2 -1
@@ -1,7 +1,7 @@
1
1
  {% from "utils/misc.liq" import report_jobs, table_of_images -%}
2
2
  <script>
3
- import { Image, DataTable } from "@@";
4
- import { Dropdown } from "carbon-components-svelte";
3
+ import { Image, DataTable } from "$lib";
4
+ import { Dropdown } from "$ccs";
5
5
 
6
6
  let count_sample;
7
7
 
@@ -39,7 +39,7 @@
39
39
 
40
40
  <h{{h}}>Residency plots</h{{h}}>
41
41
 
42
- {% if job.out.outdir | joinpaths: "sample_groups" | as_path | attr: "exists" | call %}
42
+ {% if job.out.outdir | joinpaths: "sample_groups" | exists %}
43
43
  {% for groupfile in job.out.outdir | glob: "sample_groups", "*.txt" %}
44
44
  {% set group = groupfile | stem %}
45
45
  <h{{h+1}}>{{group}}</h{{h+1}}>
@@ -57,7 +57,7 @@
57
57
 
58
58
  <h{{h}}>Clonotype overlapping</h{{h}}>
59
59
 
60
- {% if job.out.outdir | joinpaths: "sample_groups" | as_path | attr: "exists" | call %}
60
+ {% if job.out.outdir | joinpaths: "sample_groups" | exists %}
61
61
  {% for groupfile in job.out.outdir | glob: "sample_groups", "*.txt" %}
62
62
  {% set group = groupfile | stem %}
63
63
  <h{{h+1}}>{{group}}</h{{h+1}}>
@@ -1,7 +1,7 @@
1
1
  {% from "utils/misc.liq" import report_jobs, table_of_images -%}
2
2
  <script>
3
- import { Image } from "@@";
4
- import { Tabs, Tab, TabContent, Tile, UnorderedList, p } from "carbon-components-svelte";
3
+ import { Image } from "$lib";
4
+ import { Tabs, Tab, TabContent, Tile, UnorderedList, p } from "$ccs";
5
5
  </script>
6
6
 
7
7
  {%- macro report_job(job, h=1) -%}
@@ -1,7 +1,7 @@
1
1
  {% from "utils/misc.liq" import report_jobs, table_of_images -%}
2
2
  <script>
3
- import { Image } from "@@";
4
- import { Tile } from "carbon-components-svelte";
3
+ import { Image } from "$lib";
4
+ import { Tile } from "$ccs";
5
5
  </script>
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  {% from "utils/misc.liq" import report_jobs -%}
2
2
  <script>
3
- import { Image, DataTable } from "@@";
4
- import { Tabs, Tab, TabContent } from "carbon-components-svelte";
3
+ import { Image, DataTable } from "$lib";
4
+ import { Tabs, Tab, TabContent } from "$ccs";
5
5
  </script>
6
6
 
7
7
  {%- macro report_job(job, h=1) -%}
@@ -25,7 +25,7 @@
25
25
  </svelte:fragment>
26
26
  </Tabs>
27
27
 
28
- {%- if job.out.outdir | joinpaths: "SharedClustersByGrouping" | as_path | attr: "is_dir" | call -%}
28
+ {%- if job.out.outdir | joinpaths: "SharedClustersByGrouping" | isdir -%}
29
29
  <h{{h}}>Shared TCR clusters from groups</h{{h}}>
30
30
  <Image src={{job.out.outdir | joinpaths: "SharedClustersByGrouping/shared_clusters_by_grouping.png" | quote}} />
31
31
  {%- endif -%}
@@ -1,6 +1,6 @@
1
1
  {% from "utils/misc.liq" import report_jobs, table_of_images -%}
2
2
  <script>
3
- import { Image } from "@@";
3
+ import { Image } from "$lib";
4
4
  </script>
5
5
 
6
6
  <h1>V-J usage plots</h1>
@@ -1,7 +1,7 @@
1
1
  {% from "utils/misc.liq" import table_of_images -%}
2
2
 
3
3
  {%- macro fgsea_report_script() -%}
4
- import { Image, DataTable } from "../components";
4
+ import { Image, DataTable } from "$lib";
5
5
  {%- endmacro -%}
6
6
 
7
7
  {%- macro fgsea_report(fgsea_dir, h, envs, nrows=100) -%}
@@ -16,7 +16,7 @@
16
16
 
17
17
 
18
18
  {%- macro table_of_images_script() -%}
19
- import { Image } from "../components";
19
+ import { Image } from "$lib";
20
20
  {%- endmacro -%}
21
21
 
22
22
  {%- macro table_of_images(srcs, caps=None, col=2, table_width=100) -%}
@@ -1,6 +1,6 @@
1
1
  {% from "utils/misc.liq" import report_jobs, table_of_images -%}
2
2
  <script>
3
- import { DataTable, Image } from "@@";
3
+ import { DataTable, Image } from "$lib";
4
4
  </script>
5
5
 
6
6
  {%- macro report_job(job, h=1) -%}
@@ -1,7 +1,7 @@
1
1
  {% from "utils/misc.liq" import report_jobs -%}
2
2
  <script>
3
- import { Image } from "@@";
4
- import { Tile } from "carbon-components-svelte";
3
+ import { Image } from "$lib";
4
+ import { Tile } from "$ccs";
5
5
  </script>
6
6
 
7
7
  {%- macro report_job(job, h=1) -%}
@@ -13,7 +13,7 @@
13
13
  </pre>
14
14
  </Tile>
15
15
 
16
- {%- if job.out.outdir | joinpaths: "consistency.png" | as_path | attr: "exists" | call -%}
16
+ {%- if job.out.outdir | joinpaths: "consistency.png" | exists -%}
17
17
  <h{{h}}>Heatmap of base CNV presence for each sample</h{{h}}>
18
18
 
19
19
  <Image src={{job.out.outdir | joinpaths: "consistency.png" | quote}} />
@@ -0,0 +1,19 @@
1
+ import cmdy
2
+
3
+ infile = {{in.infile | quote}} # pyright: ignore
4
+ outfile = {{out.outfile | quote}} # pyright: ignore
5
+ bcftools = {{envs.bcftools | quote}} # pyright: ignore
6
+ gz = {{envs.gz | repr}} # pyright: ignore
7
+ args = {{envs.args | repr}} # pyright: ignore
8
+ tmpdir = {{envs.tmpdir | quote}} # pyright: ignore
9
+ index = {{envs.index | repr}} # pyright: ignore
10
+
11
+ args["_exe"] = bcftools
12
+ args["_"] = infile
13
+ args["o"] = outfile
14
+ args["O"] = "z" if gz or index else "v"
15
+
16
+ cmdy.bcftools.sort(**args).fg()
17
+
18
+ if index:
19
+ cmdy.bcftools.index(outfile).fg()
@@ -6,6 +6,7 @@ library(tidyr)
6
6
  library(tibble)
7
7
  library(Seurat)
8
8
  library(enrichR)
9
+ library(ggplot2)
9
10
  library(future)
10
11
  library(tidyseurat)
11
12
 
@@ -36,7 +37,17 @@ do_enrich = function(case, markers) {
36
37
  print(paste(" Running enrichment for case:", case))
37
38
  casedir = file.path(outdir, case)
38
39
  dir.create(casedir, showWarnings = FALSE)
40
+ if (nrow(markers) == 0) {
41
+ print(paste(" No markers found for case:", case))
42
+ cat("No markers found.", file=file.path(casedir, "error.txt"))
43
+ return()
44
+ }
39
45
  markers_sig = markers %>% filter(!!parse_expr(sigmarkers))
46
+ if (nrow(markers_sig) == 0) {
47
+ print(paste(" No significant markers found for case:", case))
48
+ cat("No significant markers.", file=file.path(casedir, "error.txt"))
49
+ return()
50
+ }
40
51
  write.table(
41
52
  markers_sig,
42
53
  file.path(casedir, "markers.txt"),
@@ -45,27 +56,45 @@ do_enrich = function(case, markers) {
45
56
  col.names=TRUE,
46
57
  quote=FALSE
47
58
  )
48
-
49
- enriched = enrichr(markers_sig$gene, dbs)
50
- for (db in dbs) {
51
- write.table(
52
- enriched[[db]],
53
- file.path(casedir, paste0("Enrichr-", db, ".txt")),
54
- sep="\t",
55
- row.names=FALSE,
56
- col.names=TRUE,
57
- quote=FALSE
58
- )
59
- png(
60
- file.path(casedir, paste0("Enrichr-", db, ".png")),
61
- res=100, height=1000, width=1000
62
- )
63
- if (nrow(markers_sig) == 0) {
64
- print(ggplot() + annotate("text", x=1, y=1, label="No significant markers."))
65
- } else {
59
+ if (nrow(markers_sig) < 5) {
60
+ for (db in dbs) {
61
+ write.table(
62
+ data.frame(Warning = "Not enough significant markers."),
63
+ file.path(casedir, paste0("Enrichr-", db, ".txt")),
64
+ sep="\t",
65
+ row.names=FALSE,
66
+ col.names=TRUE,
67
+ quote=FALSE
68
+ )
69
+ png(
70
+ file.path(casedir, paste0("Enrichr-", db, ".png")),
71
+ res=100, height=200, width=1000
72
+ )
73
+ print(
74
+ ggplot() +
75
+ annotate("text", x=1, y=1, label="Not enough significant markers.") +
76
+ theme_classic()
77
+ )
78
+ dev.off()
79
+ }
80
+ } else {
81
+ enriched = enrichr(markers_sig$gene, dbs)
82
+ for (db in dbs) {
83
+ write.table(
84
+ enriched[[db]],
85
+ file.path(casedir, paste0("Enrichr-", db, ".txt")),
86
+ sep="\t",
87
+ row.names=FALSE,
88
+ col.names=TRUE,
89
+ quote=FALSE
90
+ )
91
+ png(
92
+ file.path(casedir, paste0("Enrichr-", db, ".png")),
93
+ res=100, height=1000, width=1000
94
+ )
66
95
  print(plotEnrich(enriched[[db]], showTerms = 20, title=db))
96
+ dev.off()
67
97
  }
68
- dev.off()
69
98
  }
70
99
  }
71
100
 
@@ -82,32 +111,41 @@ mutate_meta = function(obj, mutaters) {
82
111
  }
83
112
 
84
113
  do_case = function(case) {
85
- print(paste("- Dealing with case:", case, "..."))
114
+ cat(paste("- Dealing with case:", case, "...\n"))
86
115
  casepms = cases$cases[[case]]
87
- pmnames = names(casepms)
88
116
  obj = seurat_obj
89
- if ("filter" %in% pmnames) {
117
+ if (!is.null(casepms$filter)) {
90
118
  obj = obj %>% filter(eval(parse(text=casepms$filter)))
91
119
  }
92
120
  obj = mutate_meta(obj, casepms$mutaters)
93
121
  casepms$mutaters = NULL
94
- if ("filter2" %in% pmnames) {
122
+ if (!is.null(casepms$filter2)) {
95
123
  obj = obj %>% filter(eval(parse(text=casepms$filter2)))
96
124
  }
97
-
98
- if (!"ident.1" %in% pmnames && !"ident.2" %in% pmnames) {
99
- Idents(obj) = casepms$group.by
100
- casepms$group.by = NULL
101
- casepms$object = obj
102
- allmarkers = do_call(FindAllMarkers, casepms)
103
- # Is it always cluster?
104
- for (group in sort(unique(allmarkers$cluster))) {
105
- do_enrich(paste(case, group, sep="_"), allmarkers %>% filter(cluster == group))
125
+ if (!is.null(casepms$each)) {
126
+ eachs = unique(obj@meta.data[[casepms$each]])
127
+ for (each in eachs) {
128
+ print(paste(" Dealing with unit:", each, "..."))
129
+ eachobj = obj %>% filter(!!parse_expr(casepms$each) == each)
130
+ casepms$object = eachobj
131
+ markers = do_call(FindMarkers, casepms) %>% rownames_to_column("gene")
132
+ do_enrich(paste0(case, " (", each, ")"), markers)
106
133
  }
107
134
  } else {
108
- casepms$object = obj
109
- markers = do_call(FindMarkers, casepms) %>% rownames_to_column("gene")
110
- do_enrich(case, markers)
135
+ if (is.null(casepms$ident.1) && is.null(casepms$ident.2)) {
136
+ Idents(obj) = casepms$group.by
137
+ casepms$group.by = NULL
138
+ casepms$object = obj
139
+ allmarkers = do_call(FindAllMarkers, casepms)
140
+ # Is it always cluster?
141
+ for (group in sort(unique(allmarkers$cluster))) {
142
+ do_enrich(paste(case, group, sep="_"), allmarkers %>% filter(cluster == group))
143
+ }
144
+ } else {
145
+ casepms$object = obj
146
+ markers = do_call(FindMarkers, casepms) %>% rownames_to_column("gene")
147
+ do_enrich(case, markers)
148
+ }
111
149
  }
112
150
  }
113
151
 
@@ -0,0 +1,22 @@
1
+ import cmdy
2
+
3
+ infile = {{in.infile | quote}} # pyright: ignore
4
+ outfile = {{out.outfile | quote}} # pyright: ignore
5
+ outdir = {{out.outdir | quote}} # pyright: ignore
6
+ perl = {{envs.perl | quote}} # pyright: ignore
7
+ ref = {{envs.ref | repr}} # pyright: ignore
8
+ samtools = {{envs.samtools | quote}} # pyright: ignore
9
+ args = {{envs.args | repr}} # pyright: ignore
10
+ maf2vcf = {{biopipen_dir | append: "/scripts/tcgamaf/maf2vcf.pl" | repr}} # pyright: ignore
11
+
12
+ args['input-maf'] = infile
13
+ args['output-vcf'] = outfile
14
+ args['output-dir'] = outdir
15
+ args['ref-fasta'] = ref
16
+
17
+ cmd = cmdy.perl(maf2vcf, _exe=perl, **args).hold()
18
+
19
+ print("Running:")
20
+ print(cmd.strcmd)
21
+
22
+ cmd.fg().run()
@@ -0,0 +1,14 @@
1
+
2
+ infile = {{in.infile | quote}} # pyright: ignore
3
+ outfile = {{out.outfile | quote}} # pyright: ignore
4
+
5
+ with open(infile) as fin, open(outfile, "w") as fout:
6
+ for line in fin:
7
+ if line.startswith("#") or line.startswith("Hugo_Symbol"):
8
+ fout.write(line)
9
+ else:
10
+ cols = line.split("\t")
11
+ if not cols[4].startswith("chr"):
12
+ cols[4] = f"chr{cols[4]}"
13
+ # "\n" at the last col kept
14
+ fout.write("\t".join(cols))