Gplots Library
Gplots Library R
- library('gplots')
- hmcol = colorRampPalette(brewer.pal(9, 'GnBu'))(100)
- pdf='DESeq_Results.pdf'
- pdf(pdf,paper='a4')
- window=function(x){
- quartz()
- par(mfrow=c(1,1))
- }
- pdata=read.table('pdata.txt',header=TRUE)
- conds=as.vector(pdata$condition) # Backwards compatibility with anton's old scripts
- # Make the new fangled DESeq2 counts object direct from data.
- ddsHTSeq <- DESeqDataSetFromHTSeqCount(sampleTable = pdata, directory = '.', design= ~ condition)
- # They recommend reordering conditions, not sure why though or if this has any effect for us
- colData(ddsHTSeq)$condition <- factor(colData(ddsHTSeq)$condition,levels=levels(pdata$condition))
- # Normalisation
- # Dispersion
- # New Neg. Binomial test
- window()
- res <- results(dds)
- # Lets do Anton's regular plots based around raw or log2 transformed data.
- # Effect of Normalisation on counts
- par(mfrow=c(3,1))
- barplot(colSums(counts(dds, normalized=F)), col=as.factor(conds), las=2,cex.names=0.4,main='Pre Normalised Counts')
- legend('center',conds,fill=as.factor(conds),cex=0.6,horiz=TRUE)
- barplot(colSums(counts(dds, normalized=T)), col=as.factor(conds), las=2,cex.names=0.4,main='Post Normalised Counts')
- window()
- heatmap.2(cor(counts(dds,normalized=TRUE)),trace='none',main='Sample to Sample Correlation')
- # Sample PCA
- pca <- princomp(counts(dds,normalized=T))
- plot(pca$loadings, main='Principal Component Analysis', col=colors[pdata$condition], pch=19, cex=2)
- window()
- # They recommend these as alternatives to log2 visualisations.
- # Alternative to Log2 (n+1) transformations - Wolfie and Simon say they are better ?
- vsd <- varianceStabilizingTransformation(dds, blind=TRUE)
- #window()
- #meanSdPlot(assay(rld[notAllZero,]), ylim = c(0,2.5))
- #meanSdPlot(assay(vsd[notAllZero,]), ylim = c(0,2.5))
- select <- order(rowMeans(counts(dds,normalized=TRUE)),decreasing=TRUE)[1:200]
- hmcol <- colorRampPalette(brewer.pal(9, 'GnBu'))(100)
- heatmap.2(counts(dds,normalized=TRUE)[select,], col = hmcol,
- dendrogram='none', trace='none', margin=c(10,6))
- heatmap.2(assay(rld)[select,], col = hmcol,
- dendrogram='none', trace='none', margin=c(10, 6))
- heatmap.2(assay(vsd)[select,], col = hmcol,
- dendrogram='none', trace='none', margin=c(10, 6))
- mat <- as.matrix(distsRL)
- rownames(mat) <- colnames(mat) <- with(colData(dds),
- window()
- heatmap.2(mat, trace='none', col = rev(hmcol), margin=c(13, 13))
- print(plotPCA(rld, intgroup=c('condition')))
- sig_p=0.00001
- z=results(dds)
- hitlist = (abs(z$log2FoldChange) > sig_lfc) & (z$padj <= sig_p) & (!is.na(z$log2FoldChange)) & (!is.na(z$padj))
- window()
- plot(results(dds)$log2FoldChange,-log(results(dds)$padj,10),ylab='-log10(Adjusted P)',xlab='Log2 FoldChange',main='Volcano Plot',pch=19,cex=0.4)
- points(results(dds)[hitlist,'log2FoldChange'],-log(results(dds)[hitlist,'padj'],10),pch=19,cex=0.4,col='red')
- abline(v=-sig_lfc)
- 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))
- dev.off()
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.
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.