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
28 stars 3 forks source link

ref_celltype Whether it can be set to None #18

Closed Mashuaiii closed 1 week ago

Mashuaiii commented 2 weeks ago

Hi, Rongting @Rongtingting

Thank you for your prompt answer last time. Sorry to bother you again. You know, sometimes we might not know which ones are normal, so we might start off without this normal as a reference. Therefore, I would like to know whether the parameter xconfig.ref_celltype can be set to None in RDR module, BAF module and combine module. And if there are no or too few normal cells, is it recommended to use immune cells(NK, T cells etc.) from the same sample as reference?I am looking forward to hearing from you and I would appreciate it very much.

Best regards!

Rongtingting commented 2 weeks ago

Hi @Mashuaiii

Thank you for your question.

  1. the parameter xconfig.ref_celltype can not be set to None in the RDR module; it is important in RDR to get a baseline.
  2. the parameter xconfig.ref_celltype can be None in the BAF module.
  3. xconfig.ref_celltype is not actually used in the Combine module; it can be None.

Indeed, determining what constitutes "normal" for cells can be challenging. Two primary methods are commonly employed for cell identification:

16 shows how to detect normal cells/reference cells in BAF module.

Yes, sometimes immune cells can be used as reference cells, but it depends on the sample you used.

Bests, Rongting

Mashuaiii commented 2 weeks ago

Hi Rongting, Thank you again for your timely and detailed reply, I really appreciate it! ^-^

Mashuaiii commented 1 week ago

Hi, Rongting @Rongtingting

I have an idea. Can we use the result of BAF module with xconfig.ref_celltype parameter is None to classify normal and tumor, and then send this normal information to RDRmodule?

Best regards! Mashuai

Rongtingting commented 1 week ago

Hi @Mashuaiii ,

Yes, you are right. That is why we provide the function in the BAF module. And because each module can be independent, you can do any exploration you want.

Bests, Rongting

Mashuaiii commented 1 week ago

Hi @Rongtingting,

Oh, that's really clever and interesting!Thank you Rongting. ^-^

Best, Mashuai

Mashuaiii commented 1 week ago

Hi @Rongtingting ,

Sorry to bother you again. I encountered some errors when setting the BAFmodule xconfig.ref_celltype to None. Here is my code and error message. `xconfig = xclone.XCloneConfig(dataset_name = "GBM786_BAF", module = "BAF") xconfig.set_figure_params(xclone= True, fontsize = 18) xconfig.outdir = "/home/mashuai/001-projects/4-XClone/test_GBM/xclone_output/noref" xconfig.cell_anno_key = "scRNAType" xconfig.ref_celltype = None xconfig.update_info_from_rdr = False xconfig.theo_neutral_BAF = 0.5 xconfig.xclone_plot= True xconfig.plot_cell_anno_key = "scRNAType"

xconfig.display()

BAF_merge_Xdata = xclone.model.run_BAF(BAF_adata, config_file = xconfig)`

`ValueError Traceback (most recent call last) Cell In[21], line 14 10 xconfig.plot_cell_anno_key = "scRNAType" 12 xconfig.display() ---> 14 BAF_merge_Xdata = xclone.model.run_BAF(BAF_adata, 15 config_file = xconfig)

File ~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/model/xclone_baf_wrap.py:198, in run_BAF(BAF_adata, verbose, run_verbose, config_file) 196 pass 197 else: --> 198 raise ValueError(f"[XClone error] Item '{ref_celltype}' not found in the BAF_adata's annotation.") 200 if exclude_XY: 201 BAF_adata = xclone.pp.exclude_XY_adata(BAF_adata)

ValueError: [XClone error] Item 'None' not found in the BAF_adata's annotation.`

The error should be that the cell_anno_keyparameter I set does not contain None. I tried leaving the cell_anno_key parameter unset or setting cell_anno_keyto None, but nothing worked. I am looking forward to hearing from you and I would appreciate it very much.

Bests, Mashuai

Rongtingting commented 1 week ago

Hi @Mashuaiii ,

There is a Strict setting in the released version. I will try to debug it in the next version.

Now, you can try to specify any celltype as ref_celltype if it is in your "scRNAType" annotation. And then set theo_neutral_BAF = 0.5, which will ignore the ref_celltype you used.

Thank you~ Rongting

Mashuaiii commented 1 week ago

