77# ' @param sce A SingleCellExperiment object.
88# ' @param mode String specifying the mode for velocity estimation. Can be "deterministic", "stochastic", or "dynamical".
99# ' @param use.dimred String specifying the dimensionality reduction to use. If NULL, defaults to `DefaultReduction(sce)`.
10+ # ' @param subset.row Optional row subset passed to `velociraptor::scvelo()`.
11+ # ' @param subset_row Legacy alias of `subset.row`, kept for compatibility.
1012# ' @param ... Additional arguments passed to `velociraptor::scvelo`.
1113# '
1214# ' @return A SingleCellExperiment object with velocity state updated.
1315# ' @importFrom S4Vectors metadata metadata<-
1416# ' @importFrom SummarizedExperiment colData colData<-
1517# ' @export
16- RunVelocity <- function (sce , mode = c(" deterministic" , " stochastic" , " dynamical" ), use.dimred = NULL , ... ) {
18+ RunVelocity <- function (sce , mode = c(" deterministic" , " stochastic" , " dynamical" ), use.dimred = NULL ,
19+ subset.row = NULL , subset_row = NULL , ... ) {
1720 if (! requireNamespace(" velociraptor" , quietly = TRUE )) {
1821 stop(" Please install 'velociraptor' to run RNA Velocity." )
1922 }
@@ -31,11 +34,24 @@ RunVelocity <- function(sce, mode = c("deterministic", "stochastic", "dynamical"
3134 if (! all(c(" spliced" , " unspliced" ) %in% assayNames(sce ))) {
3235 stop(" Assays 'spliced' and 'unspliced' are required for RNA velocity." )
3336 }
37+
38+ if (! is.null(subset.row ) && ! is.null(subset_row )) {
39+ stop(" Please supply only one of 'subset.row' or 'subset_row'." )
40+ }
41+ if (is.null(subset.row ) && ! is.null(subset_row )) {
42+ subset.row <- subset_row
43+ }
3444
3545 # Run scvelo via velociraptor
3646 # Note: velociraptor uses its own basilisk environment
3747 message(" Running scVelo using velociraptor..." )
38- vel_res <- velociraptor :: scvelo(sce , mode = mode , use.dimred = use.dimred , ... )
48+ vel_res <- velociraptor :: scvelo(
49+ sce ,
50+ mode = mode ,
51+ use.dimred = use.dimred ,
52+ subset.row = subset.row ,
53+ ...
54+ )
3955
4056 # vel_res is a SingleCellExperiment containing the velocity outputs
4157 # We want to extract the velocity results and attach them to the original sce
@@ -50,6 +66,7 @@ RunVelocity <- function(sce, mode = c("deterministic", "stochastic", "dynamical"
5066 metadata(sce )$ sclet $ analyses $ velocity <- list (
5167 mode = mode ,
5268 use.dimred = use.dimred ,
69+ subset.row = subset.row ,
5370 timestamp = Sys.time()
5471 )
5572
0 commit comments