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.
- biopipen/__init__.py +1 -1
- biopipen/core/config.toml +28 -0
- biopipen/core/filters.py +79 -4
- biopipen/core/proc.py +12 -3
- biopipen/core/testing.py +75 -3
- biopipen/ns/bam.py +148 -6
- biopipen/ns/bed.py +75 -0
- biopipen/ns/cellranger.py +186 -0
- biopipen/ns/cellranger_pipeline.py +126 -0
- biopipen/ns/cnv.py +19 -3
- biopipen/ns/cnvkit.py +1 -1
- biopipen/ns/cnvkit_pipeline.py +20 -12
- biopipen/ns/delim.py +34 -35
- biopipen/ns/gene.py +68 -23
- biopipen/ns/gsea.py +63 -37
- biopipen/ns/misc.py +39 -14
- biopipen/ns/plot.py +304 -1
- biopipen/ns/protein.py +183 -0
- biopipen/ns/regulatory.py +290 -0
- biopipen/ns/rnaseq.py +142 -5
- biopipen/ns/scrna.py +2053 -473
- biopipen/ns/scrna_metabolic_landscape.py +228 -382
- biopipen/ns/snp.py +659 -0
- biopipen/ns/stats.py +484 -0
- biopipen/ns/tcr.py +683 -98
- biopipen/ns/vcf.py +236 -2
- biopipen/ns/web.py +97 -6
- biopipen/reports/bam/CNVpytor.svelte +4 -9
- biopipen/reports/cellranger/CellRangerCount.svelte +18 -0
- biopipen/reports/cellranger/CellRangerSummary.svelte +16 -0
- biopipen/reports/cellranger/CellRangerVdj.svelte +18 -0
- biopipen/reports/cnvkit/CNVkitDiagram.svelte +1 -1
- biopipen/reports/cnvkit/CNVkitHeatmap.svelte +1 -1
- biopipen/reports/cnvkit/CNVkitScatter.svelte +1 -1
- biopipen/reports/common.svelte +15 -0
- biopipen/reports/protein/ProdigySummary.svelte +16 -0
- biopipen/reports/scrna/CellsDistribution.svelte +4 -39
- biopipen/reports/scrna/DimPlots.svelte +1 -1
- biopipen/reports/scrna/MarkersFinder.svelte +6 -126
- biopipen/reports/scrna/MetaMarkers.svelte +3 -75
- biopipen/reports/scrna/RadarPlots.svelte +4 -20
- biopipen/reports/scrna_metabolic_landscape/MetabolicFeatures.svelte +61 -22
- biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayActivity.svelte +88 -82
- biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayHeterogeneity.svelte +70 -10
- biopipen/reports/snp/PlinkCallRate.svelte +24 -0
- biopipen/reports/snp/PlinkFreq.svelte +18 -0
- biopipen/reports/snp/PlinkHWE.svelte +18 -0
- biopipen/reports/snp/PlinkHet.svelte +18 -0
- biopipen/reports/snp/PlinkIBD.svelte +18 -0
- biopipen/reports/tcr/CDR3AAPhyschem.svelte +19 -66
- biopipen/reports/tcr/ClonalStats.svelte +16 -0
- biopipen/reports/tcr/CloneResidency.svelte +3 -93
- biopipen/reports/tcr/Immunarch.svelte +4 -155
- biopipen/reports/tcr/TCRClusterStats.svelte +3 -45
- biopipen/reports/tcr/TESSA.svelte +11 -28
- biopipen/reports/utils/misc.liq +22 -7
- biopipen/scripts/bam/BamMerge.py +11 -15
- biopipen/scripts/bam/BamSampling.py +90 -0
- biopipen/scripts/bam/BamSort.py +141 -0
- biopipen/scripts/bam/BamSplitChroms.py +10 -10
- biopipen/scripts/bam/BamSubsetByBed.py +38 -0
- biopipen/scripts/bam/CNAClinic.R +41 -5
- biopipen/scripts/bam/CNVpytor.py +153 -54
- biopipen/scripts/bam/ControlFREEC.py +13 -14
- biopipen/scripts/bam/SamtoolsView.py +33 -0
- biopipen/scripts/bed/Bed2Vcf.py +5 -5
- biopipen/scripts/bed/BedConsensus.py +5 -5
- biopipen/scripts/bed/BedLiftOver.sh +6 -4
- biopipen/scripts/bed/BedtoolsIntersect.py +54 -0
- biopipen/scripts/bed/BedtoolsMakeWindows.py +47 -0
- biopipen/scripts/bed/BedtoolsMerge.py +4 -4
- biopipen/scripts/cellranger/CellRangerCount.py +138 -0
- biopipen/scripts/cellranger/CellRangerSummary.R +181 -0
- biopipen/scripts/cellranger/CellRangerVdj.py +112 -0
- biopipen/scripts/cnv/AneuploidyScore.R +55 -20
- biopipen/scripts/cnv/AneuploidyScoreSummary.R +221 -163
- biopipen/scripts/cnv/TMADScore.R +25 -9
- biopipen/scripts/cnv/TMADScoreSummary.R +57 -86
- biopipen/scripts/cnvkit/CNVkitAccess.py +7 -6
- biopipen/scripts/cnvkit/CNVkitAutobin.py +26 -18
- biopipen/scripts/cnvkit/CNVkitBatch.py +6 -6
- biopipen/scripts/cnvkit/CNVkitCall.py +3 -3
- biopipen/scripts/cnvkit/CNVkitCoverage.py +4 -3
- biopipen/scripts/cnvkit/CNVkitDiagram.py +5 -5
- biopipen/scripts/cnvkit/CNVkitFix.py +3 -3
- biopipen/scripts/cnvkit/CNVkitGuessBaits.py +12 -8
- biopipen/scripts/cnvkit/CNVkitHeatmap.py +5 -5
- biopipen/scripts/cnvkit/CNVkitReference.py +6 -5
- biopipen/scripts/cnvkit/CNVkitScatter.py +5 -5
- biopipen/scripts/cnvkit/CNVkitSegment.py +5 -5
- biopipen/scripts/cnvkit/guess_baits.py +166 -93
- biopipen/scripts/delim/RowsBinder.R +1 -1
- biopipen/scripts/delim/SampleInfo.R +116 -118
- biopipen/scripts/gene/GeneNameConversion.R +67 -0
- biopipen/scripts/gene/GenePromoters.R +61 -0
- biopipen/scripts/gsea/Enrichr.R +5 -5
- biopipen/scripts/gsea/FGSEA.R +184 -50
- biopipen/scripts/gsea/GSEA.R +2 -2
- biopipen/scripts/gsea/PreRank.R +5 -5
- biopipen/scripts/misc/Config2File.py +2 -2
- biopipen/scripts/misc/Plot.R +80 -0
- biopipen/scripts/misc/Shell.sh +15 -0
- biopipen/scripts/misc/Str2File.py +2 -2
- biopipen/scripts/plot/Heatmap.R +3 -3
- biopipen/scripts/plot/Manhattan.R +147 -0
- biopipen/scripts/plot/QQPlot.R +146 -0
- biopipen/scripts/plot/ROC.R +88 -0
- biopipen/scripts/plot/Scatter.R +112 -0
- biopipen/scripts/plot/VennDiagram.R +5 -9
- biopipen/scripts/protein/MMCIF2PDB.py +33 -0
- biopipen/scripts/protein/PDB2Fasta.py +60 -0
- biopipen/scripts/protein/Prodigy.py +119 -0
- biopipen/scripts/protein/ProdigySummary.R +140 -0
- biopipen/scripts/protein/RMSD.py +178 -0
- biopipen/scripts/regulatory/MotifAffinityTest.R +102 -0
- biopipen/scripts/regulatory/MotifAffinityTest_AtSNP.R +127 -0
- biopipen/scripts/regulatory/MotifAffinityTest_MotifBreakR.R +104 -0
- biopipen/scripts/regulatory/MotifScan.py +159 -0
- biopipen/scripts/regulatory/VariantMotifPlot.R +78 -0
- biopipen/scripts/regulatory/motifs-common.R +324 -0
- biopipen/scripts/rnaseq/Simulation-ESCO.R +180 -0
- biopipen/scripts/rnaseq/Simulation-RUVcorr.R +45 -0
- biopipen/scripts/rnaseq/Simulation.R +21 -0
- biopipen/scripts/rnaseq/UnitConversion.R +325 -54
- biopipen/scripts/scrna/AnnData2Seurat.R +40 -0
- biopipen/scripts/scrna/CCPlotR-patch.R +161 -0
- biopipen/scripts/scrna/CellCellCommunication.py +150 -0
- biopipen/scripts/scrna/CellCellCommunicationPlots.R +93 -0
- biopipen/scripts/scrna/CellSNPLite.py +30 -0
- biopipen/scripts/scrna/CellTypeAnnotation-celltypist.R +185 -0
- biopipen/scripts/scrna/CellTypeAnnotation-direct.R +68 -31
- biopipen/scripts/scrna/CellTypeAnnotation-hitype.R +27 -22
- biopipen/scripts/scrna/CellTypeAnnotation-sccatch.R +28 -20
- biopipen/scripts/scrna/CellTypeAnnotation-sctype.R +48 -25
- biopipen/scripts/scrna/CellTypeAnnotation.R +37 -1
- biopipen/scripts/scrna/CellsDistribution.R +456 -167
- biopipen/scripts/scrna/DimPlots.R +1 -1
- biopipen/scripts/scrna/ExprImputation-alra.R +109 -0
- biopipen/scripts/scrna/ExprImputation-rmagic.R +256 -0
- biopipen/scripts/scrna/{ExprImpution-scimpute.R → ExprImputation-scimpute.R} +8 -5
- biopipen/scripts/scrna/ExprImputation.R +7 -0
- biopipen/scripts/scrna/LoomTo10X.R +51 -0
- biopipen/scripts/scrna/MQuad.py +25 -0
- biopipen/scripts/scrna/MarkersFinder.R +679 -400
- biopipen/scripts/scrna/MetaMarkers.R +265 -161
- biopipen/scripts/scrna/ModuleScoreCalculator.R +66 -11
- biopipen/scripts/scrna/PseudoBulkDEG.R +678 -0
- biopipen/scripts/scrna/RadarPlots.R +355 -134
- biopipen/scripts/scrna/ScFGSEA.R +298 -100
- biopipen/scripts/scrna/ScSimulation.R +65 -0
- biopipen/scripts/scrna/ScVelo.py +617 -0
- biopipen/scripts/scrna/Seurat2AnnData.R +7 -0
- biopipen/scripts/scrna/SeuratClusterStats-clustree.R +87 -0
- biopipen/scripts/scrna/SeuratClusterStats-dimplots.R +36 -30
- biopipen/scripts/scrna/SeuratClusterStats-features.R +138 -187
- biopipen/scripts/scrna/SeuratClusterStats-ngenes.R +81 -0
- biopipen/scripts/scrna/SeuratClusterStats-stats.R +78 -89
- biopipen/scripts/scrna/SeuratClusterStats.R +47 -10
- biopipen/scripts/scrna/SeuratClustering.R +36 -233
- biopipen/scripts/scrna/SeuratLoading.R +2 -2
- biopipen/scripts/scrna/SeuratMap2Ref.R +84 -113
- biopipen/scripts/scrna/SeuratMetadataMutater.R +16 -6
- biopipen/scripts/scrna/SeuratPreparing.R +223 -173
- biopipen/scripts/scrna/SeuratSubClustering.R +64 -0
- biopipen/scripts/scrna/SeuratTo10X.R +27 -0
- biopipen/scripts/scrna/Slingshot.R +65 -0
- biopipen/scripts/scrna/Subset10X.R +2 -2
- biopipen/scripts/scrna/TopExpressingGenes.R +169 -135
- biopipen/scripts/scrna/celltypist-wrapper.py +195 -0
- biopipen/scripts/scrna/scvelo_paga.py +313 -0
- biopipen/scripts/scrna/seurat_anndata_conversion.py +98 -0
- biopipen/scripts/scrna_metabolic_landscape/MetabolicFeatures.R +447 -82
- biopipen/scripts/scrna_metabolic_landscape/MetabolicPathwayActivity.R +348 -241
- biopipen/scripts/scrna_metabolic_landscape/MetabolicPathwayHeterogeneity.R +188 -166
- biopipen/scripts/snp/MatrixEQTL.R +217 -0
- biopipen/scripts/snp/Plink2GTMat.py +148 -0
- biopipen/scripts/snp/PlinkCallRate.R +199 -0
- biopipen/scripts/snp/PlinkFilter.py +100 -0
- biopipen/scripts/snp/PlinkFreq.R +291 -0
- biopipen/scripts/snp/PlinkFromVcf.py +81 -0
- biopipen/scripts/snp/PlinkHWE.R +85 -0
- biopipen/scripts/snp/PlinkHet.R +96 -0
- biopipen/scripts/snp/PlinkIBD.R +196 -0
- biopipen/scripts/snp/PlinkSimulation.py +124 -0
- biopipen/scripts/snp/PlinkUpdateName.py +124 -0
- biopipen/scripts/stats/ChowTest.R +146 -0
- biopipen/scripts/stats/DiffCoexpr.R +152 -0
- biopipen/scripts/stats/LiquidAssoc.R +135 -0
- biopipen/scripts/stats/Mediation.R +108 -0
- biopipen/scripts/stats/MetaPvalue.R +130 -0
- biopipen/scripts/stats/MetaPvalue1.R +74 -0
- biopipen/scripts/tcgamaf/Maf2Vcf.py +2 -2
- biopipen/scripts/tcgamaf/MafAddChr.py +2 -2
- biopipen/scripts/tcr/Attach2Seurat.R +3 -2
- biopipen/scripts/tcr/CDR3AAPhyschem.R +211 -143
- biopipen/scripts/tcr/CDR3Clustering.R +343 -0
- biopipen/scripts/tcr/ClonalStats.R +526 -0
- biopipen/scripts/tcr/CloneResidency.R +255 -131
- biopipen/scripts/tcr/CloneSizeQQPlot.R +4 -4
- biopipen/scripts/tcr/GIANA/GIANA.py +1356 -797
- biopipen/scripts/tcr/GIANA/GIANA4.py +1362 -789
- biopipen/scripts/tcr/GIANA/query.py +164 -162
- biopipen/scripts/tcr/Immunarch-basic.R +31 -9
- biopipen/scripts/tcr/Immunarch-clonality.R +25 -5
- biopipen/scripts/tcr/Immunarch-diversity.R +352 -134
- biopipen/scripts/tcr/Immunarch-geneusage.R +45 -5
- biopipen/scripts/tcr/Immunarch-kmer.R +68 -8
- biopipen/scripts/tcr/Immunarch-overlap.R +84 -4
- biopipen/scripts/tcr/Immunarch-spectratyping.R +35 -6
- biopipen/scripts/tcr/Immunarch-tracking.R +38 -6
- biopipen/scripts/tcr/Immunarch-vjjunc.R +165 -0
- biopipen/scripts/tcr/Immunarch.R +63 -11
- biopipen/scripts/tcr/Immunarch2VDJtools.R +2 -2
- biopipen/scripts/tcr/ImmunarchFilter.R +4 -4
- biopipen/scripts/tcr/ImmunarchLoading.R +38 -29
- biopipen/scripts/tcr/SampleDiversity.R +1 -1
- biopipen/scripts/tcr/ScRepCombiningExpression.R +40 -0
- biopipen/scripts/tcr/ScRepLoading.R +166 -0
- biopipen/scripts/tcr/TCRClusterStats.R +176 -22
- biopipen/scripts/tcr/TCRDock.py +110 -0
- biopipen/scripts/tcr/TESSA.R +102 -118
- biopipen/scripts/tcr/VJUsage.R +5 -5
- biopipen/scripts/tcr/immunarch-patched.R +142 -0
- biopipen/scripts/tcr/vdjtools-patch.sh +1 -1
- biopipen/scripts/vcf/BcftoolsAnnotate.py +91 -0
- biopipen/scripts/vcf/BcftoolsFilter.py +90 -0
- biopipen/scripts/vcf/BcftoolsMerge.py +31 -0
- biopipen/scripts/vcf/BcftoolsSort.py +113 -0
- biopipen/scripts/vcf/BcftoolsView.py +73 -0
- biopipen/scripts/vcf/TruvariBench.sh +14 -7
- biopipen/scripts/vcf/TruvariBenchSummary.R +16 -13
- biopipen/scripts/vcf/TruvariConsistency.R +1 -1
- biopipen/scripts/vcf/Vcf2Bed.py +2 -2
- biopipen/scripts/vcf/VcfAnno.py +11 -11
- biopipen/scripts/vcf/VcfDownSample.sh +22 -10
- biopipen/scripts/vcf/VcfFilter.py +5 -5
- biopipen/scripts/vcf/VcfFix.py +7 -7
- biopipen/scripts/vcf/VcfFix_utils.py +13 -4
- biopipen/scripts/vcf/VcfIndex.py +3 -3
- biopipen/scripts/vcf/VcfIntersect.py +3 -3
- biopipen/scripts/vcf/VcfLiftOver.sh +5 -0
- biopipen/scripts/vcf/VcfSplitSamples.py +4 -4
- biopipen/scripts/vcf/bcftools_utils.py +52 -0
- biopipen/scripts/web/Download.py +8 -4
- biopipen/scripts/web/DownloadList.py +5 -5
- biopipen/scripts/web/GCloudStorageDownloadBucket.py +82 -0
- biopipen/scripts/web/GCloudStorageDownloadFile.py +23 -0
- biopipen/scripts/web/gcloud_common.py +49 -0
- biopipen/utils/gene.py +108 -60
- biopipen/utils/misc.py +146 -20
- biopipen/utils/reference.py +64 -20
- biopipen/utils/reporter.py +177 -0
- biopipen/utils/vcf.py +1 -1
- biopipen-0.34.26.dist-info/METADATA +27 -0
- biopipen-0.34.26.dist-info/RECORD +292 -0
- {biopipen-0.21.0.dist-info → biopipen-0.34.26.dist-info}/WHEEL +1 -1
- {biopipen-0.21.0.dist-info → biopipen-0.34.26.dist-info}/entry_points.txt +6 -2
- biopipen/ns/bcftools.py +0 -111
- biopipen/ns/scrna_basic.py +0 -255
- biopipen/reports/delim/SampleInfo.svelte +0 -36
- biopipen/reports/scrna/GeneExpressionInvistigation.svelte +0 -32
- biopipen/reports/scrna/ScFGSEA.svelte +0 -35
- biopipen/reports/scrna/SeuratClusterStats.svelte +0 -82
- biopipen/reports/scrna/SeuratMap2Ref.svelte +0 -20
- biopipen/reports/scrna/SeuratPreparing.svelte +0 -38
- biopipen/reports/scrna/TopExpressingGenes.svelte +0 -55
- biopipen/reports/scrna_metabolic_landscape/MetabolicFeaturesIntraSubset.svelte +0 -31
- biopipen/reports/utils/gsea.liq +0 -110
- biopipen/scripts/bcftools/BcftoolsAnnotate.py +0 -42
- biopipen/scripts/bcftools/BcftoolsFilter.py +0 -79
- biopipen/scripts/bcftools/BcftoolsSort.py +0 -19
- biopipen/scripts/gene/GeneNameConversion.py +0 -66
- biopipen/scripts/scrna/ExprImpution-alra.R +0 -32
- biopipen/scripts/scrna/ExprImpution-rmagic.R +0 -29
- biopipen/scripts/scrna/ExprImpution.R +0 -7
- biopipen/scripts/scrna/GeneExpressionInvistigation.R +0 -132
- biopipen/scripts/scrna/Write10X.R +0 -11
- biopipen/scripts/scrna_metabolic_landscape/MetabolicFeaturesIntraSubset.R +0 -150
- biopipen/scripts/tcr/TCRClustering.R +0 -280
- biopipen/utils/common_docstrs.py +0 -61
- biopipen/utils/gene.R +0 -49
- biopipen/utils/gsea.R +0 -193
- biopipen/utils/io.R +0 -20
- biopipen/utils/misc.R +0 -114
- biopipen/utils/mutate_helpers.R +0 -433
- biopipen/utils/plot.R +0 -173
- biopipen/utils/rnaseq.R +0 -48
- biopipen/utils/single_cell.R +0 -115
- biopipen-0.21.0.dist-info/METADATA +0 -22
- biopipen-0.21.0.dist-info/RECORD +0 -218
|
@@ -1,112 +1,477 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
library(parallel)
|
|
1
|
+
library(rlang)
|
|
4
2
|
library(Seurat)
|
|
3
|
+
library(biopipen.utils)
|
|
4
|
+
library(enrichit)
|
|
5
|
+
library(tidyseurat)
|
|
5
6
|
|
|
6
7
|
sobjfile <- {{ in.sobjfile | r }}
|
|
7
8
|
outdir <- {{ out.outdir | r }}
|
|
8
|
-
gmtfile <- {{ envs.gmtfile | r }}
|
|
9
9
|
ncores <- {{ envs.ncores | r }}
|
|
10
|
-
fgsea <- {{ envs.fgsea | r }}
|
|
11
|
-
top <- {{ envs.top | r }}
|
|
12
10
|
prerank_method <- {{ envs.prerank_method | r }}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
gmtfile <- {{ envs.gmtfile | r }}
|
|
12
|
+
subset_by <- {{ envs.subset_by | r }}
|
|
13
|
+
group_by <- {{ envs.group_by | r }}
|
|
14
|
+
comparisons <- {{ envs.comparisons | r }}
|
|
15
|
+
fgsea_args <- {{ envs.fgsea_args | r }}
|
|
16
|
+
plots <- {{ envs.plots | r }}
|
|
17
|
+
cases <- {{ envs.cases | r }}
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
grouping_prefix = paste0(grouping_prefix, "_")
|
|
20
|
-
}
|
|
19
|
+
set.seed(8525)
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
21
|
+
log <- get_logger()
|
|
22
|
+
reporter <- get_reporter()
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
log$info("Loading Seurat object ...")
|
|
25
|
+
sobj <- read_obj(sobjfile)
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
defaults <- list(
|
|
28
|
+
prerank_method = prerank_method,
|
|
29
|
+
subset_by = subset_by,
|
|
30
|
+
group_by = group_by,
|
|
31
|
+
comparisons = comparisons,
|
|
32
|
+
fgsea_args = fgsea_args,
|
|
33
|
+
plots = plots
|
|
34
|
+
)
|
|
35
|
+
log$info("Expanding cases ...")
|
|
36
|
+
default_case <- subset_by %||% "DEFAULT"
|
|
37
|
+
cases <- expand_cases(
|
|
38
|
+
cases,
|
|
39
|
+
defaults,
|
|
40
|
+
function(name, case) {
|
|
41
|
+
if (is.null(case$group_by)) {
|
|
42
|
+
stop("'group_by' is required in case: ", name)
|
|
43
|
+
}
|
|
44
|
+
stats::setNames(list(case), name)
|
|
45
|
+
},
|
|
46
|
+
default_case = default_case)
|
|
35
47
|
|
|
36
|
-
pathways
|
|
48
|
+
log$info("Loading metabolic pathways ...")
|
|
49
|
+
pathways <- ParseGMT(gmtfile)
|
|
50
|
+
pathway_names <- names(pathways)
|
|
37
51
|
metabolics <- unique(as.vector(unname(unlist(pathways))))
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
do_comparison <- function(object, caseinfo, subset_by, subset_val, group_by, group1, group2, prerank_method, plots, fgsea_args) {
|
|
55
|
+
log$info(" {group_by}: {group1} vs {group2} ...")
|
|
56
|
+
if (!is.null(group2)) {
|
|
57
|
+
# object <- subset(object, subset = !!sym(group_by) %in% c(group1, group2))
|
|
58
|
+
object <- tryCatch(
|
|
59
|
+
filter(object, !!sym(group_by) %in% c(group1, group2)),
|
|
60
|
+
error = function(e) NULL
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!is.null(subset_by)) {
|
|
65
|
+
if (length(cases) == 1 && identical(caseinfo$name, subset_by)) {
|
|
66
|
+
# No need to show the case name in report
|
|
67
|
+
h1 <- paste0(subset_by, ": ", subset_val)
|
|
68
|
+
h2 <- paste0(group_by, ": ", group1, " vs ", group2 %||% "REST")
|
|
69
|
+
h3 <- "#"
|
|
70
|
+
} else {
|
|
71
|
+
h1 <- caseinfo$name
|
|
72
|
+
h2 <- paste0(subset_by, ": ", subset_val)
|
|
73
|
+
h3 <- paste0(group_by, ": ", group1, " vs ", group2 %||% "REST")
|
|
74
|
+
}
|
|
75
|
+
odir <- file.path(caseinfo$prefix, slugify(paste0(subset_by, "_", subset_val)))
|
|
76
|
+
} else if (length(cases) > 1) {
|
|
77
|
+
h1 <- caseinfo$name
|
|
78
|
+
h2 <- "#"
|
|
79
|
+
h3 <- paste0(group_by, ": ", group1, " vs ", group2 %||% "REST")
|
|
80
|
+
odir <- file.path(caseinfo$prefix, "No_Subsetting")
|
|
81
|
+
} else {
|
|
82
|
+
h1 <- paste0(group_by, ": ", group1, " vs ", group2 %||% "REST")
|
|
83
|
+
h2 <- "#"
|
|
84
|
+
h3 <- "#"
|
|
85
|
+
odir <- caseinfo$prefix
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (is.null(object) || ncol(object) < 10) {
|
|
89
|
+
msg <- paste0(" ! skipped. Groups together have less than 10 cells: ", group_by, " = ", group1, " vs ", group2)
|
|
90
|
+
log$warn(msg)
|
|
91
|
+
reporter$add(
|
|
92
|
+
list(kind = "error", content = msg),
|
|
93
|
+
h1 = h1,
|
|
94
|
+
h2 = h2,
|
|
95
|
+
h3 = h3
|
|
96
|
+
)
|
|
97
|
+
return(invisible())
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
classes <- as.character(object@meta.data[[group_by]])
|
|
101
|
+
if (!group1 %in% classes) {
|
|
102
|
+
stop("Group '", group1, "' not found in '", group_by, "' column of the Seurat object.")
|
|
103
|
+
}
|
|
104
|
+
if (!is.null(group2) && !group2 %in% classes) {
|
|
105
|
+
stop("Group '", group2, "' not found in '", group_by, "' column of the Seurat object.")
|
|
106
|
+
}
|
|
107
|
+
classes[classes != group1] <- "Other"
|
|
108
|
+
if (any(table(classes) < 5)) {
|
|
109
|
+
msg <- paste0(
|
|
110
|
+
" ! skipped. Group has less than 5 cells: ",
|
|
111
|
+
paste(names(table(classes)[table(classes) < 5]), collapse = ", ")
|
|
112
|
+
)
|
|
113
|
+
log$warn(msg)
|
|
114
|
+
|
|
115
|
+
reporter$add(
|
|
116
|
+
list(kind = "error", content = msg),
|
|
117
|
+
h1 = h1,
|
|
118
|
+
h2 = h2,
|
|
119
|
+
h3 = h3
|
|
120
|
+
)
|
|
121
|
+
return(invisible())
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
features = intersect(rownames(object), metabolics)
|
|
125
|
+
ranks <- RunGSEAPreRank(
|
|
126
|
+
GetAssayData(object)[features, , drop = FALSE],
|
|
127
|
+
classes = object@meta.data[[group_by]],
|
|
128
|
+
case = group1,
|
|
129
|
+
control = group2,
|
|
130
|
+
method = prerank_method
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
fgsea_args <- fgsea_args %||% list()
|
|
134
|
+
fgsea_args$ranks <- ranks
|
|
135
|
+
fgsea_args$genesets <- pathways
|
|
136
|
+
fgsea_args$nproc <- fgsea_args$nproc %||% ncores
|
|
137
|
+
result <- do_call(RunGSEA, fgsea_args)
|
|
138
|
+
|
|
139
|
+
if (is.null(group2)) {
|
|
140
|
+
odir <- file.path(odir, slugify(paste0(group_by, "_", group1, "_vs_REST")))
|
|
141
|
+
} else {
|
|
142
|
+
odir <- file.path(odir, slugify(paste0(group_by, "_", group1, "_vs_", group2)))
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
dir.create(odir, showWarnings = FALSE, recursive = TRUE)
|
|
146
|
+
write.table(as.data.frame(result), file = file.path(odir, "fgsea_results.txt"), sep = "\t", quote = FALSE, row.names = FALSE)
|
|
147
|
+
write.table(data.frame(Gene = names(ranks), Rank = ranks), file = file.path(odir, "fgsea_ranks.txt"), sep = "\t", quote = FALSE, row.names = FALSE)
|
|
148
|
+
|
|
149
|
+
reporter$add(
|
|
150
|
+
list(kind = "descr", content = "A summary table of the GSEA results"),
|
|
151
|
+
list(kind = "table", src = file.path(odir, "fgsea_results.txt")),
|
|
152
|
+
h1 = h1,
|
|
153
|
+
h2 = h2,
|
|
154
|
+
h3 = h3
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
for (plot in names(plots)) {
|
|
158
|
+
plotargs <- plots[[plot]]
|
|
159
|
+
plotargs$level <- plotargs$level %||% "group"
|
|
160
|
+
if (plotargs$level != "group") { next }
|
|
161
|
+
plotargs$devpars <- plotargs$devpars %||% list()
|
|
162
|
+
plotargs$devpars$res <- plotargs$devpars$res %||% 100
|
|
163
|
+
|
|
164
|
+
if (identical(plotargs$plot_type, "summary")) {
|
|
165
|
+
p <- do_call(VizGSEA, c(list(result), plotargs))
|
|
166
|
+
plotprefix <- file.path(odir, slugify(plot))
|
|
167
|
+
plotargs$devpars$width <- plotargs$devpars$width %||% (attr(p, "width") * plotargs$devpars$res) %||% 800
|
|
168
|
+
plotargs$devpars$height <- plotargs$devpars$height %||% (attr(p, "height") * plotargs$devpars$res) %||% 600
|
|
169
|
+
png(
|
|
170
|
+
filename = paste0(plotprefix, ".png"),
|
|
171
|
+
width = plotargs$devpars$width,
|
|
172
|
+
height = plotargs$devpars$height,
|
|
173
|
+
res = plotargs$devpars$res
|
|
174
|
+
)
|
|
175
|
+
print(p)
|
|
176
|
+
dev.off()
|
|
177
|
+
|
|
178
|
+
reporter$add(
|
|
179
|
+
list(
|
|
180
|
+
name = plot,
|
|
181
|
+
contents = list(
|
|
182
|
+
list(kind = "descr", content = plotargs$descr %||% plot),
|
|
183
|
+
reporter$image(plotprefix, "png", FALSE, kind = "image")
|
|
184
|
+
)
|
|
185
|
+
),
|
|
186
|
+
h1 = h1,
|
|
187
|
+
h2 = h2,
|
|
188
|
+
h3 = h3,
|
|
189
|
+
ui = "tabs"
|
|
57
190
|
)
|
|
58
191
|
} else {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
192
|
+
plotargs$combine = FALSE
|
|
193
|
+
plotargs$top_term = plotargs$top_term %||% 10
|
|
194
|
+
plotargs$gs <- result$pathway[1:plotargs$top_term]
|
|
195
|
+
|
|
196
|
+
ps <- do_call(VizGSEA, c(list(result), plotargs))
|
|
197
|
+
plotprefix <- file.path(odir, slugify(plot))
|
|
198
|
+
devpars <- plotargs$devpars
|
|
199
|
+
images <- list()
|
|
200
|
+
for (pname in names(ps)) {
|
|
201
|
+
p <- ps[[pname]]
|
|
202
|
+
devpars$width <- devpars$width %||% (attr(p, "width") * devpars$res) %||% 800
|
|
203
|
+
devpars$height <- devpars$height %||% (attr(p, "height") * devpars$res) %||% 600
|
|
204
|
+
prefix <- paste0(plotprefix, ".", slugify(pname))
|
|
205
|
+
images[[length(images) + 1]] <- reporter$image(prefix, c(), FALSE, kind = "table_image")
|
|
206
|
+
png(
|
|
207
|
+
filename = paste0(prefix, ".png"),
|
|
208
|
+
width = devpars$width,
|
|
209
|
+
height = devpars$height,
|
|
210
|
+
res = devpars$res
|
|
211
|
+
)
|
|
212
|
+
print(p)
|
|
213
|
+
dev.off()
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
reporter$add(
|
|
217
|
+
list(
|
|
218
|
+
name = plot,
|
|
219
|
+
ui = "table_of_images:2",
|
|
220
|
+
contents = images
|
|
221
|
+
),
|
|
222
|
+
h1 = h1,
|
|
223
|
+
h2 = h2,
|
|
224
|
+
h3 = h3,
|
|
225
|
+
ui = "tabs"
|
|
64
226
|
)
|
|
65
227
|
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
warning(e)
|
|
70
|
-
})
|
|
71
|
-
|
|
228
|
+
}
|
|
229
|
+
result$comparison <- paste0(group1, " vs ", group2 %||% "REST")
|
|
230
|
+
return(result)
|
|
72
231
|
}
|
|
73
232
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (is.null(
|
|
77
|
-
|
|
78
|
-
|
|
233
|
+
|
|
234
|
+
do_subset <- function(object, caseinfo, subset_by, subset_val, group_by, comparisons, prerank_method, plots, fgsea_args) {
|
|
235
|
+
if (!is.null(subset_by)) {
|
|
236
|
+
log$info("- Handling subset: {subset_by} = {subset_val} ...")
|
|
237
|
+
# object <- subset(object, subset = !!sym(subset_by) == subset_val)
|
|
238
|
+
object <- tryCatch(
|
|
239
|
+
filter(object, !!sym(subset_by) == subset_val & !is.na(!!sym(group_by))),
|
|
240
|
+
error = function(e) NULL
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
if (is.null(object) || ncol(object) < 5) {
|
|
244
|
+
if (length(cases) == 1 && identical(caseinfo$name, subset_by)) {
|
|
245
|
+
# No need to show case name in report
|
|
246
|
+
h1 <- paste0(subset_by, ": ", subset_val)
|
|
247
|
+
h2 <- "#"
|
|
248
|
+
} else {
|
|
249
|
+
h1 <- caseinfo$name
|
|
250
|
+
h2 <- paste0(subset_by, ": ", subset_val)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
msg <- paste0(" ! skipped. Subset has less than 5 cells: ", subset_by, " = ", subset_val)
|
|
254
|
+
log$warn(msg)
|
|
255
|
+
reporter$add(list(kind = "error", content = msg), h1 = h1)
|
|
256
|
+
return(NULL)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
groups <- unique(object@meta.data[[group_by]])
|
|
261
|
+
if (length(comparisons) == 0) {
|
|
262
|
+
result <- do_call(
|
|
263
|
+
rbind, lapply(
|
|
264
|
+
as.character(groups),
|
|
265
|
+
function(group) {
|
|
266
|
+
do_comparison(object, caseinfo, subset_by, subset_val, group_by, group, NULL, prerank_method, plots, fgsea_args)
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
)
|
|
79
270
|
} else {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
271
|
+
result <- do_call(
|
|
272
|
+
rbind, lapply(
|
|
273
|
+
as.character(comparisons),
|
|
274
|
+
function(comparison) {
|
|
275
|
+
if (grepl(":", comparison)) {
|
|
276
|
+
group1 <- trimws(unlist(strsplit(comparison, ":")))
|
|
277
|
+
group2 <- group1[2]
|
|
278
|
+
group1 <- group1[1]
|
|
279
|
+
} else {
|
|
280
|
+
group1 <- comparison
|
|
281
|
+
group2 <- NULL
|
|
282
|
+
}
|
|
283
|
+
do_comparison(object, caseinfo, subset_by, subset_val, group_by, group1, group2, prerank_method, plots, fgsea_args)
|
|
284
|
+
}
|
|
285
|
+
)
|
|
286
|
+
)
|
|
83
287
|
}
|
|
84
|
-
dir.create(outputdir, showWarnings = FALSE)
|
|
85
288
|
|
|
86
|
-
|
|
289
|
+
result[["-log10(pval)"]] <- -log10(result$pval)
|
|
290
|
+
result[["-log10(padj)"]] <- -log10(result$padj)
|
|
87
291
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
292
|
+
odir <- NULL
|
|
293
|
+
if (!is.null(subset_by)) {
|
|
294
|
+
if (length(cases) == 1 && identical(caseinfo$name, subset_by)) {
|
|
295
|
+
# No need to show case name in report
|
|
296
|
+
h1 <- paste0(subset_by, ": ", subset_val)
|
|
297
|
+
h2 <- "Summary plots for all comparisons"
|
|
298
|
+
h3 <- "#"
|
|
299
|
+
} else {
|
|
300
|
+
h1 <- caseinfo$name
|
|
301
|
+
h2 <- paste0(subset_by, ": ", subset_val)
|
|
302
|
+
h3 <- "Summary plots for all comparisons"
|
|
303
|
+
}
|
|
304
|
+
odir <- file.path(caseinfo$prefix, slugify(paste0(subset_by, "_", subset_val)))
|
|
305
|
+
} else if (length(cases) > 1) {
|
|
306
|
+
h1 <- caseinfo$name
|
|
307
|
+
h2 <- "Summary plots for all comparisons"
|
|
308
|
+
h3 <- "#"
|
|
309
|
+
odir <- file.path(caseinfo$prefix, "No_Subsetting")
|
|
94
310
|
}
|
|
95
|
-
}
|
|
96
311
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
312
|
+
if (!is.null(odir)) {
|
|
313
|
+
dir.create(odir, showWarnings = FALSE, recursive = TRUE)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
for (plot in names(plots)) {
|
|
317
|
+
plotargs <- plots[[plot]]
|
|
318
|
+
plotargs$level <- plotargs$level %||% "group"
|
|
319
|
+
if (plotargs$level != "subset") { next }
|
|
320
|
+
if (is.null(odir)) {
|
|
321
|
+
stop("'subset_by' is NULL but plot level is 'subset': ", plot, ", use level = 'case' instead.")
|
|
322
|
+
}
|
|
323
|
+
plotargs$devpars <- plotargs$devpars %||% list()
|
|
324
|
+
plotargs$devpars$res <- plotargs$devpars$res %||% 100
|
|
325
|
+
plotargs$plot_type <- plotargs$plot_type %||% "dot"
|
|
326
|
+
|
|
327
|
+
if (identical(plotargs$plot_type, "dot")) {
|
|
328
|
+
plotargs$x <- plotargs$x %||% "comparison"
|
|
329
|
+
plotargs$y <- plotargs$y %||% "pathway"
|
|
330
|
+
plotargs$size_by <- plotargs$size_by %||% "NES"
|
|
331
|
+
plotargs$fill_by <- plotargs$fill_by %||% "-log10(padj)"
|
|
332
|
+
plotargs$fill_cutoff <- plotargs$fill_cutoff %||% -log10(0.05)
|
|
333
|
+
plotargs$fill_cutoff_name <- plotargs$fill_cutoff_name %||% "Insignificant"
|
|
334
|
+
plotargs$aspect.ratio <- plotargs$aspect.ratio %||% (length(unique(result$pathway)) / length(unique(result$comparison)) / 4)
|
|
335
|
+
plotargs$x_text_angle <- plotargs$x_text_angle %||% 90
|
|
336
|
+
p <- do_call(plotthis::DotPlot, c(list(result), plotargs))
|
|
337
|
+
plotprefix <- file.path(odir, slugify(plot))
|
|
338
|
+
plotargs$devpars$width <- plotargs$devpars$width %||% (attr(p, "width") * plotargs$devpars$res) %||% 800
|
|
339
|
+
plotargs$devpars$height <- plotargs$devpars$height %||% (attr(p, "height") * plotargs$devpars$res) %||% 600
|
|
340
|
+
png(
|
|
341
|
+
filename = paste0(plotprefix, ".png"),
|
|
342
|
+
width = plotargs$devpars$width,
|
|
343
|
+
height = plotargs$devpars$height,
|
|
344
|
+
res = plotargs$devpars$res
|
|
345
|
+
)
|
|
346
|
+
print(p)
|
|
347
|
+
dev.off()
|
|
348
|
+
|
|
349
|
+
reporter$add(
|
|
350
|
+
list(kind = "descr", content = plotargs$descr %||% plot),
|
|
351
|
+
reporter$image(plotprefix, "png", FALSE, kind = "image"),
|
|
352
|
+
h1 = h1,
|
|
353
|
+
h2 = h2,
|
|
354
|
+
h3 = h3
|
|
355
|
+
)
|
|
356
|
+
} else {
|
|
357
|
+
stop("`subset` level plot type not supported yet: ", plotargs$plot_type)
|
|
358
|
+
}
|
|
100
359
|
}
|
|
101
|
-
|
|
102
|
-
|
|
360
|
+
if (!is.null(subset_by)) {
|
|
361
|
+
result[[subset_by]] <- subset_val
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return(result)
|
|
103
365
|
}
|
|
104
366
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
367
|
+
|
|
368
|
+
do_case <- function(casename) {
|
|
369
|
+
log$info("Processing case: {casename} ...")
|
|
370
|
+
case <- cases[[casename]]
|
|
371
|
+
caseinfo <- case_info(casename, outdir, create = TRUE)
|
|
372
|
+
|
|
373
|
+
if (is.null(case$subset_by)) {
|
|
374
|
+
result <- do_subset(
|
|
375
|
+
sobj,
|
|
376
|
+
caseinfo,
|
|
377
|
+
subset_by = NULL,
|
|
378
|
+
subset_val = NULL,
|
|
379
|
+
group_by = case$group_by,
|
|
380
|
+
comparisons = case$comparisons,
|
|
381
|
+
prerank_method = case$prerank_method,
|
|
382
|
+
plots = case$plots,
|
|
383
|
+
fgsea_args = case$fgsea_args
|
|
384
|
+
)
|
|
385
|
+
} else {
|
|
386
|
+
sobj_avail <- filter(sobj, !is.na(!!sym(case$subset_by)))
|
|
387
|
+
subsets <- if (is.factor(sobj_avail@meta.data[[case$subset_by]])) {
|
|
388
|
+
levels(sobj_avail@meta.data[[case$subset_by]])
|
|
389
|
+
} else {
|
|
390
|
+
unique(sobj_avail@meta.data[[case$subset_by]])
|
|
391
|
+
}
|
|
392
|
+
result <- do_call(
|
|
393
|
+
rbind, lapply(
|
|
394
|
+
as.character(subsets),
|
|
395
|
+
function(subset_val) {
|
|
396
|
+
do_subset(
|
|
397
|
+
sobj_avail,
|
|
398
|
+
caseinfo,
|
|
399
|
+
subset_by = case$subset_by,
|
|
400
|
+
subset_val = subset_val,
|
|
401
|
+
group_by = case$group_by,
|
|
402
|
+
comparisons = case$comparisons,
|
|
403
|
+
prerank_method = case$prerank_method,
|
|
404
|
+
plots = case$plots,
|
|
405
|
+
fgsea_args = case$fgsea_args
|
|
406
|
+
)
|
|
407
|
+
}
|
|
408
|
+
)
|
|
409
|
+
)
|
|
410
|
+
result[[case$subset_by]] <- factor(result[[case$subset_by]], levels = subsets)
|
|
411
|
+
}
|
|
412
|
+
result$pathway <- factor(result$pathway, levels = pathway_names)
|
|
413
|
+
|
|
414
|
+
if (!is.null(case$subset_by)) {
|
|
415
|
+
if (length(cases) == 1 && identical(caseinfo$name, case$subset_by)) {
|
|
416
|
+
h1 <- "Summary plots for all subsets"
|
|
417
|
+
h2 <- "#"
|
|
418
|
+
} else {
|
|
419
|
+
h1 <- caseinfo$name
|
|
420
|
+
h2 <- "Summary plots for all subsets"
|
|
421
|
+
}
|
|
422
|
+
} else if (length(cases) > 1) {
|
|
423
|
+
h1 <- caseinfo$name
|
|
424
|
+
h2 <- "Summary plots for all comparisons"
|
|
425
|
+
} else {
|
|
426
|
+
h1 <- "Summary plots for all comparisons"
|
|
427
|
+
h2 <- "#"
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
for (plot in names(plots)) {
|
|
431
|
+
plotargs <- plots[[plot]]
|
|
432
|
+
plotargs$level <- plotargs$level %||% "group"
|
|
433
|
+
if (plotargs$level != "case") { next }
|
|
434
|
+
plotargs$devpars <- plotargs$devpars %||% list()
|
|
435
|
+
plotargs$devpars$res <- plotargs$devpars$res %||% 100
|
|
436
|
+
plotargs$plot_type <- plotargs$plot_type %||% "dot"
|
|
437
|
+
|
|
438
|
+
if (identical(plotargs$plot_type, "dot")) {
|
|
439
|
+
plotargs$x <- plotargs$x %||% "comparison"
|
|
440
|
+
plotargs$y <- plotargs$y %||% "pathway"
|
|
441
|
+
plotargs$size_by <- plotargs$size_by %||% "NES"
|
|
442
|
+
plotargs$fill_by <- plotargs$fill_by %||% "-log10(padj)"
|
|
443
|
+
plotargs$fill_cutoff <- plotargs$fill_cutoff %||% -log10(0.05)
|
|
444
|
+
plotargs$fill_cutoff_name <- plotargs$fill_cutoff_name %||% "Insignificant"
|
|
445
|
+
plotargs$aspect.ratio <- plotargs$aspect.ratio %||% (length(unique(result$pathway)) / length(unique(result$comparison)) / 4)
|
|
446
|
+
plotargs$x_text_angle <- plotargs$x_text_angle %||% 90
|
|
447
|
+
if (!is.null(subset_by)) {
|
|
448
|
+
plotargs$split_by <- plotargs$split_by %||% subset_by
|
|
449
|
+
}
|
|
450
|
+
p <- do_call(plotthis::DotPlot, c(list(result), plotargs))
|
|
451
|
+
plotprefix <- file.path(caseinfo$prefix, slugify(plot))
|
|
452
|
+
plotargs$devpars$width <- plotargs$devpars$width %||% (attr(p, "width") * plotargs$devpars$res) %||% 800
|
|
453
|
+
plotargs$devpars$height <- plotargs$devpars$height %||% (attr(p, "height") * plotargs$devpars$res) %||% 600
|
|
454
|
+
png(
|
|
455
|
+
filename = paste0(plotprefix, ".png"),
|
|
456
|
+
width = plotargs$devpars$width,
|
|
457
|
+
height = plotargs$devpars$height,
|
|
458
|
+
res = plotargs$devpars$res
|
|
459
|
+
)
|
|
460
|
+
print(p)
|
|
461
|
+
dev.off()
|
|
462
|
+
|
|
463
|
+
reporter$add(
|
|
464
|
+
list(kind = "descr", content = plotargs$descr %||% plot),
|
|
465
|
+
reporter$image(plotprefix, "png", FALSE, kind = "image"),
|
|
466
|
+
h1 = h1,
|
|
467
|
+
h2 = h2
|
|
468
|
+
)
|
|
469
|
+
} else {
|
|
470
|
+
stop("`case` level plot type not supported yet: ", plotargs$plot_type)
|
|
471
|
+
}
|
|
110
472
|
}
|
|
111
473
|
}
|
|
112
474
|
|
|
475
|
+
sapply(names(cases), do_case)
|
|
476
|
+
|
|
477
|
+
reporter$save(dirname(outdir))
|