0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Dataframeを列あるいは行単位でまとめて標準化する方法

Posted at

PythonでDataframeを列あるいは行単位でまとめて標準化(zscore)する

標準化:平均を0、分散を1となるように値を変換すること

RNA-seqで得られた遺伝子発現量(TMM, TPMなど)を遺伝子間で比較する際、値をzscoreか、log10かのどちらかで取ることがあると思います。
今回はzscoreの取り方を備忘録として書きます。

やり方

def mean_norm(df_input):
    return df_input.apply(lambda x: (x-x.mean())/ x.std(), axis=1)

# 列ごとの標準化の場合は axis=0

以上。
上記の関数のdf_inputのところにdataframeを代入すれば、標準化ができる。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?