View Single Post
Old 07-16-2014, 01:11 PM   #5
Richard Finney
Senior Member
 
Location: bethesda

Join Date: Feb 2009
Posts: 700
Default

Slight Tangent ... Using "htseq-count" outputs ... this works for me ....

Here's the template I hack for deseq2 ....

source("http://bioconductor.org/biocLite.R")
library(DESeq2,lib.loc="/home/finneyr/Rlib")

sampleFiles = c(
"file1.txt" ,
"file2.txt" ,
#... (fill in the names of you htseq count files here 1 to N files.
:"filen.txt"
)

#set your condtions for the files in SampleFiles
sampleCondition = c( "treated" , "treated" , "treated" , "treated" , "treated" , "treated" , "treated" , "treated" , "treated" , "treated" , "treated" , "treated" , "treated" , "treated" , "treated" , "treated" , "treated" , "treated" , "untreated" , "untreated" , "untreated" , "untreated" , "untreated" )

sampleTable<-data.frame(sampleName=sampleFiles, fileName=sampleFiles, condition=sampleCondition)

#might need this ... I'm not sure
libType = c ( "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" , "paired-end" )

options(max.print=100000)
options(width=500)

#set directory to your place where you keep your files llisted in "sampleFiles" which are htseqcount output files.
directory="/data/nextgen/finneyr/novo/CNT"
ddsHTSeq<-DESeqDataSetFromHTSeqCount(sampleTable=sampleTable, directory=directory, design=~condition)
print(ddsHTSeq)

colData(ddsHTSeq)$condition<-factor(colData(ddsHTSeq)$condition, levels=c("treated","untreated"))

dds<-DESeq(ddsHTSeq)
print(dds)
res<-results(dds)
print(res);
# sort by padj (:adjusted p-value") ...
res<-res[order(res$padj),]

#write results to file name "rpt5" , change this to your output file name, deseq2 explains log2foldchange and other fields.
write.csv(as.data.frame(res),file="rpt5")
q(save="no")

Last edited by Richard Finney; 07-16-2014 at 01:21 PM.
Richard Finney is offline   Reply With Quote