File tree Expand file tree Collapse file tree
openproblems/tasks/_batch_integration
batch_integration_embed/methods Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,14 +35,15 @@ def _randomize_graph(adata, partition=None):
3535 return adata
3636
3737
38- def _random_embedding (partition ):
38+ def _random_embedding (partition , jitter = 0.01 ):
3939 from sklearn .preprocessing import LabelEncoder
4040 from sklearn .preprocessing import OneHotEncoder
4141
4242 embedding = OneHotEncoder ().fit_transform (
4343 LabelEncoder ().fit_transform (partition )[:, None ]
4444 )
45- embedding = embedding + np .random .uniform (- 0.01 , 0.01 , embedding .shape )
45+ if jitter is not None :
46+ embedding = embedding + np .random .uniform (- 1 * jitter , jitter , embedding .shape )
4647 return embedding
4748
4849
Original file line number Diff line number Diff line change 3434from ...batch_integration_graph .methods .scvi import scvi_full_unscaled
3535from ...batch_integration_graph .methods .scvi import scvi_hvg_unscaled
3636from .baseline import celltype_random_embedding
37+ from .baseline import celltype_random_embedding_jitter
3738from .baseline import no_integration_batch
3839from .scalex import scalex_full
3940from .scalex import scalex_hvg
Original file line number Diff line number Diff line change 1616)
1717
1818
19+ @_baseline_method (
20+ method_name = "Random Embedding by Celltype (with jitter)" ,
21+ )
22+ def celltype_random_embedding_jitter (adata , test = False ):
23+ adata .obsm ["X_emb" ] = _random_embedding (partition = adata .obs ["labels" ], jitter = 0.01 )
24+ adata .uns ["method_code_version" ] = check_version ("openproblems" )
25+ return adata
26+
27+
1928@_baseline_method (
2029 method_name = "Random Embedding by Celltype" ,
2130)
2231def celltype_random_embedding (adata , test = False ):
23- adata .obsm ["X_emb" ] = _random_embedding (partition = adata .obs ["labels" ])
32+ adata .obsm ["X_emb" ] = _random_embedding (partition = adata .obs ["labels" ], jitter = None )
2433 adata .uns ["method_code_version" ] = check_version ("openproblems" )
2534 return adata
2635
You can’t perform that action at this time.
0 commit comments