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,139 +1,110 @@
|
|
|
1
|
-
source("{{biopipen_dir}}/utils/misc.R")
|
|
2
|
-
|
|
3
1
|
library(Seurat)
|
|
4
|
-
library(
|
|
2
|
+
library(rlang)
|
|
3
|
+
library(biopipen.utils)
|
|
4
|
+
|
|
5
|
+
set.seed(8525)
|
|
5
6
|
|
|
6
7
|
sobjfile = {{in.sobjfile | r}}
|
|
7
8
|
outfile = {{out.outfile | r}}
|
|
9
|
+
joboutdir = {{job.outdir | r}}
|
|
8
10
|
use = {{envs.use | r}}
|
|
9
|
-
|
|
11
|
+
ident = {{envs.ident | r}}
|
|
10
12
|
ref = {{envs.ref | r}}
|
|
13
|
+
refnorm = {{envs.refnorm | r}}
|
|
14
|
+
ncores = {{envs.ncores | r}}
|
|
15
|
+
split_by = {{envs.split_by | r}}
|
|
16
|
+
mutaters = {{envs.mutaters | r}}
|
|
17
|
+
skip_if_normalized = {{envs.skip_if_normalized | r}}
|
|
11
18
|
sctransform_args = {{envs.SCTransform | r: todot="-"}}
|
|
19
|
+
normalizedata_args = {{envs.NormalizeData | r: todot="-"}}
|
|
12
20
|
findtransferanchors_args = {{envs.FindTransferAnchors | r: todot="-"}}
|
|
13
21
|
mapquery_args = {{envs.MapQuery | r: todot="-"}}
|
|
14
|
-
|
|
22
|
+
cache = {{envs.cache | r}}
|
|
23
|
+
plots = {{envs.plots | r}}
|
|
15
24
|
|
|
16
|
-
|
|
25
|
+
log <- get_logger()
|
|
26
|
+
reporter <- get_reporter()
|
|
27
|
+
|
|
28
|
+
options(future.globals.maxSize = Inf)
|
|
29
|
+
options(future.rng.onMisuse="ignore")
|
|
30
|
+
options(Seurat.object.assay.version = "v5")
|
|
17
31
|
|
|
18
32
|
# See if we have a reference
|
|
19
33
|
if (is.null(ref)) {
|
|
20
|
-
|
|
34
|
+
stop("No reference provided (envs.ref)")
|
|
21
35
|
}
|
|
22
36
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (is.numeric(args[[name]]) && length(args[[name]] == 1)) {
|
|
26
|
-
args[[name]] = 1:args[[name]]
|
|
27
|
-
}
|
|
28
|
-
args
|
|
29
|
-
}
|
|
30
|
-
findtransferanchors_args = .expand_dims(findtransferanchors_args)
|
|
31
|
-
|
|
32
|
-
# Load reference
|
|
33
|
-
print("Loading reference")
|
|
34
|
-
if (endsWith(ref, ".rds") || endsWith(ref, ".RDS")) {
|
|
35
|
-
reference = readRDS(ref)
|
|
36
|
-
} else if (endsWith(ref, ".h5ad") || endsWith(ref, ".H5AD")) {
|
|
37
|
-
reference = ReadH5AD(ref)
|
|
38
|
-
} else {
|
|
39
|
-
reference = LoadH5Seurat(ref)
|
|
37
|
+
if (is.null(use)) {
|
|
38
|
+
stop("No use provided (envs.use), don't know which column to transfer as cluster")
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
sctransform_args$residual.features = rownames(x = reference)
|
|
50
|
-
query = do_call(SCTransform, sctransform_args)
|
|
51
|
-
|
|
52
|
-
# Find anchors between query and reference
|
|
53
|
-
print("Finding anchors")
|
|
54
|
-
findtransferanchors_args$reference = reference
|
|
55
|
-
findtransferanchors_args$query = query
|
|
56
|
-
anchors = do_call(FindTransferAnchors, findtransferanchors_args)
|
|
57
|
-
|
|
58
|
-
# Map query to reference
|
|
59
|
-
print("Mapping query to reference")
|
|
60
|
-
mapquery_args$reference = reference
|
|
61
|
-
mapquery_args$query = query
|
|
62
|
-
mapquery_args$anchorset = anchors
|
|
63
|
-
query = do_call(MapQuery, mapquery_args)
|
|
64
|
-
|
|
65
|
-
# Calculating mapping score
|
|
66
|
-
print("Calculating mapping score")
|
|
67
|
-
mappingscore_args$anchors = anchors
|
|
68
|
-
mappingscore = tryCatch({
|
|
69
|
-
do_call(MappingScore, mappingscore_args)
|
|
70
|
-
}, error = function(e) {
|
|
71
|
-
if (e$message == "subscript out of bounds") {
|
|
72
|
-
stop(paste0(
|
|
73
|
-
"While calculating mapping score, the following error was encountered: \n",
|
|
74
|
-
"subscript out of bounds. \n\n",
|
|
75
|
-
"You may want to try a smaller `ndim` (default: 50) in `envs.MappingScore`."
|
|
76
|
-
))
|
|
77
|
-
}
|
|
78
|
-
stop(e)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
# Calculate mapping score and add to metadata
|
|
82
|
-
print("Calculating mapping score")
|
|
83
|
-
query = AddMetaData(
|
|
84
|
-
object = query,
|
|
85
|
-
metadata = mappingscore,
|
|
86
|
-
col.name = "mapping.score"
|
|
87
|
-
)
|
|
41
|
+
outdir = dirname(outfile)
|
|
42
|
+
if (isTRUE(cache)) {
|
|
43
|
+
cache = joboutdir
|
|
44
|
+
}
|
|
45
|
+
if (is.null(split_by)) {
|
|
46
|
+
future::plan(strategy = "multicore", workers = ncores)
|
|
47
|
+
}
|
|
88
48
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
49
|
+
log$info("Loading reference ...")
|
|
50
|
+
if (endsWith(ref, ".rds") || endsWith(ref, ".RDS") || endsWith(ref, ".qs") || endsWith(ref, ".qs2")) {
|
|
51
|
+
reference <- read_obj(ref)
|
|
52
|
+
} else if (endsWith(ref, ".h5seurat") || endsWith(ref, ".H5Seurat")) {
|
|
53
|
+
reference <- SeuratDisk::LoadH5Seurat(ref)
|
|
54
|
+
} else {
|
|
55
|
+
stop("Reference file must be .qs, .qs2, .rds, .RDS, .h5seurat or .H5Seurat")
|
|
56
|
+
}
|
|
57
|
+
reference <- tryCatch(JoinLayers(reference), error = function(e) {reference})
|
|
58
|
+
Idents(reference) <- reference@meta.data[[use]]
|
|
59
|
+
|
|
60
|
+
log$info("Loading query data ...")
|
|
61
|
+
sobj <- read_obj(sobjfile)
|
|
62
|
+
|
|
63
|
+
sobj <- RunSeuratMap2Ref(
|
|
64
|
+
object = sobj, ref = reference, use = use,
|
|
65
|
+
ident = ident, refnorm = refnorm, skip_if_normalized = skip_if_normalized,
|
|
66
|
+
split_by = split_by, ncores = ncores,
|
|
67
|
+
SCTransformArgs = sctransform_args,
|
|
68
|
+
NormalizeDataArgs = normalizedata_args,
|
|
69
|
+
FindTransferAnchorsArgs = findtransferanchors_args,
|
|
70
|
+
MapQueryArgs = mapquery_args,
|
|
71
|
+
log = log, cache = cache
|
|
95
72
|
)
|
|
96
73
|
|
|
97
74
|
# Save
|
|
98
|
-
|
|
99
|
-
|
|
75
|
+
gc()
|
|
76
|
+
log$info("Saving result ...")
|
|
77
|
+
save_obj(sobj, file = outfile)
|
|
100
78
|
|
|
101
79
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
# # Plot the UMAP
|
|
107
|
-
print("Plotting")
|
|
108
|
-
for (refname in names(mapquery_args$refdata)) {
|
|
109
|
-
if (refname == "predicted_ADT") {
|
|
80
|
+
### Plotting
|
|
81
|
+
log$info("Plotting features ...")
|
|
82
|
+
for (name in names(plots)) {
|
|
83
|
+
if (is.null(plots[[name]])) {
|
|
110
84
|
next
|
|
111
85
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
) + NoLegend()
|
|
135
|
-
|
|
136
|
-
png(file.path(outdir, paste0("Query_UMAP_", refname, ".png")), width = 1000, height = 1000, res = 100)
|
|
137
|
-
print(p)
|
|
138
|
-
dev.off()
|
|
86
|
+
log$info("- {name} ...")
|
|
87
|
+
plots[[name]]$features <- gsub("{use}", use, plots[[name]]$features, fixed = TRUE)
|
|
88
|
+
plots[[name]]$features <- gsub("{ident}", ident, plots[[name]]$features, fixed = TRUE)
|
|
89
|
+
|
|
90
|
+
plots[[name]]$devpars <- plots[[name]]$devpars %||% list()
|
|
91
|
+
plots[[name]]$devpars$res <- plots[[name]]$devpars$res %||% 100
|
|
92
|
+
plots[[name]]$devpars$width <- plots[[name]]$devpars$width %||% 1200
|
|
93
|
+
plots[[name]]$devpars$height <- plots[[name]]$devpars$height %||% 720
|
|
94
|
+
plots[[name]]$more_formats <- plots[[name]]$more_formats %||% character()
|
|
95
|
+
plots[[name]]$save_code <- FALSE
|
|
96
|
+
plots[[name]]$descr <- plots[[name]]$descr %||% name
|
|
97
|
+
extract_vars(plots[[name]], "devpars", "more_formats", "save_code", "descr")
|
|
98
|
+
|
|
99
|
+
plot_fn <- gglogger::register(VizSeuratMap2Ref)
|
|
100
|
+
p <- do_call(plot_fn, c(list(query = sobj, ref = reference), plots[[name]]))
|
|
101
|
+
prefix <- file.path(outdir, paste0(slugify(name), ".map2ref"))
|
|
102
|
+
save_plot(p, prefix, devpars, formats = c("png", more_formats))
|
|
103
|
+
|
|
104
|
+
reporter$add(
|
|
105
|
+
reporter$image(prefix, more_formats, save_code = FALSE, kind = "image"),
|
|
106
|
+
h1 = name
|
|
107
|
+
)
|
|
139
108
|
}
|
|
109
|
+
|
|
110
|
+
reporter$save(joboutdir)
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
source("{{biopipen_dir}}/utils/mutate_helpers.R")
|
|
2
1
|
library(rlang)
|
|
3
2
|
library(tibble)
|
|
4
3
|
library(dplyr)
|
|
5
4
|
library(Seurat)
|
|
5
|
+
library(biopipen.utils)
|
|
6
6
|
|
|
7
|
-
srtobj = {{in.srtobj |
|
|
7
|
+
srtobj = {{in.srtobj | r}}
|
|
8
8
|
metafile = {{in.metafile | r}}
|
|
9
9
|
mutaters = {{envs.mutaters | r}}
|
|
10
|
-
|
|
10
|
+
outfile = {{out.outfile | r}}
|
|
11
11
|
|
|
12
|
-
srt =
|
|
12
|
+
srt = read_obj(srtobj)
|
|
13
13
|
metadata = srt@meta.data
|
|
14
14
|
|
|
15
15
|
if (!is.null(metafile)) {
|
|
16
16
|
mdata = read.table(metafile, header=TRUE, row.names=1, sep="\t", check.names=FALSE)
|
|
17
|
-
|
|
17
|
+
ov_cols = intersect(colnames(metadata), colnames(mdata))
|
|
18
|
+
if (length(ov_cols) > 0) {
|
|
19
|
+
log_warn(paste0(
|
|
20
|
+
"The following columns are already present in Seurat object and will be ignored: ",
|
|
21
|
+
paste(ov_cols, collapse=', ')
|
|
22
|
+
))
|
|
23
|
+
}
|
|
24
|
+
metadata = cbind(
|
|
25
|
+
metadata,
|
|
26
|
+
mdata[rownames(metadata), setdiff(colnames(mdata), ov_cols), drop=FALSE]
|
|
27
|
+
)
|
|
18
28
|
}
|
|
19
29
|
|
|
20
30
|
expr = list()
|
|
@@ -28,4 +38,4 @@ if (!is.null(expr) && length(expr) > 0) {
|
|
|
28
38
|
srt@meta.data = metadata
|
|
29
39
|
}
|
|
30
40
|
|
|
31
|
-
|
|
41
|
+
save_obj(srt, outfile)
|