Phenotyping API¶
Module for T cell phenotype classification.
phenotype ¶
T cell phenotyping for TCRsift.
Classifies cells as CD4+ or CD8+ based on gene expression markers.
TCELL_TYPE_CATEGORIES
module-attribute
¶
TCELL_TYPE_CATEGORIES = ['Confident CD8+', 'Confident CD4+', 'Likely CD8+', 'Likely CD4+', 'Unknown']
phenotype_cells ¶
phenotype_cells(adata: AnnData, cd4_cd8_ratio: float = 3.0, min_cd3_reads: int = 10, verbose: bool = True, show_progress: bool = True) -> ad.AnnData
Add T cell phenotype classification to AnnData object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adata
|
AnnData
|
AnnData with T cell marker expression in obs (CD3, CD4, CD8) |
required |
cd4_cd8_ratio
|
float
|
Ratio threshold for confident CD4/CD8 classification |
3.0
|
min_cd3_reads
|
int
|
Minimum CD3 reads to consider a valid T cell |
10
|
verbose
|
bool
|
Print detailed progress information |
True
|
show_progress
|
bool
|
Show progress bar |
True
|
Returns:
| Type | Description |
|---|---|
AnnData
|
AnnData with Tcell_type column added to obs |
Source code in tcrsift/phenotype.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
classify_tcell_type ¶
Classify a single cell as CD4+ or CD8+ based on expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cd4_expr
|
float
|
CD4 gene expression (raw counts) |
required |
cd8_expr
|
float
|
CD8A + CD8B combined expression (raw counts) |
required |
cd4_cd8_ratio
|
float
|
Ratio threshold for confident classification |
3.0
|
Returns:
| Type | Description |
|---|---|
str
|
T cell type classification |
Source code in tcrsift/phenotype.py
filter_by_tcell_type ¶
Filter AnnData to only include cells of specified T cell type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adata
|
AnnData
|
AnnData with Tcell_type column |
required |
tcell_type
|
str
|
Type to keep: "cd8", "cd4", or "both" |
'cd8'
|
verbose
|
bool
|
Print progress information |
True
|
Returns:
| Type | Description |
|---|---|
AnnData
|
Filtered AnnData |
Source code in tcrsift/phenotype.py
get_phenotype_summary ¶
Get summary of T cell phenotypes by sample.
Returns:
| Type | Description |
|---|---|
DataFrame
|
Summary with counts and percentages per sample |
Source code in tcrsift/phenotype.py
validate_phenotype_vs_expected ¶
Compare observed phenotypes to expected based on sample metadata.
Returns list of warning messages for mismatches.