Hi @Rongtingting ,

Thank you ~,The problem was solved with your help. But I had a new problem (T⌓T). Maybe the latest version of 0.3.8 does not have the functions for finding normal and tumor cells in XClone BAF module?When I tested, I found an error indicating that exploreClusteringand OnestopBAFClustering were not available.

I'm sorry to bother you so many times with my questions. Thank you very much for your help, which is timely, detailed and effective every time.^-^

Bests, Mashuai

Rongtingting commented 1 week ago

Hi @Mashuaiii, Thank you for your support in giving feedback. Yes, I have not released these functions. Could you try to install it from GitHub directly?

Bests, Rongting

Mashuaiii commented 1 week ago

Hi @Rongtingting,

Yeah, install it from Github directly is version 0.3.9, the above problem has been solved. ^-^

However, I have some question I don't understand. What do ref_anno_key and clone_anno_key do. adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "posterior_mtx", n_clusters = 2, ref_anno_key = "scRNAType", clone_anno_key = "scRNAType", plot_title = "GBM786_withoutref_BAF(XClone)", file_save_path = "/xclone_output/noref/analysis/", file_save_name = "GBM786_withoutref_BAF_2clones", complex_plot = True)

And I got an error. `NotImplementedError Traceback (most recent call last) Cell In[22], line 18 14 xclone.al.exploreClustering(adata, ref_anno_key = "scRNAType", Xlayer = "posterior_mtx", max_clusters = 5) 17 ## explore the BAF clustering by specify 2 clusters ---> 18 adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "posterior_mtx", 19 n_clusters = 2, ref_anno_key = "scRNAType", clone_anno_key = "scRNAType", 20 plot_title = "GBM786_withoutref_BAF(XClone)", 21 file_save_path = "/home/mashuai/001-projects/4-XClone/test_GBM/xclone_output/noref/analysis/", 22 file_save_name = "GBM786_withoutref_BAF_2clones", complex_plot = True) 24 ## Similarly, explore the BAF clustering by specify 3 clusters 25 # adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "posterior_mtx", 26 # n_clusters = 3, ref_anno_key = "spot_anno", clone_anno_key = "clone(3)", 27 # plot_title = "xxxx (XClone)", 28 # file_save_path = "xxxx/analysis/", file_save_name = "xxx_3clones", complex_plot = True)

File ~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:84, in OnestopBAFClustering(adata, Xlayer, n_clusters, ref_anno_key, clone_anno_key, plot_title, file_save_path, file_save_name, complex_plot) 82 cell_anno_key_plot = [clone_anno_key, ref_anno_key] 83 clusters_display_name = [clone_anno_key, ref_anno_key] ---> 84 Complex_BAF_CNV_visualization(adata, Xlayer = Xlayer, 85 cell_anno_key = cell_anno_key_plot, clusters_display_name = clusters_display_name, 86 title = plot_title, save_file = True, out_file = out_path) 87 else: 88 BAF_CNV_visualization(adata, Xlayer = Xlayer, 89 cell_anno_key = clone_anno_key, clusters_display_name = clone_anno_key, ... --> 203 raise NotImplementedError("isna is not defined for MultiIndex") 204 elif isinstance(obj, type): 205 return False

NotImplementedError: isna is not defined for MultiIndex`

Maybe because of this error, I did not get relevant information about clonal label?The result is only a plot. image How do I get the clone label for each cell, and which clone is normal or tumor? I am looking forward to hearing from you and I would appreciate it very much. ^-^

Bests, Mashuai

Rongtingting commented 1 week ago

Hi @Mashuaiii , Have you tried the follwing?

import xclone
import scanpy as sc

data_dir = "xxxxxx/BCH869_scRNA_trials/"
baf_final_file = data_dir + "data/BAF_merge_Xdata_KNN_HMM_post.h5ad"

adata = sc.read(baf_final_file)

## explore the clusters numbers by UMAP visualization
xclone.al.exploreClustering(adata, ref_anno_key = "spot_anno", Xlayer = "posterior_mtx", max_clusters = 5)

Here, we take the posterior_mtx layer from BAF module to do clustering (specify clusters = 2, 3, 4, 5) and saved the clustering label. in adata.obs.

For the step you asked, we can visualize the clustering results concordance with your original cell type annotation. For your case, I guess you should specify

