Giter VIP home page Giter VIP logo

quantile_normalize's People

Contributors

shawnlyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

quantile_normalize's Issues

np.nan

Dear ShawnLYU,

nice piece of code! what you think about preserving np.nan values in the dataframe?
cheers

Michele

Input data format

It says in the 'Readme' file:

Input data is a Pandas dataframe (df). Each row stands for an observations and each column stands for an attribute

Not sure if I got it right with what you meant by 'observations' and 'attribute'. According to Quantile Normalization, in the case of gene expression data, your codes are actually fit for input with each row being a gene (attribute?) and each column being a sample (observation?).

numpy version

I found the code useful. I rewrote the function using 2D numpy array as input in my use case. I'm posting it here if it's of any help to others or as an addition to your code.

import numpy as np
import pandas as pd

def qnorm_np(arr):
    sorted_arr = arr.astype(float)
    sorted_arr.sort(axis=0)
    rank = sorted_arr.mean(axis=1)
    for col in range(arr.shape[1]):
        t = np.searchsorted(np.sort(arr[:, col]), arr[:,col])
        sorted_arr[:,col] = rank[t]
    return sorted_arr

#Test
df_input =  pd.DataFrame({'C1': {'A': 5, 'B': 2, 'C': 3, 'D': 4},
                   'C2': {'A': 4, 'B': 1, 'C': 4, 'D': 2},
                   'C3': {'A': 3, 'B': 4, 'C': 6, 'D': 8}})
arr_norm = qnorm_np(df_input.values)
  • P

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.