Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VolcanoPlot error with x_cutoff #7

Closed
tonypanx opened this issue Jan 9, 2025 · 10 comments
Closed

VolcanoPlot error with x_cutoff #7

tonypanx opened this issue Jan 9, 2025 · 10 comments

Comments

@tonypanx
Copy link

tonypanx commented Jan 9, 2025

I get this error when I set x_cutoff to any value other than 0:

Error in scale$guide == "none" : comparison (1) is possible only for atomic and list types

@pwwang
Copy link
Owner

pwwang commented Jan 10, 2025

Is this related to #8 ?

@tonypanx
Copy link
Author

#8 refers to the xlim, this issue refers to the x_cutoff line. I clarify what I mean in the other issue.

@pwwang
Copy link
Owner

pwwang commented Jan 13, 2025

Can you post a minimal and runnable code to reproduce?

@tonypanx
Copy link
Author

VolcanoPlot(markers, x = 'avg_log2FC', y = 'p_val_adj', x_cutoff = 1, label_size = 4, flip_negatives = F, y_cutoff = 10^-2, highlight_color = 'orange', pt_alpha = 0.8)

@pwwang
Copy link
Owner

pwwang commented Jan 13, 2025

Again, I can't reproduce it with the data from builtin examples:

set.seed(8525)
# Obtained by Seurat::FindMakers for the first cluster of pbmc_small
data <- data.frame(
   avg_log2FC = c(
     -3.69, -4.10, -2.68, -3.51, -3.09, -2.52, -3.53, -3.35, -2.82, -2.71, -3.16, -2.24,
     -5.62, -3.10, -3.42, -2.72, -3.23, -3.25, -4.68, 3.67, -2.66, 4.79, -2.99, 10.14,
     -1.78, -2.67, -2.26, -2.59, -3.39, 5.36, 4.56, 4.62, -2.94, -9.47, -9.12, -1.63,
     -2.77, 3.31, -1.53, -3.89, -4.21, 4.72, -2.98, -2.29, -1.41, -9.48, -4.30, 3.01,
     -1.19, -4.83, -1.35, -1.68, -1.63, -2.70, 3.86, 3.81, 7.23, -1.45, -0.92, -2.45,
     3.91, -4.45, -9.33, 3.56, 2.27, -1.60, -1.15, 11.40, -9.77, -8.32, 2.61, -1.25,
     -1.72, 10.61, 11.34, 10.02, 2.78, -3.48, -1.98, 5.86, 5.57, 4.57, 9.75, 9.97,
     10.90, 9.19, 2.93, 5.10, -1.52, -3.93, -1.95, -2.46, -0.64, 4.60, -1.82, -0.80,
     9.34, 7.51, 6.45, 5.23, 4.41, 3.60, -1.94, -1.15),
   p_val_adj = c(
     3.82e-09, 1.52e-07, 1.79e-07, 4.68e-07, 4.83e-07, 6.26e-07, 2.61e-06, 1.33e-05,
     1.79e-05, 3.71e-05, 5.21e-05, 5.36e-05, 5.83e-05, 6.66e-05, 8.22e-05, 2.89e-04,
     3.00e-04, 4.94e-04, 7.62e-04, 8.93e-04, 9.55e-04, 9.61e-04, 1.12e-03, 1.47e-03,
     1.66e-03, 1.95e-03, 2.06e-03, 3.01e-03, 3.26e-03, 4.35e-03, 4.85e-03, 5.12e-03,
     5.40e-03, 7.18e-03, 7.18e-03, 1.04e-02, 1.24e-02, 1.90e-02, 1.94e-02, 1.97e-02,
     2.09e-02, 2.13e-02, 2.25e-02, 2.61e-02, 3.18e-02, 3.27e-02, 3.69e-02, 3.80e-02,
     4.95e-02, 5.73e-02, 5.77e-02, 6.10e-02, 6.22e-02, 6.31e-02, 6.72e-02, 9.23e-02,
     9.85e-02, 1.06e-01, 1.07e-01, 1.11e-01, 1.31e-01, 1.38e-01, 1.40e-01, 1.43e-01,
     2.00e-01, 2.39e-01, 2.49e-01, 2.57e-01, 2.86e-01, 2.86e-01, 2.98e-01, 3.32e-01,
     4.15e-01, 4.91e-01, 4.91e-01, 4.91e-01, 5.97e-01, 7.11e-01, 7.59e-01, 8.38e-01,
     9.20e-01, 9.20e-01, 9.29e-01, 9.29e-01, 9.29e-01, 9.29e-01, 9.34e-01, 9.68e-01,
     1.00e+00, 1.00e+00, 1.00e+00, 1.00e+00, 1.00e+00, 1.00e+00, 1.00e+00, 1.00e+00,
     1.00e+00, 1.00e+00, 1.00e+00, 1.00e+00, 1.00e+00, 1.00e+00, 1.00e+00, 1.00e+00),
   gene = c(
     "HLA-DPB1", "LYZ", "HLA-DRA", "TYMP", "HLA-DPA1", "HLA-DRB1", "CST3", "HLA-DQB1",
     "HLA-DRB5", "LST1", "HLA-DQA1", "AIF1", "S100A8", "IFITM3", "HLA-DMB", "FCGRT",
     "SERPINA1", "IFI30", "S100A9", "CCL5", "GRN", "LCK", "HLA-DMA", "MS4A6A", "CTSS",
     "CFP", "FCN1", "BID", "CFD", "CD3D", "CD7", "CD3E", "LGALS2", "CD14", "SMCO4",
     "LINC00936", "HCK", "CTSW", "LGALS1", "HLA-DQA2", "LRRC25", "GZMM", "RNF130",
     "LGALS3", "S100A11", "C5AR1", "IL1B", "GZMA", "FCER1G", "MPEG1", "TYROBP", "TSPO",
     "GSTP1", "CTSB", "IL32", "CD247", "GNLY", "COTL1", "NFKBIA", "NUP214", "LAMP1",
     "FPR1", "CLEC10A", "CST7", "PRF1", "BLVRA", "PSAP", "GZMH", "EAF2", "ASGR1",
     "RARRES3", "SAT1", "LY86", "GP9", "TUBB1", "NGFRAP1", "XBP1", "SCO2", "RGS2", "GZMB",
     "HIST1H2AC", "KLRD1", "PGRMC1", "AKR1C3", "PTGDR", "IL2RB", "GYPC", "CCL4", "CD68",
     "FCER1A", "CD79B", "MS4A7", "CARD16", "ACAP1", "CD79A", "ANXA2", "TMEM40", "PF4",
     "GNG11", "CLU", "CD9", "FGFBP2", "TNFRSF1B", "IFI6"),
  pct_diff = c(
     -0.752, -0.457, -0.460, -0.671, -0.626, -0.701, -0.502, -0.619, -0.623, -0.598,
     -0.566, -0.626, -0.543, -0.566, -0.541, -0.542, -0.515, -0.489, -0.444, 0.428,
     -0.517, 0.461, -0.491, -0.410, -0.480, -0.491, -0.521, -0.491, -0.438, 0.411,
     0.411, 0.409, -0.438, -0.359, -0.359, -0.440, -0.386, 0.385, -0.332, -0.361, -0.361,
     0.364, -0.387, -0.415, -0.454, -0.308, -0.335, 0.364, -0.454, -0.309, -0.379, -0.427,
     -0.377, -0.389, 0.335, 0.315, 0.313, -0.284, -0.502, -0.309, 0.313, -0.284, -0.256,
     0.309, 0.313, -0.364, -0.406, 0.244, -0.231, -0.231, 0.281, -0.311, -0.312, 0.220,
     0.220, 0.220, 0.261, -0.232, -0.367, 0.240, 0.218, 0.218, 0.195, 0.195, 0.195, 0.195,
     0.262, 0.218, -0.288, -0.207, -0.290, -0.233, -0.367, 0.217, -0.233, -0.403, 0.171,
     0.194, 0.194, 0.194, 0.194, 0.213, -0.235, -0.292),
  group = sample(LETTERS[1:2], 104, replace = TRUE)
)
rownames(data) <- data$gene

VolcanoPlot(data, x = 'avg_log2FC', y = 'p_val_adj', x_cutoff = 1, label_size = 4,
    flip_negatives = F,  y_cutoff = 10^-2, highlight_color = 'orange', pt_alpha = 0.8)

image

@tonypanx
Copy link
Author

I tried to reproduce the example with the code provided but obtained the same error:

Error in scale$guide == "none" : comparison (1) is possible only for atomic and list types

Here is the error traceback and my session info:

12: isTRUE(scale$guide == "none")
11: FUN(X[[i]], ...)
10: lapply(scales, bump_aes_scale, new_aes = new_aes)
9: bump_aes_scales(plot$scales$scales, new_aes = object)
8: ggplot_add.new_aes(object, p, objectname)
7: ggplot_add(object, p, objectname)
6: add_ggplot(e1, e2, e2name)
5: +.gg(p, new_scale_color())
4: VolcanoPlotAtomic(datas[[nm]], x = x, y = y, ytrans = ytrans,
color_by = color_by, color_name = color_name, flip_negatives = flip_negatives,
x_cutoff = x_cutoff, y_cutoff = y_cutoff, x_cutoff_name = x_cutoff_name,
y_cutoff_name = y_cutoff_name, x_cutoff_color = x_cutoff_color,
y_cutoff_color = y_cutoff_color, x_cutoff_linetype = x_cutoff_linetype,
y_cutoff_linetype = y_cutoff_linetype, x_cutoff_linewidth = x_cutoff_linewidth,
y_cutoff_linewidth = y_cutoff_linewidth, pt_size = pt_size,
pt_alpha = pt_alpha, nlabel = nlabel, labels = labels, label_size = label_size,
label_fg = label_fg, label_bg = label_bg, label_bg_r = label_bg_r,
highlight = highlight, highlight_color = highlight_color,
highlight_size = highlight_size, highlight_alpha = highlight_alpha,
highlight_stroke = highlight_stroke, facet_by = facet_by,
facet_scales = facet_scales, facet_ncol = facet_ncol, facet_nrow = facet_nrow,
facet_byrow = facet_byrow, theme = theme, theme_args = theme_args,
palette = palette, palcolor = palcolor, title = title, subtitle = subtitle,
xlab = xlab, ylab = ylab, aspect.ratio = aspect.ratio, legend.position = legend.position,
legend.direction = legend.direction, seed = seed, ...)
3: FUN(X[[i]], ...)
2: lapply(names(datas), function(nm) {
default_title <- if (length(datas) == 1 && identical(nm,
"..."))
NULL
else nm
if (is.function(title)) {
title <- title(default_title)
}
else {
title <- title %||% default_title
}
VolcanoPlotAtomic(datas[[nm]], x = x, y = y, ytrans = ytrans,
color_by = color_by, color_name = color_name, flip_negatives = flip_negatives,
x_cutoff = x_cutoff, y_cutoff = y_cutoff, x_cutoff_name = x_cutoff_name,
y_cutoff_name = y_cutoff_name, x_cutoff_color = x_cutoff_color,
y_cutoff_color = y_cutoff_color, x_cutoff_linetype = x_cutoff_linetype,
y_cutoff_linetype = y_cutoff_linetype, x_cutoff_linewidth = x_cutoff_linewidth,
y_cutoff_linewidth = y_cutoff_linewidth, pt_size = pt_size,
pt_alpha = pt_alpha, nlabel = nlabel, labels = labels,
label_size = label_size, label_fg = label_fg, label_bg = label_bg,
label_bg_r = label_bg_r, highlight = highlight, highlight_color = highlight_color,
highlight_size = highlight_size, highlight_alpha = highlight_alpha,
highlight_stroke = highlight_stroke, facet_by = facet_by,
facet_scales = facet_scales, facet_ncol = facet_ncol,
facet_nrow = facet_nrow, facet_byrow = facet_byrow, theme = theme,
theme_args = theme_args, palette = palette, palcolor = palcolor,
title = title, subtitle = subtitle, xlab = xlab, ylab = ylab,
aspect.ratio = aspect.ratio, legend.position = legend.position,
legend.direction = legend.direction, seed = seed, ...)
})
1: VolcanoPlot(data, x = "avg_log2FC", y = "p_val_adj", x_cutoff = 1,
label_size = 4, flip_negatives = F, y_cutoff = 10^-2, highlight_color = "orange",
pt_alpha = 0.8)

version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux 8.4 (Ootpa)

Matrix products: default
BLAS/LAPACK: /software/openblas-0.3.13-el8-x86_64/lib/libopenblas_skylakexp-r0.3.13.so

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] scplotter_0.0.2 dplyr_1.1.4 plyr_1.8.9

loaded via a namespace (and not attached):
[1] tinytex_0.38 circlize_0.4.15 shape_1.4.6 spam_2.8-0 zoo_1.8-11 tidyselect_1.2.0 xfun_0.38
[8] purrr_1.0.1 listenv_0.8.0 lattice_0.20-45 colorspace_2.0-3 vctrs_0.6.5 generics_0.1.3 utf8_1.2.2
[15] rlang_1.1.4 gridtext_0.1.5 pillar_1.9.0 glue_1.6.2 sp_1.6-0 lifecycle_1.0.4 stringr_1.5.1
[22] dotCall64_1.0-1 munsell_0.5.0 gtable_0.3.0 progressr_0.10.0 future_1.25.0 GlobalOptions_0.1.2 codetools_0.2-18
[29] forcats_1.0.0 parallel_4.2.0 fansi_1.0.3 Rcpp_1.0.13 scales_1.3.0 showtext_0.9-7 plotthis_0.5.0
[36] sysfonts_0.8.9 parallelly_1.31.1 ggplot2_3.5.1 digest_0.6.29 stringi_1.8.3 showtextdb_3.0 ggrepel_0.9.3
[43] SeuratObject_5.0.1 grid_4.2.0 cowplot_1.1.1 cli_3.6.2 tools_4.2.0 magrittr_2.0.3 patchwork_1.2.0
[50] tibble_3.2.1 tidyr_1.3.0 future.apply_1.9.0 pkgconfig_2.0.3 Matrix_1.6-4 ggnewscale_0.4.8 xml2_1.3.3
[57] rstudioapi_0.14 R6_2.5.1 globals_0.14.0 ggtext_0.1.2 compiler_4.2.0

@pwwang
Copy link
Owner

pwwang commented Jan 14, 2025

scplotter_0.0.2 is way outdated. Try the latest version.

@tonypanx
Copy link
Author

I updated to scplotter 0.2.0, same issue.

@pwwang
Copy link
Owner

pwwang commented Jan 14, 2025

Maybe try to upgrade ggnewscale to 0.5.0.

I saw similar issues reported here.

@tonypanx
Copy link
Author

The update solved the issue, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants