zktuong/dandelion

local variable 'h_ccall_p_igm_count' referenced before assignment

YuxuanZheng94 opened this issue · 3 comments

Dear developers,
When I used the function filter_contigs under sc-dandelion (version: 0.2.5 development) asvdj = ddl.pp.filter_contigs(bcr), the error raised UnboundLocalError: local variable 'h_ccall_p_igm_count' referenced before assignment. And then I changed the version of sc-dandelion to 0.2.4, this error still existed. However, when I changed the version into 0.2.1, this problem was resolved. Would you tell me what happened here?

hi @YuxuanZheng94, thanks for reporting this bug!

The issue here is that there a couple of refactoring of the steps (to simplify the code between 0.2.1 and 0.2.4), resulting in new variables being created and the logic must have been incomplete, resulting in a for-loop running expecting h_ccall_p_igm_count to have been created but it isn't in your case.

I'm thinking that perhaps that my if statement on line 3239 was returning False in your dataset/rows:

if "IGHD" in h_ccall_p:
if all(x in ["IGHM", "IGHD"] for x in h_ccall_p):
if len(list(set(h_ccall_p))) == 2:
h_ccall_p_igm_count = dict(
data1[data1["c_call"] == "IGHM"][
"duplicate_count"
]
)
h_ccall_p_igd_count = dict(
data1[data1["c_call"] == "IGHD"][
"duplicate_count"
]
)

I'm currently travelling so will be a bit slow in fixing this but i'm looking into perhaps by the end of the week. In the mean time, can you paste for me the full error trace? just want to confirm which line number in the code this is tripping at.

hi @YuxuanZheng94, can you try and install with

pip install git+https://github.com/zktuong/dandelion.git@fix_unreference_variable-182

and see if the error appears?

hi @YuxuanZheng94, can you try and install with

pip install git+https://github.com/zktuong/dandelion.git@fix_unreference_variable-182

and see if the error appears?

This update works! There is no error reported! Thank you very much!