Preprocessing¶
A module to preprocess data for TRIBAL.
preprocess(df, roots, isotypes, min_size=4, use_light_chain=True, cores=1, verbose=False)
¶
Preprocess the input data to prepare data for TRIBAL.
The clonotypes will first be filtered to ensure each clonotype has at least min_size
cells.
Each retained clonotype is aligned to the root sequence and then maximum parsimony forest is
enumerated for the B cells with that clonotype.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
A dataframe with columns including 'clonotype', 'heavy_chain_seq', 'light_chain_seq', 'heavy_chain_v_allele', 'light_chain_v_allele', and 'heavy_chain_isotype'. The 'Light Chain' columns are optional. |
required |
roots |
DataFrame
|
A dataframe containing the root sequences. |
required |
isotypes |
list
|
A list of the ordered isotype labels, i.e., ['IghM', ...,'IghA']. These labels should match the isotype labels in the input dataframe. See notes below. |
required |
min_size |
int
|
The minimum number of B cells needed to form a clonotype (default is 4). |
4
|
use_light_chain |
bool
|
Should the light chain be included in the BCR sequences (default is True). |
True
|
cores |
int
|
The number of CPU cores to use (default is 1). |
1
|
verbose |
bool
|
Should verbose output be printed (default is False). |
False
|
Returns:
Type | Description |
---|---|
dict
|
A dictionary of clonotype objects formatted for input to tribal with clonotype id as key |
DataFrame
|
A dataframe that is filtered to contain only unfiltered B cells |
Notes
Ensure that the isotype labels in isotypes
match the labels in the input dataframe.
Source code in tribal/preprocess.py
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 213 214 215 |
|