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.

Files changed (150) hide show
  1. biopipen/__init__.py +1 -1
  2. biopipen/core/filters.py +10 -183
  3. biopipen/core/proc.py +5 -3
  4. biopipen/core/testing.py +8 -1
  5. biopipen/ns/bam.py +40 -4
  6. biopipen/ns/cnv.py +1 -1
  7. biopipen/ns/cnvkit.py +1 -1
  8. biopipen/ns/delim.py +1 -1
  9. biopipen/ns/gsea.py +63 -37
  10. biopipen/ns/misc.py +38 -0
  11. biopipen/ns/plot.py +8 -0
  12. biopipen/ns/scrna.py +307 -288
  13. biopipen/ns/scrna_metabolic_landscape.py +207 -366
  14. biopipen/ns/tcr.py +165 -97
  15. biopipen/reports/bam/CNVpytor.svelte +4 -9
  16. biopipen/reports/cnvkit/CNVkitDiagram.svelte +1 -1
  17. biopipen/reports/cnvkit/CNVkitHeatmap.svelte +1 -1
  18. biopipen/reports/cnvkit/CNVkitScatter.svelte +1 -1
  19. biopipen/reports/{delim/SampleInfo.svelte → common.svelte} +2 -3
  20. biopipen/reports/scrna/DimPlots.svelte +1 -1
  21. biopipen/reports/scrna_metabolic_landscape/MetabolicFeatures.svelte +51 -22
  22. biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayActivity.svelte +46 -42
  23. biopipen/reports/scrna_metabolic_landscape/MetabolicPathwayHeterogeneity.svelte +63 -6
  24. biopipen/reports/snp/PlinkCallRate.svelte +2 -2
  25. biopipen/reports/snp/PlinkFreq.svelte +1 -1
  26. biopipen/reports/snp/PlinkHWE.svelte +1 -1
  27. biopipen/reports/snp/PlinkHet.svelte +1 -1
  28. biopipen/reports/snp/PlinkIBD.svelte +1 -1
  29. biopipen/reports/tcr/CDR3AAPhyschem.svelte +1 -1
  30. biopipen/scripts/bam/CNAClinic.R +41 -6
  31. biopipen/scripts/bam/CNVpytor.py +2 -1
  32. biopipen/scripts/bam/ControlFREEC.py +2 -3
  33. biopipen/scripts/bam/SamtoolsView.py +33 -0
  34. biopipen/scripts/cnv/AneuploidyScore.R +25 -13
  35. biopipen/scripts/cnv/AneuploidyScoreSummary.R +218 -163
  36. biopipen/scripts/cnv/TMADScore.R +4 -4
  37. biopipen/scripts/cnv/TMADScoreSummary.R +51 -84
  38. biopipen/scripts/cnvkit/CNVkitGuessBaits.py +3 -3
  39. biopipen/scripts/cnvkit/CNVkitHeatmap.py +3 -3
  40. biopipen/scripts/cnvkit/CNVkitReference.py +3 -3
  41. biopipen/scripts/delim/RowsBinder.R +1 -1
  42. biopipen/scripts/delim/SampleInfo.R +14 -2
  43. biopipen/scripts/gene/GeneNameConversion.R +14 -12
  44. biopipen/scripts/gsea/Enrichr.R +2 -2
  45. biopipen/scripts/gsea/FGSEA.R +184 -50
  46. biopipen/scripts/gsea/PreRank.R +3 -3
  47. biopipen/scripts/misc/Plot.R +80 -0
  48. biopipen/scripts/plot/VennDiagram.R +2 -2
  49. biopipen/scripts/protein/ProdigySummary.R +34 -27
  50. biopipen/scripts/regulatory/MotifAffinityTest.R +11 -9
  51. biopipen/scripts/regulatory/MotifAffinityTest_AtSNP.R +5 -5
  52. biopipen/scripts/regulatory/MotifAffinityTest_MotifBreakR.R +4 -4
  53. biopipen/scripts/regulatory/VariantMotifPlot.R +10 -8
  54. biopipen/scripts/regulatory/motifs-common.R +10 -9
  55. biopipen/scripts/rnaseq/Simulation-ESCO.R +14 -11
  56. biopipen/scripts/rnaseq/Simulation-RUVcorr.R +7 -4
  57. biopipen/scripts/rnaseq/Simulation.R +0 -2
  58. biopipen/scripts/rnaseq/UnitConversion.R +6 -5
  59. biopipen/scripts/scrna/AnnData2Seurat.R +25 -73
  60. biopipen/scripts/scrna/CellCellCommunication.py +1 -1
  61. biopipen/scripts/scrna/CellCellCommunicationPlots.R +51 -168
  62. biopipen/scripts/scrna/CellTypeAnnotation-celltypist.R +99 -150
  63. biopipen/scripts/scrna/CellTypeAnnotation-direct.R +11 -9
  64. biopipen/scripts/scrna/CellTypeAnnotation-hitype.R +12 -9
  65. biopipen/scripts/scrna/CellTypeAnnotation-sccatch.R +14 -11
  66. biopipen/scripts/scrna/CellTypeAnnotation-sctype.R +19 -16
  67. biopipen/scripts/scrna/CellTypeAnnotation.R +10 -2
  68. biopipen/scripts/scrna/CellsDistribution.R +1 -1
  69. biopipen/scripts/scrna/ExprImputation-alra.R +87 -11
  70. biopipen/scripts/scrna/ExprImputation-rmagic.R +247 -21
  71. biopipen/scripts/scrna/ExprImputation-scimpute.R +8 -5
  72. biopipen/scripts/scrna/LoomTo10X.R +51 -0
  73. biopipen/scripts/scrna/MarkersFinder.R +348 -217
  74. biopipen/scripts/scrna/MetaMarkers.R +3 -3
  75. biopipen/scripts/scrna/ModuleScoreCalculator.R +14 -13
  76. biopipen/scripts/scrna/RadarPlots.R +1 -1
  77. biopipen/scripts/scrna/ScFGSEA.R +157 -75
  78. biopipen/scripts/scrna/ScSimulation.R +11 -10
  79. biopipen/scripts/scrna/ScVelo.py +605 -0
  80. biopipen/scripts/scrna/Seurat2AnnData.R +2 -3
  81. biopipen/scripts/scrna/SeuratClusterStats-clustree.R +1 -1
  82. biopipen/scripts/scrna/SeuratClusterStats-features.R +39 -30
  83. biopipen/scripts/scrna/SeuratClusterStats-ngenes.R +56 -65
  84. biopipen/scripts/scrna/SeuratClusterStats-stats.R +4 -4
  85. biopipen/scripts/scrna/SeuratClusterStats.R +9 -6
  86. biopipen/scripts/scrna/SeuratClustering.R +31 -48
  87. biopipen/scripts/scrna/SeuratLoading.R +2 -2
  88. biopipen/scripts/scrna/SeuratMap2Ref.R +66 -367
  89. biopipen/scripts/scrna/SeuratMetadataMutater.R +5 -7
  90. biopipen/scripts/scrna/SeuratPreparing.R +76 -24
  91. biopipen/scripts/scrna/SeuratSubClustering.R +46 -185
  92. biopipen/scripts/scrna/{SlingShot.R → Slingshot.R} +12 -16
  93. biopipen/scripts/scrna/Subset10X.R +2 -2
  94. biopipen/scripts/scrna/TopExpressingGenes.R +141 -184
  95. biopipen/scripts/scrna/celltypist-wrapper.py +6 -4
  96. biopipen/scripts/scrna/seurat_anndata_conversion.py +81 -0
  97. biopipen/scripts/scrna_metabolic_landscape/MetabolicFeatures.R +429 -123
  98. biopipen/scripts/scrna_metabolic_landscape/MetabolicPathwayActivity.R +346 -245
  99. biopipen/scripts/scrna_metabolic_landscape/MetabolicPathwayHeterogeneity.R +182 -173
  100. biopipen/scripts/snp/MatrixEQTL.R +39 -20
  101. biopipen/scripts/snp/PlinkCallRate.R +43 -34
  102. biopipen/scripts/snp/PlinkFreq.R +34 -41
  103. biopipen/scripts/snp/PlinkHWE.R +23 -18
  104. biopipen/scripts/snp/PlinkHet.R +26 -22
  105. biopipen/scripts/snp/PlinkIBD.R +30 -34
  106. biopipen/scripts/stats/ChowTest.R +9 -8
  107. biopipen/scripts/stats/DiffCoexpr.R +13 -11
  108. biopipen/scripts/stats/LiquidAssoc.R +7 -8
  109. biopipen/scripts/stats/Mediation.R +8 -8
  110. biopipen/scripts/stats/MetaPvalue.R +11 -13
  111. biopipen/scripts/stats/MetaPvalue1.R +6 -5
  112. biopipen/scripts/tcr/CDR3AAPhyschem.R +105 -164
  113. biopipen/scripts/tcr/ClonalStats.R +5 -4
  114. biopipen/scripts/tcr/CloneResidency.R +3 -3
  115. biopipen/scripts/tcr/CloneSizeQQPlot.R +2 -2
  116. biopipen/scripts/tcr/Immunarch2VDJtools.R +2 -2
  117. biopipen/scripts/tcr/ImmunarchFilter.R +3 -3
  118. biopipen/scripts/tcr/ImmunarchLoading.R +5 -5
  119. biopipen/scripts/tcr/ScRepCombiningExpression.R +39 -0
  120. biopipen/scripts/tcr/ScRepLoading.R +114 -92
  121. biopipen/scripts/tcr/TCRClusterStats.R +2 -2
  122. biopipen/scripts/tcr/TCRClustering.R +86 -97
  123. biopipen/scripts/tcr/TESSA.R +65 -115
  124. biopipen/scripts/tcr/VJUsage.R +5 -5
  125. biopipen/scripts/vcf/TruvariBenchSummary.R +15 -11
  126. biopipen/utils/common_docstrs.py +66 -63
  127. biopipen/utils/reporter.py +177 -0
  128. {biopipen-0.33.0.dist-info → biopipen-0.34.0.dist-info}/METADATA +2 -1
  129. {biopipen-0.33.0.dist-info → biopipen-0.34.0.dist-info}/RECORD +131 -144
  130. {biopipen-0.33.0.dist-info → biopipen-0.34.0.dist-info}/WHEEL +1 -1
  131. biopipen/reports/scrna/CellCellCommunicationPlots.svelte +0 -14
  132. biopipen/reports/scrna/SeuratClusterStats.svelte +0 -16
  133. biopipen/reports/scrna/SeuratMap2Ref.svelte +0 -37
  134. biopipen/reports/scrna/SeuratPreparing.svelte +0 -15
  135. biopipen/reports/scrna_metabolic_landscape/MetabolicFeaturesIntraSubset.svelte +0 -28
  136. biopipen/reports/utils/gsea.liq +0 -110
  137. biopipen/scripts/scrna/CellTypeAnnotation-common.R +0 -10
  138. biopipen/scripts/scrna/SeuratClustering-common.R +0 -213
  139. biopipen/scripts/scrna_metabolic_landscape/MetabolicFeaturesIntraSubset.R +0 -193
  140. biopipen/utils/caching.R +0 -44
  141. biopipen/utils/gene.R +0 -95
  142. biopipen/utils/gsea.R +0 -329
  143. biopipen/utils/io.R +0 -20
  144. biopipen/utils/misc.R +0 -602
  145. biopipen/utils/mutate_helpers.R +0 -581
  146. biopipen/utils/plot.R +0 -209
  147. biopipen/utils/repr.R +0 -146
  148. biopipen/utils/rnaseq.R +0 -48
  149. biopipen/utils/single_cell.R +0 -207
  150. {biopipen-0.33.0.dist-info → biopipen-0.34.0.dist-info}/entry_points.txt +0 -0
