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,147 +1,172 @@
|
|
|
1
|
-
source("{{biopipen_dir}}/utils/misc.R")
|
|
2
|
-
source("{{biopipen_dir}}/utils/plot.R")
|
|
3
|
-
|
|
4
|
-
library(ggplot2)
|
|
5
|
-
library(ggprism)
|
|
6
1
|
library(dplyr)
|
|
7
2
|
library(tidyr)
|
|
8
3
|
library(tibble)
|
|
9
|
-
library(
|
|
4
|
+
library(plotthis)
|
|
5
|
+
library(biopipen.utils)
|
|
10
6
|
|
|
11
|
-
asdirs
|
|
12
|
-
metafile
|
|
13
|
-
outdir
|
|
14
|
-
group_cols
|
|
15
|
-
sample_name_fun
|
|
16
|
-
heatmap_cases
|
|
7
|
+
asdirs <- {{in.asdirs | r}}
|
|
8
|
+
metafile <- {{in.metafile | r}}
|
|
9
|
+
outdir <- {{out.outdir | r}}
|
|
10
|
+
group_cols <- {{envs.group_cols | r}}
|
|
11
|
+
sample_name_fun <- {{envs.sample_name | r}}
|
|
12
|
+
heatmap_cases <- {{envs.heatmap_cases | r}}
|
|
17
13
|
|
|
18
14
|
if (!is.null(sample_name_fun)) {
|
|
19
|
-
sample_name_fun
|
|
15
|
+
sample_name_fun <- eval(parse(text = sample_name_fun))
|
|
20
16
|
}
|
|
21
17
|
|
|
22
|
-
get_sample_from_asdir
|
|
23
|
-
x
|
|
18
|
+
get_sample_from_asdir <- function(asdir) {
|
|
19
|
+
x <- basename(asdir)
|
|
24
20
|
if (endsWith(x, ".aneuploidy_score")) {
|
|
25
|
-
x
|
|
21
|
+
x <- substr(x, 1, nchar(x) - 17)
|
|
26
22
|
}
|
|
27
23
|
if (endsWith(x, ".call")) {
|
|
28
|
-
x
|
|
24
|
+
x <- substr(x, 1, nchar(x) - 5)
|
|
29
25
|
}
|
|
30
26
|
if (!is.null(sample_name_fun)) {
|
|
31
|
-
x
|
|
27
|
+
x <- sample_name_fun(x)
|
|
32
28
|
}
|
|
33
29
|
x
|
|
34
30
|
}
|
|
35
31
|
|
|
36
|
-
|
|
32
|
+
asdir_to_sample <- lapply(asdirs, get_sample_from_asdir)
|
|
33
|
+
names(asdir_to_sample) <- asdirs
|
|
34
|
+
table_sams <- table(unlist(asdir_to_sample))
|
|
35
|
+
if (any(table_sams > 1)) {
|
|
36
|
+
log_warn("Duplicate sample names found in asdirs: ")
|
|
37
|
+
dup_sams <- names(table_sams[table_sams > 1])
|
|
38
|
+
for (dup_sam in dup_sams) {
|
|
39
|
+
i <- 1
|
|
40
|
+
for (asdir in asdirs) {
|
|
41
|
+
if (asdir_to_sample[[asdir]] == dup_sam) {
|
|
42
|
+
dedup_sam <- paste0(dup_sam, "_", i)
|
|
43
|
+
log_warn(paste0("- Changing ", dup_sam, "(", asdir, ") to ", dedup_sam))
|
|
44
|
+
asdir_to_sample[[asdir]] <- paste0(dup_sam, "_", i)
|
|
45
|
+
i <- i + 1
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
sams <- unlist(asdir_to_sample)
|
|
37
51
|
|
|
38
|
-
meta_cols
|
|
52
|
+
meta_cols <- c()
|
|
39
53
|
if (!is.null(group_cols)) {
|
|
40
54
|
for (group_col in group_cols) {
|
|
41
55
|
if (grepl(",", group_col, fixed = TRUE)) {
|
|
42
|
-
subcols
|
|
56
|
+
subcols <- strsplit(group_col, ",")[[1]]
|
|
43
57
|
if (length(subcols) > 2) {
|
|
44
58
|
stop("Only support 2 columns combined for group_cols")
|
|
45
59
|
}
|
|
46
|
-
meta_cols
|
|
60
|
+
meta_cols <- union(meta_cols, subcols)
|
|
47
61
|
} else {
|
|
48
|
-
meta_cols
|
|
62
|
+
meta_cols <- union(meta_cols, group_col)
|
|
49
63
|
}
|
|
50
64
|
}
|
|
51
65
|
}
|
|
52
66
|
|
|
53
67
|
if (!is.null(metafile)) {
|
|
54
|
-
metadf
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
metadf <- read.table(metafile, header=T, row.names=NULL, sep="\t", stringsAsFactors=F)
|
|
69
|
+
if (!is.null(metadf$Sample)) {
|
|
70
|
+
metadf$Sample <- as.character(metadf$Sample)
|
|
71
|
+
} else {
|
|
72
|
+
colnames(metadf)[1] <- "Sample"
|
|
73
|
+
}
|
|
74
|
+
metadf <- metadf[metadf$Sample %in% sams, c("Sample", meta_cols), drop=FALSE]
|
|
75
|
+
rownames(metadf) <- metadf$Sample
|
|
58
76
|
if (nrow(metadf) != length(sams)) {
|
|
59
77
|
stop(paste("Not all samples in metafile:", paste(setdiff(sams, metadf$Sample), collapse=", ")))
|
|
60
78
|
}
|
|
61
79
|
} else {
|
|
62
|
-
metadf
|
|
80
|
+
metadf <- NULL
|
|
63
81
|
if (!is.null(group_cols) && length(group_cols) > 0) {
|
|
64
82
|
stop("`envs.group_cols` given but no metafile provided")
|
|
65
83
|
}
|
|
66
84
|
}
|
|
67
85
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
read_caa = function(asdir) {
|
|
86
|
+
read_caa <- function(asdir) {
|
|
71
87
|
# Sample Arms arm seg
|
|
72
|
-
sample
|
|
73
|
-
caa
|
|
88
|
+
sample <- asdir_to_sample[[asdir]]
|
|
89
|
+
caa <- read.table(
|
|
74
90
|
file.path(asdir, "CAA.txt"),
|
|
75
91
|
header=T,
|
|
76
92
|
row.names=NULL,
|
|
77
93
|
sep="\t",
|
|
78
94
|
stringsAsFactors=F,
|
|
79
95
|
)
|
|
80
|
-
caa$Sample
|
|
96
|
+
caa$Sample <- sample
|
|
81
97
|
caa
|
|
82
98
|
}
|
|
83
99
|
|
|
84
|
-
read_as
|
|
100
|
+
read_as <- function(asdir) {
|
|
85
101
|
# Sample SignalType Signal
|
|
86
|
-
sample
|
|
87
|
-
as
|
|
102
|
+
sample <- asdir_to_sample[[asdir]]
|
|
103
|
+
as <- read.table(
|
|
88
104
|
file.path(asdir, "AS.txt"),
|
|
89
105
|
header=F,
|
|
90
106
|
row.names=NULL,
|
|
91
107
|
sep="\t",
|
|
92
108
|
stringsAsFactors=F,
|
|
93
109
|
)
|
|
94
|
-
colnames(as)
|
|
95
|
-
as$Sample
|
|
110
|
+
colnames(as) <- c("SignalType", "Signal")
|
|
111
|
+
as$Sample <- sample
|
|
96
112
|
as
|
|
97
113
|
}
|
|
98
114
|
|
|
99
115
|
# Sample Arms arm seg
|
|
100
|
-
caa
|
|
116
|
+
caa <- do_call(rbind, lapply(asdirs, read_caa))
|
|
101
117
|
# Sample SignalType Signal
|
|
102
|
-
as
|
|
118
|
+
as <- do_call(rbind, lapply(asdirs, read_as))
|
|
103
119
|
|
|
104
120
|
# Sample chr1_p chr1_q chr2_p chr2_q ...
|
|
105
|
-
caa_arm
|
|
121
|
+
caa_arm <- caa %>%
|
|
106
122
|
select(-"seg") %>%
|
|
107
123
|
pivot_wider(names_from="Arms", values_from="arm")
|
|
108
124
|
|
|
109
125
|
# Sample chr1_p chr1_q chr2_p chr2_q ...
|
|
110
|
-
caa_seg
|
|
126
|
+
caa_seg <- caa %>%
|
|
111
127
|
select(-"arm") %>%
|
|
112
128
|
pivot_wider(names_from="Arms", values_from="seg")
|
|
113
129
|
|
|
114
130
|
# Sample SignalType Signal
|
|
115
|
-
as_arm
|
|
116
|
-
as_seg
|
|
131
|
+
as_arm <- as %>% filter(SignalType == "arm") %>% select(-"SignalType")
|
|
132
|
+
as_seg <- as %>% filter(SignalType == "seg") %>% select(-"SignalType")
|
|
117
133
|
|
|
118
134
|
if (!is.null(metadf)) {
|
|
119
|
-
caa_arm
|
|
120
|
-
caa_seg
|
|
121
|
-
as_arm
|
|
122
|
-
as_seg
|
|
135
|
+
caa_arm <- caa_arm %>% left_join(metadf, by="Sample")
|
|
136
|
+
caa_seg <- caa_seg %>% left_join(metadf, by="Sample")
|
|
137
|
+
as_arm <- as_arm %>% left_join(metadf, by="Sample")
|
|
138
|
+
as_seg <- as_seg %>% left_join(metadf, by="Sample")
|
|
123
139
|
}
|
|
124
140
|
|
|
125
|
-
|
|
126
141
|
write.table(caa_arm, file.path(outdir, "CAA_arm.txt"), sep="\t", quote=F, row.names=F, col.names=T)
|
|
127
142
|
write.table(caa_seg, file.path(outdir, "CAA_seg.txt"), sep="\t", quote=F, row.names=F, col.names=T)
|
|
128
143
|
write.table(as_arm, file.path(outdir, "AS_arm.txt"), sep="\t", quote=F, row.names=F, col.names=T)
|
|
129
144
|
write.table(as_seg, file.path(outdir, "AS_seg.txt"), sep="\t", quote=F, row.names=F, col.names=T)
|
|
130
145
|
|
|
131
146
|
# Plot AS without grouping
|
|
132
|
-
p_as_arm
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
147
|
+
p_as_arm <- BarPlot(
|
|
148
|
+
as_arm,
|
|
149
|
+
x="Sample",
|
|
150
|
+
y="Signal",
|
|
151
|
+
title="Aneuploidy Score (Arm)",
|
|
152
|
+
xlab="Sample",
|
|
153
|
+
ylab="Aneuploidy Score",
|
|
154
|
+
x_text_angle = 90
|
|
155
|
+
)
|
|
136
156
|
|
|
137
157
|
png(file.path(outdir, "AS_arm.png"), width=400 + nrow(caa_arm) * 12, height=600, res=100)
|
|
138
158
|
print(p_as_arm)
|
|
139
159
|
dev.off()
|
|
140
160
|
|
|
141
|
-
p_as_seg
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
161
|
+
p_as_seg <- BarPlot(
|
|
162
|
+
as_seg,
|
|
163
|
+
x="Sample",
|
|
164
|
+
y="Signal",
|
|
165
|
+
title="Aneuploidy Score (Segment)",
|
|
166
|
+
xlab="Sample",
|
|
167
|
+
ylab="Aneuploidy Score",
|
|
168
|
+
x_text_angle = 90
|
|
169
|
+
)
|
|
145
170
|
|
|
146
171
|
png(file.path(outdir, "AS_seg.png"), width=400 + nrow(caa_seg) * 12, height=600, res=100)
|
|
147
172
|
print(p_as_seg)
|
|
@@ -151,49 +176,70 @@ dev.off()
|
|
|
151
176
|
if (!is.null(group_cols)) {
|
|
152
177
|
for (group_col in group_cols) {
|
|
153
178
|
if (!grepl(",", group_col, fixed = TRUE)) {
|
|
154
|
-
|
|
155
|
-
p_as_arm_bar_group
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
179
|
+
|
|
180
|
+
p_as_arm_bar_group <- BarPlot(
|
|
181
|
+
as_arm,
|
|
182
|
+
x="Sample",
|
|
183
|
+
y="Signal",
|
|
184
|
+
fill=group_col,
|
|
185
|
+
title=paste0("Aneuploidy Score (Arm) - ", group_col),
|
|
186
|
+
xlab="Sample",
|
|
187
|
+
ylab="Aneuploidy Score",
|
|
188
|
+
x_text_angle = 90
|
|
189
|
+
)
|
|
161
190
|
|
|
162
191
|
png(file.path(outdir, paste0("AS_arm_bar_", group_col, ".png")), width=400 + nrow(caa_arm) * 12, height=600, res=100)
|
|
163
192
|
print(p_as_arm_bar_group)
|
|
164
193
|
dev.off()
|
|
165
194
|
|
|
166
|
-
p_as_seg_bar_group
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
195
|
+
p_as_seg_bar_group <- BarPlot(
|
|
196
|
+
as_seg,
|
|
197
|
+
x="Sample",
|
|
198
|
+
y="Signal",
|
|
199
|
+
fill=group_col,
|
|
200
|
+
title=paste0("Aneuploidy Score (Segment) - ", group_col),
|
|
201
|
+
xlab="Sample",
|
|
202
|
+
ylab="Aneuploidy Score",
|
|
203
|
+
x_text_angle = 90
|
|
204
|
+
)
|
|
172
205
|
|
|
173
206
|
png(file.path(outdir, paste0("AS_seg_bar_", group_col, ".png")), width=400 + nrow(caa_seg) * 12, height=600, res=100)
|
|
174
207
|
print(p_as_seg_bar_group)
|
|
175
208
|
dev.off()
|
|
176
209
|
|
|
177
210
|
# Voilin + boxplot
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
211
|
+
|
|
212
|
+
p_as_arm_violin_group <- ViolinPlot(
|
|
213
|
+
as_arm,
|
|
214
|
+
x=group_col,
|
|
215
|
+
y="Signal",
|
|
216
|
+
title=paste0("Aneuploidy Score (Arm) - ", group_col),
|
|
217
|
+
xlab=group_col,
|
|
218
|
+
ylab="Aneuploidy Score",
|
|
219
|
+
x_text_angle = 90,
|
|
220
|
+
comparisons = TRUE,
|
|
221
|
+
sig_label = "p.format",
|
|
222
|
+
add_point = TRUE,
|
|
223
|
+
add_box = TRUE
|
|
224
|
+
)
|
|
185
225
|
|
|
186
226
|
png(file.path(outdir, paste0("AS_arm_violin_", group_col, ".png")), width=1000, height=600, res=100)
|
|
187
227
|
print(p_as_arm_violin_group)
|
|
188
228
|
dev.off()
|
|
189
229
|
|
|
190
|
-
p_as_seg_violin_group
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
230
|
+
p_as_seg_violin_group <- ViolinPlot(
|
|
231
|
+
as_seg,
|
|
232
|
+
x=group_col,
|
|
233
|
+
y="Signal",
|
|
234
|
+
title=paste0("Aneuploidy Score (Segment) - ", group_col),
|
|
235
|
+
xlab=group_col,
|
|
236
|
+
ylab="Aneuploidy Score",
|
|
237
|
+
x_text_angle = 90,
|
|
238
|
+
comparisons = TRUE,
|
|
239
|
+
sig_label = "p.format",
|
|
240
|
+
add_point = TRUE,
|
|
241
|
+
add_box = TRUE
|
|
242
|
+
)
|
|
197
243
|
|
|
198
244
|
png(file.path(outdir, paste0("AS_seg_violin_", group_col, ".png")), width=1000, height=600, res=100)
|
|
199
245
|
print(p_as_seg_violin_group)
|
|
@@ -201,26 +247,27 @@ if (!is.null(group_cols)) {
|
|
|
201
247
|
|
|
202
248
|
} else {
|
|
203
249
|
# Multiple layers with group_col
|
|
204
|
-
group_cols
|
|
205
|
-
group_col1
|
|
206
|
-
group_col2
|
|
250
|
+
group_cols <- strsplit(group_col, ",")[[1]]
|
|
251
|
+
group_col1 <- group_cols[1]
|
|
252
|
+
group_col2 <- group_cols[2]
|
|
207
253
|
|
|
208
254
|
# For each group_col1, plot a barplot with group_col2 as fill, and
|
|
209
255
|
# concatenate them together using patch work, with ncol=2
|
|
210
256
|
# calcuate the height and width of the plot based on the number of
|
|
211
257
|
# groups
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
258
|
+
as_arm <- as_arm %>% arrange(!!sym(group_col1), !!sym(group_col2)) %>% mutate(Sample=factor(Sample, levels=Sample))
|
|
259
|
+
p <- BarPlot(
|
|
260
|
+
as_arm,
|
|
261
|
+
x="Sample",
|
|
262
|
+
y="Signal",
|
|
263
|
+
split_by=group_col1,
|
|
264
|
+
fill=group_col2,
|
|
265
|
+
xlab="Sample",
|
|
266
|
+
ylab="Aneuploidy Score",
|
|
267
|
+
x_text_angle = 90,
|
|
268
|
+
ncol = 2
|
|
269
|
+
)
|
|
270
|
+
|
|
224
271
|
png(
|
|
225
272
|
file.path(outdir, paste0("AS_arm_bar_", group_col, ".png")),
|
|
226
273
|
width=1000,
|
|
@@ -230,18 +277,18 @@ if (!is.null(group_cols)) {
|
|
|
230
277
|
print(p)
|
|
231
278
|
dev.off()
|
|
232
279
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
280
|
+
as_seg <- as_seg %>% arrange(!!sym(group_col1), !!sym(group_col2)) %>% mutate(Sample=factor(Sample, levels=Sample))
|
|
281
|
+
p <- BarPlot(
|
|
282
|
+
as_seg,
|
|
283
|
+
x="Sample",
|
|
284
|
+
y="Signal",
|
|
285
|
+
split_by=group_col1,
|
|
286
|
+
fill=group_col2,
|
|
287
|
+
xlab="Sample",
|
|
288
|
+
ylab="Aneuploidy Score",
|
|
289
|
+
x_text_angle = 90,
|
|
290
|
+
ncol = 2
|
|
291
|
+
)
|
|
245
292
|
png(
|
|
246
293
|
file.path(outdir, paste0("AS_seg_bar_", group_col, ".png")),
|
|
247
294
|
width=1000,
|
|
@@ -252,19 +299,21 @@ if (!is.null(group_cols)) {
|
|
|
252
299
|
dev.off()
|
|
253
300
|
|
|
254
301
|
# Do the same for Voilin + boxplot
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
302
|
+
p <- ViolinPlot(
|
|
303
|
+
as_arm,
|
|
304
|
+
x=group_col2,
|
|
305
|
+
y="Signal",
|
|
306
|
+
split_by = group_col1,
|
|
307
|
+
xlab=group_col2,
|
|
308
|
+
ylab="Aneuploidy Score",
|
|
309
|
+
x_text_angle = 90,
|
|
310
|
+
comparisons = TRUE,
|
|
311
|
+
sig_label = "p.format",
|
|
312
|
+
add_point = TRUE,
|
|
313
|
+
add_box = TRUE,
|
|
314
|
+
ncol = 2
|
|
315
|
+
)
|
|
316
|
+
|
|
268
317
|
png(
|
|
269
318
|
file.path(outdir, paste0("AS_arm_violin_", group_col, ".png")),
|
|
270
319
|
width=1000,
|
|
@@ -274,19 +323,21 @@ if (!is.null(group_cols)) {
|
|
|
274
323
|
print(p)
|
|
275
324
|
dev.off()
|
|
276
325
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
326
|
+
p <- ViolinPlot(
|
|
327
|
+
as_seg,
|
|
328
|
+
x=group_col2,
|
|
329
|
+
y="Signal",
|
|
330
|
+
split_by = group_col1,
|
|
331
|
+
xlab=group_col2,
|
|
332
|
+
ylab="Aneuploidy Score",
|
|
333
|
+
x_text_angle = 90,
|
|
334
|
+
comparisons = TRUE,
|
|
335
|
+
sig_label = "p.format",
|
|
336
|
+
add_point = TRUE,
|
|
337
|
+
add_box = TRUE,
|
|
338
|
+
ncol = 2
|
|
339
|
+
)
|
|
340
|
+
|
|
290
341
|
png(
|
|
291
342
|
file.path(outdir, paste0("AS_seg_violin_", group_col, ".png")),
|
|
292
343
|
width=1000,
|
|
@@ -301,39 +352,46 @@ if (!is.null(group_cols)) {
|
|
|
301
352
|
|
|
302
353
|
# Heatmaps
|
|
303
354
|
for (heatmap_name in names(heatmap_cases)) {
|
|
304
|
-
arms
|
|
355
|
+
arms <- heatmap_cases[[heatmap_name]]
|
|
305
356
|
if (all(arms != "ALL")) {
|
|
306
|
-
caa_df
|
|
357
|
+
caa_df <- caa_arm %>% select(Sample, !!meta_cols, !!arms)
|
|
307
358
|
} else {
|
|
308
|
-
caa_df
|
|
359
|
+
caa_df <- caa_arm
|
|
309
360
|
}
|
|
310
|
-
caa_df
|
|
361
|
+
caa_df <- caa_df %>% column_to_rownames("Sample")
|
|
311
362
|
if (!is.null(metadf)) {
|
|
312
|
-
caa_df
|
|
363
|
+
caa_df <- caa_df %>% select(-!!meta_cols)
|
|
313
364
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
365
|
+
caa_df <- caa_df %>%
|
|
366
|
+
rownames_to_column("Sample") %>%
|
|
367
|
+
pivot_longer(cols=-"Sample", names_to="Arms", values_to="Signal") %>%
|
|
368
|
+
pivot_wider(names_from="Sample", values_from="Signal")
|
|
369
|
+
|
|
370
|
+
height <- 300 + 20 * ncol(caa_df) # all arms: 300 + 30 * 46 = 1680
|
|
371
|
+
width <- 300 + 25 * nrow(caa_df) # 10 samples: 300 + 30 * 10 = 600
|
|
372
|
+
# print(caa_df)
|
|
373
|
+
hmp <- Heatmap(
|
|
374
|
+
caa_df,
|
|
375
|
+
rows_data = metadf,
|
|
318
376
|
name = "CAA",
|
|
319
|
-
|
|
377
|
+
rows_by = setdiff(colnames(caa_df), "Arms"),
|
|
378
|
+
columns_by = "Arms",
|
|
320
379
|
cluster_rows = FALSE,
|
|
380
|
+
cluster_columns = FALSE,
|
|
321
381
|
row_names_side = "left",
|
|
322
|
-
|
|
382
|
+
show_row_names = TRUE,
|
|
383
|
+
show_column_names = TRUE,
|
|
384
|
+
row_annotation = colnames(metadf),
|
|
385
|
+
lower_cutoff = -1,
|
|
386
|
+
upper_cutoff = 1
|
|
323
387
|
)
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
args$right_annotation = do_call(ComplexHeatmap::rowAnnotation, row_annos)
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
plotHeatmap(
|
|
334
|
-
caa_df,
|
|
335
|
-
args = args,
|
|
336
|
-
devpars = list(width=width, height=height, res=100),
|
|
337
|
-
outfile = file.path(outdir, paste0("Heatmap_", heatmap_name, ".png"))
|
|
388
|
+
|
|
389
|
+
png(
|
|
390
|
+
file.path(outdir, paste0("Heatmap_", heatmap_name, ".png")),
|
|
391
|
+
width=width,
|
|
392
|
+
height=height,
|
|
393
|
+
res=100
|
|
338
394
|
)
|
|
395
|
+
plot(hmp)
|
|
396
|
+
dev.off()
|
|
339
397
|
}
|
biopipen/scripts/cnv/TMADScore.R
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
library(dplyr)
|
|
2
2
|
|
|
3
|
-
segfile = {{in.segfile |
|
|
4
|
-
outfile = {{out.outfile |
|
|
5
|
-
chrom_col = {{envs.chrom_col |
|
|
3
|
+
segfile = {{in.segfile | r}}
|
|
4
|
+
outfile = {{out.outfile | r}}
|
|
5
|
+
chrom_col = {{envs.chrom_col | r}}
|
|
6
6
|
excl_chroms = {{envs.excl_chroms | r}}
|
|
7
|
-
seg_col = {{envs.seg_col |
|
|
7
|
+
seg_col = {{envs.seg_col | r}}
|
|
8
8
|
segmean_transform = {{envs.segmean_transform | r}}
|
|
9
9
|
|
|
10
10
|
if (is.character(segmean_transform)) {
|
|
11
11
|
segmean_transform = eval(parse(text=segmean_transform))
|
|
12
12
|
} # otherwise NULL
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
|
|
15
|
+
if (endsWith(segfile, ".vcf") || endsWith(segfile, ".vcf.gz")) {
|
|
16
|
+
library(VariantAnnotation)
|
|
17
|
+
segments = readVcf(segfile)
|
|
18
|
+
seg = data.frame(
|
|
19
|
+
chrom = as.character(seqnames(segments)),
|
|
20
|
+
log2 = segments@info[[seg_col]]
|
|
21
|
+
)
|
|
22
|
+
} else if (endsWith(segfile, ".bed")) {
|
|
23
|
+
segments = read.table(segfile, header=F, row.names=NULL, sep="\t", stringsAsFactors=F)
|
|
24
|
+
seg = data.frame(
|
|
25
|
+
chrom = segments[, 1],
|
|
26
|
+
log2 = segments[, 5]
|
|
27
|
+
)
|
|
28
|
+
} else {
|
|
29
|
+
segments = read.table(segfile, header=T, row.names=NULL, sep="\t", stringsAsFactors=F)
|
|
30
|
+
seg = data.frame(
|
|
31
|
+
chrom = segments[, chrom_col],
|
|
32
|
+
log2 = segments[, seg_col]
|
|
33
|
+
)
|
|
34
|
+
}
|
|
19
35
|
rm(segments)
|
|
20
36
|
|
|
21
37
|
if (!is.null(excl_chroms) && length(excl_chroms) > 0) {
|