Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output of clonalQuant() and clonalOccupy() differ? #477

Closed
sejjer7 opened this issue Feb 11, 2025 · 4 comments
Closed

Output of clonalQuant() and clonalOccupy() differ? #477

sejjer7 opened this issue Feb 11, 2025 · 4 comments
Labels
more info needed Waiting on more information

Comments

@sejjer7
Copy link

sejjer7 commented Feb 11, 2025

Hi Nick

The number of unique clones I get when I run clonalQuant() and group.by 'ident' (cell cluster) with cloneCall = strict on the TCR data I have integrated into my Seurat object is different to the number of single clones I get when I use clonalOccupy() with ident on x.axis. I am actually still using v1.8 so it's quantContig() and occupiedscRepertoire() but the same principle applies. Shouldn't these be the same?

This is the last bit of analysis for my doctoral thesis that I'm intending to submit imminently so I think/hope this is more my misunderstanding than an issue in my data (!), but would be grateful for your advice/help

Thanks and best wishes

@ncborcherding
Copy link
Member

Hey @sejjer7

First off congrats on being so close!!!

Could you do me a favor and show me the specific code calls and examples of the plots you're getting? I think I know the issue, but just want to make sure.

Thanks,

Nick

@ncborcherding ncborcherding added the more info needed Waiting on more information label Feb 11, 2025
@sejjer7
Copy link
Author

sejjer7 commented Feb 11, 2025

Thanks - it's been quite the journey as a part-time 'mature' student over the last almost 5 years. I hadn't even heard of R when I started! I'll be back to the regular job in a couple of months (similar to you I'm the equivalent of a Clinical Pathologist here in the UK) and though right now I just want to finish my thesis I will really miss this.

So the code I have run is:

percent_unique2 <- quantContig(CD42, cloneCall = "strict", scale = F, split.by = "integrated_snn_res.0.1")

Which gives me

Image

contigs values total scaled
1 9154 CM-CD4 10099 90.64264
2 3775 GZMA+ CD4 Tr1 4969 75.97102
3 3292 KLRB1+ CD4 T helper 3950 83.34177
4 3064 TpH 7339 41.74956
5 6136 Treg 9990 61.42142

and then

occupiedscRepertoire(CD42, x.axis = "integrated_snn_res.0.1")

though I did also have some code I wrote myself before I realising there was a function in the package which did the same thing

cluster_info2 <- [email protected][c("cloneType", "integrated_snn_res.0.1")]

clonotype_counts2 <- cluster_info2 %>%
group_by(cloneType, integrated_snn_res.0.1) %>%
summarise(Count = n(), .groups = 'drop')

summary_counts2 <- clonotype_counts2 %>%
group_by(integrated_snn_res.0.1, cloneType) %>%
summarise(total_count = sum(Count)) %>%
ungroup()

bar <- ggplot(summary_counts2, aes(x = integrated_snn_res.0.1, y = total_count, fill = cloneType)) +
geom_bar(stat = "identity", position = "stack") +
geom_text(aes(label = total_count), position = position_stack(vjust = 0.5), color = "black") +
labs(title = "Clonotype Categories by Cluster", x = "Cluster", y = "Total Number of Clonotypes") +
scale_fill_manual(values = category_colors) +
theme_minimal() +
theme(axis.text.x = element_text(hjust = 1))

print(bar)

Both give me this:

Image

So taking the Tregs as an example there's either 4589 single clones or 6136 unique clones.

I'd be very glad if it was simple misunderstanding on my part!

Cheers

sejjer7 (though we have interacted on Twitter/X where I have a different handle, not that I use X these days...)

@ncborcherding
Copy link
Member

@sejjer7

Very cool! I think an even bigger congrats to you for the nontraditional route! Also thanks for following up with the great run down.

The major issue I think here stems from the fact unique clones != single clones.

For your Tregs, you have 9990 total cells, with 4589 single clones (or cells with only 1 clone). You have an additional 1547 clones in the remaining 5131 cells.

Nick

@sejjer7
Copy link
Author

sejjer7 commented Feb 11, 2025

Oh my goodness, yes of course - I was muddling up unique clonotypes and the cells themselves in my thinking (how embarrassing)

I've looked again at the TCR data in my Seurat object and, for example, in my hyperexpanded cells I have 2 clonotypes expressed by those 415 cells (271 cells with one, 144 with the other clonotype), for my cells in the large category it's 21 clonotypes expressed amongst those 641 cells and so on and so on.

Now just to make sure I explain it clearly in my thesis! Thanks again for taking the time to help me, I really appreciate it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more info needed Waiting on more information
Projects
None yet
Development

No branches or pull requests

2 participants