Skip to content

Sparse matrix dimensions #105

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

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