QA Classes

RetentionTimeChecker

class avoca.qa_class.rt.RetentionTimeChecker(*args, **kwargs)

Tries to check if there is a problem with the assignment of the retention times.

The very simple way of doing, it to check the correlation between the retention times of the measurements. The correlation is usually very high. If one compound has a low correlation with the others, it probably means that is was miss-assigned at some points.

Parameters:
  • rt_threshold – The threshold for the retention time deviation. Unit is time unit (minutes or seconds, as in the data). This will try to fit a linear regression from the average training retention times to the measured ones for each sample. If after the regression a datapoint is higher than this threshold, it will be removed.

  • rt_relative_max_deviation – The maximum relative deviation allowed from the average retention time. This is used to remove outliers that are too far from the average. if 0.5 is given, it means that the retention time can be 50% higher or lower than the average retention time.

ExtremeValues

class avoca.qa_class.zscore.ExtremeValues(*args, **kwargs)

Detect extreme values.

The method is based on the z-score, which is calculated as follows:

\[z = \frac{x - \mu}{\sigma}\]

where \(x\) is the value, \(\mu\) is the mean of the values and \(\sigma\) is the standard deviation of the values.

If the z-score is greater than a threshold, the value is flagged.

Parameters:
  • variable – The variable to check for extreme values.

  • threshold – The threshold for the z-score. To flag values.

  • use_log_normal – If True, the log of the values will be used to calculate the z-score. This can be useful if the values are log-normal distributed.

  • only_greater – If True, only values greater than the threshold will be flagged. The values lower than the negative threshold will not be flagged. By default, this is True if use_log_normal is True, and False otherwise.

RollingWindow

class avoca.qa_class.rolling.RollingWindow(*args, **kwargs)

Detect in rolling windows.

The method is based on outliers in a rolling window using the median and standard deviation. The training is done directly on the fitted data.

Parameters:
  • variable – The variable to check for extreme values.

  • threshold – The threshold for the z-score. To flag values.

  • use_log_normal – If True, the log of the values will be used to calculate the z-score. This can be useful if the values are log-normal distributed.

  • only_greater – If True, only values greater than the threshold will be flagged. The values lower than the negative threshold will not be flagged. By default, this is True if use_log_normal is True, and False otherwise.

  • rolling_window – The size of the rolling window as a timedelta object. See window parameters in pandas documentation for more details. https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.rolling.html#pandas-dataframe-rolling

ExtremeConcentrations

class avoca.qa_class.concs.ExtremeConcentrations(*args, **kwargs)

Assigns QA flags to extreme concentrations.

Subclass of ExtremeValues. Some parameters are set to apply only to concentrations.

XY_Correlations

class avoca.qa_class.zscore.XY_Correlations(*args, **kwargs)

Compare values of various compunds using a correlation.

This assumes the data between two compounds is linearly correlated. If a value is outside the threshold around the linear regression line, it is flagged.

Parameters:
  • variable – The variable to compare the compounds on.

  • threshold – The threshold for the residuals of the linear regression.

TestAssigner

class avoca.qa_class.test.TestAssigner(*args, **kwargs)

Test assigner for QA class.

InvalidValues

class avoca.qa_class.invalid.InvalidValues(*args, **kwargs)

Flag invalid values.

Parameters:
  • variables – The variables to be flagged. If a string is given, it will be converted to a list.

  • negative_values – If True, negative values will be flagged. Default is False.

  • zeroes – If True, zero values will be flagged. Default is False.

Para m flag:

The flag to be assigned. Default is QA_Flag.INVALID_VALUES.