@@ -42,20 +42,22 @@ RunInSilicoPerturbation <- function(sce, target_gene, perturbation_value = 0.0,
4242
4343 message(" Running CellOracle via basilisk..." )
4444
45- co_res <- basilisk :: basiliskRun(env = sclet_celloracle_env , fun = function (counts , cl , emb , tgt , pval , grn_f , ... ) {
45+ co_res <- basilisk :: basiliskRun(
46+ env = sclet_celloracle_env ,
47+ fun = function (counts , cluster_labels , emb , tgt , pval , grn_f , reduction_name , ... ) {
4648 ad <- reticulate :: import(" anndata" )
4749 pd <- reticulate :: import(" pandas" )
4850 co <- reticulate :: import(" celloracle" )
4951 sc <- reticulate :: import(" scanpy" )
5052
51- obs <- pd $ DataFrame(list (clusters = cl ), index = rownames(counts ))
53+ obs <- pd $ DataFrame(list (clusters = cluster_labels ), index = rownames(counts ))
5254 adata <- ad $ AnnData(X = counts , obs = obs )
53- adata $ obsm [paste0(" X_" , tolower(reduction ))] <- emb
55+ adata $ obsm [paste0(" X_" , tolower(reduction_name ))] <- emb
5456
5557 # Preprocessing inside Python
5658 sc $ pp $ normalize_total(adata , target_sum = 10000 )
5759 sc $ pp $ log1p(adata )
58- sc $ pp $ neighbors(adata , use_rep = paste0(" X_" , tolower(reduction )))
60+ sc $ pp $ neighbors(adata , use_rep = paste0(" X_" , tolower(reduction_name )))
5961
6062 # Load base GRN
6163 base_grn <- pd $ read_csv(grn_f , index_col = 0L )
@@ -81,7 +83,15 @@ RunInSilicoPerturbation <- function(sce, target_gene, perturbation_value = 0.0,
8183 shift <- oracle $ adata $ obsm [" delta_X" ]
8284
8385 return (as.matrix(shift ))
84- }, counts = counts_mat , cl = clusters , emb = emb , tgt = target_gene , pval = perturbation_value , grn_f = base_grn_path , ... )
86+ },
87+ counts = counts_mat ,
88+ cluster_labels = clusters ,
89+ emb = emb ,
90+ tgt = target_gene ,
91+ pval = perturbation_value ,
92+ grn_f = base_grn_path ,
93+ reduction_name = reduction ,
94+ ... )
8595
8696 # Store the shift vector in reducedDim, e.g., "celloracle_shift"
8797 rownames(co_res ) <- colnames(sce )
0 commit comments