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,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
{{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
|
|
2
2
|
|
|
3
3
|
library(rlang)
|
|
4
4
|
library(dplyr)
|
|
@@ -9,14 +9,15 @@ library(ggnewscale)
|
|
|
9
9
|
library(ggplot2)
|
|
10
10
|
library(ggprism)
|
|
11
11
|
library(ggVennDiagram)
|
|
12
|
-
library(
|
|
12
|
+
library(ComplexUpset)
|
|
13
13
|
|
|
14
14
|
theme_set(theme_prism())
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
immfile <- {{ in.immdata |
|
|
17
|
+
immfile <- {{ in.immdata | r }}
|
|
18
18
|
metafile <- {{ in.metafile | r }}
|
|
19
|
-
outdir <- {{ out.outdir |
|
|
19
|
+
outdir <- {{ out.outdir | r }}
|
|
20
|
+
joboutdir <- {{ job.outdir | r }}
|
|
20
21
|
|
|
21
22
|
subject_key <- {{ envs.subject | r }}
|
|
22
23
|
group_key <- {{ envs.group | r }}
|
|
@@ -25,11 +26,13 @@ section <- {{ envs.section | r }}
|
|
|
25
26
|
mutaters <- {{ envs.mutaters | r }}
|
|
26
27
|
subset <- {{ envs.subset | r }}
|
|
27
28
|
prefix <- {{ envs.prefix | r }}
|
|
29
|
+
upset_ymax <- {{ envs.upset_ymax | r }}
|
|
30
|
+
upset_trans <- {{ envs.upset_trans | r }}
|
|
28
31
|
cases <- {{ envs.cases | r }}
|
|
29
32
|
|
|
30
33
|
# Fill up cases using `envs.xxx` if not provided and compose a DEFAULT case
|
|
31
34
|
# if no cases are provided
|
|
32
|
-
|
|
35
|
+
log_info("Preparing cases...")
|
|
33
36
|
if (is.null(cases) || length(cases) == 0) {
|
|
34
37
|
cases <- list(
|
|
35
38
|
DEFAULT = list(
|
|
@@ -37,34 +40,28 @@ if (is.null(cases) || length(cases) == 0) {
|
|
|
37
40
|
group = group_key,
|
|
38
41
|
order = sample_order,
|
|
39
42
|
subset = subset,
|
|
40
|
-
section = section
|
|
43
|
+
section = section,
|
|
44
|
+
upset_ymax = upset_ymax,
|
|
45
|
+
upset_trans = upset_trans
|
|
41
46
|
)
|
|
42
47
|
)
|
|
43
48
|
} else {
|
|
44
49
|
for (key in names(cases)) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
cases[[key]]$order <- sample_order
|
|
53
|
-
}
|
|
54
|
-
if (is.null(cases[[key]]$section)) {
|
|
55
|
-
cases[[key]]$section <- section
|
|
56
|
-
}
|
|
57
|
-
if (is.null(cases[[key]]$subset)) {
|
|
58
|
-
cases[[key]]$subset <- subset
|
|
59
|
-
}
|
|
50
|
+
cases[[key]]$subject <- cases[[key]]$subject %||% subject_key
|
|
51
|
+
cases[[key]]$group <- cases[[key]]$group %||% group_key
|
|
52
|
+
cases[[key]]$order <- cases[[key]]$order %||% sample_order
|
|
53
|
+
cases[[key]]$section <- cases[[key]]$section %||% section
|
|
54
|
+
cases[[key]]$subset <- cases[[key]]$subset %||% subset
|
|
55
|
+
cases[[key]]$upset_ymax <- cases[[key]]$upset_ymax %||% upset_ymax
|
|
56
|
+
cases[[key]]$upset_trans <- cases[[key]]$upset_trans %||% upset_trans
|
|
60
57
|
}
|
|
61
58
|
}
|
|
62
59
|
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
log_info("Preparing data ...")
|
|
61
|
+
log_info("- Loading immdata ...")
|
|
65
62
|
immdata <- readRDS(immfile)
|
|
66
63
|
|
|
67
|
-
|
|
64
|
+
log_info("- Expanding immdata$data to cell-level ...")
|
|
68
65
|
cldata <- do_call(rbind, lapply(names(immdata$data), function(name) {
|
|
69
66
|
dat <- immdata$data[[name]] %>% separate_rows(Barcode, sep = ";") # Split barcodes
|
|
70
67
|
dat$Sample <- name
|
|
@@ -76,7 +73,7 @@ cldata <- do_call(rbind, lapply(names(immdata$data), function(name) {
|
|
|
76
73
|
}))
|
|
77
74
|
|
|
78
75
|
if (!is.null(metafile)) {
|
|
79
|
-
|
|
76
|
+
log_info("- Loading metafile ...")
|
|
80
77
|
# Check if extension is rds/RDS, if so, it should be a Seurat object
|
|
81
78
|
if (endsWith(metafile, ".rds") || endsWith(metafile, ".RDS")) {
|
|
82
79
|
meta <- readRDS(metafile)@meta.data
|
|
@@ -86,14 +83,14 @@ if (!is.null(metafile)) {
|
|
|
86
83
|
)
|
|
87
84
|
}
|
|
88
85
|
|
|
89
|
-
|
|
86
|
+
log_info("- Merging metafile to cldata ...")
|
|
90
87
|
cldata <- cbind(
|
|
91
88
|
cldata,
|
|
92
89
|
meta[cldata$Barcode, setdiff(colnames(meta), colnames(cldata)), drop = FALSE]
|
|
93
90
|
)
|
|
94
91
|
}
|
|
95
92
|
|
|
96
|
-
|
|
93
|
+
log_info("Applying mutaters ...")
|
|
97
94
|
if (!is.null(mutaters) && length(mutaters) > 0) {
|
|
98
95
|
cldata <- cldata %>% mutate(!!!lapply(mutaters, parse_expr))
|
|
99
96
|
}
|
|
@@ -115,13 +112,13 @@ get_groups <- function(order) {
|
|
|
115
112
|
}
|
|
116
113
|
|
|
117
114
|
perpare_case <- function(casename, case) {
|
|
118
|
-
|
|
115
|
+
log_info("- Processing case: {casename} ...")
|
|
119
116
|
# Check if required keys are provided
|
|
120
117
|
if (is.null(case$subject) || length(case$subject) == 0) {
|
|
121
|
-
stop(paste("`subject` is required for case:", casename))
|
|
118
|
+
stop(paste(" `subject` is required for case:", casename))
|
|
122
119
|
}
|
|
123
120
|
if (is.null(case$group) || length(case$group) == 0) {
|
|
124
|
-
stop(paste("`group` is required for case:", casename))
|
|
121
|
+
stop(paste(" `group` is required for case:", casename))
|
|
125
122
|
}
|
|
126
123
|
if (!is.null(case$order) && length(case$order) > 0) {
|
|
127
124
|
has_comma <- grepl(",", case$order)
|
|
@@ -133,14 +130,8 @@ perpare_case <- function(casename, case) {
|
|
|
133
130
|
))
|
|
134
131
|
} else if (!any(has_comma)) {
|
|
135
132
|
if (length(case$order) > 2) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
"- Order of groups in case:", casename,
|
|
139
|
-
" is not recommended, please use comma to separate groups. \n",
|
|
140
|
-
"Instead of `['A', 'B', 'C']`, use `['A,B', 'A,C', 'B,C']`."
|
|
141
|
-
),
|
|
142
|
-
immediate. = TRUE
|
|
143
|
-
)
|
|
133
|
+
log_warn(" Order of groups is not recommended, please use comma to separate groups.")
|
|
134
|
+
log_warn(" Instead of `['A', 'B', 'C']`, use `['A,B', 'A,C', 'B,C']`.")
|
|
144
135
|
case$order <- sapply(
|
|
145
136
|
combn(case$order, 2, simplify = FALSE),
|
|
146
137
|
function(x) paste(x, collapse = ",")
|
|
@@ -151,8 +142,8 @@ perpare_case <- function(casename, case) {
|
|
|
151
142
|
} else {
|
|
152
143
|
stop(
|
|
153
144
|
paste0(
|
|
154
|
-
"
|
|
155
|
-
" is not consistent, please use comma to separate groups.
|
|
145
|
+
" Order of groups in case:", casename,
|
|
146
|
+
" is not consistent, please use comma to separate groups. ",
|
|
156
147
|
"Instead of `['A', 'B', 'C']`, use `['A,B', 'A,C', 'B,C']`, ",
|
|
157
148
|
"however, this is inconsistent: `['A,B', 'C']`"
|
|
158
149
|
)
|
|
@@ -162,19 +153,19 @@ perpare_case <- function(casename, case) {
|
|
|
162
153
|
|
|
163
154
|
# Create case-specific directories
|
|
164
155
|
# Scatter plots
|
|
165
|
-
scatter_dir <- file.path(outdir, casename, "scatter")
|
|
156
|
+
scatter_dir <- file.path(outdir, slugify(casename), "scatter")
|
|
166
157
|
dir.create(scatter_dir, recursive = TRUE, showWarnings = FALSE)
|
|
167
158
|
|
|
168
159
|
# Venn diagrams
|
|
169
|
-
venn_dir <- file.path(outdir, casename, "venn")
|
|
160
|
+
venn_dir <- file.path(outdir, slugify(casename), "venn")
|
|
170
161
|
dir.create(venn_dir, recursive = TRUE, showWarnings = FALSE)
|
|
171
162
|
|
|
172
163
|
# Upset plots
|
|
173
|
-
upset_dir <- file.path(outdir, casename, "upset")
|
|
164
|
+
upset_dir <- file.path(outdir, slugify(casename), "upset")
|
|
174
165
|
dir.create(upset_dir, recursive = TRUE, showWarnings = FALSE)
|
|
175
166
|
|
|
176
167
|
# Counts
|
|
177
|
-
counts_dir <- file.path(outdir, casename, "counts")
|
|
168
|
+
counts_dir <- file.path(outdir, slugify(casename), "counts")
|
|
178
169
|
dir.create(counts_dir, recursive = TRUE, showWarnings = FALSE)
|
|
179
170
|
|
|
180
171
|
case
|
|
@@ -255,14 +246,16 @@ plot_scatter <- function(counts, subject, suf1, suf2) {
|
|
|
255
246
|
}
|
|
256
247
|
ggplot(plotdata) +
|
|
257
248
|
geom_point(
|
|
258
|
-
|
|
259
|
-
x =
|
|
249
|
+
aes(
|
|
250
|
+
x = !!sym(suf1),
|
|
251
|
+
y = !!sym(suf2),
|
|
252
|
+
color = Type,
|
|
253
|
+
size = Size,
|
|
254
|
+
fill = Type
|
|
260
255
|
),
|
|
261
256
|
alpha = .6,
|
|
262
257
|
shape = 21
|
|
263
258
|
) +
|
|
264
|
-
# geom_point(aes_string(x=x, y=y, color='color'), shape=1) +
|
|
265
|
-
# scale_color_manual(values=color) +
|
|
266
259
|
scale_x_continuous(
|
|
267
260
|
trans = "log2",
|
|
268
261
|
limits = c(minx, maxx),
|
|
@@ -277,7 +270,6 @@ plot_scatter <- function(counts, subject, suf1, suf2) {
|
|
|
277
270
|
) +
|
|
278
271
|
theme_prism(base_size = 16) +
|
|
279
272
|
scale_size(guide = "none") +
|
|
280
|
-
# theme(legend.position = "none") +
|
|
281
273
|
labs(
|
|
282
274
|
title = bquote(.(subject) ~ (italic(n) == .(n_formatted))),
|
|
283
275
|
subtitle = subtitle
|
|
@@ -302,80 +294,115 @@ plot_venndg <- function(counts, groups, singletons) {
|
|
|
302
294
|
venn <- Venn(venn_data)
|
|
303
295
|
vdata <- process_data(venn)
|
|
304
296
|
vregion <- venn_region(vdata)
|
|
305
|
-
|
|
306
|
-
sregion$count = singletons[sregion$name, "count"]
|
|
307
|
-
sregion <- sregion %>% mutate(name = paste0(name, " singletons"))
|
|
297
|
+
vregion$singleton_count = singletons[vregion$name, "count"]
|
|
308
298
|
vregion <- vregion %>% mutate(
|
|
309
299
|
count_perc = round(count / sum(count) * 100, 1),
|
|
310
|
-
count_str = paste0(count, " (", count_perc, "%)")
|
|
300
|
+
count_str = paste0(count, " (", count_perc, "%)"),
|
|
301
|
+
count_str = if_else(is.na(singleton_count), count_str, paste0(count_str, "\nsingletons = ", singleton_count))
|
|
311
302
|
)
|
|
312
303
|
|
|
313
|
-
# Align the catagory labels
|
|
314
|
-
cat_nudge_y <- 0
|
|
315
|
-
if (length(groups) == 3) { cat_nudge_y <- c(-400, 0, -400) }
|
|
316
|
-
# Shift Count labels
|
|
317
|
-
count_nudge_y <- -10
|
|
318
|
-
if (length(groups) == 3) { count_nudge_y <- c(20, -20, 20, rep(0, nrow(vregion) - 3)) }
|
|
319
|
-
# Shift the singletons stat labels
|
|
320
|
-
label_nudge_y <- 60
|
|
321
|
-
if (length(groups) == 3) { label_nudge_y <- c(60, -60, -60) }
|
|
322
|
-
|
|
323
304
|
venn_p <- ggplot() +
|
|
324
305
|
# 1. region count layer
|
|
325
306
|
geom_sf(aes(fill = count), data = venn_region(vdata)) +
|
|
326
307
|
# 2. set edge layer
|
|
327
308
|
# geom_sf(aes(color = factor(id)), data = venn_setedge(data), show.legend = FALSE) +
|
|
328
309
|
# 3. set label layer
|
|
329
|
-
geom_sf_text(aes(label = name), data = venn_setlabel(vdata)
|
|
310
|
+
geom_sf_text(aes(label = name), data = venn_setlabel(vdata)) +
|
|
330
311
|
# 4. region label layer
|
|
331
312
|
geom_sf_label(
|
|
332
313
|
aes(label = count_str),
|
|
333
314
|
alpha = .8,
|
|
334
315
|
label.padding = unit(.2, "lines"),
|
|
335
|
-
data = vregion
|
|
336
|
-
nudge_y = count_nudge_y
|
|
316
|
+
data = vregion
|
|
337
317
|
) +
|
|
338
318
|
# 5. singletons label layer
|
|
339
319
|
scale_fill_distiller(palette = "Oranges", direction = 1) +
|
|
340
|
-
new_scale_fill() +
|
|
341
|
-
geom_sf_label(
|
|
342
|
-
aes(label = count, fill = name),
|
|
343
|
-
alpha = .6,
|
|
344
|
-
data = sregion,
|
|
345
|
-
nudge_y = label_nudge_y,
|
|
346
|
-
label.padding = unit(1, "lines"),
|
|
347
|
-
label.r = unit(1.2, "lines"),
|
|
348
|
-
label.size = 0.05,
|
|
349
|
-
show.legend = TRUE
|
|
350
|
-
) +
|
|
351
320
|
theme_void() +
|
|
352
|
-
theme(plot.margin = margin(1,1,1,1, "cm"))
|
|
353
|
-
scale_fill_brewer(palette = "Reds", name = "Singletons")
|
|
321
|
+
theme(plot.margin = margin(1,1,1,1, "cm"))
|
|
354
322
|
|
|
355
323
|
venn_p
|
|
356
324
|
}
|
|
357
325
|
|
|
358
|
-
plot_upset <- function(counts, singletons) {
|
|
359
|
-
query_singleton <- function(row) { row["Singletons"] == "true" }
|
|
326
|
+
plot_upset <- function(counts, singletons, upset_ymax, upset_trans) {
|
|
360
327
|
|
|
361
328
|
cnts <- column_to_rownames(counts, "CDR3.aa") %>%
|
|
362
329
|
mutate(across(everything(), ~ as.integer(as.logical(.x))))
|
|
363
330
|
sgltns <- unlist(singletons$CDR3.aa)
|
|
364
|
-
cnts
|
|
365
|
-
cnts[sgltns, "
|
|
366
|
-
sets <- setdiff(colnames(cnts), "
|
|
331
|
+
cnts$..type <- "Multiplets"
|
|
332
|
+
cnts[sgltns, "..type"] <- "Singletons"
|
|
333
|
+
sets <- setdiff(colnames(cnts), "..type")
|
|
334
|
+
|
|
335
|
+
p <- ggplot(mapping = aes(x = intersection, fill = ..type)) +
|
|
336
|
+
theme(
|
|
337
|
+
legend.position = "top",
|
|
338
|
+
legend.title = element_blank(),
|
|
339
|
+
panel.grid = element_blank(),
|
|
340
|
+
axis.line.y = element_line(color = "#3b3b3b"),
|
|
341
|
+
axis.ticks.y = element_line(color = "#3b3b3b"),
|
|
342
|
+
) +
|
|
343
|
+
scale_fill_manual(values = c("#3b3b3b", "orange")) +
|
|
344
|
+
ylab("Intersection size")
|
|
345
|
+
|
|
346
|
+
if (is.null(upset_trans)) {
|
|
347
|
+
p <- p + geom_bar(stat = "count", position = "stack") +
|
|
348
|
+
geom_text(
|
|
349
|
+
aes(label = ..count.., vjust = ifelse(..type == "Multiplets", -0.25, +1.25)),
|
|
350
|
+
stat = "count", position = "stack", size = 2.8)
|
|
351
|
+
if (!is.null(upset_ymax)) {
|
|
352
|
+
p <- p + ylim(0, upset_ymax)
|
|
353
|
+
}
|
|
354
|
+
} else {
|
|
355
|
+
p <- p + geom_bar(stat = "count", position = "dodge2") +
|
|
356
|
+
geom_text(
|
|
357
|
+
aes(label = ..count..),
|
|
358
|
+
stat = "count", position = position_dodge(width = 0.9), vjust = -0.25, size = 2.5)
|
|
359
|
+
|
|
360
|
+
# limit the y and do log10 transformation
|
|
361
|
+
if (!is.null(upset_ymax)) {
|
|
362
|
+
p <- p + scale_y_continuous(trans = "log10", limits = c(1, upset_ymax))
|
|
363
|
+
} else {
|
|
364
|
+
p <- p + scale_y_continuous(trans = "log10")
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
367
|
|
|
368
|
-
upset(
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
368
|
+
upset(
|
|
369
|
+
cnts, rev(sets),
|
|
370
|
+
sort_sets = FALSE,
|
|
371
|
+
# Remove the base annotations
|
|
372
|
+
base_annotations = list(),
|
|
373
|
+
annotations = list('IntersectSize' = p),
|
|
374
|
+
themes = upset_modify_themes(
|
|
375
|
+
list(
|
|
376
|
+
intersections_matrix = theme(
|
|
377
|
+
axis.line = element_line(color = "#3b3b3b"),
|
|
378
|
+
axis.ticks.y = element_line(color = "#3b3b3b"),
|
|
379
|
+
)
|
|
380
|
+
)
|
|
374
381
|
)
|
|
375
|
-
)
|
|
382
|
+
)
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
headings <- function(section, casename, subject) {
|
|
386
|
+
list(h1 = ifelse(
|
|
387
|
+
is.null(section),
|
|
388
|
+
ifelse(casename == "DEFAULT", subject, casename),
|
|
389
|
+
section
|
|
390
|
+
),
|
|
391
|
+
h2 = ifelse(
|
|
392
|
+
is.null(section),
|
|
393
|
+
ifelse(casename == "DEFAULT", "#", subject),
|
|
394
|
+
ifelse(casename == "DEFAULT", subject, casename)
|
|
395
|
+
),
|
|
396
|
+
h3 = ifelse(
|
|
397
|
+
is.null(section),
|
|
398
|
+
"#",
|
|
399
|
+
ifelse(casename == "DEFAULT", "#", subject)
|
|
400
|
+
)
|
|
401
|
+
)
|
|
376
402
|
}
|
|
377
403
|
|
|
378
404
|
handle_subject <- function(i, subjects, casename, case) {
|
|
405
|
+
casedir = file.path(outdir, slugify(casename))
|
|
379
406
|
# Generate a residency table
|
|
380
407
|
# | CDR3.aa | Tumor | Normal |
|
|
381
408
|
# | SEABESRWEFAEF | 0 | 10 |
|
|
@@ -384,10 +411,10 @@ handle_subject <- function(i, subjects, casename, case) {
|
|
|
384
411
|
subject_row <- subjects[i, , drop = FALSE]
|
|
385
412
|
subject <- subject_row %>%
|
|
386
413
|
select(all_of(case$subject)) %>%
|
|
387
|
-
as.character
|
|
414
|
+
mutate(across(everything(), as.character)) %>%
|
|
388
415
|
paste(collapse = "-")
|
|
389
416
|
|
|
390
|
-
|
|
417
|
+
log_info(" Handling {i}/{nrow(subjects)}: {subject} ...")
|
|
391
418
|
|
|
392
419
|
if (!is.null(case$subset)) {
|
|
393
420
|
counts <- cldata %>% filter(!!parse_expr(case$subset))
|
|
@@ -412,10 +439,7 @@ handle_subject <- function(i, subjects, casename, case) {
|
|
|
412
439
|
case$order <- sapply(combn(groups, 2, simplify = FALSE), function(x) paste(x, collapse = ","))
|
|
413
440
|
}
|
|
414
441
|
if (length(unique(counts[[case$group]])) < 2) {
|
|
415
|
-
|
|
416
|
-
paste0("-", casename, ", Subject doesn't have enough groups:", subject),
|
|
417
|
-
immediate. = TRUE
|
|
418
|
-
)
|
|
442
|
+
log_warn(" - Subject doesn't have enough groups: {subject}")
|
|
419
443
|
return()
|
|
420
444
|
}
|
|
421
445
|
singletons = counts %>%
|
|
@@ -435,70 +459,107 @@ handle_subject <- function(i, subjects, casename, case) {
|
|
|
435
459
|
select(CDR3.aa, !!!syms(groups))
|
|
436
460
|
counts[is.na(counts)] <- 0
|
|
437
461
|
|
|
438
|
-
# Save samples to group_by so they can be aligned accordingly in the report
|
|
439
|
-
if (!is.null(section)) {
|
|
440
|
-
group_dir <- file.path(outdir, casename, "section")
|
|
441
|
-
dir.create(group_dir, showWarnings = FALSE)
|
|
442
|
-
|
|
443
|
-
sgroups <- subject_row %>%
|
|
444
|
-
left_join(cldata) %>%
|
|
445
|
-
pull(section) %>%
|
|
446
|
-
unique() %>%
|
|
447
|
-
paste(collapse = "-")
|
|
448
|
-
group_file <- file.path(group_dir, paste0(sgroups, ".txt"))
|
|
449
|
-
cat(subject, file = group_file, sep = "\n", append = TRUE)
|
|
450
|
-
}
|
|
451
|
-
|
|
452
462
|
# Save counts
|
|
453
|
-
counts_dir <- file.path(
|
|
463
|
+
counts_dir <- file.path(casedir, "counts")
|
|
464
|
+
countfile <- file.path(counts_dir, paste0(slugify(subject), ".txt"))
|
|
454
465
|
write.table(
|
|
455
466
|
counts,
|
|
456
|
-
file =
|
|
467
|
+
file = countfile,
|
|
457
468
|
sep = "\t",
|
|
458
469
|
row.names = TRUE,
|
|
459
470
|
col.names = TRUE,
|
|
460
471
|
quote = FALSE
|
|
461
472
|
)
|
|
462
473
|
|
|
474
|
+
h <- headings(case$section, casename, "Clone Size Tables")
|
|
475
|
+
add_report(
|
|
476
|
+
list(kind = "table", src = countfile, ds_name = subject),
|
|
477
|
+
h1 = h$h1,
|
|
478
|
+
h2 = h$h2,
|
|
479
|
+
h3 = h$h3,
|
|
480
|
+
ui = "dropdown_switcher"
|
|
481
|
+
)
|
|
482
|
+
|
|
463
483
|
# scatter plot
|
|
464
484
|
# Make plots B ~ A, C ~ B, and C ~ A for order A, B, C
|
|
465
485
|
# combns <- combn(groups, 2, simplify = FALSE)
|
|
466
|
-
|
|
486
|
+
h <- headings(case$section, casename, "Residency Plots")
|
|
487
|
+
scatter_dir <- file.path(casedir, "scatter")
|
|
467
488
|
for (j in seq_along(case$order)) {
|
|
468
489
|
pair <- strsplit(case$order[j], ",")[[1]]
|
|
469
490
|
if (length(setdiff(pair, groups)) > 0) {
|
|
470
|
-
|
|
471
|
-
paste0(
|
|
472
|
-
"- One of the comparisons doesn't exist in case (", casename,
|
|
473
|
-
") for subject (", subject, "): ",
|
|
474
|
-
case$order[j]
|
|
475
|
-
),
|
|
476
|
-
immediate. = TRUE
|
|
477
|
-
)
|
|
491
|
+
log_warn(" - Comparison {case$order[j]} doesn't exist.")
|
|
478
492
|
next
|
|
479
493
|
}
|
|
480
494
|
scatter_p <- plot_scatter(counts, subject, pair[1], pair[2])
|
|
481
495
|
scatter_png <- file.path(
|
|
482
496
|
scatter_dir,
|
|
483
|
-
paste0("scatter_", subject, "_", pair[1], "_", pair[2], ".png")
|
|
497
|
+
paste0("scatter_", slugify(subject), "_", slugify(pair[1]), "_", slugify(pair[2]), ".png")
|
|
484
498
|
)
|
|
485
499
|
png(scatter_png, res = 100, height = 800, width = 1000)
|
|
486
500
|
print(scatter_p)
|
|
487
501
|
dev.off()
|
|
502
|
+
|
|
503
|
+
scatter_pdf <- gsub(".png$", ".pdf", scatter_png)
|
|
504
|
+
pdf(scatter_pdf, width = 10, height = 8)
|
|
505
|
+
print(scatter_p)
|
|
506
|
+
dev.off()
|
|
507
|
+
|
|
508
|
+
add_report(
|
|
509
|
+
list(
|
|
510
|
+
name = paste0(subject, " (", pair[1], " - ", pair[2], ")"),
|
|
511
|
+
src = scatter_png,
|
|
512
|
+
download = scatter_pdf
|
|
513
|
+
),
|
|
514
|
+
h1 = h$h1,
|
|
515
|
+
h2 = h$h2,
|
|
516
|
+
h3 = h$h3,
|
|
517
|
+
ui = "table_of_images:3"
|
|
518
|
+
)
|
|
488
519
|
}
|
|
489
520
|
|
|
490
521
|
# upset/venn
|
|
491
|
-
venn_dir <- file.path(
|
|
492
|
-
venn_png <- file.path(venn_dir, paste0("venn_", subject, ".png"))
|
|
522
|
+
venn_dir <- file.path(casedir, "venn")
|
|
523
|
+
venn_png <- file.path(venn_dir, paste0("venn_", slugify(subject), ".png"))
|
|
524
|
+
venn_pdf <- gsub(".png$", ".pdf", venn_png)
|
|
525
|
+
p <- plot_venndg(counts, groups, singletons)
|
|
493
526
|
png(venn_png, res = 100, height = 600, width = 800)
|
|
494
|
-
print(
|
|
527
|
+
print(p)
|
|
495
528
|
dev.off()
|
|
496
529
|
|
|
497
|
-
|
|
498
|
-
|
|
530
|
+
pdf(venn_pdf, width = 8, height = 6)
|
|
531
|
+
print(p)
|
|
532
|
+
dev.off()
|
|
533
|
+
|
|
534
|
+
h <- headings(case$section, casename, "Overlapping Clones (Venn Diagram)")
|
|
535
|
+
add_report(
|
|
536
|
+
list(src = venn_png, name = subject, download = venn_pdf),
|
|
537
|
+
h1 = h$h1,
|
|
538
|
+
h2 = h$h2,
|
|
539
|
+
h3 = h$h3,
|
|
540
|
+
ui = "table_of_images:3"
|
|
541
|
+
)
|
|
542
|
+
|
|
543
|
+
upset_dir <- file.path(casedir, "upset")
|
|
544
|
+
upset_png <- file.path(upset_dir, paste0("upset_", slugify(subject), ".png"))
|
|
545
|
+
upset_pdf <- gsub(".png$", ".pdf", upset_png)
|
|
546
|
+
p <- plot_upset(counts, singletons, case$upset_ymax, case$upset_trans)
|
|
499
547
|
png(upset_png, res = 100, height = 600, width = 800)
|
|
500
|
-
print(
|
|
548
|
+
print(p)
|
|
501
549
|
dev.off()
|
|
550
|
+
|
|
551
|
+
pdf(upset_pdf, width = 8, height = 6)
|
|
552
|
+
print(p)
|
|
553
|
+
dev.off()
|
|
554
|
+
|
|
555
|
+
h <- headings(case$section, casename, "Overlapping Clones (UpSet Plots)")
|
|
556
|
+
add_report(
|
|
557
|
+
list(src = upset_png, name = subject, download = upset_pdf),
|
|
558
|
+
h1 = h$h1,
|
|
559
|
+
h2 = h$h2,
|
|
560
|
+
h3 = h$h3,
|
|
561
|
+
ui = "table_of_images:3"
|
|
562
|
+
)
|
|
502
563
|
}
|
|
503
564
|
|
|
504
565
|
handle_case <- function(casename, case) {
|
|
@@ -513,9 +574,72 @@ handle_case <- function(casename, case) {
|
|
|
513
574
|
distinct(!!!syms(case$subject)) %>%
|
|
514
575
|
drop_na()
|
|
515
576
|
}
|
|
577
|
+
|
|
578
|
+
h <- headings(case$section, casename, "Clone Size Tables")
|
|
579
|
+
add_report(
|
|
580
|
+
list(ds_name = "Select a subject ..."),
|
|
581
|
+
h1 = h$h1,
|
|
582
|
+
h2 = h$h2,
|
|
583
|
+
h3 = h$h3,
|
|
584
|
+
ui = "dropdown_switcher"
|
|
585
|
+
)
|
|
586
|
+
|
|
587
|
+
h <- headings(case$section, casename, "Residency Plots")
|
|
588
|
+
add_report(
|
|
589
|
+
list(
|
|
590
|
+
kind = "descr",
|
|
591
|
+
content = paste0(
|
|
592
|
+
"The residency plots showing the clones of paired samples (x-axis and y-axis). ",
|
|
593
|
+
"The size of the dot represents the relative abundance of the clone. ",
|
|
594
|
+
"The color of the dot represents the type of the clone: "
|
|
595
|
+
)
|
|
596
|
+
),
|
|
597
|
+
list(
|
|
598
|
+
kind = "list",
|
|
599
|
+
items = c(
|
|
600
|
+
"Collapsed (clones that are less abundant in the y-axis sample)",
|
|
601
|
+
"Dual (clones that are equally abundant in both samples)",
|
|
602
|
+
"Expanded (clones that are more abundant in the y-axis sample)",
|
|
603
|
+
"(x-axis sample) Multiplet (clones that are only present in the x-axis sample, with multiple cells)",
|
|
604
|
+
"(x-axis sample) Singleton (clones that are only present in the x-axis sample, with a single cell)",
|
|
605
|
+
"(y-axis sample) Multiplet (clones that are only present in the y-axis sample, with multiple cells)",
|
|
606
|
+
"(y-axis sample) Singleton (clones that are only present in the y-axis sample, with a single cell)"
|
|
607
|
+
)
|
|
608
|
+
),
|
|
609
|
+
h1 = h$h1,
|
|
610
|
+
h2 = h$h2,
|
|
611
|
+
h3 = h$h3,
|
|
612
|
+
ui = "flat"
|
|
613
|
+
)
|
|
614
|
+
|
|
615
|
+
h <- headings(case$section, casename, "Overlapping Clones (Venn Diagram)")
|
|
616
|
+
add_report(
|
|
617
|
+
list(
|
|
618
|
+
kind = "descr",
|
|
619
|
+
content = "For samples in each subject, showing the overlapping clones between samples in Venn diagrams."
|
|
620
|
+
),
|
|
621
|
+
h1 = h$h1,
|
|
622
|
+
h2 = h$h2,
|
|
623
|
+
h3 = h$h3,
|
|
624
|
+
ui = "flat"
|
|
625
|
+
)
|
|
626
|
+
|
|
627
|
+
h <- headings(case$section, casename, "Overlapping Clones (UpSet Plots)")
|
|
628
|
+
add_report(
|
|
629
|
+
list(
|
|
630
|
+
kind = "descr",
|
|
631
|
+
content = "For samples in each subject, showing the overlapping clones between samples in UpSet plots."
|
|
632
|
+
),
|
|
633
|
+
h1 = h$h1,
|
|
634
|
+
h2 = h$h2,
|
|
635
|
+
h3 = h$h3,
|
|
636
|
+
ui = "flat"
|
|
637
|
+
)
|
|
516
638
|
sapply(seq_len(nrow(subjects)), handle_subject, subjects, casename, case)
|
|
517
639
|
}
|
|
518
640
|
|
|
519
|
-
for (casename in names(cases)) {
|
|
641
|
+
for (casename in sort(names(cases))) {
|
|
520
642
|
handle_case(casename, cases[[casename]])
|
|
521
|
-
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
save_report(joboutdir)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
{{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
|
|
2
|
+
{{ biopipen_dir | joinpaths: "utils", "plot.R" | source_r }}
|
|
3
3
|
|
|
4
4
|
library(dplyr)
|
|
5
5
|
library(tidyr)
|
|
6
6
|
library(ggprism)
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
immfile <- {{ in.immdata |
|
|
10
|
-
outdir <- {{ out.outdir |
|
|
9
|
+
immfile <- {{ in.immdata | r }}
|
|
10
|
+
outdir <- {{ out.outdir | r }}
|
|
11
11
|
|
|
12
12
|
subject_key <- {{ envs.subject | r }}
|
|
13
13
|
group_key <- {{ envs.group | r }}
|