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
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
{{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
|
|
2
|
+
|
|
3
|
+
library(rlang)
|
|
4
|
+
library(ggmanh)
|
|
5
|
+
|
|
6
|
+
infile <- {{in.infile | r}}
|
|
7
|
+
outfile <- {{out.outfile | r}}
|
|
8
|
+
chrom_col <- {{envs.chrom_col | r}}
|
|
9
|
+
pos_col <- {{envs.pos_col | r}}
|
|
10
|
+
pval_col <- {{envs.pval_col | r}}
|
|
11
|
+
label_col <- {{envs.label_col | r}}
|
|
12
|
+
devpars <- {{envs.devpars | r}}
|
|
13
|
+
title <- {{envs.title | r}}
|
|
14
|
+
ylabel <- {{envs.ylabel | r}}
|
|
15
|
+
rescale <- {{envs.rescale | r}}
|
|
16
|
+
rescale_ratio_threshold <- {{envs.rescale_ratio_threshold | r}}
|
|
17
|
+
signif <- {{envs.signif | r}}
|
|
18
|
+
hicolors <- {{envs.hicolors | r}}
|
|
19
|
+
thin_n <- {{envs.thin_n | r}}
|
|
20
|
+
thin_bins <- {{envs.thin_bins | r}}
|
|
21
|
+
zoom <- {{envs.zoom | r}}
|
|
22
|
+
zoom_devpars <- {{envs.zoom_devpars | r}}
|
|
23
|
+
chroms <- {{envs.chroms | r}}
|
|
24
|
+
args <- {{envs.args | r: todot="-"}}
|
|
25
|
+
|
|
26
|
+
data <- read.table(infile, header=TRUE, sep="\t", stringsAsFactors=FALSE, check.names = FALSE)
|
|
27
|
+
|
|
28
|
+
# normalize columns
|
|
29
|
+
cnames <- colnames(data)
|
|
30
|
+
if (is.numeric(chrom_col)) { chrom_col <- cnames[chrom_col] }
|
|
31
|
+
if (is.numeric(pos_col)) { pos_col <- cnames[pos_col] }
|
|
32
|
+
if (is.numeric(pval_col)) { pval_col <- cnames[pval_col] }
|
|
33
|
+
if (is.numeric(label_col)) { label_col <- cnames[label_col] }
|
|
34
|
+
|
|
35
|
+
# normalize chroms
|
|
36
|
+
norm_chroms <- function(chrs) {
|
|
37
|
+
chrs <- as.character(chrs)
|
|
38
|
+
if (length(chrs) == 1 && grepl(",", chrs)) {
|
|
39
|
+
chrs <- trimws(unlist(strsplit(chrs, ",")))
|
|
40
|
+
}
|
|
41
|
+
if (length(chrs) > 1) {
|
|
42
|
+
return(unique(unlist(sapply(chrs, function(chr) norm_chroms(chr)))))
|
|
43
|
+
}
|
|
44
|
+
if (!grepl("-", chrs)) { return(chrs) }
|
|
45
|
+
|
|
46
|
+
# expand chr1-22 -> chr1, chr2, ..., chr22
|
|
47
|
+
# chr1-22 -> 'chr1', '22'
|
|
48
|
+
chrs <- unlist(strsplit(chrs, "-"))
|
|
49
|
+
if (length(chrs) != 2) {
|
|
50
|
+
stop(paste0("Invalid chroms: ", chrs))
|
|
51
|
+
}
|
|
52
|
+
# detect prefix
|
|
53
|
+
prefix1 <- gsub("[0-9]", "", chrs[1])
|
|
54
|
+
prefix2 <- gsub("[0-9]", "", chrs[2])
|
|
55
|
+
if (nchar(prefix2) > 0 && prefix1 != prefix2) {
|
|
56
|
+
stop(paste0("Invalid chroms: ", chrs, " (prefix mismatch)"))
|
|
57
|
+
}
|
|
58
|
+
chr_a <- as.integer(substring(chrs[1], nchar(prefix1) + 1))
|
|
59
|
+
chr_b <- as.integer(substring(chrs[2], nchar(prefix2) + 1))
|
|
60
|
+
chr_min <- min(chr_a, chr_b)
|
|
61
|
+
chr_max <- max(chr_a, chr_b)
|
|
62
|
+
return(paste0(prefix1, chr_min:chr_max))
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
log_info("Preparing data for plotting ...")
|
|
66
|
+
if (length(chroms) == 1 && chroms == "auto") {
|
|
67
|
+
chroms <- unique(data[[chrom_col]])
|
|
68
|
+
} else {
|
|
69
|
+
chroms <- norm_chroms(chroms)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# prepare data
|
|
73
|
+
mp_prep_args = list()
|
|
74
|
+
if (length(signif) == 1 && is.character(signif)) {
|
|
75
|
+
signif <- as.numeric(trimws(unlist(strsplit(signif, ","))))
|
|
76
|
+
}
|
|
77
|
+
siglevel <- min(signif)
|
|
78
|
+
if (!is.null(label_col)) {
|
|
79
|
+
data$.label <- ifelse(data[[pval_col]] < siglevel, data[[label_col]], "")
|
|
80
|
+
}
|
|
81
|
+
if (!is.null(hicolors)) {
|
|
82
|
+
sig_str <- "Significant"
|
|
83
|
+
nsig_str <- "Not significant"
|
|
84
|
+
data$.highlight <- ifelse(data[[pval_col]] < siglevel, sig_str, nsig_str)
|
|
85
|
+
if (length(hicolors) == 1) { hicolors <- c(hicolors, "grey") }
|
|
86
|
+
names(hicolors) <- c(sig_str, nsig_str)
|
|
87
|
+
mp_prep_args$highlight.colname <- ".highlight"
|
|
88
|
+
mp_prep_args$highlight.col <- hicolors
|
|
89
|
+
}
|
|
90
|
+
mp_prep_args$x <- data
|
|
91
|
+
mp_prep_args$chr.colname <- chrom_col
|
|
92
|
+
mp_prep_args$pos.colname <- pos_col
|
|
93
|
+
mp_prep_args$pval.colname <- pval_col
|
|
94
|
+
mp_prep_args$chr.order <- chroms
|
|
95
|
+
if (!is.null(thin_n) && thin_n > 0) {
|
|
96
|
+
mp_prep_args$thin.n <- thin_n
|
|
97
|
+
mp_prep_args$thin.bins <- thin_bins
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
mpdata <- do_call(manhattan_data_preprocess, mp_prep_args)
|
|
101
|
+
|
|
102
|
+
# plot
|
|
103
|
+
log_info("Plotting Manhattan plot ...")
|
|
104
|
+
args$x <- mpdata
|
|
105
|
+
args$signif <- signif
|
|
106
|
+
args$plot.title <- title
|
|
107
|
+
args$rescale <- rescale
|
|
108
|
+
args$rescale.ratio.threshold <- rescale_ratio_threshold
|
|
109
|
+
args$y.label <- ylabel
|
|
110
|
+
if (!is.null(hicolors)) { args$color.by.highlight <- TRUE }
|
|
111
|
+
if (!is.null(label_col)) { args$label.colname <- ".label" }
|
|
112
|
+
g <- do_call(manhattan_plot, args)
|
|
113
|
+
|
|
114
|
+
png(outfile, width=devpars$width, height=devpars$height, res=devpars$res)
|
|
115
|
+
print(g)
|
|
116
|
+
dev.off()
|
|
117
|
+
|
|
118
|
+
# zoom into chromosomes
|
|
119
|
+
all_chroms <- as.character(unique(mpdata$data[[mpdata$chr.colname]]))
|
|
120
|
+
if (!is.null(zoom)) {
|
|
121
|
+
log_info("Zooming into chromosomes ...")
|
|
122
|
+
zoom <- norm_chroms(zoom)
|
|
123
|
+
for (z in zoom) {
|
|
124
|
+
if (!z %in% all_chroms) {
|
|
125
|
+
log_warn("- {z}: not found in data")
|
|
126
|
+
next
|
|
127
|
+
}
|
|
128
|
+
log_info("- {z}")
|
|
129
|
+
args_z <- args
|
|
130
|
+
args_z$chromosome <- z
|
|
131
|
+
args_z$plot.title <- paste0(title, " (", z, ")")
|
|
132
|
+
args_z$x.label <- "Position"
|
|
133
|
+
g_z <- do_call(manhattan_plot, args_z)
|
|
134
|
+
outfile_z <- gsub("\\.png$", paste0("-", z, ".png"), outfile)
|
|
135
|
+
zm_devpars <- zoom_devpars
|
|
136
|
+
zm_devpars$res <- zm_devpars$res %||% devpars$res
|
|
137
|
+
zm_devpars$height <- zm_devpars$height %||% devpars$height
|
|
138
|
+
png(
|
|
139
|
+
outfile_z,
|
|
140
|
+
width=zm_devpars$width,
|
|
141
|
+
height=zm_devpars$height,
|
|
142
|
+
res=zm_devpars$res
|
|
143
|
+
)
|
|
144
|
+
print(g_z)
|
|
145
|
+
dev.off()
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
{{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
|
|
2
|
+
|
|
3
|
+
library(rlang)
|
|
4
|
+
library(stats)
|
|
5
|
+
library(ggplot2)
|
|
6
|
+
library(ggprism)
|
|
7
|
+
library(qqplotr)
|
|
8
|
+
|
|
9
|
+
theme_set(theme_prism())
|
|
10
|
+
|
|
11
|
+
infile <- {{in.infile | r}}
|
|
12
|
+
theorfile <- {{in.theorfile | r}}
|
|
13
|
+
outfile <- {{out.outfile | r}}
|
|
14
|
+
val_col <- {{envs.val_col | r}}
|
|
15
|
+
theor_col <- {{envs.theor_col | r}}
|
|
16
|
+
theor_trans <- {{envs.theor_trans | r}}
|
|
17
|
+
theor_funs <- {{envs.theor_funs | r}}
|
|
18
|
+
devpars <- {{envs.devpars | r}}
|
|
19
|
+
title <- {{envs.title | r}}
|
|
20
|
+
xlabel <- {{envs.xlabel | r}}
|
|
21
|
+
ylabel <- {{envs.ylabel | r}}
|
|
22
|
+
kind <- {{envs.kind | r}}
|
|
23
|
+
trans <- {{envs.trans | r}}
|
|
24
|
+
args <- {{envs.args | r}}
|
|
25
|
+
band_args <- {{envs.band | r}}
|
|
26
|
+
line_args <- {{envs.line | r}}
|
|
27
|
+
point_args <- {{envs.point | r}}
|
|
28
|
+
ggs <- {{envs.ggs | r}}
|
|
29
|
+
|
|
30
|
+
.eval_fun <- function(fun) {
|
|
31
|
+
if (is.character(fun)) {
|
|
32
|
+
fun <- trimws(fun)
|
|
33
|
+
if (grepl("^-\\s*[a-zA-Z\\.][0-9a-zA-Z\\._]*$", fun)) {
|
|
34
|
+
fun <- trimws(substring(fun, 2))
|
|
35
|
+
fun <- eval(parse(text = fun))
|
|
36
|
+
return(function(x) -fun(x))
|
|
37
|
+
} else {
|
|
38
|
+
return(eval(parse(text = fun)))
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
return(fun)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
indata <- read.table(infile, header=TRUE, sep="\t", stringsAsFactors=FALSE, check.names = FALSE)
|
|
46
|
+
if (is.numeric(val_col)) {
|
|
47
|
+
val_col <- colnames(indata)[val_col]
|
|
48
|
+
}
|
|
49
|
+
if (!is.null(trans)) {
|
|
50
|
+
trans <- .eval_fun(trans)
|
|
51
|
+
indata[[val_col]] <- trans(indata[[val_col]])
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!is.null(theor_col)) {
|
|
55
|
+
if (is.numeric(theor_col)) {
|
|
56
|
+
theor_col <- colnames(theor)[theor_col]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!is.null(theorfile)) {
|
|
60
|
+
theor <- read.table(theorfile, header=TRUE, sep="\t", stringsAsFactors=FALSE, check.names = FALSE)
|
|
61
|
+
theor_vals <- theor[[theor_col]]
|
|
62
|
+
} else {
|
|
63
|
+
theor_vals <- indata[[theor_col]]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!is.null(theor_trans)) {
|
|
67
|
+
theor_trans <- .eval_fun(theor_trans)
|
|
68
|
+
theor_vals <- theor_trans(theor_vals)
|
|
69
|
+
}
|
|
70
|
+
theor_vals <- sort(na.omit(theor_vals))
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
band_fun <- ifelse(kind == "pp", stat_pp_band, stat_qq_band)
|
|
74
|
+
line_fun <- ifelse(kind == "pp", stat_pp_line, stat_qq_line)
|
|
75
|
+
point_fun <- ifelse(kind == "pp", stat_pp_point, stat_qq_point)
|
|
76
|
+
|
|
77
|
+
for (fun in names(theor_funs)) {
|
|
78
|
+
assign(fun, .eval_fun(theor_funs[[fun]]))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!is.null(band_args) || isFALSE(band_args)) {
|
|
82
|
+
if (isTRUE(band_args$disabled)) {
|
|
83
|
+
band_args <- NULL
|
|
84
|
+
} else {
|
|
85
|
+
band_args$disabled <- NULL
|
|
86
|
+
band_args <- list_update(band_args, args)
|
|
87
|
+
if (band_args$distribution == "custom") {
|
|
88
|
+
band_args$dparams <- band_args$dparams %||% list()
|
|
89
|
+
band_args$dparams$values <- theor_vals
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (!is.null(line_args) || isFALSE(line_args)) {
|
|
94
|
+
if (isTRUE(line_args$disabled)) {
|
|
95
|
+
line_args <- NULL
|
|
96
|
+
} else {
|
|
97
|
+
line_args$disabled <- NULL
|
|
98
|
+
line_args <- list_update(line_args, args)
|
|
99
|
+
if (line_args$distribution == "custom") {
|
|
100
|
+
line_args$dparams <- line_args$dparams %||% list()
|
|
101
|
+
line_args$dparams$values <- theor_vals
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (!is.null(point_args) || isFALSE(point_args)) {
|
|
106
|
+
if (isTRUE(point_args$disabled)) {
|
|
107
|
+
point_args <- NULL
|
|
108
|
+
} else {
|
|
109
|
+
point_args$disabled <- NULL
|
|
110
|
+
point_args <- list_update(point_args, args)
|
|
111
|
+
if (point_args$distribution == "custom") {
|
|
112
|
+
point_args$dparams <- point_args$dparams %||% list()
|
|
113
|
+
point_args$dparams$values <- theor_vals
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
title <- title %||% waiver()
|
|
119
|
+
xlabel <- xlabel %||% waiver()
|
|
120
|
+
ylabel <- ylabel %||% waiver()
|
|
121
|
+
|
|
122
|
+
indata <- indata[complete.cases(indata), , drop = FALSE]
|
|
123
|
+
indata <- indata[order(indata[[val_col]]), , drop = FALSE]
|
|
124
|
+
|
|
125
|
+
p <- ggplot(data = indata, mapping = aes(sample = !!sym(val_col))) +
|
|
126
|
+
labs(title = title, x = xlabel, y = ylabel)
|
|
127
|
+
|
|
128
|
+
if (!is.null(band_args)) {
|
|
129
|
+
p <- p + do_call(band_fun, band_args)
|
|
130
|
+
}
|
|
131
|
+
if (!is.null(line_args)) {
|
|
132
|
+
p <- p + do_call(line_fun, line_args)
|
|
133
|
+
}
|
|
134
|
+
if (!is.null(point_args)) {
|
|
135
|
+
p <- p + do_call(point_fun, point_args)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (!is.null(ggs)) {
|
|
139
|
+
for (gg in ggs) {
|
|
140
|
+
p <- p + eval(parse(text = gg))
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
png(outfile, width=devpars$width, height=devpars$height, res=devpars$res)
|
|
145
|
+
print(p)
|
|
146
|
+
dev.off()
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
|
|
2
|
+
{{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
|
|
3
|
+
|
|
4
|
+
library(rlang)
|
|
5
|
+
library(ggplot2)
|
|
6
|
+
library(plotROC)
|
|
7
|
+
|
|
8
|
+
infile <- {{in.infile | r}}
|
|
9
|
+
outfile <- {{out.outfile | r}}
|
|
10
|
+
joboutdir <- {{job.outdir | r}}
|
|
11
|
+
noids <- {{envs.noids | r}}
|
|
12
|
+
pos_label <- {{envs.pos_label | r}}
|
|
13
|
+
ci <- {{envs.ci | r}}
|
|
14
|
+
devpars <- {{envs.devpars | r}}
|
|
15
|
+
show_auc <- {{envs.show_auc | r}}
|
|
16
|
+
args <- {{envs.args | r: todot="-"}}
|
|
17
|
+
style_roc_args <- {{envs.style_roc | r: todot="-"}}
|
|
18
|
+
if (!is.null(style_roc_args$theme)) {
|
|
19
|
+
style_roc_args$theme <- eval(parse(text=style_roc_args$theme))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
data <- read.table(infile, header=TRUE, sep="\t", row.names = NULL, check.names = FALSE, stringsAsFactors=FALSE)
|
|
23
|
+
if (!noids) {
|
|
24
|
+
data <- data[, -1]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Normalize the first column (labels) into 0 and 1.
|
|
28
|
+
# If they are not 0/1, use pos_label to determine the positive class.
|
|
29
|
+
label_col <- colnames(data)[1]
|
|
30
|
+
if (is.character(data[[label_col]])) {
|
|
31
|
+
data[[label_col]] <- as.numeric(data[[label_col]] == pos_label)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
models <- colnames(data)[2:ncol(data)]
|
|
35
|
+
|
|
36
|
+
if (length(models) > 1) {
|
|
37
|
+
# pivot longer the models, and put the model names into the column 'model'
|
|
38
|
+
data <- melt_roc(data, label_col, colnames(data)[2:ncol(data)])
|
|
39
|
+
} else {
|
|
40
|
+
data <- data.frame(
|
|
41
|
+
D = data[[label_col]],
|
|
42
|
+
M = data[[models]],
|
|
43
|
+
name = rep(models, nrow(data))
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# Plot the ROC curve
|
|
48
|
+
p <- ggplot(data, aes(d = D, m = M, color = name))
|
|
49
|
+
|
|
50
|
+
if (isTRUE(ci)) {
|
|
51
|
+
p <- p + do.call(geom_rocci, args)
|
|
52
|
+
} else {
|
|
53
|
+
p <- p + do.call(geom_roc, args)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
p <- p + do.call(style_roc, style_roc_args)
|
|
57
|
+
p <- p + scale_color_biopipen()
|
|
58
|
+
|
|
59
|
+
if (length(models) > 1) {
|
|
60
|
+
p <- p + theme(legend.title = element_blank())
|
|
61
|
+
} else {
|
|
62
|
+
p <- p + theme(legend.position = "none")
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
aucs = calc_auc(p)
|
|
66
|
+
write.table(aucs, file=file.path(joboutdir, "aucs.tsv"), sep="\t", quote=FALSE, row.names=FALSE)
|
|
67
|
+
|
|
68
|
+
if (show_auc) {
|
|
69
|
+
aucs = split(aucs$AUC, aucs$name)
|
|
70
|
+
if (length(aucs) > 1) {
|
|
71
|
+
# Add AUC values to the legend items
|
|
72
|
+
p <- p +
|
|
73
|
+
scale_color_manual(
|
|
74
|
+
values = pal_biopipen()(length(models)),
|
|
75
|
+
labels = sapply(models, function(m) paste(m, " (AUC =", round(aucs[[m]], 2), ")")),
|
|
76
|
+
breaks = models)
|
|
77
|
+
} else {
|
|
78
|
+
p <- p +
|
|
79
|
+
geom_text(
|
|
80
|
+
x = 0.8, y = 0.2, label = paste("AUC =", round(unlist(aucs), 2)),
|
|
81
|
+
color = "black", size = 4)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
devpars$filename <- outfile
|
|
86
|
+
do.call(png, devpars)
|
|
87
|
+
print(p)
|
|
88
|
+
dev.off()
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
|
|
2
|
+
|
|
3
|
+
library(ggpmisc)
|
|
4
|
+
library(rlang)
|
|
5
|
+
library(ggplot2)
|
|
6
|
+
library(ggprism)
|
|
7
|
+
|
|
8
|
+
theme_set(theme_prism())
|
|
9
|
+
|
|
10
|
+
infile <- {{in.infile | r}}
|
|
11
|
+
outfile <- {{out.outfile | r}}
|
|
12
|
+
x_col <- {{envs.x_col | r}}
|
|
13
|
+
y_col <- {{envs.y_col | r}}
|
|
14
|
+
devpars <- {{envs.devpars | r}}
|
|
15
|
+
args <- {{envs.args | r}}
|
|
16
|
+
ggs <- {{envs.ggs | r}}
|
|
17
|
+
formula <- {{envs.formula | r}}
|
|
18
|
+
mapping <- {{envs.mapping | r}}
|
|
19
|
+
stats <- {{envs.stats | r}}
|
|
20
|
+
|
|
21
|
+
.ensure_r <- function(ex, recursive=TRUE) {
|
|
22
|
+
if (is.character(ex)) {
|
|
23
|
+
ex <- trimws(ex)
|
|
24
|
+
if (grepl("^-\\s*[a-zA-Z\\.][0-9a-zA-Z\\._]*$", ex)) {
|
|
25
|
+
ex <- trimws(substring(ex, 2))
|
|
26
|
+
ex <- eval(parse(text = ex))
|
|
27
|
+
return(function(x) -ex(x))
|
|
28
|
+
} else {
|
|
29
|
+
return(eval(parse(text = ex)))
|
|
30
|
+
}
|
|
31
|
+
} else if (is.list(ex) && recursive) {
|
|
32
|
+
return(lapply(ex, .ensure_r, recursive=TRUE))
|
|
33
|
+
} else {
|
|
34
|
+
return(ex)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.merge_aes <- function(aes1, aes2) {
|
|
39
|
+
if (is.null(aes1)) {
|
|
40
|
+
return(aes2)
|
|
41
|
+
}
|
|
42
|
+
if (is.null(aes2)) {
|
|
43
|
+
return(aes1)
|
|
44
|
+
}
|
|
45
|
+
merged <- c(aes1, aes2) # list
|
|
46
|
+
out <- list()
|
|
47
|
+
for (key in names(merged)) {
|
|
48
|
+
if (is.null(out[[key]])) {
|
|
49
|
+
out[[key]] <- merged[[key]]
|
|
50
|
+
} else {
|
|
51
|
+
log_warn(paste("Overwriting mapping key:", key))
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return(do.call(aes, out))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (is.null(formula)) {
|
|
58
|
+
stop("Formula must be provided")
|
|
59
|
+
}
|
|
60
|
+
if (!is.null(mapping)) {
|
|
61
|
+
if (startsWith(mapping, "(") && endsWith(mapping, ")")) {
|
|
62
|
+
mapping <- paste0("aes", mapping)
|
|
63
|
+
} else if (!startsWith(mapping, "aes(")) {
|
|
64
|
+
mapping <- paste0("aes(", mapping, ")")
|
|
65
|
+
}
|
|
66
|
+
mapping <- .ensure_r(mapping)
|
|
67
|
+
}
|
|
68
|
+
formula <- as.formula(formula)
|
|
69
|
+
|
|
70
|
+
indata <- read.table(infile, header=TRUE, sep="\t", stringsAsFactors=FALSE, check.names = FALSE)
|
|
71
|
+
if (is.numeric(x_col)) {
|
|
72
|
+
x_col <- colnames(indata)[x_col]
|
|
73
|
+
}
|
|
74
|
+
if (is.numeric(y_col)) {
|
|
75
|
+
y_col <- colnames(indata)[y_col]
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
args <- lapply(args, .ensure_r)
|
|
79
|
+
args$mapping <- .merge_aes(args$mapping, mapping)
|
|
80
|
+
|
|
81
|
+
if (!is.null(stats)) {
|
|
82
|
+
stats <- lapply(stats, .ensure_r)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
p <- ggplot(indata, aes(x = !!sym(x_col), y = !!sym(y_col))) +
|
|
86
|
+
do.call(geom_point, args)
|
|
87
|
+
|
|
88
|
+
for (stat in names(stats)) {
|
|
89
|
+
if (startsWith(stat, "stat_")) {
|
|
90
|
+
stat <- substring(stat, 6)
|
|
91
|
+
}
|
|
92
|
+
if (grepl("#", stat)) {
|
|
93
|
+
st <- paste0("stat_", strsplit(stat, "#")[[1]][1])
|
|
94
|
+
} else {
|
|
95
|
+
st <- paste0("stat_", stat)
|
|
96
|
+
}
|
|
97
|
+
stats[[stat]]$formula <- stats[[stat]]$formula %||% formula
|
|
98
|
+
stats[[stat]]$mapping <- .merge_aes(stats[[stat]]$mapping, mapping)
|
|
99
|
+
p <- p + do.call(st, stats[[stat]])
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!is.null(ggs)) {
|
|
103
|
+
for (gg in ggs) {
|
|
104
|
+
p <- p + eval(parse(text = gg))
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
p <- p + scale_color_biopipen()
|
|
109
|
+
|
|
110
|
+
png(outfile, width=devpars$width, height=devpars$height, res=devpars$res)
|
|
111
|
+
print(p)
|
|
112
|
+
dev.off()
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
{{ biopipen_dir | joinpaths: "utils", "io.R" | source_r }}
|
|
2
|
+
{{ biopipen_dir | joinpaths: "utils", "plot.R" | source_r }}
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
infile = {{in.infile | quote}}
|
|
7
|
-
outfile = {{out.outfile | quote}}
|
|
4
|
+
infile = {{in.infile | r}}
|
|
5
|
+
outfile = {{out.outfile | r}}
|
|
8
6
|
inopts = {{envs.inopts | r}}
|
|
9
7
|
intype = {{envs.intype | r}}
|
|
10
8
|
devpars = {{envs.devpars | r}}
|
|
@@ -18,9 +16,7 @@ if (intype == "raw") {
|
|
|
18
16
|
indata = lapply(indata, function(x) unlist(strsplit(x, ",", fixed=TRUE)))
|
|
19
17
|
} else { # computed
|
|
20
18
|
elems = rownames(indata)
|
|
21
|
-
indata = indata
|
|
22
|
-
mutate(across(everything(), function(x) elems[as.logical(x)])) %>%
|
|
23
|
-
as.list()
|
|
19
|
+
indata = apply(indata, 2, function(x) elems[as.logical(x)])
|
|
24
20
|
}
|
|
25
21
|
|
|
26
22
|
plotVenn(
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from shutil import which
|
|
3
|
+
from diot import Diot # noqa: F401
|
|
4
|
+
from biopipen.utils.misc import run_command, dict_to_cli_args
|
|
5
|
+
|
|
6
|
+
infile: str = {{in.infile | quote}} # pyright: ignore # noqa
|
|
7
|
+
outfile: str = {{out.outfile | quote}} # pyright: ignore
|
|
8
|
+
envs: dict = {{envs | repr}} # pyright: ignore
|
|
9
|
+
tool: str = envs.pop("tool", "maxit")
|
|
10
|
+
maxit: str = envs.pop("maxit", "maxit")
|
|
11
|
+
beem = envs.pop("beem", "BeEM")
|
|
12
|
+
|
|
13
|
+
if tool == "maxit":
|
|
14
|
+
maxit_found = which(maxit)
|
|
15
|
+
if not maxit_found:
|
|
16
|
+
raise ValueError(f"maxit executable not found: {maxit}")
|
|
17
|
+
|
|
18
|
+
maxit_exe = Path(maxit_found).expanduser().resolve()
|
|
19
|
+
rcsbroot = maxit_exe.parent.parent
|
|
20
|
+
envs["input"] = infile
|
|
21
|
+
envs["output"] = outfile
|
|
22
|
+
envs["o"] = 2
|
|
23
|
+
envs["log"] = Path(outfile).with_suffix(".log")
|
|
24
|
+
run_command([maxit, *dict_to_cli_args(envs, prefix="-")], fg=True, env={"RCSBROOT": rcsbroot})
|
|
25
|
+
|
|
26
|
+
else:
|
|
27
|
+
outfile: Path = Path(outfile) # type: ignore
|
|
28
|
+
envs["_"] = infile
|
|
29
|
+
envs["p"] = outfile.parent.joinpath(outfile.stem)
|
|
30
|
+
envs["outfmt"] = 3
|
|
31
|
+
args = dict_to_cli_args(envs, prefix="-", sep="=")
|
|
32
|
+
|
|
33
|
+
run_command([beem, *args], fg=True)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# """
|
|
2
|
+
# LICENSE
|
|
3
|
+
|
|
4
|
+
# GNU General Public License v2.0
|
|
5
|
+
|
|
6
|
+
# The code is based on the script from:
|
|
7
|
+
# https://github.com/kad-ecoli/pdb2fasta/blob/master/pdb2fasta.py
|
|
8
|
+
|
|
9
|
+
# The original code is licensed under GNU General Public License v2.0.
|
|
10
|
+
# The original code is modified by biopipen developers to fit the biopipen.
|
|
11
|
+
# """
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
import re
|
|
14
|
+
from collections import defaultdict
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
infile: str = {{in.infile | quote}} # pyright: ignore # noqa: E999
|
|
18
|
+
outfile: str = {{out.outfile | quote}} # pyright: ignore
|
|
19
|
+
chains: str | list | None = {{envs.chains | repr}} # pyright: ignore
|
|
20
|
+
wrap: int = {{envs.wrap | repr}} # pyright: ignore
|
|
21
|
+
|
|
22
|
+
if isinstance(chains, str):
|
|
23
|
+
chains = [chain.strip() for chain in chains.split(",")]
|
|
24
|
+
|
|
25
|
+
aa3to1 = {
|
|
26
|
+
'ALA':'A', 'VAL':'V', 'PHE':'F', 'PRO':'P', 'MET':'M',
|
|
27
|
+
'ILE':'I', 'LEU':'L', 'ASP':'D', 'GLU':'E', 'LYS':'K',
|
|
28
|
+
'ARG':'R', 'SER':'S', 'THR':'T', 'TYR':'Y', 'HIS':'H',
|
|
29
|
+
'CYS':'C', 'ASN':'N', 'GLN':'Q', 'TRP':'W', 'GLY':'G',
|
|
30
|
+
'MSE':'M',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
ca_pattern = re.compile(
|
|
34
|
+
r"^ATOM\s{2,6}\d{1,5}\s{2}CA\s[\sA]([A-Z]{3})\s([\s\w])|^HETATM\s{0,4}\d{1,5}\s{2}CA\s[\sA](MSE)\s([\s\w])" # noqa: W605
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
filename = Path(infile).stem
|
|
38
|
+
chain_dict = defaultdict(str)
|
|
39
|
+
|
|
40
|
+
with open(infile, 'r') as fp:
|
|
41
|
+
for line in fp:
|
|
42
|
+
if line.startswith("ENDMDL"):
|
|
43
|
+
break
|
|
44
|
+
|
|
45
|
+
match_list = ca_pattern.findall(line)
|
|
46
|
+
if match_list:
|
|
47
|
+
resn = match_list[0][0] + match_list[0][2]
|
|
48
|
+
chain = match_list[0][1] + match_list[0][3]
|
|
49
|
+
if chains is None or chain in chains:
|
|
50
|
+
chain_dict[chain] += aa3to1[resn]
|
|
51
|
+
|
|
52
|
+
with open(outfile, 'w') as fp:
|
|
53
|
+
for chain in chain_dict:
|
|
54
|
+
fp.write(f">{filename}:{chain}\n")
|
|
55
|
+
sequence = chain_dict[chain]
|
|
56
|
+
if wrap > 0:
|
|
57
|
+
for i in range(0, len(sequence), 80):
|
|
58
|
+
fp.write(sequence[i:i+80] + "\n")
|
|
59
|
+
else:
|
|
60
|
+
fp.write(sequence + "\n")
|