biopipen 0.33.0__py3-none-any.whl → 0.34.0__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.
Potentially problematic release.
This version of biopipen might be problematic. Click here for more details.
- biopipen/__init__.py +1 -1
- biopipen/core/filters.py +10 -183
- biopipen/core/proc.py +5 -3
- biopipen/core/testing.py +8 -1
- biopipen/ns/bam.py +40 -4
- biopipen/ns/cnv.py +1 -1
- biopipen/ns/cnvkit.py +1 -1
- biopipen/ns/delim.py +1 -1
- biopipen/ns/gsea.py +63 -37
- biopipen/ns/misc.py +38 -0
- biopipen/ns/plot.py +8 -0
- biopipen/ns/scrna.py +307 -288
- biopipen/ns/scrna_metabolic_landscape.py +207 -366
- biopipen/ns/tcr.py +165 -97
- biopipen/reports/bam/CNVpytor.svelte +4 -9
- biopipen/reports/cnvkit/CNVkitDiagram.svelte +1 -1
- biopipen/reports/cnvkit/CNVkitHeatmap.svelte +1 -1
- biopipen/reports/cnvkit/CNVkitScatter.svelte +1 -1
- biopipen/reports/{delim/SampleInfo.svelte → common.svelte} +2 -3
- biopipen/reports/scrna/DimPlots.svelte +1 -1
- biopipen/reports/scrna_metabolic_landscape/MetabolicFeatures.svelte +51 -22
- biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayActivity.svelte +46 -42
- biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayHeterogeneity.svelte +63 -6
- biopipen/reports/snp/PlinkCallRate.svelte +2 -2
- biopipen/reports/snp/PlinkFreq.svelte +1 -1
- biopipen/reports/snp/PlinkHWE.svelte +1 -1
- biopipen/reports/snp/PlinkHet.svelte +1 -1
- biopipen/reports/snp/PlinkIBD.svelte +1 -1
- biopipen/reports/tcr/CDR3AAPhyschem.svelte +1 -1
- biopipen/scripts/bam/CNAClinic.R +41 -6
- biopipen/scripts/bam/CNVpytor.py +2 -1
- biopipen/scripts/bam/ControlFREEC.py +2 -3
- biopipen/scripts/bam/SamtoolsView.py +33 -0
- biopipen/scripts/cnv/AneuploidyScore.R +25 -13
- biopipen/scripts/cnv/AneuploidyScoreSummary.R +218 -163
- biopipen/scripts/cnv/TMADScore.R +4 -4
- biopipen/scripts/cnv/TMADScoreSummary.R +51 -84
- biopipen/scripts/cnvkit/CNVkitGuessBaits.py +3 -3
- biopipen/scripts/cnvkit/CNVkitHeatmap.py +3 -3
- biopipen/scripts/cnvkit/CNVkitReference.py +3 -3
- biopipen/scripts/delim/RowsBinder.R +1 -1
- biopipen/scripts/delim/SampleInfo.R +14 -2
- biopipen/scripts/gene/GeneNameConversion.R +14 -12
- biopipen/scripts/gsea/Enrichr.R +2 -2
- biopipen/scripts/gsea/FGSEA.R +184 -50
- biopipen/scripts/gsea/PreRank.R +3 -3
- biopipen/scripts/misc/Plot.R +80 -0
- biopipen/scripts/plot/VennDiagram.R +2 -2
- biopipen/scripts/protein/ProdigySummary.R +34 -27
- biopipen/scripts/regulatory/MotifAffinityTest.R +11 -9
- biopipen/scripts/regulatory/MotifAffinityTest_AtSNP.R +5 -5
- biopipen/scripts/regulatory/MotifAffinityTest_MotifBreakR.R +4 -4
- biopipen/scripts/regulatory/VariantMotifPlot.R +10 -8
- biopipen/scripts/regulatory/motifs-common.R +10 -9
- biopipen/scripts/rnaseq/Simulation-ESCO.R +14 -11
- biopipen/scripts/rnaseq/Simulation-RUVcorr.R +7 -4
- biopipen/scripts/rnaseq/Simulation.R +0 -2
- biopipen/scripts/rnaseq/UnitConversion.R +6 -5
- biopipen/scripts/scrna/AnnData2Seurat.R +25 -73
- biopipen/scripts/scrna/CellCellCommunication.py +1 -1
- biopipen/scripts/scrna/CellCellCommunicationPlots.R +51 -168
- biopipen/scripts/scrna/CellTypeAnnotation-celltypist.R +99 -150
- biopipen/scripts/scrna/CellTypeAnnotation-direct.R +11 -9
- biopipen/scripts/scrna/CellTypeAnnotation-hitype.R +12 -9
- biopipen/scripts/scrna/CellTypeAnnotation-sccatch.R +14 -11
- biopipen/scripts/scrna/CellTypeAnnotation-sctype.R +19 -16
- biopipen/scripts/scrna/CellTypeAnnotation.R +10 -2
- biopipen/scripts/scrna/CellsDistribution.R +1 -1
- biopipen/scripts/scrna/ExprImputation-alra.R +87 -11
- biopipen/scripts/scrna/ExprImputation-rmagic.R +247 -21
- biopipen/scripts/scrna/ExprImputation-scimpute.R +8 -5
- biopipen/scripts/scrna/LoomTo10X.R +51 -0
- biopipen/scripts/scrna/MarkersFinder.R +348 -217
- biopipen/scripts/scrna/MetaMarkers.R +3 -3
- biopipen/scripts/scrna/ModuleScoreCalculator.R +14 -13
- biopipen/scripts/scrna/RadarPlots.R +1 -1
- biopipen/scripts/scrna/ScFGSEA.R +157 -75
- biopipen/scripts/scrna/ScSimulation.R +11 -10
- biopipen/scripts/scrna/ScVelo.py +605 -0
- biopipen/scripts/scrna/Seurat2AnnData.R +2 -3
- biopipen/scripts/scrna/SeuratClusterStats-clustree.R +1 -1
- biopipen/scripts/scrna/SeuratClusterStats-features.R +39 -30
- biopipen/scripts/scrna/SeuratClusterStats-ngenes.R +56 -65
- biopipen/scripts/scrna/SeuratClusterStats-stats.R +4 -4
- biopipen/scripts/scrna/SeuratClusterStats.R +9 -6
- biopipen/scripts/scrna/SeuratClustering.R +31 -48
- biopipen/scripts/scrna/SeuratLoading.R +2 -2
- biopipen/scripts/scrna/SeuratMap2Ref.R +66 -367
- biopipen/scripts/scrna/SeuratMetadataMutater.R +5 -7
- biopipen/scripts/scrna/SeuratPreparing.R +76 -24
- biopipen/scripts/scrna/SeuratSubClustering.R +46 -185
- biopipen/scripts/scrna/{SlingShot.R → Slingshot.R} +12 -16
- biopipen/scripts/scrna/Subset10X.R +2 -2
- biopipen/scripts/scrna/TopExpressingGenes.R +141 -184
- biopipen/scripts/scrna/celltypist-wrapper.py +6 -4
- biopipen/scripts/scrna/seurat_anndata_conversion.py +81 -0
- biopipen/scripts/scrna_metabolic_landscape/MetabolicFeatures.R +429 -123
- biopipen/scripts/scrna_metabolic_landscape/MetabolicPathwayActivity.R +346 -245
- biopipen/scripts/scrna_metabolic_landscape/MetabolicPathwayHeterogeneity.R +182 -173
- biopipen/scripts/snp/MatrixEQTL.R +39 -20
- biopipen/scripts/snp/PlinkCallRate.R +43 -34
- biopipen/scripts/snp/PlinkFreq.R +34 -41
- biopipen/scripts/snp/PlinkHWE.R +23 -18
- biopipen/scripts/snp/PlinkHet.R +26 -22
- biopipen/scripts/snp/PlinkIBD.R +30 -34
- biopipen/scripts/stats/ChowTest.R +9 -8
- biopipen/scripts/stats/DiffCoexpr.R +13 -11
- biopipen/scripts/stats/LiquidAssoc.R +7 -8
- biopipen/scripts/stats/Mediation.R +8 -8
- biopipen/scripts/stats/MetaPvalue.R +11 -13
- biopipen/scripts/stats/MetaPvalue1.R +6 -5
- biopipen/scripts/tcr/CDR3AAPhyschem.R +105 -164
- biopipen/scripts/tcr/ClonalStats.R +5 -4
- biopipen/scripts/tcr/CloneResidency.R +3 -3
- biopipen/scripts/tcr/CloneSizeQQPlot.R +2 -2
- biopipen/scripts/tcr/Immunarch2VDJtools.R +2 -2
- biopipen/scripts/tcr/ImmunarchFilter.R +3 -3
- biopipen/scripts/tcr/ImmunarchLoading.R +5 -5
- biopipen/scripts/tcr/ScRepCombiningExpression.R +39 -0
- biopipen/scripts/tcr/ScRepLoading.R +114 -92
- biopipen/scripts/tcr/TCRClusterStats.R +2 -2
- biopipen/scripts/tcr/TCRClustering.R +86 -97
- biopipen/scripts/tcr/TESSA.R +65 -115
- biopipen/scripts/tcr/VJUsage.R +5 -5
- biopipen/scripts/vcf/TruvariBenchSummary.R +15 -11
- biopipen/utils/common_docstrs.py +66 -63
- biopipen/utils/reporter.py +177 -0
- {biopipen-0.33.0.dist-info → biopipen-0.34.0.dist-info}/METADATA +2 -1
- {biopipen-0.33.0.dist-info → biopipen-0.34.0.dist-info}/RECORD +131 -144
- {biopipen-0.33.0.dist-info → biopipen-0.34.0.dist-info}/WHEEL +1 -1
- biopipen/reports/scrna/CellCellCommunicationPlots.svelte +0 -14
- biopipen/reports/scrna/SeuratClusterStats.svelte +0 -16
- biopipen/reports/scrna/SeuratMap2Ref.svelte +0 -37
- biopipen/reports/scrna/SeuratPreparing.svelte +0 -15
- biopipen/reports/scrna_metabolic_landscape/MetabolicFeaturesIntraSubset.svelte +0 -28
- biopipen/reports/utils/gsea.liq +0 -110
- biopipen/scripts/scrna/CellTypeAnnotation-common.R +0 -10
- biopipen/scripts/scrna/SeuratClustering-common.R +0 -213
- biopipen/scripts/scrna_metabolic_landscape/MetabolicFeaturesIntraSubset.R +0 -193
- biopipen/utils/caching.R +0 -44
- biopipen/utils/gene.R +0 -95
- biopipen/utils/gsea.R +0 -329
- biopipen/utils/io.R +0 -20
- biopipen/utils/misc.R +0 -602
- biopipen/utils/mutate_helpers.R +0 -581
- biopipen/utils/plot.R +0 -209
- biopipen/utils/repr.R +0 -146
- biopipen/utils/rnaseq.R +0 -48
- biopipen/utils/single_cell.R +0 -207
- {biopipen-0.33.0.dist-info → biopipen-0.34.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,87 +1,39 @@
|
|
|
1
|
-
{{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
|
|
2
|
-
|
|
3
1
|
library(rlang)
|
|
4
2
|
library(Seurat)
|
|
5
|
-
library(
|
|
6
|
-
library(
|
|
3
|
+
library(scplotter)
|
|
4
|
+
library(biopipen.utils)
|
|
7
5
|
|
|
8
6
|
adfile <- {{in.adfile | r}}
|
|
9
7
|
outfile <- {{out.outfile | r}}
|
|
10
8
|
dotplot_check <- {{envs.dotplot_check | r}}
|
|
11
9
|
outdir <- dirname(outfile)
|
|
12
10
|
assay <- {{envs.assay | r}}
|
|
13
|
-
outtype <- {{envs.outtype | r}}
|
|
14
|
-
|
|
15
|
-
if (outtype == "rds") {
|
|
16
|
-
h5seurat_file <- file.path(
|
|
17
|
-
outdir,
|
|
18
|
-
paste0(tools::file_path_sans_ext(basename(outfile)), ".h5seurat")
|
|
19
|
-
)
|
|
20
|
-
} else if (outtype == "h5seurat") {
|
|
21
|
-
h5seurat_file <- outfile
|
|
22
|
-
} else {
|
|
23
|
-
stop("Unknown output file type: ", outtype)
|
|
24
|
-
}
|
|
25
11
|
|
|
26
|
-
|
|
27
|
-
file.remove(h5seurat_file)
|
|
28
|
-
}
|
|
12
|
+
log <- get_logger()
|
|
29
13
|
|
|
30
|
-
|
|
31
|
-
log_info("Converting to H5Seurat file ...")
|
|
32
|
-
Convert(adfile, dest = h5seurat_file, assay = assay, overwrite = TRUE)
|
|
33
|
-
} else {
|
|
34
|
-
log_info("Using existing H5Seurat file ...")
|
|
35
|
-
}
|
|
14
|
+
ConvertAnnDataToSeurat(adfile, outfile = outfile, assay = assay, log = log)
|
|
36
15
|
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# https://github.com/mojaveazure/seurat-disk/issues/109#issuecomment-1722394184
|
|
41
|
-
f <- H5File$new(h5seurat_file, "r+")
|
|
42
|
-
groups <- f$ls(recursive = TRUE)
|
|
16
|
+
if (!isFALSE(dotplot_check)) {
|
|
17
|
+
log$info("Reading Seurat object ...")
|
|
18
|
+
sobj <- read_obj(outfile)
|
|
43
19
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (!f$exists(codenames)) {
|
|
53
|
-
# No codes, skip
|
|
54
|
-
next
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (!f$exists(levelnames)) {
|
|
58
|
-
f[[levelnames]] <- f[[name]]
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (!f$exists(valuenames)) {
|
|
62
|
-
f[[valuenames]] <- f[[codenames]]
|
|
63
|
-
grp <- f[[valuenames]]
|
|
64
|
-
grp$write(args = list(1:grp$dims), value = grp$read() + 1)
|
|
65
|
-
}
|
|
20
|
+
log$info("Checking dotplot ...")
|
|
21
|
+
dotfig <- file.path(outdir, "dotplot.png")
|
|
22
|
+
if (isTRUE(dotplot_check)) {
|
|
23
|
+
vobj <- FindVariableFeatures(
|
|
24
|
+
sobj, selection.method = "vst", nfeatures = 2000)
|
|
25
|
+
dotplot_check <- head(VariableFeatures(vobj), 10)
|
|
26
|
+
} else if (is.character(dotplot_check)) {
|
|
27
|
+
dotplot_check <- trimws(strsplit(dotplot_check, ",")[[1]])
|
|
66
28
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
dotplot_check <- head(VariableFeatures(vobj), 10)
|
|
78
|
-
} else if (is.character(dotplot_check)) {
|
|
79
|
-
dotplot_check <- trimws(strsplit(dotplot_check, ",")[[1]])
|
|
80
|
-
}
|
|
81
|
-
png(dotfig, width = 800, height = 800, res = 70)
|
|
82
|
-
p <- DotPlot(sobj, features = dotplot_check, assay = assay)
|
|
83
|
-
print(p)
|
|
84
|
-
dev.off()
|
|
85
|
-
}
|
|
86
|
-
saveRDS(sobj, outfile)
|
|
29
|
+
p <- FeatureStatPlot(
|
|
30
|
+
sobj, features = dotplot_check, plot_type = "dot",
|
|
31
|
+
assay = assay
|
|
32
|
+
)
|
|
33
|
+
res = 70
|
|
34
|
+
height <- attr(p, "height") * res
|
|
35
|
+
width <- attr(p, "width") * res
|
|
36
|
+
png(dotfig, width = width, height = height, res = res)
|
|
37
|
+
print(p)
|
|
38
|
+
dev.off()
|
|
87
39
|
}
|
|
@@ -40,7 +40,7 @@ if subset_using == "auto":
|
|
|
40
40
|
subset_using = "python" if subset and "[" in subset else "r"
|
|
41
41
|
split_by = envs.pop("split_by")
|
|
42
42
|
|
|
43
|
-
if sobjfile.suffix.lower()
|
|
43
|
+
if sobjfile.suffix.lower() in (".rds", ".qs", "qs2"):
|
|
44
44
|
logger.info("Converting the Seurat object to h5ad ...")
|
|
45
45
|
|
|
46
46
|
annfile = outfile.parent / f"{sobjfile.stem}.h5ad"
|
|
@@ -1,191 +1,74 @@
|
|
|
1
|
-
{{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
|
|
2
1
|
library(rlang)
|
|
3
2
|
library(dplyr)
|
|
4
|
-
library(
|
|
5
|
-
library(
|
|
6
|
-
{{ biopipen_dir | joinpaths: "scripts", "scrna", "CCPlotR-patch.R" | source_r }}
|
|
3
|
+
library(scplotter)
|
|
4
|
+
library(biopipen.utils)
|
|
7
5
|
|
|
8
6
|
cccfile <- {{ in.cccfile | r }}
|
|
9
|
-
expfile <- {{ in.expfile | r }}
|
|
10
7
|
outdir <- {{ out.outdir | r }}
|
|
11
8
|
joboutdir <- {{ job.outdir | r }}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
envs <- {{ envs | r }}
|
|
10
|
+
envs <- extract_vars(
|
|
11
|
+
envs,
|
|
12
|
+
"magnitude", "specificity", "devpars", "subset", "cases", "more_formats", "descr"
|
|
13
|
+
)
|
|
15
14
|
|
|
16
15
|
ccc <- read.table(cccfile, header=TRUE, sep="\t", check.names = FALSE)
|
|
17
|
-
if (!is.null(subset)) {
|
|
18
|
-
ccc <- ccc %>% dplyr::filter(!!parse_expr(subset))
|
|
19
|
-
}
|
|
20
|
-
if (ncol(ccc) > 10) {
|
|
21
|
-
# from CellCellCommunication
|
|
22
|
-
if (!is.null(expfile)) {
|
|
23
|
-
log_warn("in.cccfile is from CellCellCommunication, in.expfile will be ignored")
|
|
24
|
-
}
|
|
25
|
-
if (is.null(score_col)) {
|
|
26
|
-
stop("'envs.score_col' is required for CellCellCommunication output")
|
|
27
|
-
}
|
|
28
|
-
if (!score_col %in% colnames(ccc)) {
|
|
29
|
-
stop(paste("Score column", score_col, "not found in the in.cccfile"))
|
|
30
|
-
}
|
|
31
|
-
# compose the expression data frame
|
|
32
|
-
exp <- data.frame(
|
|
33
|
-
cell_type = c(ccc$source, ccc$target),
|
|
34
|
-
gene = c(ccc$ligand, ccc$receptor),
|
|
35
|
-
mean_exp = c(ccc$ligand_trimean, ccc$receptor_trimean)
|
|
36
|
-
) %>% distinct()
|
|
37
|
-
ccc <- ccc %>% select(
|
|
38
|
-
source, target,
|
|
39
|
-
ligand, receptor,
|
|
40
|
-
!!sym(score_col)
|
|
41
|
-
) %>% rename(score = !!sym(score_col))
|
|
42
|
-
} else {
|
|
43
|
-
if (!is.null(expfile)) {
|
|
44
|
-
exp <- read.table(expfile, header=TRUE, sep="\t", check.names = FALSE)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
16
|
|
|
48
|
-
if (length(
|
|
49
|
-
stop("No
|
|
17
|
+
if (length(ccc) == 0) {
|
|
18
|
+
stop("No data found in the input file: ", cccfile)
|
|
50
19
|
}
|
|
51
20
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
list(
|
|
61
|
-
res = 100,
|
|
62
|
-
width = 800,
|
|
63
|
-
height = 800
|
|
64
|
-
)
|
|
65
|
-
} else if (kind == "dotplot") {
|
|
66
|
-
list(
|
|
67
|
-
res = 100,
|
|
68
|
-
width = 120 + ncols * 60,
|
|
69
|
-
height = 300 + nrows * 40
|
|
70
|
-
)
|
|
71
|
-
} else if (kind == "heatmap") {
|
|
72
|
-
list(
|
|
73
|
-
res = 100,
|
|
74
|
-
width = 120 + ncols * 60,
|
|
75
|
-
height = 300 + ncols * 40
|
|
76
|
-
)
|
|
77
|
-
} else if (kind == "network") {
|
|
78
|
-
list(
|
|
79
|
-
res = 100,
|
|
80
|
-
width = 1200,
|
|
81
|
-
height = 1200
|
|
82
|
-
)
|
|
83
|
-
} else if (kind == "sigmoid") {
|
|
84
|
-
list(
|
|
85
|
-
res = 100,
|
|
86
|
-
width = max(800, ncols * 200),
|
|
87
|
-
height = 100 + nrows * 60
|
|
88
|
-
)
|
|
89
|
-
}
|
|
90
|
-
}
|
|
21
|
+
defaults <- list(
|
|
22
|
+
magnitude = NULL,
|
|
23
|
+
specificity = NULL,
|
|
24
|
+
subset = subset,
|
|
25
|
+
descr = descr,
|
|
26
|
+
more_formats = more_formats,
|
|
27
|
+
devpars = list(res = 100)
|
|
28
|
+
)
|
|
91
29
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
30
|
+
cases <- expand_cases(cases, defaults)
|
|
31
|
+
log <- get_logger()
|
|
32
|
+
reporter <- get_reporter()
|
|
95
33
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
case
|
|
34
|
+
do_case <- function(name) {
|
|
35
|
+
log$info("- Case: {name}")
|
|
36
|
+
case <- cases[[name]]
|
|
37
|
+
info <- case_info(name, outdir, is_dir = FALSE)
|
|
38
|
+
case <- extract_vars(case, "subset", "devpars", "more_formats", "descr")
|
|
99
39
|
|
|
100
|
-
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
if (is.null(cell_types) || length(cell_types) != 2) {
|
|
104
|
-
stop("'case.cell_types' is required and must be a vector of length 2")
|
|
105
|
-
}
|
|
106
|
-
n_ligand <- length(unique(ccc[ccc$source == cell_types[1], "ligand"]))
|
|
107
|
-
n_receptor <- length(unique(ccc[ccc$target == cell_types[2], "receptor"]))
|
|
108
|
-
default_devpars <- .get_default_devpars(kind, nrows = max(n_ligand, n_receptor))
|
|
109
|
-
} else if (kind == "circos") {
|
|
110
|
-
nrows <- length(unique(c(ccc$source, ccc$target)))
|
|
111
|
-
default_devpars <- .get_default_devpars(kind, nrows = nrows)
|
|
112
|
-
} else if (kind == "dotplot" || kind == "heatmap") {
|
|
113
|
-
nrows <- length(unique(ccc$source))
|
|
114
|
-
ncols <- length(unique(ccc$target))
|
|
115
|
-
default_devpars <- .get_default_devpars(kind, nrows = nrows, ncols = ncols)
|
|
116
|
-
if (
|
|
117
|
-
(kind == "heatmap" && (is.null(case$option) || case$option != "B")) ||
|
|
118
|
-
(kind == "dotplot" && (is.null(case$option) || case$option != "B"))) {
|
|
119
|
-
gg <- theme(axis.text.x = element_text(angle = 90, hjust = 1))
|
|
120
|
-
}
|
|
121
|
-
} else if (kind == "network") {
|
|
122
|
-
nrows <- length(unique(c(ccc$source, ccc$target)))
|
|
123
|
-
ncols <- length(unique(c(ccc$ligand, ccc$receptor)))
|
|
124
|
-
default_devpars <- .get_default_devpars(kind, nrows = nrows, ncols = ncols)
|
|
125
|
-
gg <- theme(plot.margin = margin(c(50, 50, 50, 50), "pt"))
|
|
126
|
-
} else if (kind == "sigmoid") {
|
|
127
|
-
nrows <- (case$n_top_ints %||% 20) / 2 # approx
|
|
128
|
-
ncols <- length(unique(c(ccc$source, ccc$target))) / 2
|
|
129
|
-
default_devpars <- .get_default_devpars(kind, nrows = nrows, ncols = ncols)
|
|
40
|
+
case$data <- ccc
|
|
41
|
+
if (!is.null(case$subset)) {
|
|
42
|
+
case$data <- ccc %>% dplyr::filter(!!parse_expr(case$subset))
|
|
130
43
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
section <- case$section
|
|
138
|
-
case$section <- NULL
|
|
139
|
-
|
|
140
|
-
case$cc_df <- ccc
|
|
141
|
-
if ("exp_df" %in% names(formals(fun))) {
|
|
142
|
-
case$exp_df <- exp
|
|
44
|
+
if (is.null(case$magnitude)) {
|
|
45
|
+
case$magnitude <- NULL
|
|
46
|
+
}
|
|
47
|
+
if (is.null(case$specificity)) {
|
|
48
|
+
case$specificity <- NULL
|
|
143
49
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
dev.off()
|
|
50
|
+
p <- do_call(scplotter::CCCPlot, case)
|
|
51
|
+
save_plot(
|
|
52
|
+
p, info$prefix,
|
|
53
|
+
devpars = devpars, formats = unique(c("png", more_formats))
|
|
54
|
+
)
|
|
150
55
|
|
|
151
|
-
list(
|
|
152
|
-
section = section,
|
|
56
|
+
report <- list(
|
|
153
57
|
kind = "table_image",
|
|
154
|
-
src =
|
|
155
|
-
|
|
58
|
+
src = paste0(info$prefix, ".png"),
|
|
59
|
+
download = list(),
|
|
60
|
+
descr = html_escape(descr),
|
|
61
|
+
name = html_escape(info$name)
|
|
156
62
|
)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
image$section <- NULL
|
|
163
|
-
if (is.null(section)) {
|
|
164
|
-
section = "DEFAULT"
|
|
63
|
+
exformats <- setdiff(more_formats, "png")
|
|
64
|
+
if (length(exformats) > 0) {
|
|
65
|
+
report$download <- lapply(exformats, function(fmt) {
|
|
66
|
+
paste0(info$prefix, ".", fmt)
|
|
67
|
+
})
|
|
165
68
|
}
|
|
166
|
-
|
|
167
|
-
section_images[[section]] = list()
|
|
168
|
-
}
|
|
169
|
-
section_images[[section]][[length(section_images[[section]]) + 1]] = image
|
|
69
|
+
reporter$add2(report, hs = c(info$section, info$name), ui = "table_of_images:2")
|
|
170
70
|
}
|
|
171
71
|
|
|
172
|
-
|
|
173
|
-
add_report(
|
|
174
|
-
section_images,
|
|
175
|
-
h1 = "Cell-Cell Communication Plots",
|
|
176
|
-
ui = "table_of_images"
|
|
177
|
-
)
|
|
178
|
-
} else {
|
|
179
|
-
for (section in names(section_images)) {
|
|
180
|
-
imgplots = section_images[[section]]
|
|
181
|
-
add_report(
|
|
182
|
-
list(
|
|
183
|
-
ui = "table_of_images",
|
|
184
|
-
contents = imgplots
|
|
185
|
-
),
|
|
186
|
-
h1 = section
|
|
187
|
-
)
|
|
188
|
-
}
|
|
189
|
-
}
|
|
72
|
+
sapply(names(cases), do_case)
|
|
190
73
|
|
|
191
|
-
|
|
74
|
+
reporter$save(joboutdir)
|