Skip to content

Instantly share code, notes, and snippets.

@lucananni93
Created May 28, 2019 11:57
Show Gist options
  • Save lucananni93/37cecdde5bc30287c8633f3738db6a96 to your computer and use it in GitHub Desktop.
Save lucananni93/37cecdde5bc30287c8633f3738db6a96 to your computer and use it in GitHub Desktop.
Quantile Normalization using Numpy
import numpy as np
def quantile_normalization(m):
sort_idx = np.argsort(m, axis=0)
ranks = np.argsort(sort_idx, axis=0)
sorted_cols = np.sort(m, axis=0)
col_ranks = sorted_cols.mean(1)
qnorm = col_ranks[ranks]
return qnorm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment