R语言收藏

转录组专题:FPKM转TPM标准化

2020-03-29  本文已影响0人  挽山
expMatrix<-read.table('fpkm_expr.txt',header = T,row.names = 1)
#假设原来的表达矩阵fpkm_expr.txt中行为基因,列为样本,中间数值是FPKM计算得到的值

countToTpm <- function(counts, effLen)
{
  rate <- log(counts) - log(effLen)
  denom <- log(sum(exp(rate)))
  exp(rate - denom + log(1e6))}

countToFpkm <- function(counts, effLen)
{
  N <- sum(counts)
  exp( log(counts) + log(1e9) - log(effLen) - log(N) )}

fpkmToTpm <- function(fpkm)
{
  exp(log(fpkm)-log(sum(fpkm))+log(1e6))}

countToEffCounts<-function(counts, len, effLen)
{
  counts * (len/effLen)}

#计算TPM
tpms<-apply(expMatrix,2,fpkmToTpm)
tpms[1:3,]

上一篇下一篇

猜你喜欢

热点阅读