View source: R/jj_plot_volcano.R
jj_plot_volcano | R Documentation |
jj_plot_volcano volcano plot of pval (which is -log10 transformed) against logFC
jj_plot_volcano(
plot_df,
logfc_column,
pval_column,
symbol_column = NULL,
marker_thres = c(0.5, Inf),
labs_range = NULL,
alpha = 1,
pt.size = 2.5,
highlight.pt.size = 2.5,
col_vec = c("red", "blue", "black", "green"),
markers_highlight = NULL,
markers_highlight_col = NULL,
only_highlight = FALSE,
col_by_highlight = FALSE,
use_text = TRUE,
add_thres_line = FALSE,
group_names = NULL,
arrow_pos = list(x = 0.25, xend = 1, y = 40)
)
logfc_column |
sparse matrix, vector, or data.frame |
pval_column |
vector with group annotation, has to have length equal to ncol(sparse_mat)/nrow(data.frame)/length(vector) |
symbol_column |
provide |
marker_thres |
define |
labs_range |
vector specifying range of x axis (and for fc_fc plot range of y axis) |
alpha |
alpha level for points (working?) |
col_vec |
define larger, smaller, intermediate and highlight colours |
markers_highlight |
vector of genes from the symbol_column which should additionally be highlighted |
markers_highlight_col |
named vector assigning a colour to each gene to be highlighed |
only_highlight |
if TRUE, only show markers specified in |
col_by_highlight |
if TRUE, only colour the markers specified in |
use_text |
plot text if there are any points to highlight |
add_thres_line |
if TRUE, plot dashed lines at the defined |
ggplot scatterplot of log10(pval) vs FC or FC vs FC
#Using Seurats FindMarkers output
library(Seurat)
marker_df = FindMarkers(pbmc_small, group.by = 'groups', ident.1 = 'g1', ident.2 = 'g2')
marker_df$symbol = rownames(marker_df)
#or using a random data.frame
marker_df = data.frame(avg_log2FC = rnorm(100, 0, 2),
p_val = sample(c(runif(50, 0, 0.1), runif(50))),
symbol = paste0(sample(LETTERS, 100, replace = T), sample(letters, 100, replace = T), 1:100))
jj_plot_volcano(marker_df, logfc_column = 'avg_log2FC', pval_column = 'p_val', marker_thres = Inf) + theme(legend.position = 'none')
#colour highlighting above a threshold and capping very high and low values, adding lines for the threshold
jj_plot_volcano(marker_df, logfc_column = 'avg_log2FC', pval_column = 'p_val',
labs_range = c(-2,2), marker_thres = 1.5, add_thres_line=T)
#adding text to highlighted markers, possibility to show unbalanced x axis
jj_plot_volcano(marker_df, logfc_column = 'avg_log2FC', pval_column = 'p_val', symbol_column = 'symbol',
use_text = T, labs_range = c(-2,4), marker_thres = 2)
#instead of highlighting everything above/below a threshold, specific markers can be highlighted
jj_plot_volcano(marker_df, logfc_column = 'avg_log2FC', pval_column = 'p_val', symbol_column = 'symbol',
labs_range = c(-2.5, 2.5), marker_thres = 4,
markers_highlight = marker_df$symbol[1:4], pt.size = 1.5,
only_highlight = F, col_by_highlight = T)
#specific highlighting and general highlighting can be combined
jj_plot_volcano(marker_df, logfc_column = 'avg_log2FC', pval_column = 'p_val', symbol_column = 'symbol',
labs_range = c(-2.5, 2.5), marker_thres = 2,
markers_highlight = marker_df$symbol[1:4], pt.size = 1.5, highlight.pt.size = 3,
only_highlight = F, col_by_highlight = F)
#only show highlighted markers
jj_plot_volcano(marker_df, logfc_column = 'avg_log2FC', pval_column = 'p_val', symbol_column = 'symbol',
labs_range = c(-2.5, 2.5), marker_thres = 2,
markers_highlight = marker_df$symbol[1:4], pt.size = 1.5,
only_highlight = T, col_by_highlight = F)
#to change colour and size of highlighted markers use `highlight.pt.size` and `markers_highlight_cols`
jj_plot_volcano(marker_df, logfc_column = 'avg_log2FC', pval_column = 'p_val', symbol_column = 'symbol',
labs_range = c(-4, 4), marker_thres = Inf,
markers_highlight = marker_df$symbol[1:4], pt.size = 1.5, highlight.pt.size = 3,
only_highlight = F, col_by_highlight =T,
markers_highlight_col = structure(c('red','orange','red','blue'), names = marker_df$symbol[1:4])) + theme(legend.position='none')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.