ref_anno_key = "scRNAType", clone_anno_key = "clone(2)"

Bests, Rongting

Mashuaiii commented 1 week ago

Hi, @Rongtingting Yeah, I try the the follwing

import xclone
import scanpy as sc

data_dir = "/home/mashuai/001-projects/4-XClone/test_GBM/xclone_output/noref/"
baf_final_file = data_dir + "data/BAF_merge_Xdata_KNN_HMM_post.h5ad"

adata = sc.read(baf_final_file)

## explore the clusters numbers by UMAP visualization
xclone.al.exploreClustering(adata, ref_anno_key = "spot_anno", Xlayer = "posterior_mtx", max_clusters = 5)

## explore the BAF clustering by specify 2 clusters
adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "posterior_mtx", 
                         n_clusters = 2, ref_anno_key = "spot_anno", clone_anno_key = "clone(2)", 
                         plot_title = "GBM786_withoutref_BAF(XClone)",
                         file_save_path = "/home/mashuai/001-projects/4-XClone/test_GBM/xclone_output/noref/analysis/",
                         file_save_name =  "GBM786_withoutref_BAF_2clones", complex_plot = True)

But there will be an error about spot_anno.

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File ~/miniconda3/envs/xclone/lib/python3.9/site-packages/pandas/core/indexes/base.py:3805, in Index.get_loc(self, key)
   [3804](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/pandas/core/indexes/base.py:3804) try:
-> [3805](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/pandas/core/indexes/base.py:3805)     return self._engine.get_loc(casted_key)
   [3806](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/pandas/core/indexes/base.py:3806) except KeyError as err:

File index.pyx:167, in pandas._libs.index.IndexEngine.get_loc()

File index.pyx:196, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/hashtable_class_helper.pxi:7081, in pandas._libs.hashtable.PyObjectHashTable.get_item()

File pandas/_libs/hashtable_class_helper.pxi:7089, in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'spot_anno'

The above exception was the direct cause of the following exception:

KeyError                                  Traceback (most recent call last)
Cell In[6], [line 14](vscode-notebook-cell:?execution_count=6&line=14)
     [10](vscode-notebook-cell:?execution_count=6&line=10) print(adata)
     [13](vscode-notebook-cell:?execution_count=6&line=13) ## explore the clusters numbers by UMAP visualization
---> [14](vscode-notebook-cell:?execution_count=6&line=14) xclone.al.exploreClustering(adata, ref_anno_key = "spot_anno", Xlayer = "posterior_mtx", max_clusters = 5)
     [15](vscode-notebook-cell:?execution_count=6&line=15) print(adata)
...
   [3815](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/pandas/core/indexes/base.py:3815)     #  InvalidIndexError. Otherwise we fall through and re-raise
   [3816](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/pandas/core/indexes/base.py:3816)     #  the TypeError.
   [3817](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/pandas/core/indexes/base.py:3817)     self._check_indexing_error(key)

KeyError: 'spot_anno'

So as I mentioned before get, I want to know what are the roles of the ref_anno_key and clone_anno_key. Because of this error, I changed xclone.al.exploreClustering(adata, ref_anno_key = "spot_anno", Xlayer = "posterior_mtx", max_clusters = 5) to xclone.al.exploreClustering(adata, ref_anno_key = "scRNAType", Xlayer = "posterior_mtx", max_clusters = 5). When I change to ref_anno_key="scRNAType", the results are as follows image image image But the clustering label is not in adata.obs as follows image

When I try the following

xclone.al.exploreClustering(adata, ref_anno_key = "scRNAType", Xlayer = "posterior_mtx", max_clusters = 5)

## explore the BAF clustering by specify 2 clusters
adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "posterior_mtx", 
                         n_clusters = 2, ref_anno_key = "scRNAType", clone_anno_key = "clone(2)", 
                         plot_title = "GBM786_withoutref_BAF(XClone)",
                         file_save_path = "/home/mashuai/001-projects/4-XClone/test_GBM/xclone_output/noref/analysis/",
                         file_save_name =  "GBM786_withoutref_BAF_2clones", complex_plot = True)

The result are as follows image But there is still an error

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[7], [line 19](vscode-notebook-cell:?execution_count=7&line=19)
     [15](vscode-notebook-cell:?execution_count=7&line=15) print(adata)
     [18](vscode-notebook-cell:?execution_count=7&line=18) ## explore the BAF clustering by specify 2 clusters
---> [19](vscode-notebook-cell:?execution_count=7&line=19) adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "posterior_mtx", 
     [20](vscode-notebook-cell:?execution_count=7&line=20)                          n_clusters = 2, ref_anno_key = "scRNAType", clone_anno_key = "clone(2)", 
     [21](vscode-notebook-cell:?execution_count=7&line=21)                          plot_title = "GBM786_withoutref_BAF(XClone)",
     [22](vscode-notebook-cell:?execution_count=7&line=22)                          file_save_path = "/home/mashuai/001-projects/4-XClone/test_GBM/xclone_output/noref/analysis/",
     [23](vscode-notebook-cell:?execution_count=7&line=23)                          file_save_name =  "GBM786_withoutref_BAF_2clones", complex_plot = True)
     [25](vscode-notebook-cell:?execution_count=7&line=25) ## Similarly, explore the BAF clustering by specify 3 clusters
     [26](vscode-notebook-cell:?execution_count=7&line=26) # adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "posterior_mtx", 
     [27](vscode-notebook-cell:?execution_count=7&line=27) #                          n_clusters = 3, ref_anno_key = "spot_anno", clone_anno_key = "clone(3)", 
     [28](vscode-notebook-cell:?execution_count=7&line=28) #                          plot_title = "xxxx (XClone)",
     [29](vscode-notebook-cell:?execution_count=7&line=29) #                          file_save_path = "xxxx/analysis/", file_save_name =  "xxx_3clones", complex_plot = True)

File ~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:84, in OnestopBAFClustering(adata, Xlayer, n_clusters, ref_anno_key, clone_anno_key, plot_title, file_save_path, file_save_name, complex_plot)
     [82](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:82)     cell_anno_key_plot = [clone_anno_key, ref_anno_key]
     [83](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:83)     clusters_display_name = [clone_anno_key, ref_anno_key]
---> [84](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:84)     Complex_BAF_CNV_visualization(adata, Xlayer = Xlayer,
     [85](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:85)                               cell_anno_key = cell_anno_key_plot, clusters_display_name = clusters_display_name, 
     [86](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:86)                               title = plot_title, save_file = True, out_file = out_path)
     [87](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:87) else:
     [88](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:88)     BAF_CNV_visualization(adata, Xlayer = Xlayer,
     [89](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:89)                           cell_anno_key = clone_anno_key, clusters_display_name = clone_anno_key,
...
--> [203](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/pandas/core/dtypes/missing.py:203)     raise NotImplementedError("isna is not defined for MultiIndex")
    [204](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/pandas/core/dtypes/missing.py:204) elif isinstance(obj, type):
    [205](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/pandas/core/dtypes/missing.py:205)     return False

NotImplementedError: isna is not defined for MultiIndex

I'm sorry to bother you so many times with my questions (T⌓T). Thank you very much for your help, which is timely, detailed and effective every time.

Bests, Mashuai

Rongtingting commented 1 week ago

Hi @Mashuaiii , Thank you for telling me the whole process you tried. Yes, ref_anno_key is your own annotation you wanna use to compare with the clustering results (e.g., clone_anno_key).

xclone.al.exploreClustering(adata, ref_anno_key = "scRNAType", Xlayer = "posterior_mtx", max_clusters = 5)

This step explores what cluster number you should specify. Here, we have different tasks, for you, you wanna specify 2 clusters to distinguish normal and tumor, maybe for other users they wanna get subclones next steps. So here users can specify max_clusters for exploration. Is that clear? This step only provides visualization of clusters but does not save any cluster/clone label.

Next step

## explore the BAF clustering by specify 2 clusters
adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "posterior_mtx", 
                         n_clusters = 2, ref_anno_key = "scRNAType", clone_anno_key = "clone(2)", 
                         plot_title = "GBM786_withoutref_BAF(XClone)",
                         file_save_path = "/home/mashuai/001-projects/4-XClone/test_GBM/xclone_output/noref/analysis/",
                         file_save_name =  "GBM786_withoutref_BAF_2clones", complex_plot = True)

you will get adata_anno with saved label.

I am sorry for mispointng to adata.obs.

Bests, Rongting

Mashuaiii commented 1 week ago

Hi, @Rongtingting

Thank you for your timely answer! After your detailed explanation, I understand the function of exploreClustering. Sorry, but I got an error at the last step about NotImplementedError: isna is not defined for MultiIndex

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[8], [line 19](vscode-notebook-cell:?execution_count=8&line=19)
     [15](vscode-notebook-cell:?execution_count=8&line=15) print(adata)
     [18](vscode-notebook-cell:?execution_count=8&line=18) ## explore the BAF clustering by specify 2 clusters
---> [19](vscode-notebook-cell:?execution_count=8&line=19) adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "posterior_mtx", 
     [20](vscode-notebook-cell:?execution_count=8&line=20)                          n_clusters = 2, ref_anno_key = "scRNAType", clone_anno_key = "clone(2)", 
     [21](vscode-notebook-cell:?execution_count=8&line=21)                          plot_title = "GBM786_withoutref_BAF(XClone)",
     [22](vscode-notebook-cell:?execution_count=8&line=22)                          file_save_path = "/home/mashuai/001-projects/4-XClone/test_GBM/xclone_output/noref/analysis/",
     [23](vscode-notebook-cell:?execution_count=8&line=23)                          file_save_name =  "GBM786_withoutref_BAF_2clones", complex_plot = True)
     [24](vscode-notebook-cell:?execution_count=8&line=24) print(adata_anno)
     [25](vscode-notebook-cell:?execution_count=8&line=25) ## Similarly, explore the BAF clustering by specify 3 clusters
     [26](vscode-notebook-cell:?execution_count=8&line=26) # adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "posterior_mtx", 
     [27](vscode-notebook-cell:?execution_count=8&line=27) #                          n_clusters = 3, ref_anno_key = "spot_anno", clone_anno_key = "clone(3)", 
     [28](vscode-notebook-cell:?execution_count=8&line=28) #                          plot_title = "xxxx (XClone)",
     [29](vscode-notebook-cell:?execution_count=8&line=29) #                          file_save_path = "xxxx/analysis/", file_save_name =  "xxx_3clones", complex_plot = True)

File ~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:84, in OnestopBAFClustering(adata, Xlayer, n_clusters, ref_anno_key, clone_anno_key, plot_title, file_save_path, file_save_name, complex_plot)
     [82](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:82)     cell_anno_key_plot = [clone_anno_key, ref_anno_key]
     [83](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:83)     clusters_display_name = [clone_anno_key, ref_anno_key]
---> [84](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:84)     Complex_BAF_CNV_visualization(adata, Xlayer = Xlayer,
     [85](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:85)                               cell_anno_key = cell_anno_key_plot, clusters_display_name = clusters_display_name, 
     [86](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:86)                               title = plot_title, save_file = True, out_file = out_path)
     [87](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:87) else:
     [88](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/xclone/analysis/_quickanalysis.py:88)     BAF_CNV_visualization(adata, Xlayer = Xlayer,
...
--> [203](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/pandas/core/dtypes/missing.py:203)     raise NotImplementedError("isna is not defined for MultiIndex")
    [204](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/pandas/core/dtypes/missing.py:204) elif isinstance(obj, type):
    [205](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a225a68616e676c6162227d.vscode-resource.vscode-cdn.net/home/mashuai/001-projects/4-XClone/test_GBM/~/miniconda3/envs/xclone/lib/python3.9/site-packages/pandas/core/dtypes/missing.py:205)     return False

NotImplementedError: isna is not defined for MultiIndex

Bests, Mashuai

Rongtingting commented 1 week ago

And for the error you mentioned, seems that it comes from complex plot.

Could you try to set complex_plot = False

Rongtingting commented 1 week ago

And for the error you mentioned, seems that it comes from complex plot.

Could you try to set complex_plot = False

sometimes I encounter this issue in Python 3.9 #14 However, complex_plot works well in Python 3.7.

Mashuaiii commented 1 week ago

Hi, @Rongtingting

Thank you! It worked! image So for clone1 and clone2, who is tumor and normal should be distinguished by myself?

Good night, Sweet dreams.

Rongtingting commented 1 week ago

Cool, it finally works!

Yes, you can check the saved BAF heatmap to see which clone/cluster's BAF is around 0.5 (we expect the one around 0.5 to be normal-like).

Mashuaiii commented 1 week ago

OK, Thank you ~