biopipen 0.32.3__py3-none-any.whl → 0.33.1__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/config.toml +6 -0
- biopipen/core/filters.py +35 -23
- biopipen/core/testing.py +6 -1
- biopipen/ns/bam.py +39 -0
- biopipen/ns/cellranger.py +5 -0
- biopipen/ns/cellranger_pipeline.py +2 -2
- biopipen/ns/cnvkit_pipeline.py +4 -1
- biopipen/ns/delim.py +33 -27
- biopipen/ns/protein.py +99 -0
- biopipen/ns/scrna.py +428 -250
- biopipen/ns/snp.py +16 -3
- biopipen/ns/tcr.py +125 -1
- biopipen/ns/vcf.py +34 -0
- biopipen/ns/web.py +5 -1
- biopipen/reports/scrna/SeuratClusterStats.svelte +1 -1
- biopipen/reports/scrna/SeuratMap2Ref.svelte +15 -2
- biopipen/reports/tcr/ClonalStats.svelte +15 -0
- biopipen/reports/utils/misc.liq +20 -7
- biopipen/scripts/bam/BamMerge.py +2 -2
- biopipen/scripts/bam/BamSampling.py +4 -4
- biopipen/scripts/bam/BamSort.py +141 -0
- biopipen/scripts/bam/BamSplitChroms.py +10 -10
- biopipen/scripts/bam/BamSubsetByBed.py +3 -3
- biopipen/scripts/bam/CNVpytor.py +10 -10
- biopipen/scripts/bam/ControlFREEC.py +11 -11
- 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 +4 -4
- biopipen/scripts/bed/BedtoolsMakeWindows.py +3 -3
- biopipen/scripts/bed/BedtoolsMerge.py +4 -4
- biopipen/scripts/cellranger/CellRangerCount.py +20 -9
- biopipen/scripts/cellranger/CellRangerSummary.R +20 -29
- biopipen/scripts/cellranger/CellRangerVdj.py +8 -8
- biopipen/scripts/cnvkit/CNVkitAccess.py +6 -6
- biopipen/scripts/cnvkit/CNVkitAutobin.py +25 -18
- biopipen/scripts/cnvkit/CNVkitBatch.py +5 -5
- biopipen/scripts/cnvkit/CNVkitCall.py +3 -3
- biopipen/scripts/cnvkit/CNVkitCoverage.py +2 -2
- biopipen/scripts/cnvkit/CNVkitDiagram.py +5 -5
- biopipen/scripts/cnvkit/CNVkitFix.py +3 -3
- biopipen/scripts/cnvkit/CNVkitGuessBaits.py +9 -5
- biopipen/scripts/cnvkit/CNVkitHeatmap.py +4 -4
- biopipen/scripts/cnvkit/CNVkitReference.py +2 -2
- 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/SampleInfo.R +94 -148
- biopipen/scripts/misc/Config2File.py +2 -2
- biopipen/scripts/misc/Str2File.py +2 -2
- biopipen/scripts/protein/MMCIF2PDB.py +33 -0
- biopipen/scripts/protein/PDB2Fasta.py +60 -0
- biopipen/scripts/protein/Prodigy.py +4 -4
- biopipen/scripts/protein/RMSD.py +178 -0
- biopipen/scripts/regulatory/MotifScan.py +8 -8
- biopipen/scripts/scrna/CellCellCommunication.py +59 -22
- biopipen/scripts/scrna/LoomTo10X.R +51 -0
- biopipen/scripts/scrna/MarkersFinder.R +273 -654
- biopipen/scripts/scrna/RadarPlots.R +73 -53
- biopipen/scripts/scrna/SCP-plot.R +15202 -0
- biopipen/scripts/scrna/ScVelo.py +0 -0
- biopipen/scripts/scrna/SeuratClusterStats-clustree.R +23 -31
- biopipen/scripts/scrna/SeuratClusterStats-dimplots.R +26 -54
- biopipen/scripts/scrna/SeuratClusterStats-features.R +85 -403
- biopipen/scripts/scrna/SeuratClusterStats-ngenes.R +32 -17
- biopipen/scripts/scrna/SeuratClusterStats-stats.R +45 -239
- biopipen/scripts/scrna/SeuratClusterStats.R +13 -19
- biopipen/scripts/scrna/SeuratMap2Ref.R +16 -12
- biopipen/scripts/scrna/SeuratPreparing.R +138 -81
- biopipen/scripts/scrna/SlingShot.R +71 -0
- biopipen/scripts/scrna/celltypist-wrapper.py +7 -6
- biopipen/scripts/snp/Plink2GTMat.py +26 -11
- biopipen/scripts/snp/PlinkFilter.py +7 -7
- biopipen/scripts/snp/PlinkFromVcf.py +8 -5
- biopipen/scripts/snp/PlinkSimulation.py +4 -4
- biopipen/scripts/snp/PlinkUpdateName.py +4 -4
- biopipen/scripts/stats/ChowTest.R +48 -22
- biopipen/scripts/tcgamaf/Maf2Vcf.py +2 -2
- biopipen/scripts/tcgamaf/MafAddChr.py +2 -2
- biopipen/scripts/tcr/ClonalStats.R +484 -0
- biopipen/scripts/tcr/ScRepLoading.R +127 -0
- biopipen/scripts/tcr/TCRDock.py +10 -6
- biopipen/scripts/tcr/vdjtools-patch.sh +1 -1
- biopipen/scripts/vcf/BcftoolsAnnotate.py +8 -8
- biopipen/scripts/vcf/BcftoolsFilter.py +3 -3
- biopipen/scripts/vcf/BcftoolsMerge.py +31 -0
- biopipen/scripts/vcf/BcftoolsSort.py +4 -4
- biopipen/scripts/vcf/BcftoolsView.py +5 -5
- 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 +12 -3
- 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 +3 -3
- biopipen/scripts/web/Download.py +8 -4
- biopipen/scripts/web/DownloadList.py +5 -5
- biopipen/scripts/web/GCloudStorageDownloadBucket.py +5 -5
- biopipen/scripts/web/GCloudStorageDownloadFile.py +3 -3
- biopipen/scripts/web/gcloud_common.py +1 -1
- biopipen/utils/gsea.R +75 -35
- biopipen/utils/misc.R +205 -7
- biopipen/utils/misc.py +17 -8
- biopipen/utils/reference.py +11 -11
- biopipen/utils/repr.R +146 -0
- biopipen/utils/vcf.py +1 -1
- {biopipen-0.32.3.dist-info → biopipen-0.33.1.dist-info}/METADATA +8 -8
- {biopipen-0.32.3.dist-info → biopipen-0.33.1.dist-info}/RECORD +115 -105
- {biopipen-0.32.3.dist-info → biopipen-0.33.1.dist-info}/WHEEL +1 -1
- biopipen/scripts/scrna/SeuratClusterStats-hists.R +0 -144
- biopipen/scripts/scrna/SeuratPreparing-common.R +0 -467
- biopipen/scripts/scrna/SeuratPreparing-doublet_detection.R +0 -204
- {biopipen-0.32.3.dist-info → biopipen-0.33.1.dist-info}/entry_points.txt +0 -0
|
@@ -1,262 +1,68 @@
|
|
|
1
1
|
# Loaded variables: srtfile, outdir, srtobj
|
|
2
2
|
library(circlize)
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
# stats = {{envs.stats | r: todot="-", skip=1}}
|
|
6
|
-
log_info("stats:")
|
|
4
|
+
log$info("stats:")
|
|
7
5
|
|
|
8
|
-
odir
|
|
6
|
+
odir <- file.path(outdir, "stats")
|
|
9
7
|
dir.create(odir, recursive=TRUE, showWarnings=FALSE)
|
|
10
8
|
|
|
11
|
-
do_one_stats
|
|
12
|
-
|
|
9
|
+
do_one_stats <- function(name) {
|
|
10
|
+
log$info("- Case: {name}")
|
|
13
11
|
|
|
14
|
-
case
|
|
15
|
-
case
|
|
16
|
-
case$pie_devpars = list_update(stats_defaults$pie_devpars, case$pie_devpars)
|
|
17
|
-
case$circos_devpars = list_update(stats_defaults$circos_devpars, case$circos_devpars)
|
|
18
|
-
if (isTRUE(case$pie) && !is.null(case$group.by)) {
|
|
19
|
-
stop(paste0(name, ": pie charts are not supported for group-by"))
|
|
20
|
-
}
|
|
21
|
-
if (isTRUE(case$transpose) && is.null(case$group.by)) {
|
|
22
|
-
stop(paste0(name, ": transpose is only supported for group-by"))
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
figfile = file.path(odir, paste0(slugify(name), ".bar.png"))
|
|
26
|
-
figfile_pdf = file.path(odir, paste0(slugify(name), ".bar.pdf"))
|
|
27
|
-
piefile = file.path(odir, paste0(slugify(name), ".pie.png"))
|
|
28
|
-
piefile_pdf = file.path(odir, paste0(slugify(name), ".pie.pdf"))
|
|
29
|
-
circosfile = file.path(odir, paste0(slugify(name), ".circos.png"))
|
|
30
|
-
circosfile_pdf = file.path(odir, paste0(slugify(name), ".circos.pdf"))
|
|
31
|
-
samtablefile = file.path(odir, paste0(slugify(name), ".bysample.txt"))
|
|
32
|
-
tablefile = file.path(odir, paste0(slugify(name), ".txt"))
|
|
33
|
-
|
|
34
|
-
df_cells = srtobj@meta.data %>% drop_na(!!sym(case$ident))
|
|
35
|
-
if (!is.null(case$subset)) {
|
|
36
|
-
df_cells = df_cells %>% filter(!!rlang::parse_expr(case$subset))
|
|
37
|
-
}
|
|
12
|
+
case <- list_update(stats_defaults, stats[[name]])
|
|
13
|
+
extract_vars(case, "devpars", "more_formats", "save_code", "save_data", "subset")
|
|
38
14
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
plot_df = do_call(rbind, lapply(group_split(
|
|
42
|
-
df_cells %>% select(all_of(select_cols)),
|
|
43
|
-
!!!syms(case$split.by)
|
|
44
|
-
), function(df) {
|
|
45
|
-
out <- df %>% group_by(!!!syms(select_cols)) %>% summarise(.n = n(), .groups = "drop")
|
|
46
|
-
if (!is.null(case$group.by) && case$frac != "none") {
|
|
47
|
-
if (case$frac == "all") {
|
|
48
|
-
out <- out %>% mutate(.frac = .n / sum(.n))
|
|
49
|
-
} else if (case$frac == "group") {
|
|
50
|
-
out <- out %>% group_by(!!sym(case$group.by)) %>% mutate(.frac = .n / sum(.n))
|
|
51
|
-
} else { # case$frac == "ident" or "cluster"
|
|
52
|
-
out <- out %>% group_by(!!sym(case$ident)) %>% mutate(.frac = .n / sum(.n))
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
out
|
|
56
|
-
}))
|
|
57
|
-
} else if (!is.null(case$group.by) && case$frac != "none") { # no split.by
|
|
58
|
-
plot_df <- df_cells %>%
|
|
59
|
-
select(all_of(select_cols)) %>%
|
|
60
|
-
group_by(!!!syms(select_cols)) %>%
|
|
61
|
-
summarise(.n = n(), .groups = "drop")
|
|
62
|
-
if (case$frac == "all") {
|
|
63
|
-
plot_df = plot_df %>% mutate(.frac = .n / sum(.n))
|
|
64
|
-
} else if (case$frac == "group") {
|
|
65
|
-
plot_df = plot_df %>% group_by(!!sym(case$group.by)) %>% mutate(.frac = .n / sum(.n))
|
|
66
|
-
} else { # case$frac == "ident" or "cluster"
|
|
67
|
-
plot_df = plot_df %>% group_by(!!sym(case$ident)) %>% mutate(.frac = .n / sum(.n))
|
|
68
|
-
}
|
|
15
|
+
if (!is.null(subset)) {
|
|
16
|
+
case$object <- srtobj %>% filter(!!parse_expr(subset))
|
|
69
17
|
} else {
|
|
70
|
-
|
|
71
|
-
select(all_of(select_cols)) %>%
|
|
72
|
-
group_by(!!!syms(select_cols)) %>%
|
|
73
|
-
summarise(.n = n(), .groups = "drop")
|
|
74
|
-
|
|
75
|
-
if (case$frac != "none") {
|
|
76
|
-
plot_df <- plot_df %>% mutate(.frac = .n / sum(.n))
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
write.table(plot_df, tablefile, sep="\t", quote=FALSE, row.names=FALSE)
|
|
81
|
-
|
|
82
|
-
ngroups = ifelse(is.null(case$group.by), 1, length(unique(plot_df[[case$group.by]])))
|
|
83
|
-
nidents = length(unique(plot_df[[case$ident]]))
|
|
84
|
-
bar_position = ifelse(case$position == "auto", ifelse(ngroups > 5, "stack", "dodge"), case$position)
|
|
85
|
-
p = plot_df %>%
|
|
86
|
-
ggplot(aes(
|
|
87
|
-
x=!!sym(ifelse(case$transpose, case$group.by, case$ident)),
|
|
88
|
-
y=if (case$frac != "none") .frac else .n,
|
|
89
|
-
fill=!!sym(ifelse(is.null(case$group.by) || isTRUE(case$transpose), case$ident, case$group.by))
|
|
90
|
-
)) +
|
|
91
|
-
geom_bar(stat="identity", position=bar_position, alpha=.8) +
|
|
92
|
-
theme_prism(axis_text_angle = 90) +
|
|
93
|
-
scale_fill_biopipen() +
|
|
94
|
-
ylab(ifelse(case$frac != "none", "Fraction of cells", "Number of cells"))
|
|
95
|
-
|
|
96
|
-
if (!is.null(case$split.by)) {
|
|
97
|
-
p = p + facet_wrap(case$split.by)
|
|
18
|
+
case$object <- srtobj
|
|
98
19
|
}
|
|
99
20
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
add_report(
|
|
109
|
-
list(
|
|
110
|
-
kind = "descr",
|
|
111
|
-
content = paste0(
|
|
112
|
-
"Plots showing the ",
|
|
113
|
-
ifelse(case$frac != "none", "number/faction", "number"),
|
|
114
|
-
" of cells per cluster",
|
|
115
|
-
ifelse(
|
|
116
|
-
is.null(case$group.by),
|
|
117
|
-
"",
|
|
118
|
-
paste0(", by ", paste0(case$group.by, collapse = ", "))
|
|
119
|
-
)
|
|
120
|
-
)
|
|
121
|
-
),
|
|
122
|
-
h1 = name
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
add_report(
|
|
126
|
-
list(
|
|
127
|
-
name = "Bar Plot",
|
|
128
|
-
contents = list(list(kind = "image", src = figfile, download = figfile_pdf))
|
|
129
|
-
),
|
|
130
|
-
h1 = name,
|
|
131
|
-
ui = "tabs"
|
|
132
|
-
)
|
|
133
|
-
if (isTRUE(case$table)) {
|
|
134
|
-
add_report(
|
|
135
|
-
list(
|
|
136
|
-
name = "Table",
|
|
137
|
-
contents = list(list(kind = "table", src = tablefile))
|
|
138
|
-
),
|
|
139
|
-
h1 = name,
|
|
140
|
-
ui = "tabs"
|
|
141
|
-
)
|
|
21
|
+
info <- case_info(name, odir, is_dir = FALSE, create = TRUE)
|
|
22
|
+
p <- do_call(gglogger::register(CellStatPlot), case)
|
|
23
|
+
save_plot(p, info$prefix, devpars, formats = c("png", more_formats))
|
|
24
|
+
if (save_code) {
|
|
25
|
+
save_plotcode(p, info$prefix,
|
|
26
|
+
setup = c("library(scplotter)", "load('data.RData')", "invisible(list2env('case'))"),
|
|
27
|
+
"case",
|
|
28
|
+
auto_data_setup = FALSE)
|
|
142
29
|
}
|
|
143
30
|
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
ggplot(aes(x="", y=.n, fill=!!sym(case$ident))) +
|
|
148
|
-
geom_bar(stat="identity", width=1, alpha=.8, position = position_stack(reverse = TRUE)) +
|
|
149
|
-
coord_polar("y", start=0) +
|
|
150
|
-
scale_fill_biopipen() +
|
|
151
|
-
guides(fill = guide_legend(title = case$ident)) +
|
|
152
|
-
theme_void() +
|
|
153
|
-
geom_label(
|
|
154
|
-
if (case$frac != "none")
|
|
155
|
-
aes(label=sprintf("%.1f%%", .frac * 100))
|
|
156
|
-
else
|
|
157
|
-
aes(label=.n),
|
|
158
|
-
position = position_stack(vjust = 0.5),
|
|
159
|
-
color="#333333",
|
|
160
|
-
fill="#EEEEEE",
|
|
161
|
-
size=5
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
if (!is.null(case$split.by)) {
|
|
165
|
-
p_pie = p_pie + facet_wrap(case$split.by)
|
|
31
|
+
if (save_data) {
|
|
32
|
+
if (!inherits(p$data, "data.frame") && !inherits(p$data, "matrix")) {
|
|
33
|
+
stop("'save_data = TRUE' is not supported for plot_type: ", case$plot_type)
|
|
166
34
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
print(p_pie)
|
|
170
|
-
dev.off()
|
|
171
|
-
|
|
172
|
-
pdf(piefile_pdf, width=case$pie_devpars$width / case$pie_devpars$res, height=case$pie_devpars$height / case$pie_devpars$res)
|
|
173
|
-
print(p_pie)
|
|
174
|
-
dev.off()
|
|
175
|
-
|
|
176
|
-
add_report(
|
|
35
|
+
write.table(p$data, paste0(info$prefix, ".data.txt"), sep="\t", quote=FALSE, row.names=FALSE)
|
|
36
|
+
reporter$add2(
|
|
177
37
|
list(
|
|
178
|
-
name = "
|
|
179
|
-
contents = list(
|
|
38
|
+
name = "Plot",
|
|
39
|
+
contents = list(
|
|
40
|
+
reporter$image(
|
|
41
|
+
info$prefix, more_formats, save_code, kind = "image")
|
|
42
|
+
)
|
|
180
43
|
),
|
|
181
|
-
h1 = name,
|
|
182
|
-
ui = "tabs"
|
|
183
|
-
)
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (isTRUE(case$circos)) {
|
|
187
|
-
if (is.null(case$group.by)) {
|
|
188
|
-
stop(paste0(name, ": circos plots require a group-by"))
|
|
189
|
-
}
|
|
190
|
-
if (isTRUE(case$transpose)) {
|
|
191
|
-
circos_df <- plot_df %>%
|
|
192
|
-
select(from=!!sym(case$ident), to=!!sym(case$group.by), value=.n)
|
|
193
|
-
} else {
|
|
194
|
-
circos_df <- plot_df %>%
|
|
195
|
-
select(from=!!sym(case$group.by), to=!!sym(case$ident), value=.n)
|
|
196
|
-
}
|
|
197
|
-
groups <- if (is.factor(circos_df$from)) {
|
|
198
|
-
levels(circos_df$from)
|
|
199
|
-
} else {
|
|
200
|
-
unique(circos_df$from)
|
|
201
|
-
}
|
|
202
|
-
idents <- if (is.factor(circos_df$to)) {
|
|
203
|
-
levels(circos_df$to)
|
|
204
|
-
} else {
|
|
205
|
-
unique(circos_df$to)
|
|
206
|
-
}
|
|
207
|
-
grid_cols <- pal_biopipen()(length(idents))
|
|
208
|
-
names(grid_cols) <- idents
|
|
209
|
-
gcols <- rep("#565656", length(groups))
|
|
210
|
-
names(gcols) <- groups
|
|
211
|
-
grid_cols <- c(grid_cols, gcols)
|
|
212
|
-
link_cols <- grid_cols[circos_df$to]
|
|
213
|
-
|
|
214
|
-
png(
|
|
215
|
-
circosfile,
|
|
216
|
-
width=case$circos_devpars$width,
|
|
217
|
-
height=case$circos_devpars$height,
|
|
218
|
-
res=case$circos_devpars$res
|
|
219
|
-
)
|
|
220
|
-
circos.clear()
|
|
221
|
-
if (!isTRUE(case$circos_labels_rot)) {
|
|
222
|
-
chordDiagram(
|
|
223
|
-
circos_df,
|
|
224
|
-
grid.col = grid_cols,
|
|
225
|
-
col = link_cols,
|
|
226
|
-
direction = 1,
|
|
227
|
-
direction.type = c("diffHeight", "arrows"),
|
|
228
|
-
link.arr.type = "big.arrow"
|
|
229
|
-
)
|
|
230
|
-
} else {
|
|
231
|
-
chordDiagram(
|
|
232
|
-
circos_df,
|
|
233
|
-
grid.col = grid_cols,
|
|
234
|
-
col = link_cols,
|
|
235
|
-
direction = 1,
|
|
236
|
-
annotationTrack = "grid",
|
|
237
|
-
direction.type = c("diffHeight", "arrows"),
|
|
238
|
-
link.arr.type = "big.arrow",
|
|
239
|
-
preAllocateTracks = list(track.height = max(strwidth(unlist(dimnames(circos_df)))))
|
|
240
|
-
)
|
|
241
|
-
circos.track(track.index = 1, panel.fun = function(x, y) {
|
|
242
|
-
circos.text(
|
|
243
|
-
CELL_META$xcenter, CELL_META$ylim[1],
|
|
244
|
-
CELL_META$sector.index,
|
|
245
|
-
facing = "clockwise",
|
|
246
|
-
niceFacing = TRUE,
|
|
247
|
-
adj = c(0, 0.5))
|
|
248
|
-
}, bg.border = NA) # here set bg.border to NA is important
|
|
249
|
-
}
|
|
250
|
-
dev.off()
|
|
251
|
-
|
|
252
|
-
add_report(
|
|
253
44
|
list(
|
|
254
|
-
name = "
|
|
255
|
-
contents = list(
|
|
45
|
+
name = "Data",
|
|
46
|
+
contents = list(
|
|
47
|
+
list(
|
|
48
|
+
kind = "descr",
|
|
49
|
+
content = "Data used directly for the plot"
|
|
50
|
+
),
|
|
51
|
+
list(
|
|
52
|
+
kind = "table",
|
|
53
|
+
src = paste0(info$prefix, ".data.txt"),
|
|
54
|
+
data = list(nrows = 100)
|
|
55
|
+
)
|
|
56
|
+
)
|
|
256
57
|
),
|
|
257
|
-
|
|
58
|
+
hs = c(info$section, info$name),
|
|
258
59
|
ui = "tabs"
|
|
259
60
|
)
|
|
61
|
+
} else {
|
|
62
|
+
reporter$add2(
|
|
63
|
+
reporter$image(info$prefix, more_formats, save_code, kind = "image"),
|
|
64
|
+
hs = c(info$section, info$name)
|
|
65
|
+
)
|
|
260
66
|
}
|
|
261
67
|
}
|
|
262
68
|
|
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
{{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
|
|
2
|
-
{{ biopipen_dir | joinpaths: "utils", "mutate_helpers.R" | source_r }}
|
|
3
|
-
{{ biopipen_dir | joinpaths: "utils", "plot.R" | source_r }}
|
|
4
|
-
|
|
5
1
|
library(Seurat)
|
|
6
2
|
library(rlang)
|
|
7
3
|
library(dplyr)
|
|
8
4
|
library(tidyr)
|
|
9
5
|
library(tibble)
|
|
10
|
-
library(
|
|
11
|
-
library(ggrepel)
|
|
6
|
+
library(forcats)
|
|
12
7
|
library(tidyseurat)
|
|
13
|
-
library(
|
|
14
|
-
library(
|
|
8
|
+
library(gglogger)
|
|
9
|
+
library(scplotter)
|
|
10
|
+
library(biopipen.utils)
|
|
11
|
+
|
|
12
|
+
log <- get_logger()
|
|
13
|
+
reporter <- get_reporter()
|
|
15
14
|
|
|
16
15
|
srtfile <- {{in.srtobj | r}}
|
|
17
16
|
outdir <- {{out.outdir | r}}
|
|
18
17
|
joboutdir <- {{job.outdir | r}}
|
|
19
18
|
mutaters <- {{envs.mutaters | r}}
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
log$info("Loading Seurat object ...")
|
|
22
21
|
srtobj = readRDS(srtfile)
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
log$info("Applying mutaters if any ...")
|
|
25
24
|
if (!is.null(mutaters) && length(mutaters) > 0) {
|
|
26
25
|
srtobj@meta.data = srtobj@meta.data %>%
|
|
27
26
|
mutate(!!!lapply(mutaters, parse_expr))
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
############## clustree ##############
|
|
31
|
-
clustrees_defaults <- {{envs.clustrees_defaults | r}}
|
|
32
|
-
clustrees <- {{envs.clustrees | r}}
|
|
30
|
+
clustrees_defaults <- {{envs.clustrees_defaults | r: todot="-"}}
|
|
31
|
+
clustrees <- {{envs.clustrees | r: todot="-", skip=1}}
|
|
33
32
|
{{ biopipen_dir | joinpaths: "scripts", "scrna", "SeuratClusterStats-clustree.R" | source_r }}
|
|
34
33
|
|
|
35
34
|
############## stats ##############
|
|
@@ -37,11 +36,6 @@ stats_defaults = {{envs.stats_defaults | r: todot="-"}}
|
|
|
37
36
|
stats = {{envs.stats | r: todot="-", skip=1}}
|
|
38
37
|
{{ biopipen_dir | joinpaths: "scripts", "scrna", "SeuratClusterStats-stats.R" | source_r }}
|
|
39
38
|
|
|
40
|
-
############## hists ##############
|
|
41
|
-
hists_defaults <- {{envs.hists_defaults | r: todot="-"}}
|
|
42
|
-
hists <- {{envs.hists | r: todot="-", skip=1}}
|
|
43
|
-
{{ biopipen_dir | joinpaths: "scripts", "scrna", "SeuratClusterStats-hists.R" | source_r }}
|
|
44
|
-
|
|
45
39
|
############## ngenes ##############
|
|
46
40
|
ngenes_defaults <- {{envs.ngenes_defaults | r: todot="-"}}
|
|
47
41
|
ngenes <- {{envs.ngenes | r: todot="-", skip=1}}
|
|
@@ -50,11 +44,11 @@ ngenes <- {{envs.ngenes | r: todot="-", skip=1}}
|
|
|
50
44
|
############## features ##############
|
|
51
45
|
features_defaults = {{envs.features_defaults | r: todot="-"}}
|
|
52
46
|
features = {{envs.features | r: todot="-", skip=1}}
|
|
53
|
-
{{ biopipen_dir | joinpaths: "scripts", "scrna", "SeuratClusterStats-features.R" | source_r }}
|
|
47
|
+
{{ biopipen_dir | joinpaths: "scripts", "scrna", "SeuratClusterStats-features.R" | source_r: chdir = False }}
|
|
54
48
|
|
|
55
49
|
############## dimplots ##############
|
|
56
50
|
dimplots_defaults = {{envs.dimplots_defaults | r: todot="-"}}
|
|
57
51
|
dimplots = {{envs.dimplots | r: todot="-", skip=1}}
|
|
58
52
|
{{ biopipen_dir | joinpaths: "scripts", "scrna", "SeuratClusterStats-dimplots.R" | source_r }}
|
|
59
53
|
|
|
60
|
-
|
|
54
|
+
reporter$save(joboutdir)
|
|
@@ -6,8 +6,11 @@ library(SeuratDisk)
|
|
|
6
6
|
library(rlang)
|
|
7
7
|
library(dplyr)
|
|
8
8
|
library(tidyr)
|
|
9
|
+
library(ggplot2)
|
|
10
|
+
library(ggprism)
|
|
9
11
|
|
|
10
12
|
set.seed(8525)
|
|
13
|
+
theme_set(theme_prism())
|
|
11
14
|
|
|
12
15
|
sobjfile = {{in.sobjfile | r}}
|
|
13
16
|
outfile = {{out.outfile | r}}
|
|
@@ -346,8 +349,16 @@ saveRDS(sobj, file = outfile)
|
|
|
346
349
|
# ############################
|
|
347
350
|
# Some plots
|
|
348
351
|
# ############################
|
|
352
|
+
log_info("- Plotting mapping score ...")
|
|
353
|
+
p <- FeaturePlot(
|
|
354
|
+
object = sobj,
|
|
355
|
+
reduction = "ref.umap",
|
|
356
|
+
features = "mapping.score",
|
|
357
|
+
cols = c("white", "blue"),
|
|
358
|
+
pt.size = 0.5
|
|
359
|
+
) + ggtitle("Mapping score for query cells")
|
|
360
|
+
save_plot(p, file.path(outdir, "mapping_score"), list(width = 800, height = 600, res = 100))
|
|
349
361
|
|
|
350
|
-
# # Plot the UMAP
|
|
351
362
|
log_info("- Plotting for transferred data ...")
|
|
352
363
|
ref.reduction = mapquery_args$reduction.model %||% "wnn.umap"
|
|
353
364
|
for (qname in names(mapquery_args$refdata)) {
|
|
@@ -358,8 +369,7 @@ for (qname in names(mapquery_args$refdata)) {
|
|
|
358
369
|
next
|
|
359
370
|
}
|
|
360
371
|
|
|
361
|
-
log_info("
|
|
362
|
-
|
|
372
|
+
log_info(" UMAP for transferred data: {qname} -> {rname}")
|
|
363
373
|
ref_p <- DimPlot(
|
|
364
374
|
object = reference,
|
|
365
375
|
reduction = ref.reduction,
|
|
@@ -378,15 +388,9 @@ for (qname in names(mapquery_args$refdata)) {
|
|
|
378
388
|
repel = TRUE,
|
|
379
389
|
) + NoLegend()
|
|
380
390
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
dev.off()
|
|
385
|
-
|
|
386
|
-
plotfile_pdf <- file.path(outdir, paste0("UMAPs-", slugify(qname), ".pdf"))
|
|
387
|
-
pdf(plotfile_pdf, width = 15, height = 7)
|
|
388
|
-
print(ref_p | query_p)
|
|
389
|
-
dev.off()
|
|
391
|
+
p <- ref_p | query_p
|
|
392
|
+
prefix <- file.path(outdir, paste0("UMAPs-", slugify(qname)))
|
|
393
|
+
save_plot(p, prefix, list(width = 1500, height = 700, res = 100))
|
|
390
394
|
|
|
391
395
|
# summarize the stats
|
|
392
396
|
log_info(" Summarizing stats: {qname} -> {rname}")
|