Guest User

DeSeq2 sample script

a guest
May 22nd, 2015
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.69 KB | None | 0 0
  1. ################################################################################
  2. # Gaëlle LELANDAIS <[email protected]>
  3. # Stéphane LE CROM <[email protected]>
  4. ################################################################################
  5.  
  6. # library loading
  7. library(DESeq2)
  8.  
  9. # data reading
  10. countData = read.table("count_data_diffAnalysis.txt", row.names = 1, header = TRUE)
  11.  
  12. # general information
  13. row.names(countData)
  14. head(countData)
  15.  
  16. ################################################################################
  17.  
  18. # Loading metadata for the experiment
  19.  
  20. colData = read.table("design.txt", row.names = 1, header = TRUE)
  21. # DESeqDataSet object creation
  22. dds = DESeqDataSetFromMatrix(countData = countData, colData = colData, design = ~condition)
  23. # normalization of counts
  24. # calculation of sizeFactors
  25. dds = estimateSizeFactors(dds)
  26. sizeFactors(dds)
  27. # bar plots
  28. barplot(colSums(counts(dds)))
  29. # boxplots
  30. boxplot(log2(counts(dds)+1))
  31. boxplot(log2(counts(dds,normalized=TRUE)+1))
  32.  
  33. # variance estimations
  34. dds = estimateDispersions(dds)
  35. plotDispEsts(dds)
  36.  
  37. # differential analysis
  38. dds = nbinomWaldTest(dds)
  39. res = results(dds)
  40. mcols(res,use.names=TRUE)
  41.  
  42. # diagnostic plots
  43. # MA plot
  44. plotMA(res)
  45. # Histogram of the p values
  46. hist(res$pvalue,breaks=20,col="grey")
  47. # PCA plots
  48. vsd <- varianceStabilizingTransformation(dds, blind=TRUE)
  49. p = plotPCA(vsd)
  50. p = update(p, panel = function(x, y, ...) {lattice::panel.xyplot(x, y, ...);lattice::ltext(x=x, y=y, labels=rownames(colData(vsd)), pos=1, offset=1, cex=0.8)})
  51. print(p)
  52.  
  53.  
  54. # genes are sorted according to adjusted p-values
  55. res = res[order(res$padj),]
  56. write.table(res, "res.txt", row.name=T, quote=F, sep='\t')
Advertisement
Add Comment
Please, Sign In to add comment