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,9 +1,12 @@
|
|
|
1
1
|
# loaded variables
|
|
2
2
|
# immfile, outdir, mutaters, immdata, n_samples
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
log_info("")
|
|
5
|
+
log_info("# Gene usage analysis")
|
|
6
|
+
log_info("-----------------------------------")
|
|
5
7
|
|
|
6
8
|
# Fill up cases
|
|
9
|
+
log_info("Filling up cases ...")
|
|
7
10
|
cases = gene_usages$cases
|
|
8
11
|
if (is.null(cases) || length(cases) == 0) {
|
|
9
12
|
cases$DEFAULT = list(
|
|
@@ -92,7 +95,8 @@ for (name in names(cases)) {
|
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
do_one_case_geneusage = function(name, case, gu_dir) {
|
|
95
|
-
print(paste0(" Case: ", name))
|
|
98
|
+
# print(paste0(" Case: ", name))
|
|
99
|
+
log_info("Processing case: {name} ...")
|
|
96
100
|
odir = file.path(gu_dir, name)
|
|
97
101
|
dir.create(odir, showWarnings = FALSE)
|
|
98
102
|
|
|
@@ -119,15 +123,36 @@ do_one_case_geneusage = function(name, case, gu_dir) {
|
|
|
119
123
|
|
|
120
124
|
ofig = file.path(odir, paste0(name, ".png"))
|
|
121
125
|
png(ofig, width = case$devpars$width, height = case$devpars$height, res = case$devpars$res)
|
|
122
|
-
print(p)
|
|
126
|
+
print(p + scale_fill_biopipen())
|
|
123
127
|
dev.off()
|
|
124
128
|
|
|
129
|
+
ofig_pdf = file.path(odir, paste0(name, ".pdf"))
|
|
130
|
+
pdf(ofig_pdf, width = case$devpars$width / case$devpars$res, height = case$devpars$height / case$devpars$res)
|
|
131
|
+
print(p + scale_fill_biopipen())
|
|
132
|
+
dev.off()
|
|
133
|
+
|
|
134
|
+
add_report(
|
|
135
|
+
list(
|
|
136
|
+
kind = "table_image",
|
|
137
|
+
src = ofig,
|
|
138
|
+
download = ofig_pdf,
|
|
139
|
+
descr = paste0(
|
|
140
|
+
"Distribution of known gene segments following the ",
|
|
141
|
+
'<a href="http://www.imgt.org/IMGTrepertoire/LocusGenes/" target="_blank">IMGT</a> ',
|
|
142
|
+
"nomenclature."
|
|
143
|
+
)
|
|
144
|
+
),
|
|
145
|
+
h1 = "Gene Usage",
|
|
146
|
+
h2 = ifelse(name == "DEFAULT", "#", name)
|
|
147
|
+
)
|
|
148
|
+
|
|
125
149
|
if (!is.null(case$analyses$cases) && length(case$analyses$cases) > 0) {
|
|
126
150
|
for (aname in names(case$analyses$cases)) {
|
|
127
151
|
if (case$analyses$cases[[aname]]$method == "none") {
|
|
128
152
|
next
|
|
129
153
|
}
|
|
130
|
-
print(paste0(" Analysis: ", aname))
|
|
154
|
+
# print(paste0(" Analysis: ", aname))
|
|
155
|
+
log_info("- Processing analysis: {aname} ...")
|
|
131
156
|
tryCatch({
|
|
132
157
|
imm_gua = geneUsageAnalysis(imm_gu, .method = case$analyses$cases[[aname]]$method)
|
|
133
158
|
}, error = function(e) {
|
|
@@ -146,12 +171,28 @@ do_one_case_geneusage = function(name, case, gu_dir) {
|
|
|
146
171
|
ap = do_call(vis, avis_args)
|
|
147
172
|
if (aname == "DEFAULT") {
|
|
148
173
|
aofig = file.path(odir, paste0(name, "-analysis.png"))
|
|
174
|
+
aofig_pdf = file.path(odir, paste0(name, "-analysis.pdf"))
|
|
149
175
|
} else {
|
|
150
176
|
aofig = file.path(odir, paste0(name, "-", aname, "-analysis.png"))
|
|
177
|
+
aofig_pdf = file.path(odir, paste0(name, "-", aname, "-analysis.pdf"))
|
|
151
178
|
}
|
|
152
179
|
png(aofig, width = case$analyses$cases[[aname]]$devpars$width, height = case$analyses$cases[[aname]]$devpars$height, res = case$analyses$cases[[aname]]$devpars$res)
|
|
153
180
|
print(ap)
|
|
154
181
|
dev.off()
|
|
182
|
+
|
|
183
|
+
pdf(aofig_pdf,
|
|
184
|
+
width = case$analyses$cases[[aname]]$devpars$width / case$analyses$cases[[aname]]$devpars$res,
|
|
185
|
+
height = case$analyses$cases[[aname]]$devpars$height / case$analyses$cases[[aname]]$devpars$res)
|
|
186
|
+
print(ap)
|
|
187
|
+
dev.off()
|
|
188
|
+
|
|
189
|
+
add_report(
|
|
190
|
+
list(src = aofig, name = aname, download = aofig_pdf),
|
|
191
|
+
h1 = "Gene Usage",
|
|
192
|
+
h2 = ifelse(name == "DEFAULT", "#", name),
|
|
193
|
+
h3 = "Gene Usage Analysis",
|
|
194
|
+
ui = "table_of_images"
|
|
195
|
+
)
|
|
155
196
|
}
|
|
156
197
|
}
|
|
157
198
|
}
|
|
@@ -159,7 +200,6 @@ do_one_case_geneusage = function(name, case, gu_dir) {
|
|
|
159
200
|
gu_dir = file.path(outdir, "gene_usage")
|
|
160
201
|
dir.create(gu_dir, showWarnings = FALSE)
|
|
161
202
|
|
|
162
|
-
print("- Gene usage")
|
|
163
203
|
for (name in names(cases)) {
|
|
164
204
|
do_one_case_geneusage(name, cases[[name]], gu_dir)
|
|
165
205
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# loaded variables
|
|
2
2
|
# immfile, outdir, mutaters, immdata, n_samples
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
log_info("")
|
|
5
|
+
log_info("# K-mer analysis")
|
|
6
|
+
log_info("-----------------------------------")
|
|
5
7
|
|
|
6
8
|
# Fill up cases
|
|
9
|
+
log_info("Filling up cases ...")
|
|
7
10
|
cases = kmers$cases
|
|
8
11
|
if (is.null(cases) || length(cases) == 0) {
|
|
9
12
|
cases$DEFAULT = list(
|
|
@@ -80,8 +83,9 @@ for (name in names(cases)) {
|
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
do_one_case_kmer = function(name, case, kmer_dir) {
|
|
83
|
-
print(paste0(" Case: ", name))
|
|
84
|
-
|
|
86
|
+
# print(paste0(" Case: ", name))
|
|
87
|
+
log_info("Processing case: {name} ...")
|
|
88
|
+
odir = file.path(kmer_dir, slugify(name))
|
|
85
89
|
dir.create(odir, showWarnings = FALSE)
|
|
86
90
|
|
|
87
91
|
if (!is.null(case$subset)) {
|
|
@@ -101,34 +105,90 @@ do_one_case_kmer = function(name, case, kmer_dir) {
|
|
|
101
105
|
print(p)
|
|
102
106
|
dev.off()
|
|
103
107
|
|
|
108
|
+
ofig_pdf = file.path(odir, "Allsamples.pdf")
|
|
109
|
+
pdf(ofig_pdf, width = case$devpars$width / case$devpars$res, height = case$devpars$height / case$devpars$res)
|
|
110
|
+
print(p)
|
|
111
|
+
dev.off()
|
|
112
|
+
|
|
113
|
+
add_report(
|
|
114
|
+
list(
|
|
115
|
+
kind = "descr",
|
|
116
|
+
content = "K-mer sequence occurrences and motif analysis of CDR3 amino acid sequences"
|
|
117
|
+
),
|
|
118
|
+
h1 = "Kmer and sequence motif analysis",
|
|
119
|
+
h2 = ifelse(name == "DEFAULT", "#", name),
|
|
120
|
+
h3 = "Kmer sequence occurrences"
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
add_report(
|
|
124
|
+
list(kind = "image", src = ofig, download = ofig_pdf),
|
|
125
|
+
h1 = "Kmer and sequence motif analysis",
|
|
126
|
+
h2 = ifelse(name == "DEFAULT", "#", name),
|
|
127
|
+
h3 = "Kmer sequence occurrences"
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
add_report(
|
|
131
|
+
h1 = "Kmer and sequence motif analysis",
|
|
132
|
+
h2 = ifelse(name == "DEFAULT", "#", name),
|
|
133
|
+
h3 = "Motif analysis"
|
|
134
|
+
)
|
|
135
|
+
|
|
104
136
|
for (sample in names(d$data)) {
|
|
105
|
-
print(paste0(" Sample: ", sample))
|
|
137
|
+
# print(paste0(" Sample: ", sample))
|
|
138
|
+
log_info("- Sample: {sample} ...")
|
|
106
139
|
imm_kmer = getKmers(d$data[[sample]], case$k)
|
|
107
140
|
|
|
108
141
|
if (!is.null(case$profiles$cases) && length(case$profiles$cases) > 0) {
|
|
109
142
|
for (aname in names(case$profiles$cases)) {
|
|
110
|
-
print(paste0(" Profiling: ", aname))
|
|
143
|
+
# print(paste0(" Profiling: ", aname))
|
|
144
|
+
log_info(" Profiling: {aname} ...")
|
|
111
145
|
imm_kmera = kmer_profile(imm_kmer, case$profiles$cases[[aname]]$method)
|
|
112
146
|
avis_args = case$profiles$cases[[aname]]$vis_args
|
|
113
147
|
avis_args$.data = imm_kmera
|
|
114
148
|
ap = do_call(vis, avis_args)
|
|
115
149
|
if (aname == "DEFAULT") {
|
|
116
|
-
aofig = file.path(odir, paste0(sample, "-profile.png"))
|
|
150
|
+
aofig = file.path(odir, paste0(slugify(sample), "-profile.png"))
|
|
117
151
|
} else {
|
|
118
|
-
aofig = file.path(odir, paste0(sample, "-", aname, "-profile.png"))
|
|
152
|
+
aofig = file.path(odir, paste0(slugify(sample), "-", slugify(aname), "-profile.png"))
|
|
119
153
|
}
|
|
120
154
|
png(aofig, width = case$profiles$cases[[aname]]$devpars$width, height = case$profiles$cases[[aname]]$devpars$height, res = case$profiles$cases[[aname]]$devpars$res)
|
|
121
155
|
print(ap)
|
|
122
156
|
dev.off()
|
|
157
|
+
|
|
158
|
+
aofig_pdf = gsub(".png$", ".pdf", aofig)
|
|
159
|
+
pdf(aofig_pdf,
|
|
160
|
+
width = case$profiles$cases[[aname]]$devpars$width / case$profiles$cases[[aname]]$devpars$res,
|
|
161
|
+
height = case$profiles$cases[[aname]]$devpars$height / case$profiles$cases[[aname]]$devpars$res)
|
|
162
|
+
print(ap)
|
|
163
|
+
dev.off()
|
|
164
|
+
|
|
165
|
+
add_report(
|
|
166
|
+
list(
|
|
167
|
+
src = aofig,
|
|
168
|
+
download = aofig_pdf,
|
|
169
|
+
name = paste0(sample, ifelse(aname == "DEFAULT", "", paste0(" - ", aname)))
|
|
170
|
+
),
|
|
171
|
+
h1 = "Kmer and sequence motif analysis",
|
|
172
|
+
h2 = ifelse(name == "DEFAULT", "#", name),
|
|
173
|
+
h3 = "Motif analysis",
|
|
174
|
+
ui = "table_of_images"
|
|
175
|
+
)
|
|
123
176
|
}
|
|
124
177
|
}
|
|
125
178
|
}
|
|
126
179
|
}
|
|
127
180
|
|
|
181
|
+
add_report(
|
|
182
|
+
list(
|
|
183
|
+
kind = "descr",
|
|
184
|
+
content = "Counting k-mer occurrences"
|
|
185
|
+
),
|
|
186
|
+
h1 = "Kmer and sequence motif analysis"
|
|
187
|
+
)
|
|
188
|
+
|
|
128
189
|
kmer_dir = file.path(outdir, "kmer")
|
|
129
190
|
dir.create(kmer_dir, showWarnings = FALSE)
|
|
130
191
|
|
|
131
|
-
print("- K-mer analysis")
|
|
132
192
|
for (name in names(cases)) {
|
|
133
193
|
do_one_case_kmer(name, cases[[name]], kmer_dir)
|
|
134
194
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# loaded variables
|
|
2
2
|
# immfile, outdir, mutaters, immdata, n_samples
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
log_info("")
|
|
5
|
+
log_info("# Overlap analysis")
|
|
6
|
+
log_info("-----------------------------------")
|
|
5
7
|
|
|
6
8
|
# Fill up cases
|
|
7
9
|
cases = overlaps$cases
|
|
@@ -75,8 +77,48 @@ for (name in names(cases)) {
|
|
|
75
77
|
cases[[name]]$analyses = analyses
|
|
76
78
|
}
|
|
77
79
|
|
|
80
|
+
get_method_descr <- function(method) {
|
|
81
|
+
descr <- switch(method,
|
|
82
|
+
public = paste0(
|
|
83
|
+
"number of public (shared) clonotypes, ",
|
|
84
|
+
"a classic measure of overlap similarity"
|
|
85
|
+
),
|
|
86
|
+
overlap = paste0(
|
|
87
|
+
"overlap coefficient, a normalised measure of overlap similarity. ",
|
|
88
|
+
"It is defined as the size of the intersection divided by the smaller of ",
|
|
89
|
+
"the size of the two sets."
|
|
90
|
+
),
|
|
91
|
+
jaccard = paste0(
|
|
92
|
+
"Jaccard index, measures the similarity between finite sample sets, ",
|
|
93
|
+
"and is defined as the size of the intersection divided by the size of ",
|
|
94
|
+
"the union of the sample sets."
|
|
95
|
+
),
|
|
96
|
+
tversky = paste0(
|
|
97
|
+
"Tversky index, an asymmetric similarity measure on sets that compares ",
|
|
98
|
+
"a variant to a prototype. ",
|
|
99
|
+
"If using default arguments, it’s similar to Dice’s coefficient."
|
|
100
|
+
),
|
|
101
|
+
cosine = "cosine similarity, a measure of similarity between two non-zero vectors",
|
|
102
|
+
morisita = paste0(
|
|
103
|
+
"Morisita's overlap index, a statistical measure of dispersion of ",
|
|
104
|
+
"individuals in a population. ",
|
|
105
|
+
"It is used to compare overlap among samples."
|
|
106
|
+
)
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
if (!is.null(descr)) {
|
|
110
|
+
return(descr)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return(paste0(
|
|
114
|
+
"incremental overlap, ",
|
|
115
|
+
"overlaps of the N most abundant clonotypes with incrementally growing N"
|
|
116
|
+
))
|
|
117
|
+
}
|
|
118
|
+
|
|
78
119
|
do_one_case_overlap = function(name, case, ov_dir) {
|
|
79
|
-
print(paste0(" Case: ", name))
|
|
120
|
+
# print(paste0(" Case: ", name))
|
|
121
|
+
log_info("Processing case: {name} ...")
|
|
80
122
|
odir = file.path(ov_dir, name)
|
|
81
123
|
dir.create(odir, showWarnings = FALSE)
|
|
82
124
|
|
|
@@ -96,11 +138,32 @@ do_one_case_overlap = function(name, case, ov_dir) {
|
|
|
96
138
|
print(p)
|
|
97
139
|
dev.off()
|
|
98
140
|
|
|
141
|
+
ofig_pdf = file.path(odir, paste0(name, ".pdf"))
|
|
142
|
+
pdf(ofig_pdf, width = case$devpars$width / case$devpars$res, height = case$devpars$height / case$devpars$res)
|
|
143
|
+
print(p)
|
|
144
|
+
dev.off()
|
|
145
|
+
|
|
146
|
+
add_report(
|
|
147
|
+
list(
|
|
148
|
+
kind = "table_image",
|
|
149
|
+
src = ofig,
|
|
150
|
+
download = ofig_pdf,
|
|
151
|
+
descr = paste0(
|
|
152
|
+
"Repertoire overlap is the most common approach to measure repertoire similarity, ",
|
|
153
|
+
"using method <code>", case$method, "</code>, ",
|
|
154
|
+
get_method_descr(case$method)
|
|
155
|
+
)
|
|
156
|
+
),
|
|
157
|
+
h1 = "Repertoire Overlaps",
|
|
158
|
+
h2 = ifelse(name == "DEFAULT", "#", name)
|
|
159
|
+
)
|
|
160
|
+
|
|
99
161
|
if (!is.null(case$analyses$cases) && length(case$analyses$cases) > 0) {
|
|
100
162
|
for (aname in names(case$analyses$cases)) {
|
|
101
163
|
if (case$analyses$cases[[aname]]$method == "none") next
|
|
102
164
|
|
|
103
|
-
print(paste0(" Analysis: ", aname))
|
|
165
|
+
# print(paste0(" Analysis: ", aname))
|
|
166
|
+
log_info("- Processing analysis: {aname} ...")
|
|
104
167
|
k = min(n_samples - 1, 2)
|
|
105
168
|
tryCatch({
|
|
106
169
|
imm_ova = repOverlapAnalysis(
|
|
@@ -122,12 +185,29 @@ do_one_case_overlap = function(name, case, ov_dir) {
|
|
|
122
185
|
ap = do_call(vis, avis_args)
|
|
123
186
|
if (aname == "DEFAULT") {
|
|
124
187
|
aofig = file.path(odir, paste0(name, "-analysis.png"))
|
|
188
|
+
aofig_pdf = file.path(odir, paste0(name, "-analysis.pdf"))
|
|
125
189
|
} else {
|
|
126
190
|
aofig = file.path(odir, paste0(name, "-", aname, "-analysis.png"))
|
|
191
|
+
aofig_pdf = file.path(odir, paste0(name, "-", aname, "-analysis.pdf"))
|
|
127
192
|
}
|
|
128
193
|
png(aofig, width = case$analyses$cases[[aname]]$devpars$width, height = case$analyses$cases[[aname]]$devpars$height, res = case$analyses$cases[[aname]]$devpars$res)
|
|
129
194
|
print(ap)
|
|
130
195
|
dev.off()
|
|
196
|
+
|
|
197
|
+
pdf(aofig_pdf,
|
|
198
|
+
width = case$analyses$cases[[aname]]$devpars$width / case$analyses$cases[[aname]]$devpars$res,
|
|
199
|
+
height = case$analyses$cases[[aname]]$devpars$height / case$analyses$cases[[aname]]$devpars$res)
|
|
200
|
+
print(ap)
|
|
201
|
+
dev.off()
|
|
202
|
+
|
|
203
|
+
add_report(
|
|
204
|
+
list(src = aofig, name = aname, download = aofig_pdf),
|
|
205
|
+
h1 = "Repertoire Overlaps",
|
|
206
|
+
h2 = ifelse(name == "DEFAULT", "#", name),
|
|
207
|
+
h3 = "Repertoire Overlap Analysis",
|
|
208
|
+
ui = "table_of_images"
|
|
209
|
+
)
|
|
210
|
+
|
|
131
211
|
}
|
|
132
212
|
}
|
|
133
213
|
}
|
|
@@ -135,7 +215,7 @@ do_one_case_overlap = function(name, case, ov_dir) {
|
|
|
135
215
|
ov_dir = file.path(outdir, "overlap")
|
|
136
216
|
dir.create(ov_dir, showWarnings = FALSE)
|
|
137
217
|
|
|
138
|
-
print("- Overlap")
|
|
218
|
+
# print("- Overlap")
|
|
139
219
|
for (name in names(cases)) {
|
|
140
220
|
do_one_case_overlap(name, cases[[name]], ov_dir)
|
|
141
221
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# loaded variables
|
|
2
2
|
# immfile, outdir, mutaters, immdata, n_samples
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
log_info("")
|
|
5
|
+
log_info("# Spectratyping analysis")
|
|
6
|
+
log_info("-----------------------------------")
|
|
5
7
|
|
|
6
8
|
# Fill up cases
|
|
9
|
+
log_info("Filling up cases ...")
|
|
7
10
|
if (is.null(spects$cases) || length(spects$cases) == 0) {
|
|
8
11
|
spects$cases$DEFAULT = list(
|
|
9
12
|
quant = spects$quant,
|
|
@@ -37,8 +40,9 @@ if (is.null(spects$cases) || length(spects$cases) == 0) {
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
do_one_case_spectratyping = function(name, case, spect_dir) {
|
|
40
|
-
print(paste0(" Case: ", name))
|
|
41
|
-
|
|
43
|
+
# print(paste0(" Case: ", name))
|
|
44
|
+
log_info("- Processing case: {name} ...")
|
|
45
|
+
odir = file.path(spect_dir, slugify(name))
|
|
42
46
|
dir.create(odir, showWarnings = FALSE)
|
|
43
47
|
|
|
44
48
|
if (!is.null(case$subset)) {
|
|
@@ -48,24 +52,49 @@ do_one_case_spectratyping = function(name, case, spect_dir) {
|
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
for (sample in names(d$data)) {
|
|
51
|
-
print(paste0(" Sample: ", sample))
|
|
55
|
+
# print(paste0(" Sample: ", sample))
|
|
56
|
+
log_info(" Sample: {sample} ...")
|
|
52
57
|
spec_obj = spectratype(
|
|
53
58
|
d$data[[sample]],
|
|
54
59
|
.quant = case$quant,
|
|
55
60
|
.col = case$col
|
|
56
61
|
)
|
|
62
|
+
spectfile = file.path(odir, paste0(slugify(sample), ".spect.png"))
|
|
57
63
|
png(
|
|
58
|
-
|
|
64
|
+
spectfile,
|
|
59
65
|
res = case$devpars$res,
|
|
60
66
|
width = case$devpars$width,
|
|
61
67
|
height = case$devpars$height
|
|
62
68
|
)
|
|
63
69
|
print(vis(spec_obj))
|
|
64
70
|
dev.off()
|
|
71
|
+
|
|
72
|
+
spectfile_pdf = file.path(odir, paste0(slugify(sample), ".spect.pdf"))
|
|
73
|
+
pdf(
|
|
74
|
+
spectfile_pdf,
|
|
75
|
+
width = case$devpars$width / case$devpars$res,
|
|
76
|
+
height = case$devpars$height / case$devpars$res
|
|
77
|
+
)
|
|
78
|
+
print(vis(spec_obj))
|
|
79
|
+
dev.off()
|
|
80
|
+
|
|
81
|
+
add_report(
|
|
82
|
+
list(src = spectfile, name = sample, download = spectfile_pdf),
|
|
83
|
+
h1 = "Spectratyping",
|
|
84
|
+
h2 = name,
|
|
85
|
+
ui = "table_of_images"
|
|
86
|
+
)
|
|
65
87
|
}
|
|
66
88
|
}
|
|
67
89
|
|
|
68
|
-
|
|
90
|
+
add_report(
|
|
91
|
+
list(
|
|
92
|
+
kind = "descr",
|
|
93
|
+
content = "Spectratype is a useful way to represent distributions of genes per sequence length."
|
|
94
|
+
),
|
|
95
|
+
h1 = "Spectratyping"
|
|
96
|
+
)
|
|
97
|
+
|
|
69
98
|
spect_dir = file.path(outdir, "spectratyping")
|
|
70
99
|
dir.create(spect_dir, showWarnings = FALSE)
|
|
71
100
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
log_info("")
|
|
2
|
+
log_info("# Clonotype tracking")
|
|
3
|
+
log_info("-----------------------------------")
|
|
4
4
|
|
|
5
|
+
log_info("Filling up cases ...")
|
|
5
6
|
if (is.null(trackings$subjects)) {
|
|
6
7
|
trackings$subjects = c()
|
|
7
8
|
}
|
|
@@ -41,9 +42,11 @@ run_tracking_case = function(casename) {
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
if (is.null(case$targets)) {
|
|
44
|
-
print(paste0(" ", casename, ", skip, no targets"))
|
|
45
|
+
# print(paste0(" ", casename, ", skip, no targets"))
|
|
46
|
+
log_info("- Case: {casename}, skip, no targets")
|
|
45
47
|
} else {
|
|
46
|
-
print(paste0(" ", casename))
|
|
48
|
+
# print(paste0(" ", casename))
|
|
49
|
+
log_info("- Case: {casename}")
|
|
47
50
|
allsubjects = d$meta %>% pull(case$subject_col) %>% unlist() %>% unique() %>% na.omit()
|
|
48
51
|
if (is.null(case$subjects) || length(case$subjects) == 0) {
|
|
49
52
|
subjects = allsubjects
|
|
@@ -80,10 +83,39 @@ run_tracking_case = function(casename) {
|
|
|
80
83
|
imm_tracking = trackClonotypes(newdata, targets, .col = "aa")
|
|
81
84
|
}
|
|
82
85
|
|
|
83
|
-
tracking_png = file.path(tracking_dir, paste0(casename, ".png"))
|
|
86
|
+
tracking_png = file.path(tracking_dir, paste0(slugify(casename), ".png"))
|
|
84
87
|
png(tracking_png, res=100, height=1000, width=600 + 150 * length(subjects))
|
|
85
88
|
print(vis(imm_tracking))
|
|
86
89
|
dev.off()
|
|
90
|
+
|
|
91
|
+
tracking_pdf = file.path(tracking_dir, paste0(slugify(casename), ".pdf"))
|
|
92
|
+
pdf(tracking_pdf, height=10, width=6 + 1.5 * length(subjects))
|
|
93
|
+
print(vis(imm_tracking))
|
|
94
|
+
dev.off()
|
|
95
|
+
|
|
96
|
+
add_report(
|
|
97
|
+
list(
|
|
98
|
+
kind = "descr",
|
|
99
|
+
content = paste0(
|
|
100
|
+
"Clonotype tracking is a popular approach to monitor changes in the frequency of ",
|
|
101
|
+
"clonotypes of interest in vaccination and cancer immunology. ",
|
|
102
|
+
"For example, a researcher can track a clonotype across different time points ",
|
|
103
|
+
"in pre- and post-vaccination repertoires, or analyse the growth of ",
|
|
104
|
+
"malignant clonotypes in a tumor sample."
|
|
105
|
+
)
|
|
106
|
+
),
|
|
107
|
+
h1 = "Tracking of clonotypes"
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
add_report(
|
|
111
|
+
list(
|
|
112
|
+
src = tracking_png,
|
|
113
|
+
download = tracking_pdf,
|
|
114
|
+
name = if (casename == "DEFAULT") NULL else casename
|
|
115
|
+
),
|
|
116
|
+
h1 = "Tracking of clonotypes",
|
|
117
|
+
ui = "table_of_images"
|
|
118
|
+
)
|
|
87
119
|
}
|
|
88
120
|
}
|
|
89
121
|
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
log_info("")
|
|
2
|
+
log_info("# VJ Junction Circos Plots")
|
|
3
|
+
log_info("-----------------------------------")
|
|
4
|
+
|
|
5
|
+
# Already required by immunarch
|
|
6
|
+
library(circlize)
|
|
7
|
+
|
|
8
|
+
log_info("Filling up cases ...")
|
|
9
|
+
cases <- vj_juncs$cases
|
|
10
|
+
if (is.null(cases) || length(cases) == 0) {
|
|
11
|
+
cases$DEFAULT <- list(
|
|
12
|
+
by = vj_juncs$by,
|
|
13
|
+
by_clones = vj_juncs$by_clones,
|
|
14
|
+
subset = vj_juncs$subset,
|
|
15
|
+
devpars = vj_juncs$devpars
|
|
16
|
+
)
|
|
17
|
+
} else {
|
|
18
|
+
for (name in names(cases)) {
|
|
19
|
+
if (is.null(cases[[name]]$by)) {
|
|
20
|
+
cases[[name]]$by <- vj_juncs$by
|
|
21
|
+
}
|
|
22
|
+
if (is.null(cases[[name]]$by_clones)) {
|
|
23
|
+
cases[[name]]$by_clones <- vj_juncs$by_clones
|
|
24
|
+
}
|
|
25
|
+
if (is.null(cases[[name]]$subset)) {
|
|
26
|
+
cases[[name]]$subset <- vj_juncs$subset
|
|
27
|
+
}
|
|
28
|
+
if (is.null(cases[[name]]$devpars)) {
|
|
29
|
+
cases[[name]]$devpars <- vj_juncs$devpars
|
|
30
|
+
}
|
|
31
|
+
if (is.null(cases[[name]]$devpars$width)) {
|
|
32
|
+
cases[[name]]$devpars$width <- vj_juncs$devpars$width
|
|
33
|
+
}
|
|
34
|
+
if (is.null(cases[[name]]$devpars$height)) {
|
|
35
|
+
cases[[name]]$devpars$height <- vj_juncs$devpars$height
|
|
36
|
+
}
|
|
37
|
+
if (is.null(cases[[name]]$devpars$res)) {
|
|
38
|
+
cases[[name]]$devpars$res <- vj_juncs$devpars$res
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
vjjunc_dir = file.path(outdir, "vj_junc")
|
|
44
|
+
dir.create(vjjunc_dir, showWarnings = FALSE)
|
|
45
|
+
|
|
46
|
+
do_one_case_vjjunc <- function(name, case) {
|
|
47
|
+
log_info("Processing case: {name} ...")
|
|
48
|
+
odir = file.path(vjjunc_dir, slugify(name))
|
|
49
|
+
dir.create(odir, showWarnings = FALSE)
|
|
50
|
+
|
|
51
|
+
if (!is.null(case$subset)) {
|
|
52
|
+
d = filter_expanded_immdata(exdata, case$subset)
|
|
53
|
+
} else {
|
|
54
|
+
d = exdata
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (is.null(case$by) || length(case$by) == 0) {
|
|
58
|
+
case$by <- "Sample"
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
by = trimws(strsplit(case$by, ",")[[1]])
|
|
62
|
+
|
|
63
|
+
lapply(group_split(d, !!!syms(by)), function(gsd) {
|
|
64
|
+
by_name <- gsd[1, by, drop = FALSE] %>% unlist() %>% paste0(collapse = "-")
|
|
65
|
+
log_info("- Processing {by_name} ...")
|
|
66
|
+
|
|
67
|
+
if (isTRUE(case$by_clones)) {
|
|
68
|
+
gsd <- gsd %>% distinct(CDR3.aa, .keep_all = TRUE)
|
|
69
|
+
}
|
|
70
|
+
gsd <- gsd %>%
|
|
71
|
+
group_by(V.name, J.name) %>%
|
|
72
|
+
summarise(Size = n(), .groups = "drop") %>%
|
|
73
|
+
filter(!is.na(V.name) & !is.na(J.name) & V.name != "None" & J.name != "None") %>%
|
|
74
|
+
# if it's multiple chains, then split the chains
|
|
75
|
+
separate_rows(V.name, J.name, sep = ";") %>%
|
|
76
|
+
filter(!is.na(V.name) & !is.na(J.name) & V.name != "None" & J.name != "None") %>%
|
|
77
|
+
group_by(V.name, J.name) %>%
|
|
78
|
+
summarise(Size = sum(Size), .groups = "drop") %>%
|
|
79
|
+
arrange(desc(Size), V.name, J.name)
|
|
80
|
+
|
|
81
|
+
figfile <- file.path(odir, paste0(slugify(by_name), ".png"))
|
|
82
|
+
png(figfile, width = case$devpars$width, height = case$devpars$height, res = case$devpars$res)
|
|
83
|
+
circos.clear()
|
|
84
|
+
tryCatch({
|
|
85
|
+
chordDiagram(
|
|
86
|
+
gsd,
|
|
87
|
+
annotationTrack = c("grid", "axis"),
|
|
88
|
+
preAllocateTracks = list(track.height = 0.25)
|
|
89
|
+
)
|
|
90
|
+
}, error = function(e) {
|
|
91
|
+
log_warn("Error encountered: {e$message}, setting gap.after ...")
|
|
92
|
+
circos.par(gap.after = c(rep(1, nrow(gsd) - 1), 5, rep(1, nrow(gsd) - 1), 5))
|
|
93
|
+
chordDiagram(
|
|
94
|
+
gsd,
|
|
95
|
+
annotationTrack = c("grid", "axis"),
|
|
96
|
+
preAllocateTracks = list(track.height = 0.25)
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
})
|
|
100
|
+
circos.track(track.index = 1, panel.fun = function(x, y) {
|
|
101
|
+
circos.text(
|
|
102
|
+
CELL_META$xcenter,
|
|
103
|
+
CELL_META$ylim[1],
|
|
104
|
+
CELL_META$sector.index,
|
|
105
|
+
cex = .8,
|
|
106
|
+
facing = "clockwise",
|
|
107
|
+
niceFacing = TRUE,
|
|
108
|
+
adj = c(-0.2, 0.5)
|
|
109
|
+
)
|
|
110
|
+
}, bg.border = NA) # here set bg.border to NA is important
|
|
111
|
+
dev.off()
|
|
112
|
+
|
|
113
|
+
# figfile_pdf <- file.path(odir, paste0(slugify(by_name), ".pdf"))
|
|
114
|
+
# png(figfile_pdf, width = case$devpars$width / case$devpars$res, height = case$devpars$height / case$devpars$res)
|
|
115
|
+
# circos.clear()
|
|
116
|
+
# tryCatch({
|
|
117
|
+
# chordDiagram(
|
|
118
|
+
# gsd,
|
|
119
|
+
# annotationTrack = c("grid", "axis"),
|
|
120
|
+
# preAllocateTracks = list(track.height = 0.25)
|
|
121
|
+
# )
|
|
122
|
+
# }, error = function(e) {
|
|
123
|
+
# log_warn("Error encountered: {e$message}, setting gap.after ...")
|
|
124
|
+
# circos.par(gap.after = c(rep(1, nrow(gsd) - 1), 5, rep(1, nrow(gsd) - 1), 5))
|
|
125
|
+
# chordDiagram(
|
|
126
|
+
# gsd,
|
|
127
|
+
# annotationTrack = c("grid", "axis"),
|
|
128
|
+
# preAllocateTracks = list(track.height = 0.25)
|
|
129
|
+
# )
|
|
130
|
+
|
|
131
|
+
# })
|
|
132
|
+
# circos.track(track.index = 1, panel.fun = function(x, y) {
|
|
133
|
+
# circos.text(
|
|
134
|
+
# CELL_META$xcenter,
|
|
135
|
+
# CELL_META$ylim[1],
|
|
136
|
+
# CELL_META$sector.index,
|
|
137
|
+
# cex = .8,
|
|
138
|
+
# facing = "clockwise",
|
|
139
|
+
# niceFacing = TRUE,
|
|
140
|
+
# adj = c(-0.2, 0.5)
|
|
141
|
+
# )
|
|
142
|
+
# }, bg.border = NA) # here set bg.border to NA is important
|
|
143
|
+
# dev.off()
|
|
144
|
+
|
|
145
|
+
add_report(
|
|
146
|
+
# list(src = figfile, name = by_name, download = figfile_pdf),
|
|
147
|
+
list(src = figfile, name = by_name),
|
|
148
|
+
h1 = "V-J Junction Circos Plots",
|
|
149
|
+
h2 = ifelse(name == "DEFAULT", "#" , name),
|
|
150
|
+
ui = "table_of_images"
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
NULL
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
add_report(
|
|
158
|
+
list(
|
|
159
|
+
kind = "descr",
|
|
160
|
+
content = "V-J usage plot displaying the frequency of various V-J junctions."
|
|
161
|
+
),
|
|
162
|
+
h1 = "V-J Junction Circos Plots"
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
sapply(names(cases), function(name) do_one_case_vjjunc(name, cases[[name]]))
|