plot_dimred() error: Must supply a symbol or a string as argument
Hi!
Thanks for developping of this awesome package! Could you help me to resolve the following error?
This is the code that I used and the error message that I receive:
dataset <- wrap_expression(
counts = t(ur_counts),
expression = t(ur_normalized)
) %>%
add_grouping(ur$seurat_clusters)
model <- infer_trajectory(dataset, "slingshot")
head(get_dimred(model), 5)
# comp_1 comp_2 comp_3
# AAACCCAAGTAGCTCT-1 6.274450 -2.478266 -0.4647137
# AAACCCACACCGAATT-1 -1.657088 3.400508 -4.0767709
# AAACCCATCACGTCCT-1 -3.980528 1.925050 -1.8245143
# AAACGAACACCTAAAC-1 3.819722 -3.118579 0.4000323
# AAACGAACAGAACCGA-1 -14.138137 5.310757 3.9100437
plot_dimred(model)
# Coloring by milestone
# Using milestone_percentages from trajectory
# Error: Must supply a symbol or a string as argument
# Run `rlang::last_error()` to see where the error occurred.
And further info:
rlang::last_error()
# <error/rlang_error>
# Must supply a symbol or a string as argument
# Backtrace:
# 1. dynplot::plot_dimred(model)
# 7. tidyr:::gather.data.frame(...)
# 10. tidyr:::ensym2(key)
# Run `rlang::last_trace()` to see the full context.
rlang::last_trace()
# <error/rlang_error>
# Must supply a symbol or a string as argument
# Backtrace:
# x
# 1. +-dynplot::plot_dimred(model)
# 2. | \-dynplot:::project_waypoints_coloured(...)
# 3. | \-`%>%`(...)
# 4. +-dplyr::summarise(...)
# 5. +-dplyr::group_by(., .data$from, .data$to, .data$comp_name)
# 6. +-tidyr::gather(., .data$comp_name, .data$comp_value, starts_with("comp_"))
# 7. \-tidyr:::gather.data.frame(...)
# 8. +-rlang::as_string(ensym2(key))
# 9. | \-rlang::is_string(x)
# 10. \-tidyr:::ensym2(key)
sessionInfo()
# R version 4.0.3 (2020-10-10)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows 10 x64 (build 19042)
...
# other attached packages:
# [1] shiny_1.6.0 dyno_0.1.2 dynwrap_1.2.2
# [4] dynplot_1.1.0 dynmethods_1.0.5 dynguidelines_1.0.1
# [7] dynfeature_1.0.0 ggplotify_0.0.5 ggbeeswarm_0.6.0
....
What can be wrong?
Best, Paweł
Hi Paweł!
Thanks for reporting this issue. It seems a small bug snuck into the code during the last release.
By installing the dynplot@devel branch, you should now be able to run the following code:
library(dyno)
library(tidyverse)
ur_counts <- matrix(runif(1000), nrow = 40)
rownames(ur_counts) <- paste0("cell_", seq_len(nrow(ur_counts)))
colnames(ur_counts) <- paste0("gene_", seq_len(ncol(ur_counts)))
ur_normalized <- ur_counts
ur <- list(seurat_clusters = round(ur_counts[,1]*10))
dataset <- wrap_expression(
counts = t(ur_counts),
expression = t(ur_normalized)
) %>%
add_grouping(ur$seurat_clusters)
model <- infer_trajectory(dataset, tislingshot::ti_slingshot())
head(get_dimred(model), 5)
plot_dimred(model)
Can you run devtools::install_github("dynverse/dynplot@devel") to confirm that it has been solved?
Kind regards, Robrecht
Yes, it works now. Thank you!
A am a little bit worried now about the trajectory detected in the data. Why is it so short?

