Gplots Library

admin
Gplots Library Average ratng: 9,4/10 7634 votes
  1. Gplots Library R
  2. Plots Library
Jun 13th, 2014
Library
Never
Not a member of Pastebin yet?Sign Up, it unlocks many cool features!

Gplots Library R

  1. library('gplots')
  2. hmcol = colorRampPalette(brewer.pal(9, 'GnBu'))(100)
  3. pdf='DESeq_Results.pdf'
  4. pdf(pdf,paper='a4')
  5. window=function(x){
  6. quartz()
  7. par(mfrow=c(1,1))
  8. }
  9. pdata=read.table('pdata.txt',header=TRUE)
  10. conds=as.vector(pdata$condition) # Backwards compatibility with anton's old scripts
  11. # Make the new fangled DESeq2 counts object direct from data.
  12. ddsHTSeq <- DESeqDataSetFromHTSeqCount(sampleTable = pdata, directory = '.', design= ~ condition)
  13. # They recommend reordering conditions, not sure why though or if this has any effect for us
  14. colData(ddsHTSeq)$condition <- factor(colData(ddsHTSeq)$condition,levels=levels(pdata$condition))
  15. # Normalisation
  16. # Dispersion
  17. # New Neg. Binomial test
  18. window()
  19. res <- results(dds)
  20. # Lets do Anton's regular plots based around raw or log2 transformed data.
  21. # Effect of Normalisation on counts
  22. par(mfrow=c(3,1))
  23. barplot(colSums(counts(dds, normalized=F)), col=as.factor(conds), las=2,cex.names=0.4,main='Pre Normalised Counts')
  24. legend('center',conds,fill=as.factor(conds),cex=0.6,horiz=TRUE)
  25. barplot(colSums(counts(dds, normalized=T)), col=as.factor(conds), las=2,cex.names=0.4,main='Post Normalised Counts')
  26. window()
  27. heatmap.2(cor(counts(dds,normalized=TRUE)),trace='none',main='Sample to Sample Correlation')
  28. # Sample PCA
  29. pca <- princomp(counts(dds,normalized=T))
  30. plot(pca$loadings, main='Principal Component Analysis', col=colors[pdata$condition], pch=19, cex=2)
  31. window()
  32. # They recommend these as alternatives to log2 visualisations.
  33. # Alternative to Log2 (n+1) transformations - Wolfie and Simon say they are better ?
  34. vsd <- varianceStabilizingTransformation(dds, blind=TRUE)
  35. #window()
  36. #meanSdPlot(assay(rld[notAllZero,]), ylim = c(0,2.5))
  37. #meanSdPlot(assay(vsd[notAllZero,]), ylim = c(0,2.5))
  38. select <- order(rowMeans(counts(dds,normalized=TRUE)),decreasing=TRUE)[1:200]
  39. hmcol <- colorRampPalette(brewer.pal(9, 'GnBu'))(100)
  40. heatmap.2(counts(dds,normalized=TRUE)[select,], col = hmcol,
  41. dendrogram='none', trace='none', margin=c(10,6))
  42. heatmap.2(assay(rld)[select,], col = hmcol,
  43. dendrogram='none', trace='none', margin=c(10, 6))
  44. heatmap.2(assay(vsd)[select,], col = hmcol,
  45. dendrogram='none', trace='none', margin=c(10, 6))
  46. mat <- as.matrix(distsRL)
  47. rownames(mat) <- colnames(mat) <- with(colData(dds),
  48. window()
  49. heatmap.2(mat, trace='none', col = rev(hmcol), margin=c(13, 13))
  50. print(plotPCA(rld, intgroup=c('condition')))
  51. sig_p=0.00001
  52. z=results(dds)
  53. hitlist = (abs(z$log2FoldChange) > sig_lfc) & (z$padj <= sig_p) & (!is.na(z$log2FoldChange)) & (!is.na(z$padj))
  54. window()
  55. plot(results(dds)$log2FoldChange,-log(results(dds)$padj,10),ylab='-log10(Adjusted P)',xlab='Log2 FoldChange',main='Volcano Plot',pch=19,cex=0.4)
  56. points(results(dds)[hitlist,'log2FoldChange'],-log(results(dds)[hitlist,'padj'],10),pch=19,cex=0.4,col='red')
  57. abline(v=-sig_lfc)
  58. heatmap.2(log2(counts(dds[hitlist,],normalized=TRUE)+1),col=hmcol,trace='none',cexRow=0.5,cexCol=0.5,main=paste('Differential RNAs P< ',sig_p))
  59. dev.off()
Gplots LibraryInstall gplots library

Plots Library

The above plot is only for demonstration purposes, and it shows some of the many customization options available in the ggplot2 library. For more options, please refer to the ggplot2 documentation. If you have any questions, please feel free to leave a comment or reach out to me on Twitter. Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time. Gplot is the standard network visualization tool within the sna library. By means of clever selection of display parameters, a fair amount of display flexibility can be obtained. Graph layout - if not specified directly using coord - is determined via one of the various available algorithms.

Gplots Library

Per @mattmills49 comment, opened a new Rstudio window, successfully installed patchwork, then loaded the library into my previous R session with no trouble. Thomasp85 closed this Mar 11, 2018 Copy link.