spateo.external.CAST.utils ========================== .. py:module:: spateo.external.CAST.utils Functions --------- .. autoapisummary:: spateo.external.CAST.utils.coords2adjacentmat spateo.external.CAST.utils.hv_cutoff spateo.external.CAST.utils.detect_highly_variable_genes spateo.external.CAST.utils.extract_coords_exp spateo.external.CAST.utils.Harmony_integration spateo.external.CAST.utils.random_sample spateo.external.CAST.utils.sub_node_sum spateo.external.CAST.utils.nearest_neighbors_idx spateo.external.CAST.utils.non_zero_center_scale spateo.external.CAST.utils.sub_data_extract spateo.external.CAST.utils.preprocess_fast spateo.external.CAST.utils.cell_select spateo.external.CAST.utils.get_neighborhood_rad spateo.external.CAST.utils.delta_cell_cal spateo.external.CAST.utils.delta_exp_cal spateo.external.CAST.utils.delta_exp_sigplot spateo.external.CAST.utils.delta_exp_statistics Module Contents --------------- .. py:function:: coords2adjacentmat(coords, output_mode='adjacent', strategy_t='convex') .. py:function:: hv_cutoff(max_col, threshold=2000) .. py:function:: detect_highly_variable_genes(sdata, batch_key='batch', n_top_genes=4000, count_layer='count') .. py:function:: extract_coords_exp(sdata, batch_key='batch', cols='spatial', count_layer='count', data_format='norm1e4', ifcombat=False, if_inte=False) .. py:function:: Harmony_integration(sdata_inte, scaled_layer, use_highly_variable_t, batch_key, umap_n_neighbors, umap_n_pcs, min_dist, spread_t, source_sample_ctype_col, output_path, n_components=50, ifplot=True, ifcombat=False) .. py:function:: random_sample(coords_t, nodenum, seed_t=2) .. py:function:: sub_node_sum(coords_t, exp_t, nodenum=1000, vis=True, seed_t=2) .. py:function:: nearest_neighbors_idx(coord1, coord2, mode_t='knn') .. py:function:: non_zero_center_scale(sdata_t_X) .. py:function:: sub_data_extract(sample_list, coords_raw, exps, nodenum_t=20000, if_non_zero_center_scale=True) .. py:function:: preprocess_fast(sdata1, mode='customized', target_sum=10000.0, base=2, zero_center=True, regressout=False) .. py:function:: cell_select(coords_t, s=0.5, c=None, output_path_t=None) Select cells by drawing a polygon on the plot. Click the "Finish Polygon" button to finish drawing the polygon. Click the "Clear Polygon" button to clear the polygon. .. py:function:: get_neighborhood_rad(coords_centroids, coords_candidate, radius_px, dist=None) .. py:function:: delta_cell_cal(coords_tgt, coords_ref, ctype_tgt, ctype_ref, radius_px) coords_tgt: coordinates of niche centroids (target cells). coords_ref: coordinates of reference cells. ctype_tgt: cell type of niche centroids. ctype_ref: cell type of reference cells. radius_px: radius of neighborhood. Output: return: delta_cell_tgt, delta_cell_ref, delta_cell. e.g. coords_tgt = coords_final['injured'] coords_ref = coords_final['normal'] ctype_tgt = sdata.obs['Annotation'][right_idx] ctype_ref = sdata.obs['Annotation'][left_idx] radius_px = 1000 df_delta_cell_tgt,df_delta_cell_ref,df_delta_cell = delta_cell(coords_tgt,coords_ref,ctype_tgt,ctype_ref,radius_px) .. py:function:: delta_exp_cal(coords_tgt, coords_ref, exp_tgt, exp_ref, radius_px, valid_tgt_idx=None, valid_ref_idx=None) coords_tgt: coordinates of niche centroids (target cells). coords_ref: coordinates of reference cells. exp_tgt: gene expression of target cells. exp_ref: gene expression of reference cells. radius_px: radius of neighborhood. Output: return: delta_exp_tgt, delta_exp_ref, delta_exp. e.g. .. py:function:: delta_exp_sigplot(p_values, avg_differences, abs_10logp_cutoff=None, abs_avg_diff_cutoff=None, sig=True) .. py:function:: delta_exp_statistics(delta_exp_tgt, delta_exp_ref)