BAITS.VDJ.tl.calculate_clone_niche

BAITS.VDJ.tl.calculate_clone_niche#

BAITS.VDJ.tl.calculate_clone_niche(df, sample, target_clone, radius=50, scale=2, coord_cols=('X', 'Y'), clone_col='aaClone', celltype_col='celltype')#

Calculate spatial niche composition around a target BCR clone.

Parameters:
  • df (pandas.DataFrame) – Input dataframe containing spatial coordinates and cell type info

  • sample (str) – Sample name

  • target_clone (str) – Clone name (aaClone)

  • radius (float) – Base radius in micrometers

  • scale (float) – Spatial scaling factor

  • coord_cols (tuple) – Coordinate column names

  • clone_col (str) – Clone column name

  • celltype_col (str) – Cell type column name

Returns:

  • data (dataframe) – Data with near_target_clone column

  • niche_prop (series) – Niche composition (proportion)

  • niche_count (series) – Niche composition (counts)