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,60 +1,33 @@
1
- # Diversity estimation
1
+
2
2
  # https://immunarch.com/articles/web_only/v6_diversity.html
3
3
 
4
- # Other variables are loaded in the parent template
5
- # immdata is already loaded, meta is mutated
6
- div_method = {{envs.divs.method | r}}
7
- div_by = {{envs.divs.by | r}}
8
- div_order = {{envs.divs.order | r}}
9
- div_args = {{envs.divs.args | r: todot="-"}}
10
- div_test = {{envs.divs.test | r}}
11
- div_cases = {{envs.divs.cases | r: todot="-"}}
12
- div_devpars = {{envs.divs.devpars | r}}
13
- div_separate_by = {{envs.divs.separate_by | r}}
14
- div_align_x = {{envs.divs.align_x | r}}
15
- div_align_y = {{envs.divs.align_y | r}}
16
- div_subset = {{envs.divs.subset | r}}
17
- div_log = {{envs.divs.log | r}}
18
- div_ncol = {{envs.divs.ncol | r}}
19
- div_ymin = {{envs.divs.ymin | r}}
20
- div_ymax = {{envs.divs.ymax | r}}
4
+ log_info("")
5
+ log_info("# Diversity estimation")
6
+ log_info("-----------------------------------")
7
+
8
+ div_test = div_test %||% list(method = "none", padjust = "none")
9
+ div_devpars = div_devpars %||% list(res = 100, width = 800, height = 800)
21
10
 
22
11
  div_dir = file.path(outdir, "diversity")
23
12
  dir.create(div_dir, showWarnings = FALSE)
24
13
 
25
- print("- Diversity estimation ...")
26
-
27
14
  # Fill up the cases
