Real Data Loader
Bases: LightningDataModule
A class to load in data from the CSV data for various binding and perturbation experiments.
After loading in the data, the data loader will parse the data into the form expected by our models. It will also split the data into training, testing, and validation sets for the model to use.
NOTE: Right now the only binding dataset this works with is the brent_nf_cc dataset because it has the same set of genes in each CSV file. This is the case for all of the perturbation datasets, but not for the other 2 binding datasets. In the future we would like to write a dataModule that handles the other 2 binding datasets. For now, you can only pass in a parameter for the title of the perturb response dataset that you want to use, and brent_nf_cc is hardcoded as the binding dataset.
Source code in yeastdnnexplorer/data_loaders/real_data_loader.py
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
|
__init__(batch_size=32, val_size=0.1, test_size=0.1, random_state=42, data_dir_path=None, perturbation_dataset_title='hu_reimann_tfko')
¶
Constructor of RealDataLoader.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch_size |
int
|
The number of samples in each mini-batch |
32
|
val_size |
float
|
The proportion of the dataset to include in the validation split |
0.1
|
test_size |
float
|
The proportion of the dataset to include in the test split |
0.1
|
random_state |
int
|
The random seed to use for splitting the data (keep this consistent to ensure reproduceability) |
42
|
data_dir_path |
str | None
|
The path to the directory containing the CSV files for the binding and perturbation data |
None
|
perturbation_dataset_title |
str
|
The title of the perturbation dataset to use (one of ‘hu_reimann_tfko’, ‘kemmeren_tfko’, or ‘mcisaac_oe’) |
'hu_reimann_tfko'
|
Raises:
Type | Description |
---|---|
TypeError
|
If batch_size is not an positive integer |
TypeError
|
If val_size is not a float between 0 and 1 (inclusive) |
TypeError
|
If test_size is not a float between 0 and 1 (inclusive) |
TypeError
|
If random_state is not an integer |
ValueError
|
If val_size + test_size is greater than 1 (i.e. the splits are too large) |
ValueError
|
if no data_dir is provided |
AssertinoError
|
if the dataset sizes do not match up after reading in the data from the CSV files |
Source code in yeastdnnexplorer/data_loaders/real_data_loader.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
prepare_data()
¶
This function reads in the binding data and perturbation data from the CSV files that we have for these datasets.
It throws out any genes that are not present in both the binding and perturbation sets, and then structures the data in a way that the model expects and can use
Source code in yeastdnnexplorer/data_loaders/real_data_loader.py
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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
setup(stage=None)
¶
This function runs after prepare_data finishes and is used to split the data into train, validation, and test sets It ensures that these datasets are of the correct dimensionality and size to be used by the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stage |
str | None
|
The stage of the data setup (either ‘fit’ for training, ‘validate’ for validation, or ‘test’ for testing), unused for now as the model is not complicated enough to necessitate this |
None
|
Source code in yeastdnnexplorer/data_loaders/real_data_loader.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
test_dataloader()
¶
Function to return the testing dataloader.
Returns:
Type | Description |
---|---|
DataLoader
|
The testing dataloader |
Source code in yeastdnnexplorer/data_loaders/real_data_loader.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
|
train_dataloader()
¶
Function to return the training dataloader, we shuffle to avoid learning based on the order of the data.
Returns:
Type | Description |
---|---|
DataLoader
|
The training dataloader |
Source code in yeastdnnexplorer/data_loaders/real_data_loader.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
|
val_dataloader()
¶
Function to return the validation dataloader.
Returns:
Type | Description |
---|---|
DataLoader
|
The validation dataloader |
Source code in yeastdnnexplorer/data_loaders/real_data_loader.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|