biopipen 0.21.0__py3-none-any.whl → 0.34.26__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.
Files changed (290) hide show
  1. biopipen/__init__.py +1 -1
  2. biopipen/core/config.toml +28 -0
  3. biopipen/core/filters.py +79 -4
  4. biopipen/core/proc.py +12 -3
  5. biopipen/core/testing.py +75 -3
  6. biopipen/ns/bam.py +148 -6
  7. biopipen/ns/bed.py +75 -0
  8. biopipen/ns/cellranger.py +186 -0
  9. biopipen/ns/cellranger_pipeline.py +126 -0
  10. biopipen/ns/cnv.py +19 -3
  11. biopipen/ns/cnvkit.py +1 -1
  12. biopipen/ns/cnvkit_pipeline.py +20 -12
  13. biopipen/ns/delim.py +34 -35
  14. biopipen/ns/gene.py +68 -23
  15. biopipen/ns/gsea.py +63 -37
  16. biopipen/ns/misc.py +39 -14
  17. biopipen/ns/plot.py +304 -1
  18. biopipen/ns/protein.py +183 -0
  19. biopipen/ns/regulatory.py +290 -0
  20. biopipen/ns/rnaseq.py +142 -5
  21. biopipen/ns/scrna.py +2053 -473
  22. biopipen/ns/scrna_metabolic_landscape.py +228 -382
  23. biopipen/ns/snp.py +659 -0
  24. biopipen/ns/stats.py +484 -0
  25. biopipen/ns/tcr.py +683 -98
  26. biopipen/ns/vcf.py +236 -2
  27. biopipen/ns/web.py +97 -6
  28. biopipen/reports/bam/CNVpytor.svelte +4 -9
  29. biopipen/reports/cellranger/CellRangerCount.svelte +18 -0
  30. biopipen/reports/cellranger/CellRangerSummary.svelte +16 -0
  31. biopipen/reports/cellranger/CellRangerVdj.svelte +18 -0
  32. biopipen/reports/cnvkit/CNVkitDiagram.svelte +1 -1
  33. biopipen/reports/cnvkit/CNVkitHeatmap.svelte +1 -1
  34. biopipen/reports/cnvkit/CNVkitScatter.svelte +1 -1
  35. biopipen/reports/common.svelte +15 -0
  36. biopipen/reports/protein/ProdigySummary.svelte +16 -0
  37. biopipen/reports/scrna/CellsDistribution.svelte +4 -39
  38. biopipen/reports/scrna/DimPlots.svelte +1 -1
  39. biopipen/reports/scrna/MarkersFinder.svelte +6 -126
  40. biopipen/reports/scrna/MetaMarkers.svelte +3 -75
  41. biopipen/reports/scrna/RadarPlots.svelte +4 -20
  42. biopipen/reports/scrna_metabolic_landscape/MetabolicFeatures.svelte +61 -22
  43. biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayActivity.svelte +88 -82
  44. biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayHeterogeneity.svelte +70 -10
  45. biopipen/reports/snp/PlinkCallRate.svelte +24 -0
  46. biopipen/reports/snp/PlinkFreq.svelte +18 -0
  47. biopipen/reports/snp/PlinkHWE.svelte +18 -0
  48. biopipen/reports/snp/PlinkHet.svelte +18 -0
  49. biopipen/reports/snp/PlinkIBD.svelte +18 -0
  50. biopipen/reports/tcr/CDR3AAPhyschem.svelte +19 -66
  51. biopipen/reports/tcr/ClonalStats.svelte +16 -0
  52. biopipen/reports/tcr/CloneResidency.svelte +3 -93
  53. biopipen/reports/tcr/Immunarch.svelte +4 -155
  54. biopipen/reports/tcr/TCRClusterStats.svelte +3 -45
  55. biopipen/reports/tcr/TESSA.svelte +11 -28
  56. biopipen/reports/utils/misc.liq +22 -7
  57. biopipen/scripts/bam/BamMerge.py +11 -15
  58. biopipen/scripts/bam/BamSampling.py +90 -0
  59. biopipen/scripts/bam/BamSort.py +141 -0
  60. biopipen/scripts/bam/BamSplitChroms.py +10 -10
  61. biopipen/scripts/bam/BamSubsetByBed.py +38 -0
  62. biopipen/scripts/bam/CNAClinic.R +41 -5
  63. biopipen/scripts/bam/CNVpytor.py +153 -54
  64. biopipen/scripts/bam/ControlFREEC.py +13 -14
  65. biopipen/scripts/bam/SamtoolsView.py +33 -0
  66. biopipen/scripts/bed/Bed2Vcf.py +5 -5
  67. biopipen/scripts/bed/BedConsensus.py +5 -5
  68. biopipen/scripts/bed/BedLiftOver.sh +6 -4
  69. biopipen/scripts/bed/BedtoolsIntersect.py +54 -0
  70. biopipen/scripts/bed/BedtoolsMakeWindows.py +47 -0
  71. biopipen/scripts/bed/BedtoolsMerge.py +4 -4
  72. biopipen/scripts/cellranger/CellRangerCount.py +138 -0
  73. biopipen/scripts/cellranger/CellRangerSummary.R +181 -0
  74. biopipen/scripts/cellranger/CellRangerVdj.py +112 -0
  75. biopipen/scripts/cnv/AneuploidyScore.R +55 -20
  76. biopipen/scripts/cnv/AneuploidyScoreSummary.R +221 -163
  77. biopipen/scripts/cnv/TMADScore.R +25 -9
  78. biopipen/scripts/cnv/TMADScoreSummary.R +57 -86
  79. biopipen/scripts/cnvkit/CNVkitAccess.py +7 -6
  80. biopipen/scripts/cnvkit/CNVkitAutobin.py +26 -18
  81. biopipen/scripts/cnvkit/CNVkitBatch.py +6 -6
  82. biopipen/scripts/cnvkit/CNVkitCall.py +3 -3
  83. biopipen/scripts/cnvkit/CNVkitCoverage.py +4 -3
  84. biopipen/scripts/cnvkit/CNVkitDiagram.py +5 -5
  85. biopipen/scripts/cnvkit/CNVkitFix.py +3 -3
  86. biopipen/scripts/cnvkit/CNVkitGuessBaits.py +12 -8
  87. biopipen/scripts/cnvkit/CNVkitHeatmap.py +5 -5
  88. biopipen/scripts/cnvkit/CNVkitReference.py +6 -5
  89. biopipen/scripts/cnvkit/CNVkitScatter.py +5 -5
  90. biopipen/scripts/cnvkit/CNVkitSegment.py +5 -5
  91. biopipen/scripts/cnvkit/guess_baits.py +166 -93
  92. biopipen/scripts/delim/RowsBinder.R +1 -1
  93. biopipen/scripts/delim/SampleInfo.R +116 -118
  94. biopipen/scripts/gene/GeneNameConversion.R +67 -0
  95. biopipen/scripts/gene/GenePromoters.R +61 -0
  96. biopipen/scripts/gsea/Enrichr.R +5 -5
  97. biopipen/scripts/gsea/FGSEA.R +184 -50
  98. biopipen/scripts/gsea/GSEA.R +2 -2
  99. biopipen/scripts/gsea/PreRank.R +5 -5
  100. biopipen/scripts/misc/Config2File.py +2 -2
  101. biopipen/scripts/misc/Plot.R +80 -0
  102. biopipen/scripts/misc/Shell.sh +15 -0
  103. biopipen/scripts/misc/Str2File.py +2 -2
  104. biopipen/scripts/plot/Heatmap.R +3 -3
  105. biopipen/scripts/plot/Manhattan.R +147 -0
  106. biopipen/scripts/plot/QQPlot.R +146 -0
  107. biopipen/scripts/plot/ROC.R +88 -0
  108. biopipen/scripts/plot/Scatter.R +112 -0
  109. biopipen/scripts/plot/VennDiagram.R +5 -9
  110. biopipen/scripts/protein/MMCIF2PDB.py +33 -0
  111. biopipen/scripts/protein/PDB2Fasta.py +60 -0
  112. biopipen/scripts/protein/Prodigy.py +119 -0
  113. biopipen/scripts/protein/ProdigySummary.R +140 -0
  114. biopipen/scripts/protein/RMSD.py +178 -0
  115. biopipen/scripts/regulatory/MotifAffinityTest.R +102 -0
  116. biopipen/scripts/regulatory/MotifAffinityTest_AtSNP.R +127 -0
  117. biopipen/scripts/regulatory/MotifAffinityTest_MotifBreakR.R +104 -0
  118. biopipen/scripts/regulatory/MotifScan.py +159 -0
  119. biopipen/scripts/regulatory/VariantMotifPlot.R +78 -0
  120. biopipen/scripts/regulatory/motifs-common.R +324 -0
  121. biopipen/scripts/rnaseq/Simulation-ESCO.R +180 -0
  122. biopipen/scripts/rnaseq/Simulation-RUVcorr.R +45 -0
  123. biopipen/scripts/rnaseq/Simulation.R +21 -0
  124. biopipen/scripts/rnaseq/UnitConversion.R +325 -54
  125. biopipen/scripts/scrna/AnnData2Seurat.R +40 -0
  126. biopipen/scripts/scrna/CCPlotR-patch.R +161 -0
  127. biopipen/scripts/scrna/CellCellCommunication.py +150 -0
  128. biopipen/scripts/scrna/CellCellCommunicationPlots.R +93 -0
  129. biopipen/scripts/scrna/CellSNPLite.py +30 -0
  130. biopipen/scripts/scrna/CellTypeAnnotation-celltypist.R +185 -0
  131. biopipen/scripts/scrna/CellTypeAnnotation-direct.R +68 -31
  132. biopipen/scripts/scrna/CellTypeAnnotation-hitype.R +27 -22
  133. biopipen/scripts/scrna/CellTypeAnnotation-sccatch.R +28 -20
  134. biopipen/scripts/scrna/CellTypeAnnotation-sctype.R +48 -25
  135. biopipen/scripts/scrna/CellTypeAnnotation.R +37 -1
  136. biopipen/scripts/scrna/CellsDistribution.R +456 -167
  137. biopipen/scripts/scrna/DimPlots.R +1 -1
  138. biopipen/scripts/scrna/ExprImputation-alra.R +109 -0
  139. biopipen/scripts/scrna/ExprImputation-rmagic.R +256 -0
  140. biopipen/scripts/scrna/{ExprImpution-scimpute.R → ExprImputation-scimpute.R} +8 -5
  141. biopipen/scripts/scrna/ExprImputation.R +7 -0
  142. biopipen/scripts/scrna/LoomTo10X.R +51 -0
  143. biopipen/scripts/scrna/MQuad.py +25 -0
  144. biopipen/scripts/scrna/MarkersFinder.R +679 -400
  145. biopipen/scripts/scrna/MetaMarkers.R +265 -161
  146. biopipen/scripts/scrna/ModuleScoreCalculator.R +66 -11
  147. biopipen/scripts/scrna/PseudoBulkDEG.R +678 -0
  148. biopipen/scripts/scrna/RadarPlots.R +355 -134
  149. biopipen/scripts/scrna/ScFGSEA.R +298 -100
  150. biopipen/scripts/scrna/ScSimulation.R +65 -0
  151. biopipen/scripts/scrna/ScVelo.py +617 -0
  152. biopipen/scripts/scrna/Seurat2AnnData.R +7 -0
  153. biopipen/scripts/scrna/SeuratClusterStats-clustree.R +87 -0
  154. biopipen/scripts/scrna/SeuratClusterStats-dimplots.R +36 -30
  155. biopipen/scripts/scrna/SeuratClusterStats-features.R +138 -187
  156. biopipen/scripts/scrna/SeuratClusterStats-ngenes.R +81 -0
  157. biopipen/scripts/scrna/SeuratClusterStats-stats.R +78 -89
  158. biopipen/scripts/scrna/SeuratClusterStats.R +47 -10
  159. biopipen/scripts/scrna/SeuratClustering.R +36 -233
  160. biopipen/scripts/scrna/SeuratLoading.R +2 -2
  161. biopipen/scripts/scrna/SeuratMap2Ref.R +84 -113
  162. biopipen/scripts/scrna/SeuratMetadataMutater.R +16 -6
  163. biopipen/scripts/scrna/SeuratPreparing.R +223 -173
  164. biopipen/scripts/scrna/SeuratSubClustering.R +64 -0
  165. biopipen/scripts/scrna/SeuratTo10X.R +27 -0
  166. biopipen/scripts/scrna/Slingshot.R +65 -0
  167. biopipen/scripts/scrna/Subset10X.R +2 -2
  168. biopipen/scripts/scrna/TopExpressingGenes.R +169 -135
  169. biopipen/scripts/scrna/celltypist-wrapper.py +195 -0
  170. biopipen/scripts/scrna/scvelo_paga.py +313 -0
  171. biopipen/scripts/scrna/seurat_anndata_conversion.py +98 -0
  172. biopipen/scripts/scrna_metabolic_landscape/MetabolicFeatures.R +447 -82
  173. biopipen/scripts/scrna_metabolic_landscape/MetabolicPathwayActivity.R +348 -241
  174. biopipen/scripts/scrna_metabolic_landscape/MetabolicPathwayHeterogeneity.R +188 -166
  175. biopipen/scripts/snp/MatrixEQTL.R +217 -0
  176. biopipen/scripts/snp/Plink2GTMat.py +148 -0
  177. biopipen/scripts/snp/PlinkCallRate.R +199 -0
  178. biopipen/scripts/snp/PlinkFilter.py +100 -0
  179. biopipen/scripts/snp/PlinkFreq.R +291 -0
  180. biopipen/scripts/snp/PlinkFromVcf.py +81 -0
  181. biopipen/scripts/snp/PlinkHWE.R +85 -0
  182. biopipen/scripts/snp/PlinkHet.R +96 -0
  183. biopipen/scripts/snp/PlinkIBD.R +196 -0
  184. biopipen/scripts/snp/PlinkSimulation.py +124 -0
  185. biopipen/scripts/snp/PlinkUpdateName.py +124 -0
  186. biopipen/scripts/stats/ChowTest.R +146 -0
  187. biopipen/scripts/stats/DiffCoexpr.R +152 -0
  188. biopipen/scripts/stats/LiquidAssoc.R +135 -0
  189. biopipen/scripts/stats/Mediation.R +108 -0
  190. biopipen/scripts/stats/MetaPvalue.R +130 -0
  191. biopipen/scripts/stats/MetaPvalue1.R +74 -0
  192. biopipen/scripts/tcgamaf/Maf2Vcf.py +2 -2
  193. biopipen/scripts/tcgamaf/MafAddChr.py +2 -2
  194. biopipen/scripts/tcr/Attach2Seurat.R +3 -2
  195. biopipen/scripts/tcr/CDR3AAPhyschem.R +211 -143
  196. biopipen/scripts/tcr/CDR3Clustering.R +343 -0
  197. biopipen/scripts/tcr/ClonalStats.R +526 -0
  198. biopipen/scripts/tcr/CloneResidency.R +255 -131
  199. biopipen/scripts/tcr/CloneSizeQQPlot.R +4 -4
  200. biopipen/scripts/tcr/GIANA/GIANA.py +1356 -797
  201. biopipen/scripts/tcr/GIANA/GIANA4.py +1362 -789
  202. biopipen/scripts/tcr/GIANA/query.py +164 -162
  203. biopipen/scripts/tcr/Immunarch-basic.R +31 -9
  204. biopipen/scripts/tcr/Immunarch-clonality.R +25 -5
  205. biopipen/scripts/tcr/Immunarch-diversity.R +352 -134
  206. biopipen/scripts/tcr/Immunarch-geneusage.R +45 -5
  207. biopipen/scripts/tcr/Immunarch-kmer.R +68 -8
  208. biopipen/scripts/tcr/Immunarch-overlap.R +84 -4
  209. biopipen/scripts/tcr/Immunarch-spectratyping.R +35 -6
  210. biopipen/scripts/tcr/Immunarch-tracking.R +38 -6
  211. biopipen/scripts/tcr/Immunarch-vjjunc.R +165 -0
  212. biopipen/scripts/tcr/Immunarch.R +63 -11
  213. biopipen/scripts/tcr/Immunarch2VDJtools.R +2 -2
  214. biopipen/scripts/tcr/ImmunarchFilter.R +4 -4
  215. biopipen/scripts/tcr/ImmunarchLoading.R +38 -29
  216. biopipen/scripts/tcr/SampleDiversity.R +1 -1
  217. biopipen/scripts/tcr/ScRepCombiningExpression.R +40 -0
  218. biopipen/scripts/tcr/ScRepLoading.R +166 -0
  219. biopipen/scripts/tcr/TCRClusterStats.R +176 -22
  220. biopipen/scripts/tcr/TCRDock.py +110 -0
  221. biopipen/scripts/tcr/TESSA.R +102 -118
  222. biopipen/scripts/tcr/VJUsage.R +5 -5
  223. biopipen/scripts/tcr/immunarch-patched.R +142 -0
  224. biopipen/scripts/tcr/vdjtools-patch.sh +1 -1
  225. biopipen/scripts/vcf/BcftoolsAnnotate.py +91 -0
  226. biopipen/scripts/vcf/BcftoolsFilter.py +90 -0
  227. biopipen/scripts/vcf/BcftoolsMerge.py +31 -0
  228. biopipen/scripts/vcf/BcftoolsSort.py +113 -0
  229. biopipen/scripts/vcf/BcftoolsView.py +73 -0
  230. biopipen/scripts/vcf/TruvariBench.sh +14 -7
  231. biopipen/scripts/vcf/TruvariBenchSummary.R +16 -13
  232. biopipen/scripts/vcf/TruvariConsistency.R +1 -1
  233. biopipen/scripts/vcf/Vcf2Bed.py +2 -2
  234. biopipen/scripts/vcf/VcfAnno.py +11 -11
  235. biopipen/scripts/vcf/VcfDownSample.sh +22 -10
  236. biopipen/scripts/vcf/VcfFilter.py +5 -5
  237. biopipen/scripts/vcf/VcfFix.py +7 -7
  238. biopipen/scripts/vcf/VcfFix_utils.py +13 -4
  239. biopipen/scripts/vcf/VcfIndex.py +3 -3
  240. biopipen/scripts/vcf/VcfIntersect.py +3 -3
  241. biopipen/scripts/vcf/VcfLiftOver.sh +5 -0
  242. biopipen/scripts/vcf/VcfSplitSamples.py +4 -4
  243. biopipen/scripts/vcf/bcftools_utils.py +52 -0
  244. biopipen/scripts/web/Download.py +8 -4
  245. biopipen/scripts/web/DownloadList.py +5 -5
  246. biopipen/scripts/web/GCloudStorageDownloadBucket.py +82 -0
  247. biopipen/scripts/web/GCloudStorageDownloadFile.py +23 -0
  248. biopipen/scripts/web/gcloud_common.py +49 -0
  249. biopipen/utils/gene.py +108 -60
  250. biopipen/utils/misc.py +146 -20
  251. biopipen/utils/reference.py +64 -20
  252. biopipen/utils/reporter.py +177 -0
  253. biopipen/utils/vcf.py +1 -1
  254. biopipen-0.34.26.dist-info/METADATA +27 -0
  255. biopipen-0.34.26.dist-info/RECORD +292 -0
  256. {biopipen-0.21.0.dist-info → biopipen-0.34.26.dist-info}/WHEEL +1 -1
  257. {biopipen-0.21.0.dist-info → biopipen-0.34.26.dist-info}/entry_points.txt +6 -2
  258. biopipen/ns/bcftools.py +0 -111
  259. biopipen/ns/scrna_basic.py +0 -255
  260. biopipen/reports/delim/SampleInfo.svelte +0 -36
  261. biopipen/reports/scrna/GeneExpressionInvistigation.svelte +0 -32
  262. biopipen/reports/scrna/ScFGSEA.svelte +0 -35
  263. biopipen/reports/scrna/SeuratClusterStats.svelte +0 -82
  264. biopipen/reports/scrna/SeuratMap2Ref.svelte +0 -20
  265. biopipen/reports/scrna/SeuratPreparing.svelte +0 -38
  266. biopipen/reports/scrna/TopExpressingGenes.svelte +0 -55
  267. biopipen/reports/scrna_metabolic_landscape/MetabolicFeaturesIntraSubset.svelte +0 -31
  268. biopipen/reports/utils/gsea.liq +0 -110
  269. biopipen/scripts/bcftools/BcftoolsAnnotate.py +0 -42
  270. biopipen/scripts/bcftools/BcftoolsFilter.py +0 -79
  271. biopipen/scripts/bcftools/BcftoolsSort.py +0 -19
  272. biopipen/scripts/gene/GeneNameConversion.py +0 -66
  273. biopipen/scripts/scrna/ExprImpution-alra.R +0 -32
  274. biopipen/scripts/scrna/ExprImpution-rmagic.R +0 -29
  275. biopipen/scripts/scrna/ExprImpution.R +0 -7
  276. biopipen/scripts/scrna/GeneExpressionInvistigation.R +0 -132
  277. biopipen/scripts/scrna/Write10X.R +0 -11
  278. biopipen/scripts/scrna_metabolic_landscape/MetabolicFeaturesIntraSubset.R +0 -150
  279. biopipen/scripts/tcr/TCRClustering.R +0 -280
  280. biopipen/utils/common_docstrs.py +0 -61
  281. biopipen/utils/gene.R +0 -49
  282. biopipen/utils/gsea.R +0 -193
  283. biopipen/utils/io.R +0 -20
  284. biopipen/utils/misc.R +0 -114
  285. biopipen/utils/mutate_helpers.R +0 -433
  286. biopipen/utils/plot.R +0 -173
  287. biopipen/utils/rnaseq.R +0 -48
  288. biopipen/utils/single_cell.R +0 -115
  289. biopipen-0.21.0.dist-info/METADATA +0 -22
  290. biopipen-0.21.0.dist-info/RECORD +0 -218
@@ -1,55 +0,0 @@
1
- {% from "utils/misc.liq" import report_jobs -%}
2
- {% from "utils/gsea.liq" import enrichr_report -%}
3
- <script>
4
- import { Image, DataTable } from "$libs";
5
- import { Tabs, Tab, TabContent, InlineNotification } from "$ccs";
6
- </script>
7
-
8
-
9
- {%- macro report_job(job, h=1) -%}
10
- {%- set secdirs = job.out.outdir | glob: "*" -%}
11
- {%- if len(secdirs) == 1 -%}
12
- {%- set secname = secdirs | first | basename -%}
13
- {%- for casedir in secdirs[0] | glob: "*" -%}
14
- {%- if secname == "DEFAULT" -%}
15
- <h{{h}}>{{casedir | basename | escape}}</h{{h}}>
16
- {%- else -%}
17
- <h{{h}}>{{secname | escape}} - {{casedir | basename | escape}}</h{{h}}>
18
- {%- endif -%}
19
-
20
- <h{{h+1}}>Markers</h{{h+1}}>
21
- <DataTable
22
- src={{ casedir | joinpaths: "exprn.txt" | quote }}
23
- data={ {{ casedir | joinpaths: "exprn.txt" | datatable: sep="\t", nrows=100 }} }
24
- />
25
-
26
- <h{{h+1}}>Enrichment analysis</h{{h+1}}>
27
- {{ enrichr_report(casedir) }}
28
-
29
- {%- endfor -%}
30
- {%- else -%}
31
- {%- for secdir in secdirs -%}
32
- {%- set sec = secdir | basename -%}
33
- <h{{h}}>{{sec | escape}}</h{{h}}>
34
- {%- for casedir in secdir | glob: "*" -%}
35
- <h{{h+1}}>{{casedir | basename | escape}}</h{{h+1}}>
36
-
37
- <h{{h+2}}>Markers</h{{h+2}}>
38
- <DataTable
39
- src={{ casedir | joinpaths: "exprn.txt" | quote }}
40
- data={ {{ casedir | joinpaths: "exprn.txt" | datatable: sep="\t", nrows=100 }} }
41
- />
42
-
43
- <h{{h+2}}>Enrichment analysis</h{{h+2}}>
44
- {{ enrichr_report(casedir) }}
45
-
46
- {%- endfor -%}
47
- {%- endfor -%}
48
- {%- endif -%}
49
- {%- endmacro -%}
50
-
51
- {%- macro head_job(job) -%}
52
- <h1>{{job.in.srtobj | stem0 | escape}}</h1>
53
- {%- endmacro -%}
54
-
55
- {{ report_jobs(jobs, head_job, report_job) }}
@@ -1,31 +0,0 @@
1
- {% from "utils/misc.liq" import report_jobs, table_of_images -%}
2
- {% from "utils/gsea.liq" import fgsea_report, gsea_report -%}
3
-
4
- <script>
5
- import { Image, DataTable } from "$libs";
6
- </script>
7
-
8
- {%- macro report_job(job, h=2) -%}
9
- {% for groupdir in job.out.outdir | glob: "*" %}
10
- <h{{h}}>{{groupdir | basename}}</h{{h}}>
11
- {%- set dsdirs = groupdir | glob: "*" -%}
12
- {% for dsdir in groupdir | glob: "*" %}
13
- <h{{h+1}}>{{ dsdir | basename }}</h{{h+1}}>
14
- {% if envs.fgsea %}
15
- {% if dsdir | joinpaths: "fgsea.txt" | isfile %}
16
- {{ fgsea_report(dsdir, h+2, envs, envs.top) }}
17
- {% else %}
18
- <p>Not enough events.</p>
19
- {% endif %}
20
- {% else %}
21
- {{ gsea_report(dsdir, h+2, envs, envs.top) }}
22
- {% endif %}
23
- {% endfor %}
24
- {% endfor %}
25
- {%- endmacro -%}
26
-
27
- {%- macro head_job(job) -%}
28
- <h1>{{job.in.sobjfile | stem | escape}}</h1>
29
- {%- endmacro -%}
30
-
31
- {{ report_jobs(jobs, head_job, report_job) }}
@@ -1,110 +0,0 @@
1
- {% from "utils/misc.liq" import table_of_images -%}
2
-
3
- {%- macro fgsea_report_script() -%}
4
- import { Image, DataTable } from "$libs";
5
- {%- endmacro -%}
6
-
7
- {%- macro fgsea_report(fgsea_dir, h, envs, nrows=100) -%}
8
- {%- addfilter splitgenes -%}
9
- def splitgenes(data):
10
- for dat in data:
11
- dat["leadingEdge"] = dat["leadingEdge"].replace(",", " ")
12
- return json_dumps(data)
13
- {%- endaddfilter -%}
14
-
15
- <h{{h}}>Enrichment table</h{{h}}>
16
- <Image src={{ fgsea_dir | joinpaths: "gsea_table.png" | quote }} />
17
-
18
- {% set data = fgsea_dir | joinpaths: "fgsea.txt" | datatable: sep="\t", nrows=nrows | json_loads %}
19
-
20
- <h{{h}}>Enrichment pathways</h{{h}}>
21
- <DataTable src={{ fgsea_dir | joinpaths: "fgsea.txt" | quote }}
22
- data={ {{ data | splitgenes: }} }
23
- pageSize={10} />
24
-
25
- <h{{h}}>Enrichment plot of pathways</h{{h}}>
26
- {%- python -%}
27
- import os
28
- def fgsea_plots(pathways, fgsea_dir):
29
- out = []
30
- for pathway in pathways:
31
- pathway = pathway.replace("/", "-")
32
- pwfig = joinpaths(fgsea_dir, f"fgsea_{pathway}.png")
33
- if os.path.exists(pwfig):
34
- out.append(pwfig)
35
- return out
36
- {%- endpython -%}
37
- {{ table_of_images(
38
- fgsea_plots(liquid_map(data, "pathway"), fgsea_dir),
39
- liquid_map(data, "pathway"),
40
- table_width=75
41
- ) }}
42
-
43
- {%- endmacro -%}
44
-
45
-
46
- {%- macro gsea_report(gsea_dir, h, envs, nrows=100) -%}
47
- <h{{h}}>Global view</h{{h}}>
48
-
49
- <embed src={{gsea_dir | joinpaths: "*.global.plots.pdf" | glob | first | quote}}
50
- width="100%"
51
- height="1000"
52
- type="application/pdf" />
53
-
54
- <h{{h}}>Summary</h{{h}}>
55
- {% for sumfile in gsea_dir | joinpaths: "*.SUMMARY.RESULTS.REPORT.*.txt" | glob %}
56
- {% set klass = stem(sumfile).split(".")[-1] %}
57
- <h{{h+1}}>{{klass}}</h{{h+1}}>
58
- <DataTable data={ {{sumfile | datatable: sep="\t", nrows=nrows}} } />
59
- {% endfor %}
60
-
61
- <h{{h}}>Enrichment details</h{{h}}>
62
- {% set cutoff = envs.get("fdr.q.val.threshold", envs.get("fdr_q_val_threshold", 0.25)) %}
63
- {% for sumfile in gsea_dir | joinpaths: "*.SUMMARY.RESULTS.REPORT.*.txt" | glob %}
64
- {% set klass = stem(sumfile).split(".")[-1] %}
65
- <h{{h+1}}>{{klass}}</h{{h+1}}>
66
- {% set sumdata = sumfile | datatable: sep="\t" | json_loads %}
67
- {% set has_signif = [] %}
68
- {% for row in sumdata %}
69
- {% if row["FDR_q_val"] < cutoff %}
70
- {% set _ = has_signif.append(1) %}
71
- <embed src={{gsea_dir | joinpaths: "*." + row["GS"] + ".plot." + klass + ".*.pdf" | glob | first | quote}}
72
- width="100%"
73
- height="700"
74
- type="application/pdf" />
75
- {% endif %}
76
- {% endfor %}
77
- {% if len(has_signif) == 0 %}
78
- <Tile>No significantly (FDR_q_val &lt; {{cutoff}}) enriched pathways found.</Tile>
79
- {% endif %}
80
- {% endfor %}
81
-
82
- {%- endmacro -%}
83
-
84
-
85
- {%- macro enrichr_report_script() -%}
86
- import { Image, DataTable } from "$libs";
87
- import { Tabs, Tab, TabContent, InlineNotification } from "$ccs";
88
- {%- endmacro -%}
89
-
90
- {%- macro enrichr_report(enrichr_dir) -%}
91
- <Tabs>
92
- {% for enrtxt in enrichr_dir | glob: "Enrichr-*.txt" %}
93
- {% set db = enrtxt | stem | replace: "Enrichr-", "" %}
94
- <Tab label="{{db}}" title="{{db}}" />
95
- {% endfor %}
96
- <div slot="content">
97
- {% for enrtxt in enrichr_dir | glob: "Enrichr-*.txt" %}
98
- {% set db = enrtxt | stem | replace: "Enrichr-", "" %}
99
- <TabContent>
100
- <Image src={{enrichr_dir | joinpaths: "Enrichr-" + db + ".png" | quote}} />
101
- <DataTable
102
- src={{ enrtxt | quote }}
103
- data={ {{ enrtxt | datatable: sep="\t", nrows=100 }} }
104
- />
105
- </TabContent>
106
- {% endfor %}
107
- </div>
108
- </Tabs>
109
- {%- endmacro -%}
110
-
@@ -1,42 +0,0 @@
1
- from os import path
2
-
3
- from biopipen.utils.reference import tabix_index
4
- from biopipen.utils.misc import dict_to_cli_args, run_command
5
-
6
- infile = {{in.infile | repr}} # pyright: ignore
7
- annfile = {{(in.annfile or envs.annfile) | repr}} # pyright: ignore
8
- outfile = {{out.outfile | repr}} # pyright: ignore
9
- joboutdir = {{job.outdir | repr}} # pyright: ignore
10
- bcftools = {{envs.bcftools | repr}} # pyright: ignore
11
- tabix = {{envs.tabix | repr}} # pyright: ignore
12
- ncores = {{envs.ncores | repr}} # pyright: ignore
13
- cols = {{envs.cols | repr}} # pyright: ignore
14
- header = {{envs.header | repr}} # pyright: ignore
15
- args = {{envs.args | repr}} # pyright: ignore
16
-
17
- args[""] = bcftools
18
- args["_"] = tabix_index(infile, "vcf")
19
- args["o"] = outfile
20
- args["threads"] = ncores
21
-
22
- if annfile:
23
- abname = path.basename(annfile)
24
- ext = path.splitext(
25
- abname[:-3] if abname.endswith('.gz') else abname
26
- )[-1][1:]
27
- args["a"] = tabix_index(annfile, ext, tabix)
28
-
29
- if cols and isinstance(cols, list):
30
- args["c"] = ",".join(cols)
31
-
32
- if header:
33
- if not isinstance(header, list):
34
- header = [header]
35
-
36
- headerfile = path.join(joboutdir, "header.txt")
37
- with open(headerfile, "w") as fh:
38
- for head in header:
39
- fh.write(f"{head}\n")
40
- args["h"] = headerfile
41
-
42
- run_command(dict_to_cli_args(args, dashify=True), fg=True)
@@ -1,79 +0,0 @@
1
- import shutil
2
- from pathlib import Path
3
- from hashlib import md5
4
-
5
- from biopipen.core.filters import dict_to_cli_args, run_command
6
-
7
- infile = {{in.infile | repr}} # pyright: ignore
8
- outfile = {{out.outfile | repr}} # pyright: ignore
9
- bcftools = {{envs.bcftools | repr}} # pyright: ignore
10
- keep = {{envs.keep | repr}} # pyright: ignore
11
- args = {{envs.args | repr}} # pyright: ignore
12
- ncores = {{envs.ncores | repr}} # pyright: ignore
13
- tmpdir = {{envs.tmpdir | repr}} # pyright: ignore
14
- includes = {{envs.includes | repr}} # pyright: ignore
15
- excludes = {{envs.excludes | repr}} # pyright: ignore
16
-
17
- args[""] = bcftools
18
- args["_"] = infile
19
- args["o"] = outfile
20
- args["threads"] = ncores
21
- if "O" not in args and "output-type" not in args:
22
- args["O"] = "z" if infile.endswith(".gz") else "v"
23
- if "m" not in args and "mode" not in args:
24
- args["m"] = "+"
25
-
26
- tmpdir = (
27
- Path(tmpdir) / f"biopipen-bcftoolsfilter-{md5(infile.encode()).hexdigest()}"
28
- )
29
- tmpdir.mkdir(parents=True, exist_ok=True)
30
- # a.vcf.gz -> a
31
- # a.vcf -> a
32
- stem = Path(infile).stem
33
- if stem.endswith(".vcf"):
34
- stem = stem[:-4]
35
- # .vcf.gz
36
- # .gz
37
- ext = Path(infile).name[len(stem):]
38
-
39
- FILTER_INDEX = [1]
40
-
41
- def handle_filter(vcf, fname, filt, flag):
42
- print("- Handling filter ", fname, ": ", filt, " ...")
43
-
44
- arguments = args.copy()
45
- arguments[flag] = filt
46
- arguments["_"] = vcf
47
- arguments["o"] = tmpdir / f"{stem}.{fname}{ext}"
48
- if keep:
49
- arguments["s"] = fname
50
-
51
- run_command(dict_to_cli_args(arguments, dashify=True), fg=True)
52
- return arguments["o"]
53
-
54
-
55
- def normalize_expr(expr, flag):
56
- out = {}
57
- if not expr:
58
- return out
59
- if isinstance(expr, list):
60
- for ex in expr:
61
- out[f"FILTER{FILTER_INDEX[0]}"] = (ex, flag)
62
- FILTER_INDEX[0] += 1
63
- elif isinstance(expr, dict):
64
- for name, ex in expr.items():
65
- out[name] = (ex, flag)
66
- else: # str
67
- out[f"FILTER{FILTER_INDEX[0]}"] = (expr, flag)
68
- FILTER_INDEX[0] += 1
69
- return out
70
-
71
- includes = normalize_expr(includes, "include")
72
- excludes = normalize_expr(excludes, "exclude")
73
- includes.update(excludes)
74
-
75
- # bcftools can be only done once at one filter
76
- for fname, (filt, flag) in includes.items():
77
- infile = handle_filter(infile, fname, filt, flag)
78
-
79
- shutil.copy2(infile, outfile)
@@ -1,19 +0,0 @@
1
- from biopipen.utils.misc import run_command, dict_to_cli_args
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[""] = bcftools
12
- args["_"] = infile
13
- args["o"] = outfile
14
- args["O"] = "z" if gz or index else "v"
15
-
16
- run_command(dict_to_cli_args(args, dashify=True), fg=True)
17
-
18
- if index:
19
- run_command([bcftools, "index", outfile], fg=True)
@@ -1,66 +0,0 @@
1
- import pandas
2
- from datar.all import c, right_join, select, relocate
3
- from biopipen.utils.gene import gene_name_conversion
4
-
5
- infile = {{in.infile | quote}} # pyright: ignore
6
- outfile = {{out.outfile | quote}} # pyright: ignore
7
- inopts = {{envs.inopts | repr}} # pyright: ignore
8
- outopts = {{envs.outopts | repr}} # pyright: ignore
9
- notfound = {{envs.notfound | repr}} # pyright: ignore
10
- genecol = {{envs.genecol | repr}} # pyright: ignore
11
- output = {{envs.output | repr}} # pyright: ignore
12
- infmt = {{envs.infmt | repr}} # pyright: ignore
13
- outfmt = {{envs.outfmt | repr}} # pyright: ignore
14
- species = {{envs.species | quote}} # pyright: ignore
15
-
16
- df = pandas.read_csv(infile, **inopts)
17
-
18
- if isinstance(genecol, int):
19
- genes = df.iloc[:, genecol]
20
- else:
21
- genes = df.loc[:, genecol]
22
-
23
- colname = genes.name
24
- genes = genes.tolist()
25
-
26
- # query `outfmt`
27
- # <object> <object>
28
- # 0 1255_g_at GUCA1A
29
- # 1 1316_at THRA
30
- # 2 1320_at PTPN21
31
- # 3 1294_at MIR5193
32
- converted = gene_name_conversion(
33
- genes=genes,
34
- species=species,
35
- infmt=infmt,
36
- outfmt=outfmt,
37
- notfound=notfound,
38
- )
39
- converted.columns = [colname] + converted.columns[1:].tolist()
40
-
41
- if output == "only":
42
- out = converted
43
-
44
- elif output == "keep":
45
- out = df >> right_join(converted, by=colname, suffix=["", "_converted"])
46
-
47
- elif output == "drop":
48
- out = df >> right_join(
49
- converted,
50
- by=colname, suffix=["", "_converted"]
51
- ) >> select(~c(colname))
52
-
53
- elif output == "replace":
54
- out = df >> right_join(
55
- converted, by=colname, suffix=["", "_converted"]
56
- )
57
- converted_cols = out.columns[-len(converted.columns)+1:].tolist()
58
- pos = df.columns.get_indexer([colname])[0]
59
- out = out >> relocate(
60
- converted_cols, _after=pos+1
61
- ) >> select(~c(colname))
62
-
63
- else:
64
- raise ValueError(f"Unknown output mode: {output}.")
65
-
66
- out.to_csv(outfile, **outopts)
@@ -1,32 +0,0 @@
1
- source("{{biopipen_dir}}/utils/misc.R")
2
-
3
- library(SeuratWrappers)
4
- library(Seurat)
5
-
6
- infile = {{in.infile | r}}
7
- outfile = {{out.outfile | r}}
8
- envs = {{envs.alra_args | r}}
9
-
10
- print("Loading Seurat object")
11
- sobj = readRDS(infile)
12
- DefaultAssay(sobj) <- "RNA"
13
-
14
- print("Imputing expression values, using ALRA")
15
- envs$object = sobj
16
- sobj = do_call(RunALRA, envs)
17
-
18
- # sobj = RunALRA(sobj)
19
- print("Renaming assays")
20
- sobj = RenameAssays(sobj, RNA = "UNIMPUTED_RNA")
21
- sobj = RenameAssays(sobj, alra = "RNA")
22
- DefaultAssay(sobj) <- "RNA"
23
-
24
- attr(sobj, "impute") = "alra"
25
- print("Saving Seurat object")
26
- saveRDS(sobj, outfile)
27
-
28
- # choosek_plot_file = file.path(dirname(outfile), "choosek.png")
29
- # png(choosek_plot_file, width = 1200, height = 1000, res = 100)
30
- # p = ALRAChooseKPlot(sobj)
31
- # print(p)
32
- # dev.off()
@@ -1,29 +0,0 @@
1
-
2
- tryCatch({
3
- # in order to load Rmagic
4
- workdir = {{job.outdir | r}}
5
- conda_prefix = Sys.getenv("CONDA_PREFIX")
6
- setwd(workdir)
7
- file.symlink(conda_prefix, "miniconda3")
8
- }, error=function(e) {})
9
-
10
- python = {{envs.rmagic_args.python | r}}
11
- Sys.setenv(RETICULATE_PYTHON = Sys.which(python))
12
- # reticulate::use_python(python)
13
-
14
- library(Rmagic)
15
- library(Seurat)
16
-
17
- infile = {{in.infile | r}}
18
- outfile = {{out.outfile | r}}
19
-
20
- sobj = readRDS(infile)
21
- DefaultAssay(sobj) <- "RNA"
22
-
23
- sobj = magic(sobj)
24
- sobj = RenameAssays(sobj, RNA = "UNIMPUTED_RNA", MAGIC_RNA = "RNA")
25
-
26
- DefaultAssay(sobj) <- "RNA"
27
-
28
- attr(sobj, "impute") = "rmagic"
29
- saveRDS(sobj, outfile)
@@ -1,7 +0,0 @@
1
- {% if envs.tool == "rmagic" %}
2
- {% include biopipen_dir + "/scripts/scrna/ExprImpution-rmagic.R" %}
3
- {% elif envs.tool == "scimpute" %}
4
- {% include biopipen_dir + "/scripts/scrna/ExprImpution-scimpute.R" %}
5
- {% elif envs.tool == "alra" %}
6
- {% include biopipen_dir + "/scripts/scrna/ExprImpution-alra.R" %}
7
- {% endif %}
@@ -1,132 +0,0 @@
1
- source("{{biopipen_dir}}/utils/io.R")
2
- source("{{biopipen_dir}}/utils/misc.R")
3
- source("{{biopipen_dir}}/utils/plot.R")
4
- library(Seurat)
5
- library(dplyr)
6
- library(tidyr)
7
- library(tibble)
8
- library(rlang)
9
- library(ggplot2)
10
- library(ggprism)
11
- library(ComplexHeatmap)
12
-
13
- srtobjfile = {{in.srtobj | quote}}
14
- genefile = {{in.genefile | r}}
15
- outdir = {{out.outdir | quote}}
16
- gopts = {{envs.gopts | r}}
17
- {% if in.configfile %}
18
- config = {{in.configfile | toml_load | r}}
19
- {% set config = in.configfile | toml_load %}
20
- {% else %}
21
- config = {{envs.config | r}}
22
- {% set config = envs.config %}
23
- {% endif %}
24
-
25
- sobj = readRDS(srtobjfile)
26
- genes = read.table.opts(genefile, gopts)
27
- if (ncol(genes) == 1) {
28
- genes$.Name = genes[[1]]
29
- }
30
- colnames(genes) = c("Gene", "Name")
31
-
32
- if (!is.null(config$mutaters)) {
33
- expressions = list()
34
- for (key in names(config$mutaters)) {
35
- expressions[[key]] = parse_expr(config$mutaters[[key]])
36
- }
37
- sobj@meta.data = mutate(sobj@meta.data, !!!expressions)
38
- }
39
-
40
- if (!is.null(config$subset)) {
41
- sobj = subset(sobj, subset = {{config.subset}})
42
- }
43
-
44
- DefaultAssay(sobj) <- "RNA"
45
- sobj = NormalizeData(sobj)
46
-
47
- exprs = as.data.frame(
48
- GetAssayData(sobj, slot = "data", assay = "RNA")
49
- )[genes$Gene,,drop=F]
50
- rownames(exprs) = genes$Name
51
- exprs = rownames_to_column(exprs, "Gene")
52
-
53
- plot_heatmap = function(plotconf, outfile) {
54
- plotdata = exprs %>%
55
- pivot_longer(
56
- names(exprs)[2:ncol(exprs)],
57
- names_to = "Barcode",
58
- values_to = "Log_Expression"
59
- )
60
- metadata = sobj@meta.data[plotdata$Barcode,,drop=F]
61
- plotdata = cbind(plotdata, metadata)
62
- plotdata = plotdata %>%
63
- group_by(Gene, !!sym(config$groupby)) %>%
64
- summarise(Log_Expression = mean(Log_Expression)) %>%
65
- pivot_wider(names_from = config$groupby, values_from = "Log_Expression") %>%
66
- column_to_rownames("Gene")
67
-
68
- given_genes = rownames(plotdata)
69
- plotdata = plotdata[complete.cases(plotdata),,drop=FALSE]
70
- invalid_genes = setdiff(given_genes, rownames(plotdata))
71
- if (length(invalid_genes) > 0) {
72
- warning(
73
- paste(
74
- "The following genes were not found in the data:",
75
- invalid_genes
76
- )
77
- )
78
- }
79
-
80
- devpars = list(res=plotconf$res, width=plotconf$width, height=plotconf$height)
81
- plotconf$res = NULL
82
- plotconf$width = NULL
83
- plotconf$height = NULL
84
-
85
- for (name in names(plotconf)) {
86
- plotconf[[name]] = parse_expr(plotconf[[name]])
87
- }
88
-
89
- plotHeatmap(
90
- plotdata,
91
- plotconf,
92
- devpars = devpars,
93
- outfile = outfile
94
- )
95
- }
96
-
97
- plot_boxplot = function(plotconf, outfile) {
98
- plotdata = exprs %>%
99
- pivot_longer(
100
- names(exprs)[2:ncol(exprs)],
101
- names_to = "Barcode",
102
- values_to = "Log_Expression"
103
- )
104
- metadata = sobj@meta.data[plotdata$Barcode,,drop=F]
105
- plotdata = cbind(plotdata, metadata)
106
-
107
- cols = if (is.null(plotconf$ncol)) 3 else plotconf$ncol
108
- p = ggplot(plotdata) +
109
- geom_boxplot(aes_string(x=config$groupby, y="Log_Expression", fill=config$groupby)) +
110
- facet_wrap(~Gene, ncol=cols) +
111
- theme_prism(axis_text_angle = 90) + theme(legend.position = "none") +
112
- xlab("")
113
-
114
- devpars = list(filename = outfile, res = plotconf$res, width = plotconf$width, height = plotconf$height)
115
- do_call(png, devpars)
116
- print(p)
117
- dev.off()
118
- }
119
-
120
-
121
- for (plottype in names(config$plots)) {
122
- plotconf = config$plots[[plottype]]
123
- if (plottype == "heatmap") {
124
- plotfile = file.path(outdir, "heatmap.png")
125
- plot_heatmap(plotconf, plotfile)
126
- } else if (plottype == "boxplot") {
127
- plotfile = file.path(outdir, "boxplot.png")
128
- plot_boxplot(plotconf, plotfile)
129
- } else {
130
- stop(paste("Unknown plot type:", plottype))
131
- }
132
- }
@@ -1,11 +0,0 @@
1
- library(DropletUtils)
2
- library(Seurat)
3
-
4
- srtobjfile = {{in.srtobj | r}}
5
- outdir = {{out.outdir | r}}
6
- version = {{envs.version | r}}
7
-
8
- srtobj = readRDS(srtobjfile)
9
- counts = GetAssayData(object = srtobj, slot = "counts")
10
-
11
- write10xCounts(outdir, counts, version = version, overwrite = TRUE)