Hi Pawel125,
I have the same issue with my data. The same code works well two weeks ago.
Nicolas
Hey Nicolas,
Can you provide me with a reproducible example?
Thanks Robrecht
On Sun, 27 Jun 2021, 11:44 n.GoFF, @.***> wrote:
Hi Pawel125,
I have the same issue with my data. The same code works well two weeks ago. [image: Capture] https://user-images.githubusercontent.com/25744843/123540009-f6968000-d73c-11eb-9b27-11fd04bf9e2d.PNG
Nicolas
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dynverse/dynplot/issues/54#issuecomment-869133778, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEHFKTQU2AY37PI64BDBCDTU3XHTANCNFSM47HTPOPA .
Hi Robrecht,
Here is the code,
dataset <- wrap_expression(
counts = X,
expression = X,
dimred_acp = dyndimred::dimred_pca(X))
model_paga <- infer_trajectory(
dataset = dataset,
method = dynmethods::ti_projected_paga(filter_features = FALSE,
n_neighbors =15L,
resolution = 1L,
embedding_type = "umap"),
verbose = FALSE)
plot_dimred(model_paga, grouping = group_onto_nearest_milestones(model_paga), label_milestones=TRUE)
I have just updated the packages dynmethods, dynplot,dyno with devtools::install_github("dynverse/dynplot") Moreover it seems that figures have a different appearance, less resolute.
R version 4.1.0 (2021-05-18) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252
[3] LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RColorBrewer_1.1-2 RCurl_1.98-1.3 knitr_1.33
[4] viridis_0.6.1 viridisLite_0.4.0 arrow_4.0.1
[7] feather_0.3.5 ggthemes_4.2.4 plot3D_1.4
[10] reshape_0.8.8 Matrix_1.3-4 svglite_2.0.0
[13] readxl_1.3.1 dyno_0.1.2 dynwrap_1.2.2
[16] dynplot_1.1.1 dynmethods_1.0.5.9000 dynguidelines_1.0.1
[19] dynfeature_1.0.0 forcats_0.5.1 stringr_1.4.0
[22] dplyr_1.0.6 purrr_0.3.4 readr_1.4.0
[25] tidyr_1.1.3 tibble_3.1.2 ggplot2_3.3.5
[28] tidyverse_1.3.1
loaded via a namespace (and not attached):
[1] uuid_0.1-4 backports_1.2.1 dyndimred_1.0.4
[4] systemfonts_1.0.2 babelwhale_1.0.3 plyr_1.8.6
[7] igraph_1.2.6 repr_1.1.3 proxyC_0.2.0
[10] usethis_2.0.1 digest_0.6.27 foreach_1.5.1
[13] htmltools_0.5.1.1 fansi_0.5.0 magrittr_2.0.1
[16] memoise_2.0.0 carrier_0.1.0 remotes_2.4.0
[19] graphlayouts_0.7.1 modelr_0.1.8 RcppParallel_5.1.4
[22] dynutils_1.0.6 prettyunits_1.1.1 colorspace_2.0-1
[25] rvest_1.0.0 ggrepel_0.9.1 haven_2.4.1
[28] xfun_0.24 tcltk_4.1.0 callr_3.7.0
[31] crayon_1.4.1 jsonlite_1.7.2 iterators_1.0.13
[34] glue_1.4.2 polyclip_1.10-0 gtable_0.3.0
[37] pkgbuild_1.2.0 dynparam_1.0.2 scales_1.1.1
[40] DBI_1.1.1 Rcpp_1.0.6 xtable_1.8-4
[43] bit_4.0.4 httr_1.4.2 ellipsis_0.3.2
[46] pkgconfig_2.0.3 farver_2.1.0 dbplyr_2.1.1
[49] utf8_1.2.1 labeling_0.4.2 tidyselect_1.1.1
[52] rlang_0.4.11 reshape2_1.4.4 later_1.2.0
[55] munsell_0.5.0 cellranger_1.1.0 tools_4.1.0
[58] cachem_1.0.5 cli_2.5.0 generics_0.1.0
[61] ranger_0.12.1 devtools_2.4.2 broom_0.7.7
[64] evaluate_0.14 fastmap_1.1.0 yaml_2.2.1
[67] processx_3.5.2 bit64_4.0.5 fs_1.5.0
[70] tidygraph_1.2.0 lmds_0.1.0 ggraph_2.0.5
[73] mime_0.10 GA_3.2.1 xml2_1.3.2
[76] hdf5r_1.3.3 compiler_4.1.0 rstudioapi_0.13
[79] curl_4.3.1 testthat_3.0.2 reprex_2.0.0
[82] tweenr_1.0.2 stringi_1.6.2 ps_1.6.0
[85] desc_1.3.0 lattice_0.20-44 IRdisplay_1.0
[88] vctrs_0.3.8 pillar_1.6.1 lifecycle_1.0.0
[91] bitops_1.0-7 irlba_2.3.3 httpuv_1.6.1
[94] patchwork_1.1.0.9000 R6_2.5.0 promises_1.2.0.1
[97] gridExtra_2.3 sessioninfo_1.1.1 codetools_0.2-18
[100] MASS_7.3-54 assertthat_0.2.1 pkgload_1.2.1
[103] rprojroot_2.0.2 withr_2.4.2 hms_1.1.0
[106] grid_4.1.0 IRkernel_1.2 misc3d_0.9-0
[109] pbdZMQ_0.3-5 ggforce_0.3.3 shiny_1.6.0
[112] lubridate_1.7.10 base64enc_0.1-3
Thanks
Nicolas
Hi @Bio-data-tricks @pawel125 ,
Can you try reinstalling dynplot? (devtools::install_github("dynverse/dynplot@devel")). The issue should have been resolved.
If you can confirm the issue has been solved, I'll submit an update for dynplot to CRAN.
Kind regards, Robrecht
Thank you Robrecht, issue solved !
Robrecht,
Have you an idea why I've a bad labels positioning in this umap embedding (doing after the paga trajectory inference) ?
Nicolas
Hi Robrecht,
I have the same issue. But no matter how I tried following your suggestions above, I cannot get the program run. The followings are my code, and could you please take a look?
I have tried with devtools::install_github("dynverse/dynplot@devel")
Thanks for your time
dat <- readRDS("mySeuratProject")
dataset <- wrap_expression(
counts = t(dat@assays$RNA@counts),
expression = t(dat@assays$RNA@data)
) %>%
add_grouping(dat$finClu)
guidelines <- guidelines_shiny(dataset)
methods_selected <- guidelines$methods_selected
model <- infer_trajectory(dataset, methods_selected[1])
model <- infer_trajectory(dataset, dynmethods::ti_slingshot())
plot_dimred(
model,
expression_source = dataset$expression,
grouping = dataset$grouping
)
# The outcome for both methods above have the same error:
Coloring by grouping
Error: Must supply a symbol or a string as argument
Run `rlang::last_error()` to see where the error occurred.
> rlang::last_error()
<error/rlang_error>
Must supply a symbol or a string as argument
Backtrace:
1. dynplot::plot_dimred(...)
7. tidyr:::gather.data.frame(...)
10. tidyr:::ensym2(key)
Run `rlang::last_trace()` to see the full context.
> rlang::last_trace()
<error/rlang_error>
Must supply a symbol or a string as argument
Backtrace:
x
1. +-dynplot::plot_dimred(...)
2. | \-dynplot:::project_waypoints_coloured(...)
3. | \-`%>%`(...)
4. +-dplyr::summarise(...)
5. +-dplyr::group_by(., .data$from, .data$to, .data$comp_name)
6. +-tidyr::gather(., .data$comp_name, .data$comp_value, starts_with("comp_"))
7. \-tidyr:::gather.data.frame(...)
8. +-rlang::as_string(ensym2(key))
9. | \-rlang::is_string(x)
10. \-tidyr:::ensym2(key)
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
Hi @rcannood. Thank you for such useful tools. Unfortunately, I have the same issue as @NaijIuc. I also installed the devtools::install_github("dynverse/dynplot@devel") and followed the example you have online. Thank you
Hi @rcannood. Thank you for such useful tools. Unfortunately, I have the same issue as @NaijIuc. I also installed the devtools::install_github("dynverse/dynplot@devel") and followed the example you have online. Thank you
You can try to change R version like 3.6, 4.05, 4.10 etc.. I have no clue why I finally can let it run, but I am highly doubting that is relevant to R version.
Hi @rcannood. Thank you for such useful tools. Unfortunately, I have the same issue as @NaijIuc. I also installed the devtools::install_github("dynverse/dynplot@devel") and followed the example you have online. Thank you
You can try to change R version like 3.6, 4.05, 4.10 etc.. I have no clue why I finally can let it run, but I am highly doubting that is relevant to R version.
Thanks you. Will try
I was getting the same error with my data and even with the example from quick-start. Updated to devel version of dynplot and still had the error. I restarted my R session and tried again and it worked. So those getting this error, try again in a clean environment. Probably a conflicting function somewhere.
You can run the short reproducible example below to be sure that it works and it's not your data or the version of dynplot.
library(dyno)
#> Loading required package: dynfeature
#> Loading required package: dynguidelines
#> Loading required package: dynmethods
#> Loading required package: dynplot
#> Loading required package: dynwrap
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
data("fibroblast_reprogramming_treutlein")
dataset <- wrap_expression(
counts = fibroblast_reprogramming_treutlein$counts,
expression = fibroblast_reprogramming_treutlein$expression
)
model <- infer_trajectory(dataset, "slingshot")
#> Loading required namespace: hdf5r
model <- model %>% add_dimred(dyndimred::dimred_mds, expression_source = dataset$expression)
plot_dimred(
model,
expression_source = dataset$expression,
grouping = fibroblast_reprogramming_treutlein$grouping
)
#> Coloring by grouping
#> Loading required namespace: RColorBrewer

