@@ -23,7 +23,6 @@ meta <- list(
2323 cpus = NULL
2424)
2525# # VIASH END
26- t0 <- Sys.time()
2726
2827cores_to_use <- meta $ cpus
2928if (is.null(cores_to_use )) {
@@ -58,58 +57,55 @@ cat(paste("Compute Cell Mixing Score using", cores_to_use, "cores for split 1\n"
5857
5958cms_distr_split1 <- list ()
6059medcouples_split1 <- list ()
61- for (i in 1 : 5 ) {
62- cat(paste(" Iteration" , i , " of 5\n " ))
63- integrated_subset <- subset_by_celltype(
64- integrated_split1 ,
65- frac = 0.3 ,
66- seed = i
67- )
68- # Transform to SingleCellExperiment and subset markers
69- cat(" Transforming to SingleCellExperiment and subsetting markers\n " )
70- integrated_subset_sce <- integrated_subset $ as_SingleCellExperiment()
71- integrated_subset_sce <- integrated_subset_sce [markers_to_correct , ]
72- cat(" Computing Cell Mixing Scores\n " )
73- integrated_subset_sce <- CellMixS :: cms(
74- integrated_subset_sce ,
75- group = " batch" ,
76- assay_name = " integrated" ,
77- k = par [[" n_neighbors" ]],
78- n_dim = par [[" n_dim" ]],
79- BPPARAM = bpparam
80- )
81- distr <- SingleCellExperiment :: colData(integrated_subset_sce )[, " cms" ]
82- cms_distr_split1 [[paste0(" split1_iter_" , i )]] <- distr
83- medcouples_split1 [[paste0(" split1_iter_" , i )]] <- robustbase :: mc(distr )
84- }
60+
61+ integrated_subset <- subset_by_celltype(
62+ integrated_split1 ,
63+ frac = 0.6 ,
64+ seed = 1
65+ )
66+
67+ cat(" Transforming to SingleCellExperiment and subsetting markers\n " )
68+ integrated_subset_sce <- integrated_subset $ as_SingleCellExperiment()
69+ integrated_subset_sce <- integrated_subset_sce [markers_to_correct , ]
70+ cat(" Computing Cell Mixing Scores\n " )
71+ integrated_subset_sce <- CellMixS :: cms(
72+ integrated_subset_sce ,
73+ group = " batch" ,
74+ assay_name = " integrated" ,
75+ k = par [[" n_neighbors" ]],
76+ n_dim = par [[" n_dim" ]],
77+ BPPARAM = bpparam
78+ )
79+ distr <- SingleCellExperiment :: colData(integrated_subset_sce )[, " cms" ]
80+ cms_distr_split1 [[" split1" ]] <- distr
81+ medcouples_split1 [[" split1" ]] <- robustbase :: mc(distr )
8582
8683cat(paste(" Compute Cell Mixing Score using" , cores_to_use , " cores for split 2\n " ), flush = TRUE )
8784
8885cms_distr_split2 <- list ()
8986medcouples_split2 <- list ()
90- for (i in 1 : 5 ) {
91- cat(paste(" Iteration" , i , " of 5\n " ))
92- integrated_subset <- subset_by_celltype(
93- integrated_split2 ,
94- frac = 0.2 ,
95- seed = i
96- )
97- cat(" Transforming to SingleCellExperiment and subsetting markers\n " )
98- integrated_subset_sce <- integrated_subset $ as_SingleCellExperiment()
99- integrated_subset_sce <- integrated_subset_sce [markers_to_correct , ]
100- cat(" Computing Cell Mixing Scores\n " )
101- integrated_subset_sce <- CellMixS :: cms(
102- integrated_subset_sce ,
103- group = " batch" ,
104- assay_name = " integrated" ,
105- k = par [[" n_neighbors" ]],
106- n_dim = par [[" n_dim" ]],
107- BPPARAM = bpparam
108- )
109- distr <- SingleCellExperiment :: colData(integrated_subset_sce )[, " cms" ]
110- cms_distr_split2 [[paste0(" split2_iter_" , i )]] <- distr
111- medcouples_split2 [[paste0(" split2_iter_" , i )]] <- robustbase :: mc(distr )
112- }
87+
88+ integrated_subset <- subset_by_celltype(
89+ integrated_split2 ,
90+ frac = 0.6 ,
91+ seed = 1
92+ )
93+ cat(" Transforming to SingleCellExperiment and subsetting markers\n " )
94+ integrated_subset_sce <- integrated_subset $ as_SingleCellExperiment()
95+ integrated_subset_sce <- integrated_subset_sce [markers_to_correct , ]
96+ cat(" Computing Cell Mixing Scores\n " )
97+ integrated_subset_sce <- CellMixS :: cms(
98+ integrated_subset_sce ,
99+ group = " batch" ,
100+ assay_name = " integrated" ,
101+ k = par [[" n_neighbors" ]],
102+ n_dim = par [[" n_dim" ]],
103+ BPPARAM = bpparam
104+ )
105+ distr <- SingleCellExperiment :: colData(integrated_subset_sce )[, " cms" ]
106+ cms_distr_split2 [[" split2" ]] <- distr
107+ medcouples_split2 [[" split2" ]] <- robustbase :: mc(distr )
108+
113109
114110cat(" Aggregate scores\n " , flush = TRUE )
115111# concat named lists
@@ -118,13 +114,6 @@ medcouples_list <- c(medcouples_split1, medcouples_split2)
118114# Compute mean medcouple
119115mean_medcouple_cms <- mean(unlist(medcouples_list ))
120116
121- print(" cms_list" )
122- print(cms_distr_list )
123- print(" medcouples_list" )
124- print(medcouples_list )
125- print(" mean_medcouple_cms" )
126- print(mean_medcouple_cms )
127-
128117cat(" Write output AnnData to file\n " , flush = TRUE )
129118output <- anndataR :: AnnData(
130119 shape = c(0L , 0L ),
@@ -143,5 +132,3 @@ output <- anndataR::AnnData(
143132)
144133
145134output $ write_h5ad(par [[" output" ]], compression = " gzip" , mode = " w" )
146-
147- cat(sprintf(" Elapsed: %.3f s\n " , as.numeric(difftime(Sys.time(), t0 , units = " secs" ))))
0 commit comments