Skip to content

Commit 2c5c858

Browse files
committed
cellrank2 compatibility
1 parent 7b6f4a3 commit 2c5c858

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

scFates/tools/conversion.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def cellrank_to_tree(
1818
auto_root: bool = False,
1919
root_params: dict = {},
2020
reassign_pseudotime: bool = False,
21+
key_cellrank = "term_states_fwd_memberships",
2122
copy=False,
2223
**kwargs
2324
):
@@ -48,6 +49,8 @@ def cellrank_to_tree(
4849
min_val parameter from :func:`scFates.tl.root`
4950
reassign_pseudotime
5051
whether use the time key to replace the distances comptued from the tree.
52+
key_cellrank
53+
where to get the forward terminal fate memberships.
5154
copy
5255
Return a copy instead of writing to adata.
5356
kwargs
@@ -90,18 +93,18 @@ def cellrank_to_tree(
9093

9194
adata = adata.copy() if copy else adata
9295

93-
n_states = adata.obsm["to_terminal_states"].shape[1]
96+
n_states = adata.obsm[key_cellrank].shape[1]
9497

9598
if n_states == 2:
9699
adata.obsm["X_fates"] = np.vstack(
97100
[
98-
np.array(adata.obsm["to_terminal_states"][:, 0].flatten()),
101+
np.array(adata.obsm[key_cellrank][:, 0].flatten()),
99102
adata.obs[time],
100103
]
101104
).T
102105
logg.hint(
103106
"with .obsm['X_fates'], created by combining:\n"
104-
" .obsm['to_terminal_states'][:,0] and adata.obs['" + time + "']\n"
107+
f" .obsm[{key_cellrank}][:,0] and adata.obs['{time}']\n"
105108
)
106109
else:
107110
logg.hint(

0 commit comments

Comments
 (0)