Created
          May 28, 2019 11:57 
        
      - 
      
- 
        Save lucananni93/37cecdde5bc30287c8633f3738db6a96 to your computer and use it in GitHub Desktop. 
    Quantile Normalization using Numpy
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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