Skip to content

Sparse matrix dimensions #105

Open
Open

Description

@acihanckr

Hello,

Thank you for providing this guide, it is very helpful. I am going through some parts of the code and I realized the following line in Case-study_Mouse-intestinal-epithelium_1906.ipynb raise an error:

adata.obs['mt_frac'] = adata.X[:, mt_gene_mask].sum(1)/adata.obs['n_counts']

When I investigated a little I realized adata.X is a 2d sparse matrix so it can't be divided by 1d series. Also, applying flatten or reshape directly doesn't work because it returns a numpy matrix which can't be flatten (or I couldn't). This might be a version issue, but my solution was replacing the line with

adata.obs['mt_frac'] = np.array(adata.X[:, mt_gene_mask].sum(1)).flatten()/adata.obs['n_counts']

Best

Activity

  1. LuckyMD commented on Nov 14, 2022

    @LuckyMD
    Contributor

    Hi @acihanckr,

    This notebook hasn't been updated in a while, so it could very well be that there are some issues due to dependency updates. We're actually working on a newer version of the tutorail in github.com/theislab/single-cell-best-practices

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions