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

Finding normal cells and tumor cells in BAF module #16

Open Rongtingting opened 3 weeks ago

Rongtingting commented 3 weeks ago
          Hi @faridrashidi,

I am sorry for the late reply. I have added functions for finding normal and tumor cells in XClone BAF module (latest version via github installation). And XClone works well in Python 3.9 environment now.

Example

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)

## 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 = "xxxx (XClone)",
                         file_save_path = "xxxx/analysis/", file_save_name =  "xxx_2clones", complex_plot = True)

## Similarly, explore the BAF clustering by specify 3 clusters
adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "posterior_mtx", 
                         n_clusters = 3, ref_anno_key = "spot_anno", clone_anno_key = "clone(3)", 
                         plot_title = "xxxx (XClone)",
                         file_save_path = "xxxx/analysis/", file_save_name =  "xxx_3clones", complex_plot = True)

Bests, Rongting

Originally posted by @Rongtingting in https://github.com/single-cell-genetics/XClone/issues/5#issuecomment-2306914141

Rongtingting commented 3 weeks ago

8 https://github.com/single-cell-genetics/XClone/issues/8#issuecomment-2306947520

BAF module without specifying reference cells

Mashuaiii commented 2 weeks ago

Hi, Rongting @Rongtingting

Thank you for your prompt answer last time. Sorry to bother you again. I wonder if the normal and tumor cells identified by this BAF module can be used as the result of the final comboine? Can I cluster with the results after the combine module? Will there be any difference between the combine and BAF results? In addition, does xclone have the ability to identify subclones? I am looking forward to hearing from you and I would appreciate it very much.

Best regards!

Rongtingting commented 2 weeks ago

Hi @ShuaiManMan,

Thank you for your questions. Yes, you should cluster the results after the Combine module.

Here, BAF module clustering just provides an option for finding reference/normal cells.

If there are LOH events (similar expression level as reference populations but loss allele), only Combine module can detect.

Yes, XClone can detect subclones based on the Combine module's output.

You may find the following codes helpful

import xclone
import scanpy as sc

data_dir = "xxxxxx/BCH869_scRNA_trials/"
combine_final_file = data_dir + "data/combined_final.h5ad"

adata = sc.read(combine_final_file)

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

## explore the clustering by specify 2 clusters
adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "prob1_merge", 
                         n_clusters = 2, ref_anno_key = "spot_anno", clone_anno_key = "clone(2)", 
                         plot_title = "xxxx (XClone)",
                         file_save_path = "xxxx/analysis/", file_save_name =  "xxx_2clones", complex_plot = True)

## Similarly, explore the clustering by specify 3 clusters
adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "prob1_merge", 
                         n_clusters = 3, ref_anno_key = "spot_anno", clone_anno_key = "clone(3)", 
                         plot_title = "xxxx (XClone)",
                         file_save_path = "xxxx/analysis/", file_save_name =  "xxx_3clones", complex_plot = True)

Bests, Rongting

Mashuaiii commented 2 weeks ago

Hi Rongting, Thank you very much for your timely reply, and your answer is very detailed, I really appreciate it! ^-^

Mashuaiii commented 4 days ago

Hi @Rongtingting ,

I have some questions about the results of clustering after the Combine module. I ran the following code.

import xclone
import scanpy as sc

data_dir = "xxxxxx/BCH869_scRNA_trials/"
combine_final_file = data_dir + "data/combined_final.h5ad"

adata = sc.read(combine_final_file)

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

## explore the clustering by specify 2 clusters
adata_anno = xclone.al.OnestopBAFClustering(adata, Xlayer = "prob1_merge", 
                         n_clusters = 2, ref_anno_key = "spot_anno", clone_anno_key = "clone(2)", 
                         plot_title = "xxxx (XClone)",
                         file_save_path = "xxxx/analysis/", file_save_name =  "xxx_2clones", complex_plot = True)

the results as follow: image I want to know what the coordinates on the right mean. And how do I know which of the two clones is normal and tumor? Run the results of the combine again and label the results with this clone?I am looking forward to hearing from you and I would appreciate it very much.

Bests, Mashuai

Rongtingting commented 3 days ago

Hi @Mashuaiii,

Thank you for your updates.

Here, you have 2 clone labels; you can use that label to plot a combined module-derived heatmap to check the patterns of the 2 clones.

Bests, Rongting

Mashuaiii commented 2 days ago

Ok,Thank you ~