source("https://bioconductor.org/biocLite.R") biocLite("ballgown") library(ballgown) #X is the file which contains the expression level (FPKM) of genes in each sample, which is generated by stringTie. bg=ballgown(dataDir="X", samplePattern='tj_', meas='all') transcript_fpkm = texpr(bg, 'FPKM') row.names(transcript_fpkm) = transcriptNames(bg) bg=ballgown(dataDir="X", samplePattern='tj_', meas='all') pData(bg) = data.frame(id=sampleNames(bg), group=rep(c(1,0), each=4)) stat_results = stattest(bg, feature='gene', meas='FPKM', getFC=TRUE, covariate='group') write.csv(stat_results, 'gene_difexp.csv', row.names=F,quote=F)