Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cell_transition changed #604

Open
MUCDK opened this issue Sep 13, 2023 · 0 comments
Open

cell_transition changed #604

MUCDK opened this issue Sep 13, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@MUCDK
Copy link
Collaborator

MUCDK commented Sep 13, 2023

At the moment, we cannot reproduce the multimodality tutorial, as the cell_transition doesn't work any more.

A non-scalable work around is the following code

def aggregate_transport_matrix(adata_source, adata_target, tmat, aggregation_key = "celltype", forward = True):
    df_source = adata_source.obs[aggregation_key]
    df_target = adata_target.obs[aggregation_key]

    annotations_source = adata_source.obs[aggregation_key].cat.categories
    annotations_target = adata_target.obs[aggregation_key].cat.categories

    tm = pd.DataFrame(
        np.zeros((len(annotations_source), len(annotations_target))),
        index=annotations_source,
        columns=annotations_target,
    )
    
    for annotation_src in annotations_source:
        for annotation_tgt in annotations_target:
            tm.loc[annotation_src, annotation_tgt] = tmat[
                np.ix_((df_source == annotation_src).squeeze(), (df_target == annotation_tgt).squeeze())
            ].sum()
    return tm.div(tm.sum(axis=int(forward)), axis=int(not forward))

tm = aggregate_transport_matrix(adata_atac, adata_rna, ftp["src", "tgt"].solution.transport_matrix, forward=True, aggregation_key="cell_type")

@MUCDK MUCDK self-assigned this Sep 13, 2023
@MUCDK MUCDK added the bug Something isn't working label Sep 13, 2023
@ArinaDanilina ArinaDanilina linked a pull request Sep 24, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant