Skip to content

Quality control

These functions perform quality control checks on the clean data.

Warning

There is no golden standard for performing quality control checks!

Be careful when choosing which checks to apply, since they can have very different effects in your data. This could potentially result in, for example, inappropriate patient selection or bias.

Please make sure you consult with an UPOD expert.

perform_qc

Perform quality control (QC) on the data of the given DataFrame. For more information, see each of the qc_types.

Parameters:

Name Type Description Default
df pandas DataFrame

DataFrame with the clean data to be checked.

Tip

Cleaning can be done using the function clean_dataframe

required
qc_types list of str

List of quality control types. Possible values for each element are:

QC type Description Additional comments
wbc_scatter or leuko_scatter QC of parameters regarding the scatter measurement of white blood cells Not to be confused with WBC counts or sizes
rbc or erythro QC of (some) red blood cell parameters. Not all RBC parameters get QC!
plausible_range QC of plausible ranges of different parameters Min and max values are defined in the corresponding data dictionary
flags or suspicious_flags QC based on the presence of suspicious values (defined by corresponding flags)
fail or failure Set parameter values to NaN based on corresponding flags)
standard_values Set standard values to a given set of parameters Not recommended!
all All of the previous QC
['wbc_scatter', 'rbc_scatter', 'plausible_range', 'flags']
machine str

What machine does the data correspond to. Possible values are:

  • sapphire or sapph - Sapphire
  • alinity or alin - Alinity hq

Info

No functionality yet, but might be useful in the future.

None
verbose bool

Define if verbose output will be printed (True) or not (False).

True

Returns:

Name Type Description
df_qc pandas DataFrame

DataFrame with quality controlled data.

Source code in pycelldyn/quality_control.py
 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
def perform_qc(df, qc_types=['wbc_scatter', 'rbc_scatter', 'plausible_range', 'flags'], machine=None, verbose=True):
    """ `perform_qc`

    Perform quality control (QC) on the data of the given DataFrame.
    For more information, see each of the `qc_types`.

    Parameters
    ----------
    df : pandas DataFrame
        DataFrame with the clean data to be checked.

        !!! tip
            Cleaning can be done using the function `clean_dataframe`

    qc_types :  list of str
        List of quality control types. Possible values for each element are:

        | QC type                            | Description                                                     | Additional comments                                               |
        |------------------------------------|-----------------------------------------------------------------|-------------------------------------------------------------------|
        | `wbc_scatter` or `leuko_scatter`   | QC of parameters regarding the scatter measurement of white blood cells | Not to be confused with WBC counts or sizes               |
        | `rbc` or `erythro`                 | QC of (some) red blood cell parameters.                         | Not all RBC parameters get QC!                                    |
        | `plausible_range`                  | QC of plausible ranges of different parameters                  | Min and max values are defined in the corresponding data dictionary |
        | `flags` or `suspicious_flags`      | QC based on the presence of suspicious values (defined by corresponding flags) |                                                    |
        | `fail` or `failure`                | Set parameter values to `NaN` based on corresponding flags)     |                                                                   |
        | `standard_values`                  | Set standard values to a given set of parameters                | Not recommended!                                                  |
        | `all`                              | All of the previous QC                                          |                                                                   |

    machine : str
        What machine does the data correspond to. Possible values are:

        * `sapphire` or `sapph` - Sapphire
        * `alinity` or `alin` - Alinity hq

        !!! info
            No functionality yet, but might be useful in the future.

    verbose : bool
        Define if verbose output will be printed (`True`) or not (`False`).

    Returns
    -------
    df_qc : pandas DataFrame
        DataFrame with quality controlled data.
    """
    df_qc = df.copy()

    # Check that qc_types is not empty
    if qc_types == []:
        raise("qc_types is empty.")

    # Check if `all` QCs are needed.
    qc_types_possible = ['wbc_scatter', 'rbc_scatter', 'plausible_range', 'flags', 'fail', 'standard_values']
    if (qc_types == 'all') or ('all' in qc_types):
        qc_types = qc_types_possible


    # Perform each of the QC types.
    for qc in qc_types:

        if qc in qc_types_possible:

            if verbose:
                print(f"Performing QC {qc}...", end="", flush=True)

            match qc:

                case 'wbc_scatter' | 'leuko_scatter':
                    df_qc = qc_wbc_scatter(df_qc)

                case 'rbc' | 'erythro':
                    df_qc = qc_rbc(df_qc)

                case 'plausible_range':
                    df_qc = qc_plausible_range(df_qc)

                case 'flags' | 'suspicious_flags':
                    pass

                case 'fail' | 'failure':
                    pass

                case 'standard_values':
                    df_qc = qc_standard_values(df_qc)

                case '_':
                    print(f"{qc} is not a valid QC. It will be skipped.")

            if verbose:
                print("\tDONE!")

        else:
            print(f"{qc} is not a valid QC. It will be skipped.")

    return df_qc

qc_wbc_scatter

Perform quality control (QC) on the white blood cells (WBCs) scatter measurement parameters.

Namely, it looks at the coefficient of variance (CV) of the following parameters:

  • neutrophil_size_mean
  • neutrophil_intracellular_complexity
  • neutrophil_lobularity_polarized
  • neutrophil_lobularity_depolarized
  • neutrophil_dna_staining
  • lymphocyte_size_mean
  • lymphocyte_intracellular_complexity

and if it is below threshold (which defaults to 1e-14), it sets both values (that of the parameter and its corresponding CV) to numpy's NaN.

Info

This function was adapted from the original implementation in quality.py by Bram van Es.

Parameters:

Name Type Description Default
df pandas DataFrame

DataFrame with the clean data to be checked.

Tip

Cleaning can be done using the function clean_dataframe

required
threshold float

When the CV of any parameter is below the threshold, both the parameter and its CV will be replaced by a NaN.

1e-14
machine str

What machine does the data correspond to. Possible values are:

  • sapphire or sapph - Sapphire
  • alinity or alin - Alinity hq

Info

No functionality yet, but might be useful in the future.

None
verbose bool

Define if verbose output will be printed (True) or not (False).

True

Returns:

Name Type Description
df_qc pandas DataFrame

DataFrame with quality controlled data.

Source code in pycelldyn/quality_control.py
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
def qc_wbc_scatter(df, threshold=1e-14, machine=None, verbose=True):
    """ `qc_wbc_scatter`

    Perform quality control (QC) on the white blood cells (WBCs) scatter
    measurement parameters.

    Namely, it looks at the coefficient of variance (CV) of the following
    parameters:

    * `neutrophil_size_mean`
    * `neutrophil_intracellular_complexity`
    * `neutrophil_lobularity_polarized`
    * `neutrophil_lobularity_depolarized`
    * `neutrophil_dna_staining`
    * `lymphocyte_size_mean`
    * `lymphocyte_intracellular_complexity`

    and if it is below `threshold` (which defaults to `1e-14`), it sets 
    both values (that of the parameter and its corresponding CV) to numpy's 
    `NaN`.

    !!! info
        This function was adapted from the original implementation in
        `quality.py` by Bram van Es.

    Parameters
    ----------
    df : pandas DataFrame
        DataFrame with the clean data to be checked.

        !!! tip
            Cleaning can be done using the function clean_dataframe

    threshold : float
        When the CV of any parameter is below the threshold, both the
        parameter and its CV will be replaced by a `NaN`.

    machine : str
        What machine does the data correspond to. Possible values are:

        * `sapphire` or `sapph` - Sapphire
        * `alinity` or `alin` - Alinity hq

        !!! info
            No functionality yet, but might be useful in the future.

    verbose : bool
        Define if verbose output will be printed (`True`) or not (`False`).

    Returns
    -------
    df_qc : pandas DataFrame
        DataFrame with quality controlled data.
    """

    df_qc = df.copy()

    # Get the relevant columns.
    # These are the parameter names (not the CV names).
    cols_wbc_scatter = misc.get_cols_wbc_scatter()

    for col in cols_wbc_scatter:

        # Create the CV parameter name by just appending `_cv` at the end.
        col_cv = col + '_cv'

        # Perform QC only when both the parameter and its corresponding CV
        # column are present in the DataFrame.
        if (col in df_qc.columns) and (col_cv in df_qc.columns):
            df_qc.loc[df[col_cv] < threshold, [col_cv, col]] = np.nan

            if verbose:
                print(f"\tQC for WBC scatter parameters performed on {col} and {col_cv}.")

        # Otherwise, do nothing.
        else:
            if verbose:
                print(f"\tColumn {col} and/or {col_cv} not present in DataFrame. No WBC scatter QC performed.")

    return df_qc

qc_rbc

Perform quality control (QC) on (some) red blood cells (RBCs) parameters.

Namely, it looks at the following parameters and if they are below (i.e., <), their corresponding threshold, they will be replaced by numpy's NaN.

TODO: c_mode_rtc (mode_reti) - why change to NaN when 0?

Parameter Threshold Additional comments
reticulocytes 1e-4
reticulocytes_perc 1e-4
irf 1e-4 Immature reticulocyte fraction
rbc_intracellular_complexity 1e-4
rbc_intracellular_complexity_cv 1e-4
rbc_population_position 1e-4
rbc_population_position_cv 1e-4
reticulocyte_population_position 1e-4
reticulocyte_population_position_cv 1e-4
mchcr 1e-4 Mean Corpuscular HGB Concentration per Reticulocyte
mchr_nl 1e-4 Mean corpuscular hemoglobin per reticulocyte, aka reticulocyte hemoglobin content (in NL units)
mcvr 1e-4 Mean corpuscular volume (aka mean cell volume) of reticulocytes
hdw 1e-4 Hemoglobin distribution width per RBC
rbc_hypochromic_perc 1e-30 Hypochromic RBCs (RBCs with hemoglobin < 28 g/dL) percentage
rbc_hyperchromic_perc 1e-30 Hyperchromic RBC (RBCs with hemoglobin > 41 g/dL) percentage

Info

This function was adapted from the original implementation in quality.py by Bram van Es.

Parameters:

Name Type Description Default
df pandas DataFrame

DataFrame with the clean data to be checked.

Tip

Cleaning can be done using the function clean_dataframe

required
machine str

What machine does the data correspond to. Possible values are:

  • sapphire or sapph - Sapphire
  • alinity or alin - Alinity hq

Info

No functionality yet, but might be useful in the future.

None
verbose bool

Define if verbose output will be printed (True) or not (False).

True

Returns:

Name Type Description
df_qc pandas DataFrame

DataFrame with quality controlled data.

Source code in pycelldyn/quality_control.py
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
def qc_rbc(df, machine=None, verbose=True):
    """ `qc_rbc`

    Perform quality control (QC) on (some) red blood cells (RBCs) parameters.

    Namely, it looks at the following parameters and if they are below 
    (i.e., `<`), their corresponding threshold, they will be replaced by 
    numpy's `NaN`.

    TODO: c_mode_rtc (mode_reti) - why change to NaN when 0?

    | Parameter                             | Threshold | Additional comments                                               |
    |---------------------------------------|-----------|-------------------------------------------------------------------|
    | `reticulocytes`                       | `1e-4`    |                                                                   |
    | `reticulocytes_perc`                  | `1e-4`    |                                                                   |
    | `irf`                                 | `1e-4`    | Immature reticulocyte fraction                                    |
    | `rbc_intracellular_complexity`        | `1e-4`    |                                                                   |
    | `rbc_intracellular_complexity_cv`     | `1e-4`    |                                                                   |
    | `rbc_population_position`             | `1e-4`    |                                                                   |
    | `rbc_population_position_cv`          | `1e-4`    |                                                                   |
    | `reticulocyte_population_position`    | `1e-4`    |                                                                   |
    | `reticulocyte_population_position_cv` | `1e-4`    |                                                                   |
    | `mchcr`                               | `1e-4`    | Mean Corpuscular HGB Concentration per Reticulocyte               |
    | `mchr_nl`                             | `1e-4`    | Mean corpuscular hemoglobin per reticulocyte, aka reticulocyte hemoglobin content (in NL units)|
    | `mcvr`                                | `1e-4`    | Mean corpuscular volume (aka mean cell volume) of reticulocytes   |
    | `hdw`                                 | `1e-4`    | Hemoglobin distribution width per RBC                             |
    | `rbc_hypochromic_perc`                | `1e-30`   | Hypochromic RBCs (RBCs with hemoglobin < 28 g/dL) percentage      |
    | `rbc_hyperchromic_perc`               | `1e-30`   | Hyperchromic RBC (RBCs with hemoglobin > 41 g/dL) percentage      |

    !!! info
        This function was adapted from the original implementation in
        `quality.py` by Bram van Es.

    Parameters
    ----------
    df : pandas DataFrame
        DataFrame with the clean data to be checked.

        !!! tip
            Cleaning can be done using the function clean_dataframe

    machine : str
        What machine does the data correspond to. Possible values are:

        * `sapphire` or `sapph` - Sapphire
        * `alinity` or `alin` - Alinity hq

        !!! info
            No functionality yet, but might be useful in the future.

    verbose : bool
        Define if verbose output will be printed (`True`) or not (`False`).

    Returns
    -------
    df_qc : pandas DataFrame
        DataFrame with quality controlled data.
    """

    df_qc = df.copy()

    # Relevant columns.
    cols_rbc = ['reticulocytes',
                'reticulocytes_perc',
                'irf',
                'rbc_intracellular_complexity',
                'rbc_intracellular_complexity_cv',
                'rbc_population_position',
                'rbc_population_position_cv',
                'reticulocyte_population_position',
                'reticulocyte_population_position_cv',
                'mchcr',
                'mchr_nl',
                'mcvr',
                'hdw',
                'rbc_hypochromic_perc',
                'rbc_hyperchromic_perc'
                ]

    for col in cols_rbc:

        # Perform QC only when the correpsonding column is present 
        # in the DataFrame.
        if col in df_qc.columns:

            # Define threshold. 
            if col in ['rbc_hypochromic_perc', 'rbc_hyperchromic_perc']:
                threshold = 1e-30
            else:
                threshold = 1e-4
            df_qc.loc[df[col] < threshold, col] = np.nan

            if verbose:
                print(f"\tQC for RBCs performed on {col}.")

        # Otherwise, do nothing.
        else:
            if verbose:
                print(f"\tColumn {col} not present in DataFrame. No RBC QC performed.")

    return df_qc

qc_standard_values

Perform quality control (QC) by removing rows that do not have a predefined standard value.

Namely, it looks at the following parameters and their corresponding (standard) values:

TODO: What is this for? Why remove rows? TODO: Why only these parameters? TODO: Why hemoglobin in NL units?

Parameter Value Additional comments
rbc_intracellular_complexity 182
rbc_population_position 85
neutrophil_size_mean 140
neutrophil_intracellular_complexity 150
neutrophil_lobularity_polarized 125
neutrophil_lobularity_depolarized 28
neutrophil_dna_staining 69
lymphocyte_size_mean 100
lymphocyte_intracellular_complexity 75
hb_nl 6.206e-21 Hemoglobin (in NL units)
mch_usa 0.6206 Mean corpuscular hemoglobin (in USA units)
mchc_usa 0.6206 Mean corpuscular hemoglobin concentration (in USA units)
rbc_intracellular_complexity_cv 1.59341
rbc_population_position_cv 7.2

Info

This function was adapted from the original implementation in quality.py by Bram van Es.

Parameters:

Name Type Description Default
df pandas DataFrame

DataFrame with the clean data to be checked.

Tip

Cleaning can be done using the function clean_dataframe

required
machine str

What machine does the data correspond to. Possible values are:

  • sapphire or sapph - Sapphire
  • alinity or alin - Alinity hq

Info

No functionality yet, but might be useful in the future.

None
verbose bool

Define if verbose output will be printed (True) or not (False).

True

Returns:

Name Type Description
df_qc pandas DataFrame

DataFrame with quality controlled data.

Source code in pycelldyn/quality_control.py
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def qc_standard_values(df, machine=None, verbose=True):
    """ `qc_standard_values`

    Perform quality control (QC) by removing rows that do *not* have 
    a predefined standard value.

    Namely, it looks at the following parameters and their corresponding
    (standard) values:

    TODO: What is this for? Why remove rows?
    TODO: Why only these parameters?
    TODO: Why hemoglobin in NL units?

    | Parameter                             | Value       | Additional comments |
    |---------------------------------------|-------------|---------------------|
    | `rbc_intracellular_complexity`        | `182`       | |
    | `rbc_population_position`             | `85`        | |
    | `neutrophil_size_mean`                | `140`       | |
    | `neutrophil_intracellular_complexity` | `150`       | |
    | `neutrophil_lobularity_polarized`     | `125`       | |
    | `neutrophil_lobularity_depolarized`   | `28`        | |
    | `neutrophil_dna_staining`             | `69`        | |
    | `lymphocyte_size_mean`                | `100`       | |
    | `lymphocyte_intracellular_complexity` | `75`        | |
    | `hb_nl`                               | `6.206e-21` | Hemoglobin (in NL units) |
    | `mch_usa`                             | `0.6206`    | Mean corpuscular hemoglobin (in USA units) |
    | `mchc_usa`                            | `0.6206`    | Mean corpuscular hemoglobin concentration (in USA units) |
    | `rbc_intracellular_complexity_cv`     | `1.59341`   | |
    | `rbc_population_position_cv`          | `7.2`       | |

    !!! info
        This function was adapted from the original implementation in
        `quality.py` by Bram van Es.

    Parameters
    ----------
    df : pandas DataFrame
        DataFrame with the clean data to be checked.

        !!! tip
            Cleaning can be done using the function clean_dataframe

    machine : str
        What machine does the data correspond to. Possible values are:

        * `sapphire` or `sapph` - Sapphire
        * `alinity` or `alin` - Alinity hq

        !!! info
            No functionality yet, but might be useful in the future.

    verbose : bool
        Define if verbose output will be printed (`True`) or not (`False`).

    Returns
    -------
    df_qc : pandas DataFrame
        DataFrame with quality controlled data.
    """

    df_qc = df.copy()

    # Pair of relevant columns and standard values.
    cols_standard_values = {'rbc_intracellular_complexity': 182,
                            'rbc_population_position': 85,
                            'neutrophil_size_mean': 140,
                            'neutrophil_intracellular_complexity': 150,
                            'neutrophil_lobularity_polarized': 125,
                            'neutrophil_lobularity_depolarized': 28,
                            'neutrophil_dna_staining': 69,
                            'lymphocyte_size_mean': 100,
                            'lymphocyte_intracellular_complexity': 75,
                            'hb_nl': 6.206e-21,
                            'mch_usa': 0.6206,
                            'mchc_usa': 0.6206,
                            'rbc_intracellular_complexity_cv': 1.59341,
                            'rbc_population_position_cv': 7.2,
                            }

    for col, value in cols_standard_values:

        # Perform QC only when the corresponding column is present 
        # in the DataFrame.
        if col in df_qc.columns:

            # Remove rows that do not have the corresponding value.
            df_qc = df.loc[lambda x: x[col] != value]

            if verbose:
                print(f"\tQC for standard values performed on {col}.")

        # Otherwise, do nothing.
        else:
            if verbose:
                print(f"\tColumn {col} not present in DataFrame. No standard value QC performed.")

    return df_qc

qc_plausible_range

Perform quality control (QC) by converting values that are below or above an given threshold (defined in the data dictionary).

TODO: Why convert to NaN and not clip?

Info

This function was adapted from the original implementation in quality.py by Bram van Es.

Parameters:

Name Type Description Default
df pandas DataFrame

DataFrame with the clean data to be checked.

Tip

Cleaning can be done using the function clean_dataframe

required
df_data_dictionary pandas DataFrame

DataFrame with data dictionary information. It should have at least the following columns:

  • Computer name - The computer name of each parameter.
  • Min - Minimal allowed value
  • Max - Maximum allowed value

Tip

If the parameter has no min or max values, these should be filled in as a single dash (-).

required
machine str

What machine does the data correspond to. Possible values are:

  • sapphire or sapph - Sapphire
  • alinity or alin - Alinity hq

Info

No functionality yet, but might be useful in the future.

None
verbose bool

Define if verbose output will be printed (True) or not (False).

True

Returns:

Name Type Description
df_qc pandas DataFrame

DataFrame with quality controlled data.

Source code in pycelldyn/quality_control.py
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
def qc_plausible_range(df, df_data_dictionary, machine=None, verbose=True):
    """ `qc_plausible_range`

    Perform quality control (QC) by converting values that are below
    or above an given threshold (defined in the data dictionary).

    TODO: Why convert to NaN and not clip?

    !!! info
        This function was adapted from the original implementation in
        `quality.py` by Bram van Es.

    Parameters
    ----------
    df : pandas DataFrame
        DataFrame with the clean data to be checked.

        !!! tip
            Cleaning can be done using the function clean_dataframe

    df_data_dictionary : pandas DataFrame
        DataFrame with data dictionary information. It should have
        at least the following columns:

        * `Computer name` - The computer name of each parameter.
        * `Min` - Minimal allowed value
        * `Max` - Maximum allowed value

        !!! tip
            If the parameter has no min or max values, these should be
            filled in as a single dash (`-`).

    machine : str
        What machine does the data correspond to. Possible values are:

        * `sapphire` or `sapph` - Sapphire
        * `alinity` or `alin` - Alinity hq

        !!! info
            No functionality yet, but might be useful in the future.

    verbose : bool
        Define if verbose output will be printed (`True`) or not (`False`).

    Returns
    -------
    df_qc : pandas DataFrame
        DataFrame with quality controlled data.
    """

    df_qc = df.copy()

    # Check that columns of interest are present in the data dictionary.
    cols_interest = ['Computer name', 'Min', 'Max']
    for col in cols_interest:
        if col not in df_data_dictionary.columns:
            raise Exception(f"Column '{col}' not present in df_data_dictionary")

    # Select the data dictionary's columns of interest.
    df_data_dictionary = df_data_dictionary[cols_interest]
    df_data_dictionary = df_data_dictionary.set_index('Computer name')

    # Make sure that Min and Max columns are cast to floats properly.
    # `-` are replaced to `np.nan`.
    for col in ['Min', 'Max']:
        df_data_dictionary[col] = df_data_dictionary[col].replace('-', np.nan)
        df_data_dictionary[col] = df_data_dictionary[col].astype(float).fillna(np.nan)


    # Try to perform QC on all data columns.
    for col in df_qc.columns:

        # Check that data column exists in the data dictionary.
        if col in df_data_dictionary.index:

            col_min = df_data_dictionary.loc[col, 'Min']
            col_max = df_data_dictionary.loc[col, 'Max']

            # Perform QC only when an existing min limit is found.
            if col_min == col_min:
                df_qc.loc[df_qc[col] < col_min, col] = np.nan
                if verbose:
                    print(f"\tQC for plausible range (min = {col_min}) performed on {col}.")
            else:
                print(f"\tQC for plausible range (min) NOT performed on {col} due to NaN min value.")

            # Perform QC only when an existing max limit is found.
            if col_max == col_max:
                df_qc.loc[df_qc[col] > col_max, col] = np.nan
                if verbose:
                    print(f"\tQC for plausible range (max = {col_max}) performed on {col}.")
            else:
                print(f"\tQC for plausible range (max) NOT performed on {col} due to NaN max value.")

        # If the column does not exist, do nothing.
        else:
            if verbose:
                print(f"\tColumn {col} not present df_data_dictionary. No plausible range QC performed.")

    return df_qc