single-cell-genetics / XClone

Detection of allele-specific subclonal copy number alterations from single-cell transcriptomic data.
https://xclone-cnv.readthedocs.io/en/latest/
Apache License 2.0
21 stars 2 forks source link

error in running RDR module #5

Closed faridrashidi closed 1 year ago

faridrashidi commented 1 year ago

Hi,

I'm trying to run XClone RDR module following scripts at here on a dataset but I get the following error:

File xclone_rdr_wrap.py:232, in run_RDR(RDR_adata, verbose, run_verbose, config_file)
    230 if trans_prob is None:
    231     trans_prob = np.array([[1-2*t, t, t],[t, 1-2*t, t],[t, t, 1-2*t]])
--> 232 RDR_adata = xclone.model.CNV_optimazation(RDR_adata, depth_key = depth_key, init_state_ratio = guide_cnv_ratio,
    233                 max_iter = max_iter,
    234                 min_iter = min_iter,
    235                 HMM_brk = HMM_brk,
    236                 start_prob = start_prob,
...
    443     if verbose:
    444         print(idx_kept)
--> 446 return res, res_log

UnboundLocalError: local variable 'res' referenced before assignment

Could you please help me what I should do to resolve this issue?

Rongtingting commented 1 year ago

Hi, Thank you for using XClone. Maybe you can have a look at the tutorial TNBC1 dataset (10x) (details of params are shown in the tutorial).

And could you please show me the log of xconfig.display()?

faridrashidi commented 1 year ago

Thank you for your help. I get the same error when running the TNBC1 example. Here's the log of xconfig for the TNBC1 example:

RDR 
Configurations:
HMM_brk                        chr_arm
KNN_neighbors                  10
WMA_smooth_key                 chr_arm
WMA_window_size                40
_file_format_data              h5ad
_file_format_figs              pdf
_frameon                       True
_outdir                        .
_plot_suffix                   
_start                         1682306587.118832
_vector_friendly               True
cell_anno_key                  cluster.pred
dataset_name                   TNBC1_scRNA
dispersion_celltype            None
exclude_XY                     False
file_format_data               h5ad
file_format_figs               pdf
filter_ref_ave                 0.5
fit_GLM_libratio               False
gene_exp_group                 1
gene_exp_ref_log               True
guide_chr_anno_key             chr_arm
guide_cnv_ratio                None
guide_qt_lst                   [0.0001, 0.96, 0.99]
marker_group_anno_key          cluster.pred
max_iter                       2
min_iter                       1
module                         RDR
outdir                         .
plot_cell_anno_key             cluster
plot_suffix                    
rdr_plot_vmax                  0.7
rdr_plot_vmin                  -0.7
ref_celltype                   N
remove_guide_XY                False
remove_marker                  True
select_normal_chr_num          4
set_figtitle                   True
set_smartseq                   False
smart_transform                False
start_prob                     [0.1 0.8 0.1]
top_n_marker                   15
trans_prob                     [[9.99998e-01 1.00000e-06 1.00000e-06]
 [1.00000e-06 9.99998e-01 1.00000e-06]
 [1.00000e-06 1.00000e-06 9.99998e-01]]
trans_t                        1e-06
warninig_ignore                True
xclone_plot                    True

P.S. I use python v3.9.2 and XClone v0.3.4

Rongtingting commented 1 year ago

Hi, Could you have a try on python 3.7 and XClone v0.3.4?

faridrashidi commented 1 year ago

Thank you, Rongting, for your assistance in resolving the issue. It seems XClone only works with Python 3.7. I tried running it with Python 3.8.10 and 3.9.2, but encountered the same issue. I appreciate your help in pointing me in the right direction.

I have two more questions before closing this issue: 1) Can XClone detect tumor and normal cells without any prior information itself? 2) It seem filter_ref_ave parameter is an important factor in determining the CNV which is set to 0.5 as default. Is there any way to adjust this variable accordingly to the data e.g. based on library size?

Rongtingting commented 1 year ago

Hi @faridrashidi, thank you for your feedback! XClone is stable in Python 3.7 (3.8 and 3.9 may cause some issues in xclone's requirement packages, we will test later).

  1. Actually, our BAF module can provide smoothened B allele frequency and also CNV states' probability, which can be used to do cell clustering and the cells with balanced BAF (around 0.5) are more likely to be normal cells. We have tested this strategy in our GX109-T1c sample and in the TNBC1 sample, it can accurately detect the normal cells. However, this function is not provided in v0.3.4 yet. (If you are interested in this part, can send you an example later.)
  2. Yes, the filter_ref_ave parameter is an important factor, but here it is just a parameter that helps to do gene filtering at the first step. if the average gene value in reference cells is too low, then the gene will be discarded. In 10x seq data, we set it to 0.5 as default to keep 3000~6000 genes for analysis.
faridrashidi commented 1 year ago

Thank you very much!

Rongtingting commented 1 year ago

Hi, @faridrashidi, could you help to provide the scanpy version in your Python 3.8.10 and 3.9.2 env?

faridrashidi commented 1 year ago

For 3.8.10 is v1.9.2 For 3.9.2 is v1.9.1

faridrashidi commented 1 year ago

Hi, @Rongtingting, could you please send me the example for finding normal and tumor cells by XClone that you mentioned here?