Combine scTCR/BCR repertoire data with scRNA-seq expression data using `scRepertoire::combineExpression()`. This process integrates immune receptor information (CDR3 sequences, V(D)J genes, clonotypes) into a Seurat object's metadata, enabling clonotype-aware gene expression analysis.
Combine scTCR/BCR repertoire data with scRNA-seq expression data using scRepertoire::combineExpression(). This process integrates immune receptor information (CDR3 sequences, V(D)J genes, clonotypes) into a Seurat object's metadata, enabling clonotype-aware gene expression analysis.
[ScRepCombiningExpression]
cache = true
[ScRepCombiningExpression.in]
# Required inputs
screpfile = ["ScRepLoading"] # scRepertoire object from ScRepLoading
srtobj = ["SeuratClustering"] # Seurat object with RNA data
Note: Barcodes in srtobj must match barcodes in screpfile. Ensure both datasets were generated from the same cell calling run.
[ScRepCombiningExpression.envs]
# Clonotype definition
cloneCall = "aa" # How to define a clonotype (default: aa)
# Chain selection
chain = "both" # Which TCR/BCR chains to use (default: both)
# Frequency calculation
group_by = "Sample" # Group for frequency/proportion calculation (default: Sample)
proportion = true # Use proportion (true) or total frequency (false) (default: true)
# Filtering options
filterNA = false # Remove cells without TCR/BCR data (default: false)
# Clone size bins
cloneSize = {Rare = 0.0001, Small = 0.001, Medium = 0.01, Large = 0.1, Hyperexpanded = 1}
# Label customization
addLabel = false # Add label to frequency header (default: false)
cloneCall: Defines clonotype grouping strategy
gene: Group by V(D)JC gene usage (e.g., TRBV12-301, TRBJ2-701)nt: Group by CDR3 nucleotide sequenceaa: Group by CDR3 amino acid sequence (default)strict: Group by V(D)JC gene + CDR3 nucleotide (most specific)chain: Which receptor chains to include
both: Include both chains (e.g., TRA + TRB for TCR, IGH + IGL/IGK for BCR)TRA: T cell receptor alpha chain onlyTRB: T cell receptor beta chain onlyTRG: T cell receptor gamma chain onlyTRD: T cell receptor delta chain onlyIGH: B cell immunoglobulin heavy chain onlyIGL: B cell immunoglobulin light chain (lambda/kappa) onlygroup_by: Column for frequency calculation
"Sample": Calculate clonotype frequency per sample (default)"seurat_clusters": Calculate per RNA clusterNULL or "none": Keep input format without groupingproportion:
true: Calculate as proportion (0-1 scale) within groupfalse: Calculate as absolute frequency (counts)filterNA:
true: Remove cells without V(D)J data from Seurat objectfalse: Keep all cells, add VDJ_Presence = FALSE for non-productive cellscloneSize: Bins for categorizing clone sizes
proportion = false, upper limit may auto-adjust based on dataaddLabel: Useful when running multiple configurations with different group_by or cloneCall settings.
[ScRepCombiningExpression]
[ScRepCombiningExpression.in]
screpfile = ["ScRepLoading"]
srtobj = ["SeuratClustering"]
Use when: Default CDR3aa clonotype definition is sufficient.
[ScRepCombiningExpression]
[ScRepCombiningExpression.in]
screpfile = ["ScRepLoading"]
srtobj = ["SeuratClustering"]
[ScRepCombiningExpression.envs]
# Use CDR3 amino acid for clonotype definition
cloneCall = "aa"
# Include both TRA and TRB chains
chain = "both"
# Calculate frequency per sample
group_by = "Sample"
# Use proportional frequency
proportion = true
Use when: Analyzing TCR data with standard parameters.
[ScRepCombiningExpression]
[ScRepCombiningExpression.in]
screpfile = ["ScRepLoading"]
srtobj = ["SeuratClustering"]
[ScRepCombiningExpression.envs]
# BCR data - analyze both heavy and light chains
chain = "both"
# Use V gene + CDR3aa for specific clonotype definition
cloneCall = "aa"
# Calculate frequency per sample
group_by = "Sample"
Use when: Analyzing paired IGH + IGL/IGK BCR data.
[ScRepCombiningExpression]
[ScRepCombiningExpression.in]
screpfile = ["ScRepLoading"]
srtobj = ["SeuratClustering"]
[ScRepCombiningExpression.envs]
# Calculate clonotype frequency within each RNA cluster
group_by = "seurat_clusters"
# Use absolute counts instead of proportions
proportion = false
Use when: Need to track which RNA clusters contain expanded clones.
[ScRepCombiningExpression]
[ScRepCombiningExpression.in]
screpfile = ["ScRepLoading"]
srtobj = ["SeuratClustering"]
[ScRepCombiningExpression.envs]
# Remove cells without productive V(D)J rearrangements
filterNA = true
Use when: Analysis should only include cells with receptor data.
[ScRepCombiningExpression]
[ScRepCombiningExpression.in]
screpfile = ["ScRepLoading"]
srtobj = ["SeuratClustering"]
[ScRepCombiningExpression.envs]
# Group by V(D)JC gene usage only
cloneCall = "gene"
Use when: Interested in V gene bias rather than CDR3 specificity.
[ScRepCombiningExpression]
[ScRepCombiningExpression.in]
screpfile = ["ScRepLoading"]
srtobj = ["SeuratClustering"]
Best for: Initial exploratory analysis with default CDR3aa clonotypes.
[ScRepCombiningExpression.envs]
# Analyze only TRB chain
chain = "TRB"
Best for: TRB-focused analyses when TRA data is noisy or unavailable.
[ScRepCombiningExpression.envs]
chain = "both"
cloneCall = "aa"
# Custom bins for BCR clonal expansion
cloneSize = {Single = 1, Small = 3, Medium = 10, Large = 50, Hyperexpanded = 500}
Best for: BCR analysis where expansion patterns differ from TCR.
[ScRepCombiningExpression.envs]
# Calculate frequency per experimental condition
group_by = "Diagnosis"
# Use absolute counts
proportion = false
Best for: Comparing clonal expansion across treatment groups.
[ScRepCombiningExpression.envs]
# Most specific: V(D)JC gene + CDR3 nucleotide
cloneCall = "strict"
Best for: High-resolution clonotype analysis where gene + CDR3 matter.
After running ScRepCombiningExpression, the Seurat object's metadata will include:
CTgene: V(D)JC gene names (e.g., "TRBV12-301_TRBJ2-701" for paired chains)CTnt: CDR3 nucleotide sequencesCTaa: CDR3 amino acid sequences (separated by _ for paired chains)CTcount: Count of cells in each clonotypeCTfrequency: Frequency of clonotype within group (if group_by set)CTproportion: Proportion of clonotype within group (if group_by set)cloneSize: Category from cloneSize bins (Rare, Small, Medium, Large, Hyperexpanded)VDJ_Presence: Boolean indicating if cell has TCR/BCR sequence
TRUE: Productive V(D)J rearrangement detectedFALSE: No productive V(D)J dataTRA_1, TRA_2: Individual CDR3aa sequences for TRA chainsTRB_1, TRB_2: Individual CDR3aa sequences for TRB chainsIGH_1, IGH_2: Individual CDR3aa sequences for IGH chainsIGL_1, IGL_2: Individual CDR3aa sequences for IGL/IGK chainsScRepLoading (TCR/BCR data)
↓
SeuratClustering (RNA clusters)
↓
ScRepCombiningExpression (integrate)
↓
CDR3Clustering / TESSA / ClonalStats
screpfile must exactly match barcodes in srtobjcloneCall = "strict" requires both V(D)J genes AND CDR3 nt to matchcloneCall = "gene" only uses gene usage (may over-group clones)cloneCall = "aa" is recommended for most analyses (balance specificity and grouping)chain = "both" requires paired data (TRA+TRB for TCR, IGH+IGL/IGK for BCR)chain = "TRB" or chain = "IGH"Possible causes:
Diagnosis:
# Check barcode overlap
length(intersect(Cells(srtobj), rownames(screpfile)))
Solution: Ensure both datasets come from same cell calling run, or manually filter to common barcodes.
VDJ_Presence = FALSEPossible causes:
Solution:
filterNA = true to remove non-productive cellsCTaa columnPossible causes:
chain = "TRB" for alpha-only T cells)Solution:
chain = "both" if paired data availableScRepLoading output for chain distributionPossible causes:
group_by includes cells without V(D)J dataproportion = false (using counts, not proportions)Solution:
filterNA = true should be enabledgroup_by column is appropriateproportion = true for normalized frequenciesPossible causes:
cloneSize thresholds too high for dataproportion = false with absolute countsSolution:
cloneSize bins to match data distributionproportion = true for relative clone sizescloneCall = "aa" for most analyses (default)chain = "both" for paired receptor datagroup_by = "Sample" for frequency calculations (default)filterNA = false to distinguish productive vs non-productive cellssum(rownames(srtobj) %in% rownames(screpfile))table(srtobj$VDJ_Presence)table(srtobj$cloneSize)length(unique(srtobj$CTaa))