17  Phasor Analysis

This method focuses on visualizing the distribution of the 1st harmonic or 2nd harmonic phasor coordinates, extracted by the Lifetime fit free extractor, and performs optional clustering to highlight subpopulations or structural patterns.

17.1 Shared Interface Components

  • On the top right, users can use the filters to subset the data to find the groups of interest.
  • Below the filters, users can apply the visual channels widgets that allow users to Color by, Opacity by, and Shape by categorical features.
  • On the bottom right, users can change the plot style using the plot styling widgets.

17.2 Select Phasor Coordinate

Instead of using the bivariate selection widgets that select two generic numerical features, this method renders a dropdown menu to select the channel and another to select the harmonic.

17.3 K-means Clustering

Phasor coordinates of single-cell ROIs from the selected channel and harmonic are plotted in the phasor space. K-means clustering can be performed for each color group (created by Color by). If Perform K-means Clustering is checked, users can specify the number of clusters to be created based on their prior knowledge. In the future, automatic tuning for this parameter, akin to selecting the number of components of GMM, using silhouette analysis will be added.

K-means clustering is performed given the number of clusters specified for each color group. Mathematically, it is an iterative algorithm that finds the best cluster assignment with regard to what cluster each point belongs to and what centroid the cluster has. The best is defined as the one that minimizes the sum of the squared distances between each point and the center of the cluster it belongs to.

\[ \min_{\{C_k\}_{k=1}^K}\;\sum_{k=1}^K\sum_{x_i\in C_k}\bigl\lVert x_i-\mu(C_k)\bigr\rVert_2^2, \qquad \mu(C_k)=\frac{1}{|C_k|}\sum_{x_i\in C_k} x_i. \]

First, FLIM Playground standardizes the phasor coordinates because \(g\) (real part) and \(s\) (imaginary) are not necessarily on the same scale.

Then, it performs k-means clustering using the sklearn.cluster.KMeans function. All the other hyperparameters control the optimization process (e.g. init controls the initialization of the centroids), and they are set to their default values. 42 is used as the random seed to ensure reproducibility.

To visualize the result of clustering, FLIM Playground draws a polygon (convex hull) that contains all the points of each cluster, the color of which is determined by the color group the cluster belongs to. It uses the scipy.spatial.ConvexHull function to calculate the convex hull. The center of each cluster is marked as a black bordered cross and users can hover over it to see its coordinates.

17.3.1 Export Clustered Dataset

Users can download the clustered dataset by clicking:

The downloaded dataset keeps all the features plus the new categorical feature column (k_means_cluster), which is recognized by any method in Data Analysis as a categorical feature like others. The rows that pass the filters are included.