| volcanoPlot {MatrixQCvis} | R Documentation |
The function 'volcanoPlot' creates a volcano plot. On the y-axis the -log10(p-values) are displayed, while on the x-axis the fold changes/differences are displayed. The output of the function 'volcanoPlot' differs depending on the 'type' parameter. For 'type == "ttest"', the fold changes are plotted; for 'type == "proDA"', the differences are plotted.
volcanoPlot(df, type = c("ttest", "proDA"))
df |
'data.frame' as received from 'topTable' ('ttest') or 'test_diff' (proDA) |
type |
'character' |
Internal use in 'shinyQC'.
'plotly'
## create se
a <- matrix(1:100, nrow = 10, ncol = 10,
dimnames = list(1:10, paste("sample", 1:10)))
a[c(1, 5, 8), 1:5] <- NA
set.seed(1)
a <- a + rnorm(100)
a_i <- imputeAssay(a, method = "MinDet")
cD <- data.frame(sample = colnames(a),
type = c(rep("1", 5), rep("2", 5)))
rD <- data.frame(spectra = rownames(a))
se <- SummarizedExperiment::SummarizedExperiment(assay = a,
rowData = rD, colData = cD)
se_i <- SummarizedExperiment::SummarizedExperiment(assay = a_i,
rowData = rD, colData = cD)
## create model and contrast matrix
modelMatrix_expr <- stats::formula("~ 0 + type")
contrast_expr <- "type1-type2"
modelMatrix <- model.matrix(modelMatrix_expr, data = colData(se))
contrastMatrix <- limma::makeContrasts(contrasts = contrast_expr,
levels = modelMatrix)
## ttest
fit <- limma::lmFit(a_i, design = modelMatrix)
fit <- limma::contrasts.fit(fit, contrastMatrix)
fit <- limma::eBayes(fit, trend = TRUE)
df_ttest <- limma::topTable(fit, n = Inf, adjust = "fdr", p = 0.05)
df_ttest <- cbind(name = rownames(df_ttest), df_ttest)
## plot
volcanoPlot(df_ttest, type = "ttest")
## proDA
fit <- proDA::proDA(a, design = modelMatrix)
df_proDA <- proDA::test_diff(fit = fit, contrast = contrast_expr,
sort_by = "adj_pval")
## plot
volcanoPlot(df_proDA, type = "proDA")