-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Hello, I've noticed that xclone cannot set multiple reference cells in BAF. After reviewing your config file, I found that there is no option to set multi_refcelltype in BAF. Furthermore, I observed that the logic of the fit_BAF_theoretical_values function indeed only permits setting a single ref_celltype and does not support multiple reference cell types.
def fit_BAF_theoretical_values(Xdata, chr_lst = None, celltype_lst = None, cell_anno = "cell_type", region_anno = "chr_arm", random_seed = None, n_sample_cells = 200, AD_layer = "ad_bin_phased", DP_layer = "dp_bin", iterations = 1, calculate_ref = True, ref_celltype = "unclassified", verbose = True): """ Sample areas from copy loss/copy gain (ground truth) for fitting of state specific BAF theoretical values. Based on Binomial analytical prob(mu_). """ if random_seed is not None: rvgen = np.random.RandomState(random_seed) else: rvgen = np.random if chr_lst is None: is_region = Xdata.var[region_anno] == Xdata.var[region_anno] else: is_region = Xdata.var[region_anno].isin(chr_lst) if celltype_lst is None: is_cell = Xdata.obs[cell_anno] == Xdata.obs[cell_anno] else: is_cell = Xdata.obs[cell_anno].isin(celltype_lst) sample_pool = Xdata[:, is_region][is_cell, :].copy() n_cells = sample_pool.shape[0] theoretical_prob = [] for i in range(iterations): sample_idx = rvgen.randint(0, n_cells, n_sample_cells) AD_sum = sample_pool[sample_idx, :].layers[AD_layer].sum() DP_sum = sample_pool[sample_idx, :].layers[DP_layer].sum() theoretical_prob_value = AD_sum / (AD_sum + DP_sum) if verbose: print("[XClone]fit_BAF_theoretical_value", i, ":",theoretical_prob_value) theoretical_prob.append(theoretical_prob_value) if calculate_ref: is_ref = Xdata.obs[cell_anno] == ref_celltype ref_obs = Xdata[is_ref, :][:, is_region].copy() ref_BAF = ref_obs.layers["fill_BAF1_phased"].mean() # ref_BAF = (ref_obs.layers[AD_layer] / ref_obs.layers[DP_layer]).mean() else: ref_BAF = 0.5 if verbose: print("theoretical_prob:", theoretical_prob) print("ref_BAF:", ref_BAF) return theoretical_prob, ref_BAF