需要提前安装GenomicFeatures 和 tximport
library(GenomicFeatures)
library(tximport)
gtf_file='gene.gtf'
txdb <- makeTxDbFromGFF(gtf_file)
k <- keys(txdb, keytype = "TXNAME")
tx2gene <- select(txdb, k, "GENEID", "TXNAME")
count_dir='/data1/download'
name=c('SRR1','SRR2','SRR3','SRR4')
files <- file.path(count_dir, name,"quant.sf")
names(files) <- paste0(name)
txi.salmon <- tximport(files, type = "salmon", tx2gene = tx2gene)
counts=txi.salmon$counts
tpm=txi.salmon$abundance
write.table(tpm,'gene.tmp',sep='\t',quote=F)
网友评论