forked from BimberLab/DiscvrLabKeyModules
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPerformTcrClustering.R
More file actions
39 lines (33 loc) · 1.14 KB
/
PerformTcrClustering.R
File metadata and controls
39 lines (33 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
for (datasetId in names(seuratObjects)) {
printName(datasetId)
seuratObj <- readSeuratRDS(seuratObjects[[datasetId]])
print(paste0('Calculating distances for: ', datasetId))
seuratObj <- tcrClustR::CalculateTcrDistances(
inputData = seuratObj,
chains = chains,
organism = organism,
minimumCloneSize = 2,
calculateChainPairs = TRUE
)
print('Performing TCR Clustering')
seuratObj <- tcrClustR::RunTcrClustering(
seuratObj_TCR = seuratObj,
dianaHeight = 20,
clusterSizeThreshold = 1
)
print(paste0('Summary of distances: '))
if (!'TCR_Distances' %in% names(seuratObj@misc)) {
warning('No TCR_Distances were found, this could indicate a problem with processing')
} else {
for (an in names(seuratObj@misc$TCR_Distances)) {
ad <- seuratObj@misc$TCR_Distances[[an]]
fn <- length(unique(seuratObj[[paste0(an, '_ClusterIdx')]]))
print(paste0('Assay: ', an, ', total clones: ', nrow(ad), '. Distinct families: ', fn))
}
}
VisualizeTcrDistances(seuratObj)
saveData(seuratObj, datasetId)
# Cleanup
rm(seuratObj)
gc()
}