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

Question about the final copy number calls #7

Closed faridrashidi closed 1 year ago

faridrashidi commented 1 year ago

Hi,

I have been using XClone for a few weeks now and have found it to be a very useful tool than Numbat. However, I don't know how to derive final copy number events and potentially identify different clones based on that information. Is there any way/example helping me?

I have reviewed the examples provided in the documentation, but have not been able to find this particular feature. Can you please help provide guidance on how to find clones and copy number calls with XClone?

Thank you.

Rongtingting commented 1 year ago

Hi @faridrashidi, thank you for your kind feedback! More tutorials (including the reference-free we mentioned earlier) will be posted later. I am still testing some functions & doing some simulations to ensure they are good enough.

For the final CNV calling results, there is one example for extracting the final CNV probability matrix (cell*gene) for each CNV state.

import xclone
import scanpy as sc

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

combine_Xdata = sc.read(combine_final_file)
combine_Xdata.layers 

out_dat_dir = data_dir + "analysis/extracted_data/"
use_layer = "prob1_merge"

region_lst = ["GeneName", "GeneID"]

xclone.al.extract_xclone_matrix(combine_Xdata, use_layer, states = 0, region_lst = region_lst, out_dir = out_dat_dir + "prob_combine_copyloss/")

xclone.al.extract_xclone_matrix(combine_Xdata, use_layer, states = 1, region_lst = region_lst, out_dir = out_dat_dir + "prob_combine_loh/")

xclone.al.extract_xclone_matrix(combine_Xdata, use_layer, states = 2, region_lst = region_lst, out_dir = out_dat_dir + "prob_combine_copyneutral/")

xclone.al.extract_xclone_matrix(combine_Xdata, use_layer, states = 3, region_lst = region_lst, out_dir = out_dat_dir + "prob_combine_copygain/")

We also provide a function to change the results resolution to the chr-arm scale.

merge_Xdata = xclone.al.change_res_resolution(combine_Xdata, Xlayer = "prob1_merge", outlayer = "prob_merge")

out_dat_dir = data_dir +"analysis/extracted_data_merge_chr_arm/"

region_lst = ["chr", "start", "gene1_stop","arm", "chr_arm", "lastgene_start",  "stop", ]

use_layer = "prob_merge"
xclone.al.extract_xclone_matrix(merge_Xdata, use_layer, states = 0, region_lst = region_lst, out_dir = out_dat_dir + "prob_combine_copyloss/")

xclone.al.extract_xclone_matrix(merge_Xdata, use_layer, states = 1, region_lst = region_lst, out_dir = out_dat_dir + "prob_combine_loh/")

xclone.al.extract_xclone_matrix(merge_Xdata, use_layer, states = 2, region_lst = region_lst, out_dir = out_dat_dir + "prob_combine_copyneutral/")

xclone.al.extract_xclone_matrix(merge_Xdata, use_layer, states = 3, region_lst = region_lst, out_dir = out_dat_dir + "prob_combine_copygain/")
faridrashidi commented 1 year ago

Thank you, Rongting, for your quick response and helpful information! Before closing this thread, I have two more questions:

1) If I want to to call the haplotype-specific events (A and B alleles) do I have to change the use_layer to plot_prob_merge3 and then repeat extract_xclone_matrix for 6 states in the above codes?

2) Is there a function in XClone that can find subclones based on copy number calls? I know clustering is an option, but I'm curious if XClone has this functionality already built-in.

Rongtingting commented 1 year ago

Hi @faridrashidi

For Q1: Yes, haplotype-specific prob matrix is in plot_prob_merge3 layer in the order of ["copy lossA", "copy lossB","LOH-A", "LOH-B", "copy neutral", "copy gain"]https://github.com/single-cell-genetics/XClone/blob/0078ea8b4c22f6fbb7b1d62807e4dd2f5e9a645d/xclone/model/xclone_combine_wrap.py#L224

For Q2: We do the clustering of the final CNV calling results to find subclones for this stage. We also consider to implement a phylogenetic tree extension, but not a built-in function. I noticed that your work trisicell is nice.

Looking forward to your other feedback, if have any. Thanks!

faridrashidi commented 1 year ago

Thank you very much Rongting, very helpful!