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

Mixscape data type error #219

Closed
AlejandroTL opened this issue Mar 13, 2023 · 1 comment · Fixed by #222
Closed

Mixscape data type error #219

AlejandroTL opened this issue Mar 13, 2023 · 1 comment · Fixed by #222
Assignees
Labels
bug Something isn't working

Comments

@AlejandroTL
Copy link
Contributor

Report

Hello!

When I'm trying to reproduce the tutorial with a different dataset, I receive the following error in the function Mixscape.mixscape.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[70], line 1
----> 1 mixscape_identifier.mixscape(adata = adata, control = 'control', labels='perturbation', layer='X_pert')

File ~/miniconda3/envs/pertpy/lib/python3.9/site-packages/pertpy/tools/_mixscape.py:244, in Mixscape.mixscape(self, adata, labels, control, new_class_name, min_de_genes, layer, logfc_threshold, iter_num, split_by, pval_cutoff, perturbation_type, copy)
    240 vec = np.mean(X[guide_cells][:, de_genes_indices], axis=0) - np.mean(
    241     X[nt_cells][:, de_genes_indices], axis=0
    242 )
    243 # project cells onto the perturbation vector
--> 244 pvec = np.sum(np.multiply(dat.toarray(), vec), axis=1) / np.sum(np.multiply(vec, vec))
    245 pvec = pd.Series(np.asarray(pvec).flatten(), index=list(all_cells.index[all_cells]))
    246 if n_iter == 0:

AttributeError: 'numpy.ndarray' object has no attribute 'toarray'

Nevertheless, it doesn't happen when running with the dataset of the tutorial. I think that the problem is that Mixscape.pert_sign does not create .layers['X_pert'] as a sparse matrix, but as a normal numpy array.

Thanks!

Version information

No response

@AlejandroTL AlejandroTL added the bug Something isn't working label Mar 13, 2023
@xinyuejohn xinyuejohn self-assigned this Mar 24, 2023
@xinyuejohn
Copy link
Collaborator

@AlejandroTL Thanks for finding out this bug! I will solve this as soon as possible.

@xinyuejohn xinyuejohn linked a pull request Mar 24, 2023 that will close this issue
3 tasks
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.

2 participants