Count转化为TPM或FPKM


rm(list = ls())
library(openxlsx)
library(tidyverse)
count_raw <- read.xlsx("../all.counts.length.deg.xlsx")
names(count_raw)
rownames(count_raw) <- count_raw$Geneid

count <- count_raw %>% filter(sum > 0) %>% select(Length,7:16)
names(count)


counts <- count_raw[,5:14]

lengths = count_raw$Length

rpkm <- function(counts, lengths) {
  rate <- counts / lengths
  rate / sum(counts) * 1e9
}
exprSet_rpkm=rpkm(counts,lengths)
exprSet_tpm=1e6*exprSet_rpkm/colSums(exprSet_rpkm)
my.TPM=data.frame(Gene_ID=rownames(exprSet_tpm),exprSet_tpm)

write.xlsx(my.TPM,"../TPM.xlsx")


文章作者: chaoyuny
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 chaoyuny !
  目录