DirichletProcess Model Clustering on TCR Distances - #56
Merged
Conversation
This was referenced Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi folks,
This addresses #55 - specifically, offering a clearer way to parameterize the tcr distance/dianaHeight cutoff one may use for clustering.
There is one high level entrypoint
DirichletClusterAnalysis()which runs a nonparameteric bayesian clustering method on the distribution of TCR distances:One first needs to run the typical processing steps, including choosing a
dianaHeightthreshold.Then, you can run this function to estimate clusters and their means/variances/proportion within the cluster
Optionally, you can also choose to sample along deciles to ensure you sample rare modes. In the above data, a very clear mode is present in the small X values, but that is less likely with unsorted data. You can use the parameters:
nBins(10 for deciles, 100 for percentiles) and the number of points per binsamplesPerBin. IfnBins*samplesPerBin>maxSamples, then it's downsampled randomly to equalmaxSamplesfrom new, more uniform sampled distribution.The returned tcrDirichletResult object is a list which enables two helper functions
PlotClusterMeans()andPlotMixingProportions()to display clusters, their TCR distances, their proportional abundance, and a metadata variable to compare.e.g.:
This allows me to reparameterize the dianaHeight to a cutoff of ~40 rather than 20, such that I capture the clones that were captured by the tetramers.
I think it's worthwhile to support poisson models as well, but willing to punt for now.