Created on 2021-08-12 by the reprex package (v2.0.1)
Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.1.0 (2021-05-18)
#> os Ubuntu 20.04.2 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language en_GB:en
#> collate en_GB.UTF-8
#> ctype en_GB.UTF-8
#> tz Europe/Stockholm
#> date 2021-08-12
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.1.0)
#> babelwhale 1.0.3 2021-06-25 [1] CRAN (R 4.1.0)
#> bit 4.0.4 2020-08-04 [1] CRAN (R 4.1.0)
#> bit64 4.0.5 2020-08-30 [1] CRAN (R 4.1.0)
#> carrier 0.1.0 2018-10-16 [1] CRAN (R 4.1.0)
#> cli 3.0.1 2021-07-17 [1] CRAN (R 4.1.0)
#> codetools 0.2-18 2020-11-04 [1] CRAN (R 4.1.0)
#> colorspace 2.0-2 2021-06-24 [1] CRAN (R 4.1.0)
#> crayon 1.4.1 2021-02-08 [1] CRAN (R 4.1.0)
#> curl 4.3.2 2021-06-23 [1] CRAN (R 4.1.0)
#> DBI 1.1.1 2021-01-15 [1] CRAN (R 4.1.0)
#> desc 1.3.0 2021-03-05 [1] CRAN (R 4.1.0)
#> digest 0.6.27 2020-10-24 [1] CRAN (R 4.1.0)
#> dplyr * 1.0.7 2021-06-18 [1] CRAN (R 4.1.0)
#> dyndimred 1.0.4 2021-03-23 [1] CRAN (R 4.1.0)
#> dynfeature * 1.0.0 2021-08-12 [1] Github (dynverse/dynfeature@62981ce)
#> dynguidelines * 1.0.1 2021-08-12 [1] Github (dynverse/dynguidelines@57f2da7)
#> dynmethods * 1.0.5 2021-08-12 [1] Github (dynverse/dynmethods@53c6d1d)
#> dyno * 0.1.2 2021-08-12 [1] Github (dynverse/dyno@c461023)
#> dynparam 1.0.2 2021-01-04 [1] CRAN (R 4.1.0)
#> dynplot * 1.1.1 2021-08-12 [1] Github (dynverse/dynplot@8fff437)
#> dynutils 1.0.6 2021-03-22 [1] CRAN (R 4.1.0)
#> dynwrap * 1.2.2 2021-08-12 [1] Github (dynverse/dynwrap@250758b)
#> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.0)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 4.1.0)
#> fansi 0.5.0 2021-05-25 [1] CRAN (R 4.1.0)
#> farver 2.1.0 2021-02-28 [1] CRAN (R 4.1.0)
#> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.0)
#> foreach 1.5.1 2020-10-15 [1] CRAN (R 4.1.0)
#> fs 1.5.0 2020-07-31 [1] CRAN (R 4.1.0)
#> GA 3.2.1 2021-04-21 [1] CRAN (R 4.1.0)
#> generics 0.1.0 2020-10-31 [1] CRAN (R 4.1.0)
#> ggforce 0.3.3 2021-03-05 [1] CRAN (R 4.1.0)
#> ggplot2 3.3.5 2021-06-25 [1] CRAN (R 4.1.0)
#> ggraph 2.0.5 2021-02-23 [1] CRAN (R 4.1.0)
#> ggrepel 0.9.1 2021-01-15 [1] CRAN (R 4.1.0)
#> glue 1.4.2 2020-08-27 [1] CRAN (R 4.1.0)
#> graphlayouts 0.7.1 2020-10-26 [1] CRAN (R 4.1.0)
#> gridExtra 2.3 2017-09-09 [1] CRAN (R 4.1.0)
#> gtable 0.3.0 2019-03-25 [1] CRAN (R 4.1.0)
#> hdf5r 1.3.3 2020-08-18 [1] CRAN (R 4.1.0)
#> highr 0.9 2021-04-16 [1] CRAN (R 4.1.0)
#> hms 1.1.0 2021-05-17 [1] CRAN (R 4.1.0)
#> htmltools 0.5.1.1 2021-01-22 [1] CRAN (R 4.1.0)
#> httpuv 1.6.1 2021-05-07 [1] CRAN (R 4.1.0)
#> httr 1.4.2 2020-07-20 [1] CRAN (R 4.1.0)
#> igraph 1.2.6 2020-10-06 [1] CRAN (R 4.1.0)
#> irlba 2.3.3 2019-02-05 [1] CRAN (R 4.1.0)
#> iterators 1.0.13 2020-10-15 [1] CRAN (R 4.1.0)
#> knitr 1.33 2021-04-24 [1] CRAN (R 4.1.0)
#> labeling 0.4.2 2020-10-20 [1] CRAN (R 4.1.0)
#> later 1.2.0 2021-04-23 [1] CRAN (R 4.1.0)
#> lattice 0.20-44 2021-05-02 [1] CRAN (R 4.1.0)
#> lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.1.0)
#> lmds 0.1.0 2019-09-27 [1] CRAN (R 4.1.0)
#> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.1.0)
#> MASS 7.3-54 2021-05-03 [1] CRAN (R 4.1.0)
#> Matrix 1.3-4 2021-06-01 [1] CRAN (R 4.1.0)
#> mime 0.11 2021-06-23 [1] CRAN (R 4.1.0)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.1.0)
#> patchwork 1.1.1 2020-12-17 [1] CRAN (R 4.1.0)
#> pillar 1.6.2 2021-07-29 [1] CRAN (R 4.1.0)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.0)
#> plyr 1.8.6 2020-03-03 [1] CRAN (R 4.1.0)
#> polyclip 1.10-0 2019-03-14 [1] CRAN (R 4.1.0)
#> processx 3.5.2 2021-04-30 [1] CRAN (R 4.1.0)
#> promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.1.0)
#> proxyC 0.2.0 2021-05-11 [1] CRAN (R 4.1.0)
#> ps 1.6.0 2021-02-28 [1] CRAN (R 4.1.0)
#> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.1.0)
#> R6 2.5.0 2020-10-28 [1] CRAN (R 4.1.0)
#> ranger 0.13.1 2021-07-14 [1] CRAN (R 4.1.0)
#> RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 4.1.0)
#> Rcpp 1.0.7 2021-07-07 [1] CRAN (R 4.1.0)
#> RcppParallel 5.1.4 2021-05-04 [1] CRAN (R 4.1.0)
#> readr 2.0.1 2021-08-10 [1] CRAN (R 4.1.0)
#> remotes 2.4.0 2021-06-02 [1] CRAN (R 4.1.0)
#> reprex 2.0.1 2021-08-05 [1] CRAN (R 4.1.0)
#> reshape2 1.4.4 2020-04-09 [1] CRAN (R 4.1.0)
#> rlang 0.4.11 2021-04-30 [1] CRAN (R 4.1.0)
#> rmarkdown 2.10 2021-08-06 [1] CRAN (R 4.1.0)
#> rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.1.0)
#> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.0)
#> scales 1.1.1 2020-05-11 [1] CRAN (R 4.1.0)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.1.0)
#> shiny 1.6.0 2021-01-25 [1] CRAN (R 4.1.0)
#> stringi 1.7.3 2021-07-16 [1] CRAN (R 4.1.0)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.1.0)
#> tibble 3.1.3 2021-07-23 [1] CRAN (R 4.1.0)
#> tidygraph 1.2.0 2020-05-12 [1] CRAN (R 4.1.0)
#> tidyr 1.1.3 2021-03-03 [1] CRAN (R 4.1.0)
#> tidyselect 1.1.1 2021-04-30 [1] CRAN (R 4.1.0)
#> tweenr 1.0.2 2021-03-23 [1] CRAN (R 4.1.0)
#> tzdb 0.1.2 2021-07-20 [1] CRAN (R 4.1.0)
#> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.1.0)
#> vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.1.0)
#> viridis 0.6.1 2021-05-11 [1] CRAN (R 4.1.0)
#> viridisLite 0.4.0 2021-04-13 [1] CRAN (R 4.1.0)
#> withr 2.4.2 2021-04-18 [1] CRAN (R 4.1.0)
#> xfun 0.25 2021-08-06 [1] CRAN (R 4.1.0)
#> xml2 1.3.2 2020-04-23 [1] CRAN (R 4.1.0)
#> xtable 1.8-4 2019-04-21 [1] CRAN (R 4.1.0)
#> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.1.0)
#>
#> [1] /home/roy/miniconda3/envs/r-4.1/lib/R/library
Hi Everyone,
My figures have a different appearance, less resolute as described in the previous comments (with R4.0, R4.1, R3.5)
Have you an idea please ?
Nicolas