@@ -1,203 +1,64 @@
1
- {{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
2
- {{ biopipen_dir | joinpaths: "utils", "caching.R" | source_r }}
3
1
 
4
2
  library(Seurat)
5
3
  library(future)
6
- library(rlang)
7
- library(tidyr)
8
- library(dplyr)
9
- library(tidyseurat)
10
- library(digest)
4
+ library(biopipen.utils)
11
5
 
12
6
  set.seed(8525)
13
7
 
14
- srtfile <- {{in.srtobj | quote}}
15
- rdsfile <- {{out.rdsfile | quote}}
16
- joboutdir <- {{job.outdir | quote}}
17
- envs <- {{envs | r: todot = "-"}}
8
+ srtfile <- {{in.srtobj | r}}
9
+ outfile <- {{out.outfile | r}}
10
+ ncores <- {{envs.ncores | r}}
11
+ mutaters <- {{envs.mutaters | r}}
12
+ subset <- {{envs.subset | r}}
13
+ cache <- {{envs.cache | r}}
14
+ RunPCAArgs <- {{envs.RunPCA | r: todot = "-"}}
15
+ RunUMAPArgs <- {{envs.RunUMAP | r: todot = "-"}}
16
+ FindNeighborsArgs <- {{envs.FindNeighbors | r: todot = "-"}}
17
+ FindClustersArgs <- {{envs.FindClusters | r: todot = "-"}}
18
+ cases <- {{envs.cases | r}}
18
19
 
19
- options(str = strOptions(vec.len = 5, digits.d = 5))
20
20
  options(future.globals.maxSize = 80000 * 1024^2)
21
- plan(strategy = "multicore", workers = envs$ncores)
21
+ plan(strategy = "multicore", workers = ncores)
22
22
 
23
- .expand_dims <- function(args, name = "dims") {
24
- # Expand dims from 30 to 1:30
25
- if (!is.null(args) && is.numeric(args[[name]]) && length(args[[name]] == 1)) {
26
- args[[name]] <- 1:args[[name]]
27
- }
28
- args
29
- }
23
+ log <- get_logger()
30
24
 
31
- .expand_resolution <- function(resolution) {
32
- expanded_res <- c()
33
- for (res in resolution) {
34
- if (is.numeric(res)) {
35
- expanded_res <- c(expanded_res, res)
36
- } else {
37
- # is.character
38
- parts <- trimws(unlist(strsplit(res, ",")))
39
- for (part in parts) {
40
- if (grepl(":", part)) {
41
- ps <- trimws(unlist(strsplit(part, ":")))
42
- if (length(ps) == 2) { ps <- c(ps, 0.1) }
43
- if (length(ps) != 3) {
44
- stop("Invalid resolution format: {part}. Expected 2 or 3 parts separated by ':' for a range.")
45
- }
46
- ps <- as.numeric(ps)
47
- expanded_res <- c(expanded_res, seq(ps[1], ps[2], by = ps[3]))
48
- } else {
49
- expanded_res <- c(expanded_res, as.numeric(part))
50
- }
51
- }
52
- }
53
- }
54
- # keep the last resolution at last
55
- rev(unique(rev(round(expanded_res, 2))))
56
- }
25
+ cases <- expand_cases(cases, defaults = list(
26
+ RunPCA = RunPCAArgs,
27
+ RunUMAP = RunUMAPArgs,
28
+ FindNeighbors = FindNeighborsArgs,
29
+ FindClusters = FindClustersArgs,
30
+ subset = subset
31
+ ))
57
32
 
58
- # recode clusters from 0, 1, 2, ... to s1, s2, s3, ...
59
- .recode_clusters <- function(clusters) {
60
- recode <- function(x) paste0("s", as.integer(as.character(x)) + 1)
61
- clusters <- factor(recode(clusters), levels = recode(levels(clusters)))
62
- clusters
63
- }
33
+ if (isTRUE(cache)) {}
64
34
 
65
- envs$RunUMAP <- .expand_dims(envs$RunUMAP)
66
- envs$FindNeighbors <- .expand_dims(envs$FindNeighbors)
35
+ log$info("Reading Seurat object ...")
36
+ object <- read_obj(srtfile)
67
37
 
68
- log_info("Reading Seurat object ...")
69
- srtobj <- readRDS(srtfile)
70
-
71
- if (isTRUE(envs$cache)) { envs$cache <- joboutdir }
72
- if (length(envs$cache) > 1) {
73
- log_warn("Multiple cache directories (envs.cache) detected, using the first one.")
74
- envs$cache <- envs$cache[1]
75
- }
76
-
77
- if (!is.null(envs$mutaters) && length(envs$mutaters) > 0) {
78
- log_info("Mutating Seurat object ...")
79
- srtobj@meta.data <- srtobj@meta.data %>%
80
- mutate(!!!lapply(mutaters, parse_expr))
81
- }
82
-
83
- if (length(envs$cases) == 0) {
84
- envs$cases <- list(subcluster = list())
38
+ if (!is.null(mutaters) && length(mutaters) > 0) {
39
+ log$info("Mutating meta data ...")
40
+ object@meta.data <- mutate(
41
+ object@meta.data,
42
+ !!!lapply(mutaters, parse_expr)
43
+ )
85
44
  }
86
45
 
87
- for (key in names(envs$cases)) {
88
- log_info("")
89
- log_info("Running case '{key}' ...")
90
- log_info("===========================================")
91
- case <- envs$cases[[key]]
92
- case$RunUMAP <- .expand_dims(case$RunUMAP)
93
- case$FindNeighbors <- .expand_dims(case$FindNeighbors)
94
-
95
- case <- list_update(
96
- list(
97
- subset = envs$subset,
98
- RunUMAP = envs$RunUMAP,
99
- FindNeighbors = envs$FindNeighbors,
100
- FindClusters = envs$FindClusters
101
- ),
102
- case
46
+ for (name in names(cases)) {
47
+ case <- cases[[name]]
48
+ log$info("Processing case '{name}' ...")
49
+
50
+ object <- RunSeuratSubClustering(
51
+ object = object,
52
+ subset = case$subset,
53
+ name = name,
54
+ RunPCAArgs = case$RunPCAArgs,
55
+ RunUMAPArgs = case$RunUMAPArgs,
56
+ FindNeighborsArgs = case$FindNeighborsArgs,
57
+ FindClustersArgs = case$FindClustersArgs,
58
+ log = log,
59
+ cache = cache
103
60
  )
104
-
105
- if (is.null(case$subset) || length(case$subset) == 0) {
106
- stop(paste0("`subset` for case '", key, "' is empty."))
107
- }
108
-
109
- log_info("- Subsetting ...")
110
- sobj <- tryCatch({
111
- srtobj %>% filter(!!parse_expr(case$subset))
112
- }, error = function(e) {
113
- stop(paste0(" Error in subset: ", e$message))
114
- })
115
- sobj_sig <- capture.output(str(sobj))
116
- dig_sig <- digest::digest(sobj_sig, algo = "md5")
117
- dig_sig <- substr(dig_sig, 1, 8)
118
- cache_dir <- NULL
119
- if (is.character(envs$cache)) {
120
- cache_dir <- file.path(envs$cache, paste0(dig_sig, ".seurat_cache"))
121
- dir.create(cache_dir, recursive = TRUE, showWarnings = FALSE)
122
- writeLines(sobj_sig, file.path(cache_dir, "signature.txt"))
123
- }
124
-
125
- cached <- get_cached(case$RunUMAP, "RunUMAP", cache_dir)
126
- reduc_name <- case$RunUMAP$reduction.name %||% "umap"
127
- if (is.null(cached$data)) {
128
- log_info("- Running RunUMAP ...")
129
- umap_args <- list_setdefault(
130
- case$RunUMAP,
131
- object = sobj,
132
- dims = 1:30,
133
- reduction = sobj@misc$integrated_new_reduction %||% "pca"
134
- )
135
- ncells <- ncol(sobj)
136
- umap_args$dims <- 1:min(max(umap_args$dims), ncells - 1)
137
- umap_method <- case$RunUMAP$umap.method %||% "uwot"
138
- if (umap_method == "uwot" && is.null(case$RunUMAP$n.neighbors)) {
139
- # https://github.com/satijalab/seurat/issues/4312
140
- umap_args$n.neighbors <- min(ncells - 1, 30)
141
- }
142
- sobj <- do_call(RunUMAP, umap_args)
143
- cached$data <- list(reduc = sobj@reductions[[reduc_name]], commands = sobj@commands)
144
- save_to_cache(cached, "RunUMAP", cache_dir)
145
- } else {
146
- log_info("- Loading cached RunUMAP ...")
147
- sobj@reductions[[reduc_name]] <- cached$data$reduc
148
- sobj@commands <- cached$data$commands
149
- }
150
- reduc <- cached$data$reduc
151
-
152
- cached <- get_cached(case$FindNeighbors, "FindNeighbors", cache_dir)
153
- if (is.null(cached$data)) {
154
- log_info("- Running FindNeighbors ...")
155
- case$FindNeighbors$object <- sobj
156
- if (is.null(case$FindNeighbors$reduction)) {
157
- case$FindNeighbors$reduction <- sobj@misc$integrated_new_reduction %||% "pca"
158
- }
159
- sobj <- do_call(FindNeighbors, case$FindNeighbors)
160
- cached$data <- list(graphs = sobj@graphs, commands = sobj@commands)
161
- save_to_cache(cached, "FindNeighbors", cache_dir)
162
- } else {
163
- log_info("- Loading cached FindNeighbors ...")
164
- sobj@graphs <- cached$data$graphs
165
- sobj@commands <- cached$data$commands
166
- }
167
-
168
- case$FindClusters$random.seed <- case$FindClusters$random.seed %||% 8525
169
- resolution <- case$FindClusters$resolution <- .expand_resolution(case$FindClusters$resolution %||% 0.8)
170
- cached <- get_cached(case$FindClusters, "SubClustering", cache_dir)
171
- if (is.null(cached$data)) {
172
- log_info("- Running FindClusters at resolution: {paste(resolution, collapse = ',')} ...")
173
- case$FindClusters$object <- sobj
174
- case$FindClusters$cluster.name <- paste0(key, ".", resolution)
175
- # use sobj1 to avoid overwriting the previous clustering results (as they have the same graph name
176
- sobj1 <- do_call(FindClusters, case$FindClusters)
177
- sobj1@meta.data[[key]] <- .recode_clusters(sobj1@meta.data$seurat_clusters)
178
- for (clname in case$FindClusters$cluster.name) {
179
- sobj1@meta.data[[clname]] <- .recode_clusters(sobj1@meta.data[[clname]])
180
- }
181
- cached$data <- list(
182
- clusters = sobj1@meta.data[, c(case$FindClusters$cluster.name, key), drop = FALSE],
183
- command = sobj1@commands$FindClusters
184
- )
185
- save_to_cache(cached, "SubClustering", cache_dir)
186
- rm(sobj1)
187
- } else {
188
- log_info("- Using cached FindClusters at resolution: {paste(resolution, collapse = ',')} ...")
189
- }
190
-
191
- ident_table <- table(cached$data$clusters[[key]])
192
- log_info(" Found {length(ident_table)} clusters at resolution: {resolution[length(resolution)]}")
193
- print(ident_table)
194
- cat("\n")
195
-
196
- log_info("- Updating meta.data with subclusters...")
197
- srtobj <- AddMetaData(srtobj, metadata = cached$data$clusters)
198
- srtobj[[paste0("sub_umap_", key)]] <- reduc
199
- srtobj@commands[[paste0("FindClusters.", key)]] <- cached$data$command
200
61
  }
201
62
 
202
- log_info("Saving results ...")
203
- saveRDS(srtobj, file = rdsfile)
63
+ log$info("Saving results ...")
64
+ biopipen.utils::save_obj(object, file = outfile)
@@ -1,8 +1,7 @@
1
- {{ biopipen_dir | joinpaths: "utils", "misc.R" | source_r }}
2
-
3
1
  library(rlang)
4
2
  library(Seurat)
5
3
  library(slingshot)
4
+ library(biopipen.utils)
6
5
 
7
6
  sobjfile <- {{in.sobjfile | r}}
8
7
  outfile <- {{out.outfile | r}}
@@ -21,15 +20,17 @@ if (is.null(group_by)) {
21
20
  stop("envs.group_by is required")
22
21
  }
23
22
 
24
- log_info("Reading Seurat object ...")
25
- srt <- readRDS(sobjfile)
23
+ log <- get_logger()
24
+
25
+ log$info("Reading Seurat object ...")
26
+ srt <- read_obj(sobjfile)
26
27
 
27
28
  if (!group_by %in% colnames(srt@meta.data)) {
28
29
  stop(paste("Grouping column", group_by, "not found in the Seurat object"))
29
30
  }
30
31
 
31
32
  reduction <- reduction %||% DefaultDimReduc(srt)
32
- dims <- expand_dims(dims)
33
+ dims <- biopipen.utils:::.expand_number(dims)
33
34
 
34
35
  if (is.null(prefix)) {
35
36
  prefix <- ""
@@ -37,23 +38,16 @@ if (is.null(prefix)) {
37
38
  prefix <- paste0(prefix, "_")
38
39
  }
39
40
 
40
- log_info("Filtering cells in NA group_by ...")
41
+ log$info("Filtering cells in NA group_by ...")
41
42
  srt_sub <- srt[, !is.na(srt[[group_by, drop = TRUE]])]
42
43
 
43
- log_info("Running Slingshot ...")
44
+ log$info("Running Slingshot ...")
44
45
  sl <- slingshot(
45
46
  data = as.data.frame(srt_sub[[reduction]]@cell.embeddings[, dims]),
46
47
  clusterLabels = as.character(srt_sub[[group_by, drop = TRUE]]),
47
48
  start.clus = start, end.clus = end
48
49
  )
49
50
 
50
- command <- pbmc_small@commands[[1]]
51
- attr(command, "name") <- "SlingShot"
52
- attr(command, "call.string") <- "slingshot(...)"
53
- attr(command, "params") <- list()
54
- srt@commands <- srt@commands %||% list()
55
- srt@commands$Slingshot <- command
56
-
57
51
  df <- as.data.frame(slingPseudotime(sl))
58
52
  colnames(df) <- paste0(prefix, colnames(df))
59
53
  if (isTRUE(reverse)) {
@@ -67,5 +61,7 @@ if (isTRUE(reverse)) {
67
61
  srt <- AddMetaData(srt, metadata = df)
68
62
  srt <- AddMetaData(srt, metadata = slingBranchID(sl), col.name = paste0(prefix, "BranchID"))
69
63
 
70
- log_info("Saving Seurat object ...")
71
- saveRDS(srt, outfile)
64
+ srt <- AddSeuratCommand(srt, "Slingshot", "slingshot(...)")
65
+
66
+ log$info("Saving Seurat object ...")
67
+ save_obj(srt, outfile)
@@ -1,7 +1,7 @@
1
1
  library(Matrix)
2
2
 
3
- indir = {{in.indir | quote}}
4
- outdir = {{out.outdir | quote}}
3
+ indir = {{in.indir | r}}
4
+ outdir = {{out.outdir | r}}
5
5
  envs = {{envs | r}}
6
6
 
7
7
  set.seed(envs$seed)