setwd(“F:\ESCC”)
load(“zzc.Rdata”)
Counts2TPM <- function(counts, effLen){
rate <- log(counts) - log(effLen)
denom <- log(sum(exp(rate)))
exp(rate - denom + log(1e6))
}
gene_count <- gene_count[rownames(gene_length),]
linshi <- matrix(,dim(gene_count[1]),)
rownames(linshi) <- rownames(gene_count)
for (i in 1:dim(gene_count)[2]){
linshi <- cbind(linshi,Counts2TPM(gene_count[,i],gene_length))
}
linshi <- linshi[,-1]
colnames(linshi) <- colnames(gene_count)
linshi_end <- matrix(,,dim(gene_count)[2])
colnames(linshi_end) <- colnames(gene_count)
for (i in 1:dim(linshi)[1]){
len <- length(which(is.na(linshi[i,]) == T))
if (len <= 113){
linshi_end <- rbind(linshi_end,linshi[i,])
}
}
linshi_end <- linshi_end[-1,]
write.table(linshi_end,”ESCC_TPM.txt”,quote = F)
linshi_end1 <- log2(linshi_end + 1)
write.table(linshi_end1,”ESCC_TPM_log2.txt”,quote = F)