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

Sparse matrix dimensions #105

Open
acihanckr opened this issue Sep 15, 2022 · 1 comment
Open

Sparse matrix dimensions #105

acihanckr opened this issue Sep 15, 2022 · 1 comment

Comments

@acihanckr
Copy link

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

@LuckyMD
Copy link
Contributor

LuckyMD commented Nov 14, 2022

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants