99
1010import rapids_singlecell as rsc
1111
12+ from .utils import track_peakmem
13+
1214
1315class PreprocessingSuite :
1416 _data_dict = dict (pbmc68k_reduced = sc .datasets .pbmc68k_reduced ())
@@ -21,69 +23,81 @@ def setup(self, input_data: str):
2123 def time_calculate_qc_metrics (self , * _ ):
2224 self .adata .var ["mt" ] = self .adata .var_names .str .startswith ("MT-" )
2325 rsc .pp .calculate_qc_metrics (
24- self .adata , qc_vars = ["mt" ], percent_top = None , log1p = False , inplace = True
26+ self .adata , qc_vars = ["mt" ], log1p = False
2527 )
2628
27- def peakmem_calculate_qc_metrics (self , * _ ):
29+ @track_peakmem
30+ def track_peakmem_calculate_qc_metrics (self , * _ ):
2831 self .adata .var ["mt" ] = self .adata .var_names .str .startswith ("MT-" )
2932 rsc .pp .calculate_qc_metrics (
30- self .adata , qc_vars = ["mt" ], percent_top = None , log1p = False , inplace = True
33+ self .adata , qc_vars = ["mt" ], log1p = False
3134 )
3235
3336 def time_filter_cells (self , * _ ):
34- rsc .pp .filter_cells (self .adata , min_genes = 200 )
37+ rsc .pp .filter_cells (self .adata , qc_var = "n_counts" , min_count = 200 )
38+
39+ @track_peakmem
40+ def track_peakmem_filter_cells (self , * _ ):
41+ rsc .pp .filter_cells (self .adata , qc_var = "n_counts" , min_count = 200 )
3542
36- def peakmem_filter_cells (self , * _ ):
37- rsc .pp .filter_cells (self .adata , min_genes = 200 )
3843
3944 def time_filter_genes (self , * _ ):
40- rsc .pp .filter_genes (self .adata , min_cells = 3 )
45+ rsc .pp .filter_genes (self .adata , qc_var = "n_counts" , min_count = 3 )
4146
42- def peakmem_filter_genes (self , * _ ):
43- rsc .pp .filter_genes (self .adata , min_cells = 3 )
47+ @track_peakmem
48+ def track_peakmem_filter_genes (self , * _ ):
49+ rsc .pp .filter_genes (self .adata , qc_var = "n_counts" , min_count = 3 )
4450
4551 def time_normalize_total (self , * _ ):
4652 rsc .pp .normalize_total (self .adata , target_sum = 1e4 )
4753
48- def peakmem_normalize_total (self , * _ ):
54+ @track_peakmem
55+ def track_peakmem_normalize_total (self , * _ ):
4956 rsc .pp .normalize_total (self .adata , target_sum = 1e4 )
5057
5158 def time_log1p (self , * _ ):
5259 rsc .pp .log1p (self .adata )
5360
54- def peakmem_time_log1p (self , * _ ):
61+ @track_peakmem
62+ def track_peakmem_time_log1p (self , * _ ):
5563 rsc .pp .log1p (self .adata )
5664
5765 def time_pca (self , * _ ):
58- rsc .pp .pca (self .adata , svd_solver = "arpack" )
66+ rsc .pp .pca (self .adata )
5967
60- def peakmem_pca (self , * _ ):
61- rsc .pp .pca (self .adata , svd_solver = "arpack" )
68+ @track_peakmem
69+ def track_peakmem_pca (self , * _ ):
70+ rsc .pp .pca (self .adata )
6271
6372 def time_highly_variable_genes (self , * _ ):
6473 rsc .pp .highly_variable_genes (
6574 self .adata , min_mean = 0.0125 , max_mean = 3 , min_disp = 0.5
6675 )
6776
68- def peakmem_highly_variable_genes (self , * _ ):
77+ @track_peakmem
78+ def track_peakmem_highly_variable_genes (self , * _ ):
6979 rsc .pp .highly_variable_genes (
7080 self .adata , min_mean = 0.0125 , max_mean = 3 , min_disp = 0.5
7181 )
7282
7383 def time_regress_out (self , * _ ):
7484 rsc .pp .regress_out (self .adata , ["n_counts" , "percent_mito" ])
7585
76- def peakmem_regress_out (self , * _ ):
86+ @track_peakmem
87+ def track_peakmem_regress_out (self , * _ ):
7788 rsc .pp .regress_out (self .adata , ["n_counts" , "percent_mito" ])
7889
7990 def time_scale (self , * _ ):
8091 rsc .pp .scale (self .adata , max_value = 10 )
8192
82- def peakmem_scale (self , * _ ):
93+ @track_peakmem
94+ def track_peakmem_scale (self , * _ ):
8395 rsc .pp .scale (self .adata , max_value = 10 )
8496
8597 def time_neighbors (self , * _ ):
86- rsc .pp .neighbors (self .adata , n_neighbors = 15 , n_pcs = 100 )
98+ rsc .pp .neighbors (self .adata , n_neighbors = 15 , n_pcs = 50 )
99+
100+ @track_peakmem
101+ def track_peakmem_neighbors (self , * _ ):
102+ rsc .pp .neighbors (self .adata , n_neighbors = 15 , n_pcs = 50 )
87103
88- def peakmem_neighbors (self , * _ ):
89- rsc .pp .neighbors (self .adata , n_neighbors = 15 , n_pcs = 100 )
0 commit comments