28
- update_case = function(case) {
29
- if (is.null(case$subset)) {
30
- case$subset = div_subset
31
- }
32
- if (is.null(case$method)) {
33
- case$method = div_method
34
- }
35
- if (is.null(case$by)) {
36
- case$by = div_by
37
- }
15
+ update_case = function(case, name) {
16
+ log_debug("Filling up case: {name} ...")
17
+ case$subset <- case$subset %||% div_subset
18
+ case$method <- case$method %||% div_method
19
+ case$by <- case$by %||% div_by
38
20
  if (!is.null(case$by) && nchar(case$by) > 0) {
39
21
  case$by = unlist(strsplit(case$by, ",")) %>% trimws()
40
22
  }
41
- if (is.null(case$order)) {
42
- case$order = div_order
43
- }
44
- if (is.null(case$args)) {
45
- case$args = div_args
46
- }
23
+ case$plot_type <- case$plot_type %||% div_plot_type
24
+ case$order <- case$order %||% div_order
25
+ case$args <- case$args %||% div_args
47
26
  for (name in names(case$args)) {
48
- if (is.null(case$args[[name]])) {
49
- case$args[[name]] = div_args[[name]]
50
- }
51
- }
52
- if (is.null(case$test)) {
53
- case$test = div_test
54
- }
55
- if (is.null(case$test$method)) {
56
- case$test$method = div_test$method
27
+ case$args[[name]] = case$args[[name]] %||% div_args[[name]]
57
28
  }
29
+ case$test <- case$test %||% div_test
30
+ case$test$method <- case$test$method %||% div_test$method
58
31
  if (!case$test$method %in% c("none", "t.test", "wilcox.test")) {
59
32
  stop(paste0(
60
33
  "Diversity estimation: Unknown test method: ",
@@ -62,46 +35,27 @@ update_case = function(case) {
62
35
  ". Expected: t.test, wilcox.test"
63
36
  ))
64
37
  }
65
- if (is.null(case$test$padjust)) {
66
- case$test$group = div_test$padjust
67
- }
68
- if (is.null(case$devpars)) {
69
- case$devpars = div_devpars
70
- }
71
- if (is.null(case$devpars$res)) {
72
- case$devpars$res = div_devpars$res
73
- }
74
- if (is.null(case$devpars$width)) {
75
- case$devpars$width = div_devpars$width
76
- }
77
- if (is.null(case$devpars$height)) {
78
- case$devpars$height = div_devpars$height
79
- }
80
- if (is.null(case$separate_by)) {
81
- case$separate_by = div_separate_by
82
- }
83
- if (is.null(case$align_x)) {
84
- case$align_x = div_align_x
85
- }
86
- if (is.null(case$align_y)) {
87
- case$align_y = div_align_y
88
- }
89
- if (is.null(case$log)) {
90
- case$log = div_log
91
- }
92
- if (is.null(case$ncol)) {
93
- case$ncol = div_ncol
94
- }
95
- if (is.null(case$ymin)) {
96
- case$ymin = div_ymin
97
- }
98
- if (is.null(case$ymax)) {
99
- case$ymax = div_ymax
100
- }
38
+ case$test$padjust <- case$test$padjust %||% div_test$padjust
39
+ case$devpars <- case$devpars %||% div_devpars
40
+ case$devpars$res <- case$devpars$res %||% div_devpars$res
41
+ case$devpars$width <- case$devpars$width %||% div_devpars$width
42
+ case$devpars$height <- case$devpars$height %||% div_devpars$height
43
+ case$separate_by <- case$separate_by %||% div_separate_by
44
+ case$split_by <- case$split_by %||% div_split_by
45
+ case$split_order <- case$split_order %||% div_split_order
46
+ if (!is.null(case$separate_by) && !is.null(case$split_by)) {
47
+ stop("Diversity estimation: `separate_by` and `split_by` cannot be specified at the same time")
48
+ }
49
+ case$align_x <- case$align_x %||% div_align_x
50
+ case$align_y <- case$align_y %||% div_align_y
51
+ case$log <- case$log %||% div_log
52
+ case$ncol <- case$ncol %||% div_ncol
53
+ case$ymin <- case$ymin %||% div_ymin
54
+ case$ymax <- case$ymax %||% div_ymax
101
55
  if (!is.null(case$args) && length(case$args) > 0) {
102
56
  names(case$args) = paste0(".", names(case$args))
103
57
  }
104
- if (!is.null(case$test) && case$test != "none" && (is.null(case$by) || length(case$by) == 0)) {
58
+ if (!is.null(case$test) && case$test$method != "none" && (is.null(case$by) || length(case$by) == 0)) {
105
59
  stop("For diversity estimation, `test` is only supported when `by` is specified")
106
60
  }
107
61
  # Just ignore them for rarefraction
@@ -114,33 +68,16 @@ update_case = function(case) {
114
68
  return (case)
115
69
  }
116
70
 
117
- # See https://github.com/immunomind/immunarch/pull/341
118
- vis.immunr_gini <- function(.data, .by = NA, .meta = NA,
119
- .errorbars = c(0.025, 0.975), .errorbars.off = FALSE,
120
- .points = TRUE, .test = TRUE, .signif.label.size = 3.5, ...) {
121
- # repDiversity(..., .method = "gini") generates a matrix
122
- .data = data.frame(Sample = rownames(.data), Value = .data[, 1])
123
- vis_bar(
124
- .data = .data, .by = .by, .meta = .meta,
125
- .errorbars = .errorbars, .errorbars.off = .errorbars.off, .stack = FALSE,
126
- .points = .points, .test = .test, .signif.label.size = .signif.label.size,
127
- .defgroupby = "Sample", .grouping.var = "Group",
128
- .labs = c(NA, "Gini coefficient"),
129
- .title = "Gini coefficient", .subtitle = "Sample diversity estimation using the Gini coefficient",
130
- .legend = NA, .leg.title = NA
131
- )
132
- }
133
-
134
71
  if (is.null(div_cases) || length(div_cases) == 0) {
135
72
  if (is.null(div_method) || length(div_method) == 0 || nchar(div_method) == 0) {
136
73
  stop("No method is specified for diversity estimation")
137
74
  }
138
- default_case = update_case(list())
75
+ default_case = update_case(list(), name = "DEFAULT")
139
76
  div_cases = list(x = default_case)
140
77
  names(div_cases) = div_method
141
78
  } else {
142
79
  for (name in names(div_cases)) {
143
- div_cases[[name]] = update_case(div_cases[[name]])
80
+ div_cases[[name]] = update_case(div_cases[[name]], name = name)
144
81
  }
145
82
  }
146
83
 
@@ -161,7 +98,7 @@ filter_div = function(div, samples) {
161
98
  # case: the case with argument to be run
162
99
  # ddir: the directory to save the results
163
100
  # value_col: the column name of the value
164
- run_general = function(d, case, ddir, value_col = "Value") {
101
+ run_general = function(casename, d, case, ddir, value_col = "Value") {
165
102
  args = case$args
166
103
  args$.data = d$data
167
104
  args$.method = case$method
@@ -188,6 +125,14 @@ run_general = function(d, case, ddir, value_col = "Value") {
188
125
  )
189
126
  }
190
127
 
128
+ if (!is.null(case$split_by)) {
129
+ newdiv = newdiv %>% left_join(
130
+ d$meta[, c("Sample", case$split_by), drop = FALSE],
131
+ by = "Sample",
132
+ suffix = c(".div", "")
133
+ )
134
+ }
135
+
191
136
  write.table(
192
137
  newdiv,
193
138
  file = file.path(ddir, "diversity.txt"),
@@ -197,18 +142,41 @@ run_general = function(d, case, ddir, value_col = "Value") {
197
142
  col.names = TRUE
198
143
  )
199
144
 
145
+ .meta_vals <- function(meta, cols) {
146
+ if (length(cols) == 1) {
147
+ return (meta[[cols]])
148
+ }
149
+
150
+ vlist = lapply(cols, function(.x) meta[[.x]])
151
+ do.call(function(...) paste(..., sep = "; "), vlist)
152
+ }
153
+
200
154
  # plot
201
155
  # by, order, separate_by, align_y
202
156
  n_seps = 1
203
157
  if (!is.null(case$by) && length(case$by) > 0) {
204
158
  if (!is.null(case$separate_by)) {
205
159
  metas = split(d$meta, d$meta[[case$separate_by]])
160
+ if (!is.null(case$split_order)) {
161
+ if (is.character(case$split_order) && length(case$split_order) == 1) {
162
+ case$split_order = trimws(unlist(strsplit(case$split_order, ",")))
163
+ }
164
+ metas = metas[intersect(case$split_order, names(metas))]
165
+ }
206
166
  ps = lapply(metas, function(meta) {
207
- .test = length(unique(meta[[case$by]])) > 1
208
- p = vis(filter_div(div, meta$Sample), .by = case$by, .meta = meta, .test = .test)
209
- p = p + ggtitle(paste0(p$labels$title, " (" , case$separate_by, ": ", meta[[case$separate_by]][1], ")"))
167
+ .test = length(unique(.meta_vals(meta, case$by))) > 1
168
+ p = vis(
169
+ filter_div(div, meta$Sample),
170
+ .by = case$by,
171
+ .meta = meta,
172
+ .test = .test,
173
+ .plot.type = case$plot_type
174
+ )
175
+ p = p + xlab(paste0(case$separate_by, ": ", meta[[case$separate_by]][1], ")"))
210
176
  if (!is.null(case$order) && length(case$order) > 0) {
211
- p = p + scale_x_discrete(limits = intersect(case$order, unique(meta[[case$by]])))
177
+ p = p + scale_x_discrete(
178
+ limits = intersect(case$order, unique(.meta_vals(meta, case$by)))
179
+ )
212
180
  }
213
181
  if (!is.null(case$ymin) && !is.null(case$ymax)) {
214
182
  p = p + ylim(c(case$ymin, case$ymax))
@@ -222,20 +190,79 @@ run_general = function(d, case, ddir, value_col = "Value") {
222
190
  })
223
191
  n_seps = length(ps)
224
192
  p = wrap_plots(ps, ncol = case$ncol)
193
+ } else if (!is.null(case$split_by)) {
194
+ metas = split(d$meta, d$meta[[case$split_by]])
195
+ if (!is.null(case$split_order)) {
196
+ if (is.character(case$split_order) && length(case$split_order) == 1) {
197
+ case$split_order = trimws(unlist(strsplit(case$split_order, ",")))
198
+ }
199
+ metas = metas[intersect(case$split_order, names(metas))]
200
+ }
201
+ .i = 0
202
+ ps = lapply(metas, function(meta) {
203
+ nby = length(unique(.meta_vals(meta, case$by)))
204
+ p = vis(
205
+ filter_div(div, meta$Sample),
206
+ .by = case$by,
207
+ .meta = meta,
208
+ .test = nby > 1,
209
+ .plot.type = case$plot_type
210
+ )
211
+ if (!is.null(case$order) && length(case$order) > 0) {
212
+ p = p + scale_x_discrete(
213
+ limits = intersect(case$order, unique(.meta_vals(meta, case$by)))
214
+ )
215
+ }
216
+ p = p + xlab(meta[[case$split_by]][1]) + theme(
217
+ axis.text.x = element_blank(),
218
+ plot.title = element_blank(),
219
+ plot.subtitle = element_blank(),
220
+ legend.position = "right"
221
+ )
222
+ if (.i > 0) {
223
+ p = p + theme(
224
+ axis.text.y = element_blank(),
225
+ axis.title.y = element_blank(),
226
+ axis.ticks.y = element_blank(),
227
+ axis.line.y = element_blank()
228
+ )
229
+ }
230
+ .i <<- .i + 1
231
+ list(
232
+ p = p,
233
+ ymin = case$ymin %||% min(newdiv[[value_col]]),
234
+ ymax = case$ymax %||% max(newdiv[[value_col]]),
235
+ nby = nby
236
+ )
237
+ })
238
+ n_seps = length(ps)
239
+ ymin = do.call(min, lapply(ps, function(x) x$ymin))
240
+ ymin = max(0, ymin - 0.1)
241
+ ymax = do.call(max, lapply(ps, function(x) x$ymax))
242
+ ymax = ymax + 0.3 * (ymax - ymin) # for the pvalue marks
243
+ widths = sapply(ps, function(x) ifelse(x$nby == 1, 1.2, x$nby))
244
+ plots = lapply(ps, function(x) x$p + ylim(c(ymin, ymax)))
245
+ p = wrap_plots(plots, widths = widths, guides = "collect")
225
246
  } else {
226
- .test = length(unique(d$meta[[case$by]])) > 1
227
- p = vis(div, .by = case$by, .meta = d$meta, .test = .test)
247
+ .test = length(unique(.meta_vals(d$meta, case$by))) > 1
248
+ p = vis(div, .by = case$by, .meta = d$meta, .test = .test, .plot.type = case$plot_type)
228
249
  if (!is.null(case$order) && length(case$order) > 0) {
229
- p = p + scale_x_discrete(limits = intersect(case$order, unique(d$meta[[case$by]])))
250
+ p = p + scale_x_discrete(limits = intersect(case$order, unique(.meta_vals(d$meta, case$by))))
230
251
  }
231
252
  }
232
253
  } else if (!is.null(case$separate_by)) {
233
254
  metas = split(d$meta, d$meta[[case$separate_by]])
255
+ if (!is.null(case$split_order)) {
256
+ if (is.character(case$split_order) && length(case$split_order) == 1) {
257
+ case$split_order = trimws(unlist(strsplit(case$split_order, ",")))
258
+ }
259
+ metas = metas[intersect(case$split_order, names(metas))]
260
+ }
234
261
  ps = lapply(metas, function(meta) {
235
262
  p = vis(filter_div(div, meta$Sample))
236
263
  p = p + ggtitle(paste0(p$labels$title, " (" , case$separate_by, ": ", meta[[case$separate_by]][1], ")"))
237
264
  if (!is.null(case$order) && length(case$order) > 0) {
238
- p = p + scale_x_discrete(limits = intersect(case$order, unique(meta[[case$by]])))
265
+ p = p + scale_x_discrete(limits = intersect(case$order, unique(meta[[Sample]])))
239
266
  }
240
267
  if (!is.null(case$ymin) && !is.null(case$ymax)) {
241
268
  p = p + ylim(c(case$ymin, case$ymax))
@@ -249,10 +276,57 @@ run_general = function(d, case, ddir, value_col = "Value") {
249
276
  })
250
277
  n_seps = length(ps)
251
278
  p = wrap_plots(ps, ncol = case$ncol)
279
+ } else if (!is.null(case$split_by)) {
280
+ metas = split(d$meta, d$meta[[case$split_by]])
281
+ if (!is.null(case$split_order)) {
282
+ if (is.character(case$split_order) && length(case$split_order) == 1) {
283
+ case$split_order = trimws(unlist(strsplit(case$split_order, ",")))
284
+ }
285
+ metas = metas[intersect(case$split_order, names(metas))]
286
+ }
287
+ .i = 0
288
+ ps = lapply(metas, function(meta) {
289
+ nby = length(unique(meta$Sample))
290
+ p = vis(filter_div(div, meta$Sample))
291
+ if (!is.null(case$order) && length(case$order) > 0) {
292
+ p = p + scale_x_discrete(limits = intersect(case$order, unique(meta[[Sample]])))
293
+ }
294
+ p = p + xlab(meta[[case$split_by]][1]) + theme(
295
+ axis.text.x = element_blank(),
296
+ plot.title = element_blank(),
297
+ plot.subtitle = element_blank(),
298
+ legend.position = "right"
299
+ )
300
+ if (.i > 0) {
301
+ p = p + theme(
302
+ axis.text.y = element_blank(),
303
+ axis.title.y = element_blank(),
304
+ axis.ticks.y = element_blank(),
305
+ axis.line.y = element_blank()
306
+ )
307
+ }
308
+ .i <<- .i + 1
309
+ list(
310
+ p = p,
311
+ ymin = case$ymin %||% min(newdiv[[value_col]]),
312
+ ymax = case$ymax %||% max(newdiv[[value_col]]) + 0.1 * max(newdiv[[value_col]]),
313
+ nby = nby
314
+ )
315
+ })
316
+ n_seps = length(ps)
317
+ ymin = do.call(min, lapply(ps, function(x) x$ymin))
318
+ ymin = max(0, ymin - 0.1)
319
+ ymax = do.call(max, lapply(ps, function(x) x$ymax))
320
+ ymax = ymax + 0.3 * (ymax - ymin) # for the pvalue marks
321
+ widths = sapply(ps, function(x) ifelse(x$nby == 1, 1.2, x$nby))
322
+ plots = lapply(ps, function(x) x$p + ylim(c(ymin, ymax)))
323
+ p = wrap_plots(plots, widths = widths, guides = "collect")
252
324
  } else {
253
325
  p = vis(div)
254
326
  if (!is.null(case$order) && length(case$order) > 0) {
255
- p = p + scale_x_discrete(limits = intersect(case$order, unique(d$meta[[case$by]])))
327
+ p = p + scale_x_discrete(
328
+ limits = intersect(case$order, unique(.meta_vals(d$meta, case$by)))
329
+ )
256
330
  }
257
331
  }
258
332
 
@@ -260,24 +334,97 @@ run_general = function(d, case, ddir, value_col = "Value") {
260
334
  width = case$devpars$width
261
335
  height = case$devpars$height
262
336
  res = case$devpars$res
263
- if (is.null(res)) { res = 100 }
337
+ res = res %||% 100
264
338
  if (is.null(height)) {
265
- height = if (n_seps == 1) 800 else 600 * ceiling(n_seps / case$ncol)
339
+ if (!is.nulL(case$split_by)) {
340
+ height = 800
341
+ } else {
342
+ height = if (n_seps == 1) 800 else 600 * ceiling(n_seps / case$ncol)
343
+ }
266
344
  }
267
345
  if (is.null(width)) {
268
346
  if (!is.null(case$by) && length(case$by) > 0) {
269
- width = 200 * length(unique(d$meta[[case$by]])) + 120
347
+ width = 200 * length(unique(.meta_vals(d$meta, case$by))) + 120
270
348
  } else {
271
349
  width = 100 * length(unique(d$meta$Sample)) + 120
272
350
  }
351
+ if (!is.null(case$split_by)) { width = width / 2 }
273
352
  if (n_seps > 1) {
274
353
  width = width * case$ncol
275
354
  }
276
355
  }
277
- png(file.path(ddir, "diversity.png"), width = width, height = height, res = res)
356
+
357
+ div_plot = file.path(ddir, "diversity.png")
358
+ png(div_plot, width = width, height = height, res = res)
278
359
  print(p)
279
360
  dev.off()
280
361
 
362
+ div_plot_pdf = file.path(ddir, "diversity.pdf")
363
+ pdf(div_plot_pdf, width = width / res, height = height / res)
364
+ print(p)
365
+ dev.off()
366
+
367
+ add_report(
368
+ list(
369
+ kind = "descr",
370
+ content = paste0(
371
+ "Diversity estimation using ",
372
+ "<code>",
373
+ case$method,
374
+ "</code>: ",
375
+ switch(case$method,
376
+ chao1 = paste0(
377
+ "a nonparameteric asymptotic estimator of species richness ",
378
+ "(number of species in a population)."),
379
+ hill = paste0(
380
+ "Hill numbers are a mathematically unified family of ",
381
+ "diversity indices (differing only by an exponent q)."),
382
+ div = paste0(
383
+ "true diversity, or the effective number of types, ",
384
+ "refers to the number of equally abundant types needed for ",
385
+ "the average proportional abundance of the types to equal that ",
386
+ "observed in the dataset of interest where all types may ",
387
+ "not be equally abundant."),
388
+ gini.simp = paste0(
389
+ "the Gini-Simpson index is the probability of interspecific ",
390
+ "encounter, i.e., probability that two entities represent different types."),
391
+ inv.simp = paste0(
392
+ "Inverse Simpson index is the effective number of types ",
393
+ "that is obtained when the weighted arithmetic mean is used ",
394
+ "to quantify average proportional abundance of types in ",
395
+ "the dataset of interest."),
396
+ gini = paste0(
397
+ "the Gini coefficient measures the inequality among ",
398
+ "values of a frequency distribution (for example levels of income). ",
399
+ "A Gini coefficient of zero expresses perfect equality, ",
400
+ "where all values are the same (for example, where everyone has ",
401
+ "the same income). A Gini coefficient of one (or 100 percents ) ",
402
+ "expresses maximal inequality among values (for example where only ",
403
+ "one person has all the income)."),
404
+ d50 = paste0(
405
+ "the D50 index. ",
406
+ "It is the number of types that are needed to cover 50% of the total
407
+ abundance.")
408
+ )
409
+ )
410
+ ),
411
+ h1 = "Diversity Estimation",
412
+ h2 = casename
413
+ )
414
+ add_report(
415
+ list(
416
+ name = "Diversity Plot",
417
+ contents = list(list(kind = "image", src = div_plot, download = div_plot_pdf))
418
+ ),
419
+ list(
420
+ name = "Diversity Table",
421
+ contents = list(list(kind = "table", src = file.path(ddir, "diversity.txt")))
422
+ ),
423
+ h1 = "Diversity Estimation",
424
+ h2 = casename,
425
+ ui = "tabs"
426
+ )
427
+
281
428
  # Test
282
429
  if (!is.null(case$test) && case$test$method != "none") {
283
430
  # Use pairwise.t.test or pairwise.wilcox.test
@@ -340,6 +487,19 @@ run_general = function(d, case, ddir, value_col = "Value") {
340
487
  row.names = FALSE,
341
488
  col.names = TRUE
342
489
  )
490
+
491
+ add_report(
492
+ list(
493
+ name = paste0("Test (", case$test$method, ")"),
494
+ contents = list(list(
495
+ kind = "table",
496
+ src = file.path(ddir, paste0("diversity.test.", case$test$method, ".txt"))
497
+ ))
498
+ ),
499
+ h1 = "Diversity Estimation",
500
+ h2 = casename,
501
+ ui = "tabs"
502
+ )
343
503
  }
344
504
  }
345
505
 
@@ -406,6 +566,10 @@ run_raref_single = function(d, case, ddir, suffix = "", save_p = TRUE) {
406
566
  png(file.path(ddir, "raref.png"), width = devpars$width, height = devpars$height, res = devpars$res)
407
567
  print(p)
408
568
  dev.off()
569
+
570
+ pdf(file.path(ddir, "raref.pdf"), width = devpars$width / devpars$res, height = devpars$height / devpars$res)
571
+ print(p)
572
+ dev.off()
409
573
  } else {
410
574
  return (list(p = p, width = devpars$width))
411
575
  }
@@ -421,7 +585,8 @@ run_raref_multi = function(d, case, ddir) {
421
585
  widths = list()
422
586
  plots = list()
423
587
  for (sepvar in sepvars) {
424
- print(paste0(" ", case$separate_by, ": ", sepvar))
588
+ # print(paste0(" ", case$separate_by, ": ", sepvar))
589
+ log_info(" {case$separate_by}: {sepvar}")
425
590
  q = list(include(sepvar))
426
591
  names(q) = case$separate_by
427
592
  single_run = run_raref_single(
@@ -466,50 +631,103 @@ run_raref_multi = function(d, case, ddir) {
466
631
  } else {
467
632
  height = case$devpars$height
468
633
  }
469
- png(file.path(ddir, paste0("raref-", case$separate_by, ".png")), width = width, height = height, res = res)
634
+ png(
635
+ file.path(ddir, paste0("raref-", slugify(case$separate_by), ".png")),
636
+ width = width,
637
+ height = height,
638
+ res = res
639
+ )
640
+ print(p)
641
+ dev.off()
642
+
643
+ pdf(
644
+ file.path(ddir, paste0("raref-", slugify(case$separate_by), ".pdf")),
645
+ width = width / res,
646
+ height = height / res
647
+ )
470
648
  print(p)
471
649
  dev.off()
472
650
  }
473
651
 
474
652
  # Run the diversity estimation for one case
475
653
  run_div_case = function(casename) {
476
- print(paste0(" Case: ", casename))
654
+ log_info("Processing case: {casename} ...")
477
655
  case = div_cases[[casename]]
478
656
  if (case$method == "raref") {
479
- ddir = file.path(outdir, "rarefraction", casename)
657
+ ddir = file.path(outdir, "rarefraction", slugify(casename))
480
658
  } else {
481
- ddir = file.path(div_dir, casename)
659
+ ddir = file.path(div_dir, slugify(casename))
482
660
  }
483
661
  dir.create(ddir, recursive = TRUE, showWarnings = FALSE)
484
662
 
485
663
  # Filter
486
664
  if (!is.null(case$subset)) {
487
665
  d = immdata_from_expanded(filter_expanded_immdata(exdata, case$subset))
666
+ if (nrow(d$meta) == 0) {
667
+ stop(paste0(
668
+ "No samples/cells left after filtering. ",
669
+ "Do you have the correct `subset` for case: ",
670
+ casename, "?"))
671
+ }
488
672
  } else {
489
673
  d = immdata
490
674
  }
491
675
 
492
676
  # Run repDiversity
493
- if (case$method == "chao1") {
494
- run_general(d, case, ddir, "Estimator")
495
- } else if (case$method == "hill") {
496
- run_general(d, case, ddir)
497
- } else if (case$method == "div") {
498
- run_general(d, case, ddir)
499
- } else if (case$method == "gini.simp") {
500
- run_general(d, case, ddir)
501
- } else if (case$method == "inv.simp") {
502
- run_general(d, case, ddir)
503
- } else if (case$method == "gini") {
504
- run_general(d, case, ddir, "V1")
505
- } else if (case$method == "raref") {
677
+ if (case$method == "raref") {
678
+ add_report(
679
+ list(
680
+ kind = "descr",
681
+ content = paste0(
682
+ "Rarefaction is a technique to assess species richness from the ",
683
+ "results of sampling through extrapolation. "
684
+ )
685
+ ),
686
+ h1 = "Rarefraction",
687
+ h2 = casename
688
+ )
689
+
506
690
  if (!is.null(case$separate_by)) {
507
691
  run_raref_multi(d, case, ddir)
692
+ add_report(
693
+ list(
694
+ kind = "image",
695
+ src = file.path(ddir, paste0("raref-", slugify(case$separate_by), ".png")),
696
+ download = file.path(ddir, paste0("raref-", slugify(case$separate_by), ".pdf"))
697
+ ),
698
+ h1 = "Rarefraction",
699
+ h2 = casename
700
+ )
508
701
  } else {
509
702
  run_raref_single(d, case, ddir)
703
+ add_report(
704
+ list(
705
+ kind = "image",
706
+ src = file.path(ddir, "raref.png"),
707
+ download = file.path(ddir, "raref.pdf")
708
+ ),
709
+ h1 = "Rarefraction",
710
+ h2 = casename
711
+ )
510
712
  }
511
713
  } else {
512
- stop(paste0("Unknown diversity method: ", case$method))
714
+ if (case$method == "chao1") {
715
+ run_general(casename, d, case, ddir, "Estimator")
716
+ } else if (case$method == "hill") {
717
+ run_general(casename, d, case, ddir)
718
+ } else if (case$method == "div") {
719
+ run_general(casename, d, case, ddir)
720
+ } else if (case$method == "gini.simp") {
721
+ run_general(casename, d, case, ddir)
722
+ } else if (case$method == "inv.simp") {
723
+ run_general(casename, d, case, ddir)
724
+ } else if (case$method == "gini") {
725
+ run_general(casename, d, case, ddir, "V1")
726
+ } else if (case$method == "d50") {
727
+ run_general(casename, d, case, ddir, "Clones")
728
+ } else {
729
+ stop(paste0("Unknown diversity method: ", case$method))
730
+ }
513
731
  }
514
732
  }
515
733