cytonormpy.CytoNorm.calculate_cluster_cvs

cytonormpy.CytoNorm.calculate_cluster_cvs#

CytoNorm.calculate_cluster_cvs(n_metaclusters, n_cells=None, markers=None)#

Compute per-cluster coefficient of variation (CV) across samples for multiple meta-cluster counts.

This method obtains reference data (optionally subsampled), runs clustering for each specified number of meta-clusters, and then, for each clustering, calculates the fraction of cells from each sample assigned to each cluster. It computes the CV (standard deviation divided by mean) of these fractions across samples for each cluster. The results are stored in the cvs_by_k attribute for downstream threshold checks or plotting.

Parameters:
  • n_metaclusters (list of int) – List of meta-cluster counts to evaluate (e.g., [5, 15, 25]).

  • n_cells (int, optional) – Number of reference cells to subsample before clustering. If None, all reference cells are used.

  • markers (list of str, optional) – List of channel names to include in clustering. If None, all available channels are used.

Returns:

The computed CVs are saved to self.cvs_by_k, a dict mapping each meta-cluster count k to a list of length k containing the CV for each cluster.

Return type:

None

cvs_by_k#

After calling this method, holds the CV values for each tested k: {k: [cv_cluster_1, cv_cluster_2, …, cv_cluster_k]}.

Type:

dict[int, list[float]]