acore.normalization.strategies module#

Strategies for data normalization used by normalize_data.

median_zero_normalization(data, normalize='samples')[source]#

This function normalizes each sample by using its median.

Parameters:
  • data

  • normalize (str) – whether the normalization should be done by ‘features’ (columns) or ‘samples’ (rows)

Returns:

pandas.DataFrame.

Example:

data = pd.DataFrame({'a': [2,5,4,3,3], 'b':[4,4,6,5,3], 'c':[4,14,8,8,9]})
result = median_zero_normalization(data, normalize='samples')
result
        a         b         c
    0 -1.333333  0.666667  0.666667
    1 -2.666667 -3.666667  6.333333
    2 -2.000000  0.000000  2.000000
    3 -2.333333 -0.333333  2.666667
    4 -2.000000 -2.000000  4.000000
median_normalization(data, normalize='samples')[source]#

This function normalizes each sample by using its median.

Parameters:
  • data

  • normalize (str) – whether the normalization should be done by ‘features’ (columns) or ‘samples’ (rows)

Returns:

pandas.DataFrame.

Example:

data = pd.DataFrame({'a': [2,5,4,3,3], 'b':[4,4,6,5,3], 'c':[4,14,8,8,9]})
result = median_normalization(data, normalize='samples')
result
        a         b         c
    0 -1.333333  0.666667  0.666667
    1 -2.666667 -3.666667  6.333333
    2 -2.000000  0.000000  2.000000
    3 -2.333333 -0.333333  2.666667
    4 -2.000000 -2.000000  4.000000
zscore_normalization(data, normalize='samples')[source]#

This function normalizes each sample by using its mean and standard deviation (mean=0, std=1).

Parameters:
  • data

  • normalize (str) – whether the normalization should be done by ‘features’ (columns) or ‘samples’ (rows)

Returns:

pandas.DataFrame.

Example:

data = pd.DataFrame({'a': [2,5,4,3,3], 'b':[4,4,6,5,3], 'c':[4,14,8,8,9]})
result = zscore_normalization(data, normalize='samples')
result
          a         b         c
        0 -1.154701  0.577350  0.577350
        1 -0.484182 -0.665750  1.149932
        2 -1.000000  0.000000  1.000000
        3 -0.927173 -0.132453  1.059626
        4 -0.577350 -0.577350  1.154701
median_polish_normalization(data, max_iter=250)[source]#

This function iteratively normalizes each sample and each feature to its median until medians converge.

Parameters:
  • data

  • max_iter (int) – number of maximum iterations to prevent infinite loop.

Returns:

pandas.DataFrame.

Example:

data = pd.DataFrame({'a': [2,5,4,3,3], 'b':[4,4,6,5,3], 'c':[4,14,8,8,9]})
result = median_polish_normalization(data, max_iter = 10)
result
        a    b     c
    0  2.0  4.0   7.0
    1  5.0  7.0  10.0
    2  4.0  6.0   9.0
    3  3.0  5.0   8.0
    4  3.0  5.0   8.0
quantile_normalization(data) DataFrame[source]#

Applies quantile normalization to each column in pandas.DataFrame.

Parameters:

data – pandas.DataFrame with features as columns and samples as rows.

Returns:

pandas.DataFrame

Example:

data = pd.DataFrame({'a': [2,5,4,3,3], 'b':[4,4,6,5,3], 'c':[4,14,8,8,9]})
result = quantile_normalization(data)
result
        a    b    c
    0  3.2  4.6  4.6
    1  4.6  3.2  8.6
    2  3.2  4.6  8.6
    3  3.2  4.6  8.6
    4  3.2  3.2  8.6
linear_normalization(data, method='l1', normalize='samples') DataFrame[source]#

This function scales input data to a unit norm. For more information visit: https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.normalize.html

Parameters:
  • data – pandas.DataFrame with samples as rows and features as columns.

  • method (str) – norm to use to normalize each non-zero sample or non-zero feature (depends on axis).

  • normalize (str) – axis used to normalize the data along. If ‘samples’, independently normalize each sample, if ‘features’ normalize each feature.

Returns:

pandas.DataFrame

Example:

data = pd.DataFrame({'a': [2,5,4,3,3], 'b':[4,4,6,5,3], 'c':[4,14,8,8,9]})
result = linear_normalization(data, method = "l1", normalize = 'samples')
result
        a         b         c
    0  0.117647  0.181818  0.093023
    1  0.294118  0.181818  0.325581
    2  0.235294  0.272727  0.186047
    3  0.176471  0.227273  0.186047
    4  0.176471  0.136364  0.209302