sudo apt install libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev
BiocManager::install('EnhancedVolcano')
https://github.com/kevinblighe/EnhancedVolcano
dds <- DESeq(dds_1st, parallel = TRUE, betaPrior=FALSE)
res <- results(dds, alpha=1e-3)
res2 <- lfcShrink(dds, coef=2, type="apeglm", res=res) #, lfcThreshold=1)
volcanoes <- function(dataset, p, FC){
keyvals <- rep('grey75', nrow(dataset))
names(keyvals) <- rep('NS', nrow(dataset))
keyvals[which(abs(dataset$log2FoldChange) > FC & dataset$pvalue > p)] <- 'forestgreen'
names(keyvals)[which(abs(dataset$log2FoldChange) > FC & dataset$pvalue > p)] <- 'LFC'
keyvals[which(abs(dataset$log2FoldChange) < FC & dataset$pvalue < p)] <- 'grey25'
names(keyvals)[which(abs(dataset$log2FoldChange) < FC & dataset$pvalue < p)] <- '-Log10Q'
keyvals[which(dataset$log2FoldChange < -FC & dataset$pvalue < p)] <- 'blue2'
names(keyvals)[which(dataset$log2FoldChange < -FC & dataset$pvalue < p)] <- 'Down-regulated'
keyvals[which(dataset$log2FoldChange > FC & dataset$pvalue < p)] <- 'red2'
names(keyvals)[which(dataset$log2FoldChange > FC & dataset$pvalue < p)] <- 'Up-regulated'
unique(keyvals)
unique(names(keyvals))
library(EnhancedVolcano)
library(stringr)
EnhancedVolcano(res2,
lab = rownames(dataset),
x = 'log2FoldChange',
y = 'pvalue',
#selectLab = rownames(dataset)[which(names(keyvals) %in% c('NS','log2FoldChange','-Log10Q','low','high'))],
xlim = c(-12,12),
xlab = bquote(~Log[2]~ 'fold change'),
ylab = bquote(~-Log[10] ~ italic(P)),
title = paste0('Volcano plot ( p > ', as.character(p), ' , LFC > ', as.character(FC),' )'),
titleLabSize = 16,
subtitle = paste0(' - Dataset : ',word(fname,-3, sep = '[/_]')),
pCutoff = p,
FCcutoff = FC,
pointSize = 1,
labSize = 3.5,
#shape = c(6, 4, 2, 11, 15),
colCustom = keyvals,
colAlpha = 0.7,
legendPosition = 'right',
legendLabSize = 12,
legendIconSize = 3.0,
drawConnectors = TRUE,
widthConnectors = 0.4,
axisLabSize = 13,
colConnectors = 'grey50',
gridlines.major = TRUE,
gridlines.minor = FALSE,
border = 'partial',
borderWidth = 0.6,
borderColour = 'black')
}
volcanoes(res, 1e-69, 1)
Reference
- lfcShrink: Shrink log2 fold changes, https://rdrr.io/bioc/DESeq2/man/lfcShrink.html
'R' 카테고리의 다른 글
[R] table information (0) | 2022.01.06 |
---|---|
[R] predict (0) | 2021.10.19 |
[R] boxplot options (0) | 2021.10.06 |
[R] install packages (0) | 2021.10.05 |
[R] basic (0) | 2021.05.25 |
댓글