spateo.external.CAST

Submodules

Classes

Functions

CAST_STACK_rough(coords_raw_list[, ifsquare, ...])

coords_raw_list: list of numpy arrays, each array is the coordinates of a layer

corr_dist(query_np, ref_np[, nan_as])

region_detect(embed_dict_t, coords0[, k])

CAST_MARK(coords_raw_t, exp_dict_t, output_path_t[, ...])

CAST_PROJECT(sdata_inte, source_sample, target_sample, ...)

CAST_STACK(coords_raw, embed_dict, output_path, graph_list)

link_plot(all_cosine_knn_inds_t, coords_q, coords_r, k)

coords2adjacentmat(coords[, output_mode, strategy_t])

hv_cutoff(max_col[, threshold])

detect_highly_variable_genes(sdata[, batch_key, ...])

extract_coords_exp(sdata[, batch_key, cols, ...])

Harmony_integration(sdata_inte, scaled_layer, ...[, ...])

random_sample(coords_t, nodenum[, seed_t])

sub_node_sum(coords_t, exp_t[, nodenum, vis, seed_t])

nearest_neighbors_idx(coord1, coord2[, mode_t])

non_zero_center_scale(sdata_t_X)

sub_data_extract(sample_list, coords_raw, exps[, ...])

preprocess_fast(sdata1[, mode, target_sum, base, ...])

cell_select(coords_t[, s, c, output_path_t])

Select cells by drawing a polygon on the plot.

get_neighborhood_rad(coords_centroids, ...[, dist])

delta_cell_cal(coords_tgt, coords_ref, ctype_tgt, ...)

coords_tgt: coordinates of niche centroids (target cells).

delta_exp_cal(coords_tgt, coords_ref, exp_tgt, ...[, ...])

coords_tgt: coordinates of niche centroids (target cells).

delta_exp_sigplot(p_values, avg_differences[, ...])

delta_exp_statistics(delta_exp_tgt, delta_exp_ref)

dsplot(coords0, coords_plaque_t[, s_cell, s_plaque, ...])

kmeans_plot_multiple(embed_dict_t, graph_list, coords, ...)

plot_mid(coords_q, coords_r[, output_path, filename, ...])

plot_mid_v2(coords_q[, coords_r, output_path, ...])

Package Contents

spateo.external.CAST.CAST_STACK_rough(coords_raw_list, ifsquare=True, if_max_xy=True, percentile=None)[source]

coords_raw_list: list of numpy arrays, each array is the coordinates of a layer ifsquare: if True, the coordinates will be scaled to a square if_max_xy: if True, the coordinates will be scaled to the max value of the max_range_x and max_range_y, respectively (if ifsquare is False), or the max value of [max_range_x,max_range_y] (if ifsquare is True) percentile: if not None, the min and max will be calculated based on the percentile of the coordinates for each slice.

spateo.external.CAST.corr_dist(query_np, ref_np, nan_as='min')[source]
class spateo.external.CAST.reg_params[source]
dataname: str
theta_r1: float = 0
theta_r2: float = 0
d_list: list[float]
translation_params: list[float] = None
mirror_t: list[float] = None
alpha_basis: list[float]
iterations: int = 500
dist_penalty1: float = 0
attention_params: list[float]
mesh_trans_list: list[float]
attention_region: list[float]
attention_params_bs: list[float]
mesh_weight: list[float]
iterations_bs: list[float]
alpha_basis_bs: list[float]
meshsize: list[float]
img_size_bs: list[float]
dist_penalty2: list[float]
PaddingRate_bs: float = 0
bleeding: float = 500
diff_step: float = 5
min_qr2: float = 0
mean_q: float = 0
mean_r: float = 0
gpu: int = 0
device: str
ifrigid: bool = False
__post_init__()[source]
spateo.external.CAST.region_detect(embed_dict_t, coords0, k=20)[source]
spateo.external.CAST.CAST_MARK(coords_raw_t, exp_dict_t, output_path_t, task_name_t=None, gpu_t=None, args=None, epoch_t=None, if_plot=True, graph_strategy='convex', device='cuda:0')[source]
spateo.external.CAST.CAST_PROJECT(sdata_inte, source_sample, target_sample, coords_source, coords_target, scaled_layer='log2_norm1e4_scaled', raw_layer='raw', batch_key='protocol', use_highly_variable_t=True, ifplot=True, n_components=50, umap_n_neighbors=50, umap_n_pcs=30, min_dist=0.01, spread_t=5, k2=1, source_sample_ctype_col='level_2', output_path='', umap_feature='X_umap', pc_feature='X_pca_harmony', integration_strategy='Harmony', ave_dist_fold=3, save_result=True, ifcombat=True, alignment_shift_adjustment=50, color_dict=None, adjust_shift=False, metric_t='cosine', working_memory_t=1000)[source]
spateo.external.CAST.CAST_STACK(coords_raw, embed_dict, output_path, graph_list, params_dist=None, tmp1_f1_idx=None, mid_visual=False, sub_node_idxs=None, rescale=False, corr_q_r=None, if_embed_sub=False, early_stop_thres=None, renew_mesh_trans=True)[source]
spateo.external.CAST.coords2adjacentmat(coords, output_mode='adjacent', strategy_t='convex')[source]
spateo.external.CAST.hv_cutoff(max_col, threshold=2000)[source]
spateo.external.CAST.detect_highly_variable_genes(sdata, batch_key='batch', n_top_genes=4000, count_layer='count')[source]
spateo.external.CAST.extract_coords_exp(sdata, batch_key='batch', cols='spatial', count_layer='count', data_format='norm1e4', ifcombat=False, if_inte=False)[source]
spateo.external.CAST.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)[source]
spateo.external.CAST.random_sample(coords_t, nodenum, seed_t=2)[source]
spateo.external.CAST.sub_node_sum(coords_t, exp_t, nodenum=1000, vis=True, seed_t=2)[source]
spateo.external.CAST.nearest_neighbors_idx(coord1, coord2, mode_t='knn')[source]
spateo.external.CAST.non_zero_center_scale(sdata_t_X)[source]
spateo.external.CAST.sub_data_extract(sample_list, coords_raw, exps, nodenum_t=20000, if_non_zero_center_scale=True)[source]
spateo.external.CAST.preprocess_fast(sdata1, mode='customized', target_sum=10000.0, base=2, zero_center=True, regressout=False)[source]
spateo.external.CAST.cell_select(coords_t, s=0.5, c=None, output_path_t=None)[source]

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.

spateo.external.CAST.get_neighborhood_rad(coords_centroids, coords_candidate, radius_px, dist=None)[source]
spateo.external.CAST.delta_cell_cal(coords_tgt, coords_ref, ctype_tgt, ctype_ref, radius_px)[source]

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)

spateo.external.CAST.delta_exp_cal(coords_tgt, coords_ref, exp_tgt, exp_ref, radius_px, valid_tgt_idx=None, valid_ref_idx=None)[source]

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.

spateo.external.CAST.delta_exp_sigplot(p_values, avg_differences, abs_10logp_cutoff=None, abs_avg_diff_cutoff=None, sig=True)[source]
spateo.external.CAST.delta_exp_statistics(delta_exp_tgt, delta_exp_ref)[source]
spateo.external.CAST.dsplot(coords0, coords_plaque_t, s_cell=10, s_plaque=40, col_cell='#999999', col_plaque='red', cmap_t='vlag', alpha=1, vmax_t=None, title=None, scale_bar_200=None, output_path_t=None, coords0_mask=None)[source]
spateo.external.CAST.kmeans_plot_multiple(embed_dict_t, graph_list, coords, taskname_t, output_path_t, k=20, dot_size=10, scale_bar_t=None, minibatch=True, plot_strategy='sep', axis_off=False)[source]
spateo.external.CAST.plot_mid(coords_q, coords_r, output_path='', filename=None, title_t=['ref', 'query'], s_t=8, scale_bar_t=None, axis_off=False)[source]
spateo.external.CAST.plot_mid_v2(coords_q, coords_r=None, output_path='', filename=None, title_t=['ref', 'query'], s_t=8, scale_bar_t=None)[source]