chriscainx / mnnpy

An implementation of MNN (Mutual Nearest Neighbors) correct in python.
BSD 3-Clause "New" or "Revised" License
72 stars 31 forks source link

error when set cos_norm_out=False #16

Open yupingz opened 6 years ago

yupingz commented 6 years ago

corrected = mnnpy.mnn_correct(a,b,var_index=gene, var_subset=hvgs, batch_categories = ["A", "B"], cos_norm_out=False) Inputs are AnnData objects, var_index ignored. Performing cosine normalization... Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.7/site-packages/mnnpy/mnn.py", line 126, in mnn_correct svd_mode=svd_mode, do_concatenate=do_concatenate, **kwargs) File "/usr/local/lib/python3.7/site-packages/mnnpy/mnn.py", line 157, in mnn_correct var_subset, n_jobs) File "/usr/local/lib/python3.7/site-packages/mnnpy/utils.py", line 83, in transform_input_data return in_batches, out_batches, var_sub_index, same_set UnboundLocalError: local variable 'out_batches' referenced before assignment

fbnrst commented 6 years ago

I ran into the same error. Minimal example to reproduce:

import mnnpy
import scanpy.api as sc

sc.logging.print_versions()
adata1 = sc.datasets.blobs()
adata2 = sc.datasets.blobs()
mnnpy.mnn_correct(adata1, adata2, cos_norm_out=False)

When lookiing at utils.py it becomes clear that out_batches is not assigned in the function transform_input_data. I'm just not sure what should be assigned to out_batches in that case. I sit just out_batches = datas?

LisaSikkema commented 5 years ago

I have the same problem. Did anyone find a solution yet?

LisaSikkema commented 5 years ago

I think they just forgot to add one line (based on my understanding of the code and the MNN code in R). I created a fork with the corrected code, it can be found here: https://github.com/LisaSikkema/mnnpy