data <- file.path(salmonOut, sample,"quant.sf") names(data)<- sample txi <- tximport(data, type ='salmon', tx2gene = tx2gene)
# View expression matrix head(txi$counts)
Kallisto导入
1 2 3 4
data <- file.path(kallistoOut, sample,"abundance.h5") names(data)<- sample # if not set ignoreAfterBar = TRUE, the gene will contain the "|" and the long string. txi <- tximport(data, type ='kallisto', tx2gene = tx2gene, ignoreAfterBar =TRUE)
RSEM导入
1 2 3 4 5 6 7
data <- file.path(rsemOut, paste0(sample,".genes.results")) names(data)<- sample txi <- tximport(data, type ='rsem', txIn =TRUE, txOut =TRUE) # Fix the error: all(lengths >0) is not TRUE txi$abundance = txi$abundance[apply(txi$length,1,function(row)all(row!=0)),] txi$counts = txi$counts[apply(txi$length,1,function(row)all(row!=0)),] txi$length= txi$length[apply(txi$length,1,function(row)all(row!=0)),]
# Select the contrast result res <- results(dds, contrast =c("group","case","control")) res <- res[order(res$padj),] res <- subset(res, padj <0.1) res <- na.omit(res) write.table(res,"deg.txt", sep ="\t",quote=F, row.names =F)