-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Objective
I'm currently making an upset plot where the size of all the intersections is one, but it's actually rather convenient because it allows me to use the intersection size plot almost as a key for another variable in my dataset (diet). However, I would ideally like to order the intersections so similar diets are next to each other, but I have so many columns that when I made an intersections list that accomplishes that goal to feed into 'intersections' I get an error "Error in rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) : invalid 'times' value", which according to google means the vector is too long for R to handle. Just wondering if there are any other solutions you can recommend? I'm really liking the look of my plot so far, but being able to order the intersections would take it to the next level!
Code
upset(data = Hajara_Up_Upset, intersect = ordered_intersection_cols, min_degree=1, sort_sets = FALSE,
sort_intersections = FALSE, intersections = intersection_list,
height_ratio = 6,
set_sizes=(
upset_set_size(
geom=geom_bar(
aes(fill=Diet, x=group), show.legend = FALSE,
width=0.8
))+
scale_fill_manual(values = diet_pal) + ylab('Number of diets with genus increased')),
base_annotations = list('Intersection size' = intersection_size(
counts = FALSE,
mapping = aes(fill = Diet)) +
scale_fill_manual(values = diet_pal) + theme(axis.text.y = element_blank(), panel.grid = element_blank()) +
ylab('') + guides(fill = guide_legend(ncol = 1))
), name = 'Taxa increased per diet',
guides='collect')
#intersection_list variable just for reference, but I have also tried this pasting the values manually into a form similar to the example on the wiki
>intersection_list
[[1]]
[1] "Agathobaculum" "Akkermansia" "Anaerostipes" "Bacteroides" "Butyricicoccus" "Butyrivibrio"
[7] "Catenibacterium" "Enterorhabdus" "Lachnoclostridium" "Oscillospira" "Roseburia" "Senegalimassilia"
[13] "Slackia" "Sphingobacterium" "Succinivibrio"
[[2]]
[1] "Blautia" "Caldicellulosiruptor" "Coprococcus" "Neisseria" "Weissella"
[[3]]
[1] "Proteobacteria" "Sutterella"
[[4]]
[1] "Anaerostipes" "Coprococcus" "Streptococcus"
[[5]]
[1] "Bifidobacterium" "Lachnospira" "Lactobacillus"
[[6]]
[1] "Butyricicoccus" "Faecalibacterium" "Lactonifactor"
[[7]]
[1] "Anaerostipes" "Bilophila" "Citrobacter" "Collinsella" "Escherichia/Shigella"
[6] "Gemella" "Lautropia" "Oscillospira" "Parabacteroides" "Synergistes"
[11] "Treponema"
[[8]]
[1] "Alistipes" "Bacteroides" "Bilophila" "Faecalibacterium" "Roseburia"
[[9]]
[1] "Alistipes" "Bacteroides"
[[10]]
[1] "Bacteroides" "Bifidobacterium"
[[11]]
[1] "Bilophila" "Desulfovibrio"
[[12]]
[1] "Faecalibaculum" "Gemella" "Lachnospiraceae_UCG-004" "Oscillibacter"
[5] "Pasteurellales" "Prevotella" "Ruminococcus"
[[13]]
[1] "Bacilli" "Christensenella" "Peptococcus" "Streptococcus"
[[14]]
[1] "Bacteroides"
[[15]]
[1] "Bilophila" "Butyrivibrio" "Dorea" "Lactobacillus" "Porphyromonas" "Veillonella"
[[16]]
[1] "Holdemania" "RuminococcaceaeUBA1819"
[[17]]
[1] "Eubacterium" "Roseburia"
[[18]]
[1] "Lactobacillus" "Lactococcus" "Streptococcus"
[[19]]
[1] "Bifidobacterium" "Blautia" "Clostridium" "Coprococcus" "Faecalibacterium" "Roseburia"
[[20]]
[1] "Blautia" "Faecalibacterium" "Lactococcus" "Mollicutes" "Prevotella"
[[21]]
[1] "Slackia"Context (required)
So essentially, the intersections end up being ordered in the same manner as the factor that they're coloured by. I understand this might be a niche use-case, but any help would be greatly appreciated.
ComplexUpset version: ‘1.3.3’
R version details
$platform
[1] "x86_64-apple-darwin20"
$arch
[1] "x86_64"
$os
[1] "darwin20"
$system
[1] "x86_64, darwin20"
$status
[1] ""
$major
[1] "4"
$minor
[1] "3.1"
$year
[1] "2023"
$month
[1] "06"
$day
[1] "16"
$`svn rev`
[1] "84548"
$language
[1] "R"
$version.string
[1] "R version 4.3.1 (2023-06-16)"
$nickname
[1] "Beagle Scouts"R session information
R version 4.3.1 (2023-06-16)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.2.1
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Australia/Melbourne
tzcode source: internal
attached base packages:
[1] grid tools stats4 stats graphics grDevices utils datasets methods base
other attached packages:
[1] RColorBrewer_1.1-3 cowplot_1.1.2 colorblindcheck_1.0.2 MetBrewer_0.2.0
[5] ComplexUpset_1.3.3 readxl_1.4.3 GGally_2.2.0 ComplexHeatmap_2.16.0
[9] propr_5.0.2 DirichletMultinomial_1.42.0 IRanges_2.36.0 S4Vectors_0.40.1
[13] BiocGenerics_0.48.1 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1
[17] dplyr_1.1.4 purrr_1.0.2 readr_2.1.5 tidyr_1.3.0
[21] tibble_3.2.1 ggplot2_3.4.4 tidyverse_2.0.0 vegan_2.6-4
[25] lattice_0.22-5 permute_0.9-7 compositions_2.0-7 codacore_0.0.4
loaded via a namespace (and not attached):
[1] tensorA_0.36.2.1 rstudioapi_0.15.0 jsonlite_1.8.8 shape_1.4.6
[5] magrittr_2.0.3 farver_2.1.1 rmarkdown_2.25 GlobalOptions_0.1.2
[9] zlibbioc_1.48.0 vctrs_0.6.5 multtest_2.58.0 Cairo_1.6-2
[13] RCurl_1.98-1.14 base64enc_0.1-3 progress_1.2.3 htmltools_0.5.7
[17] S4Arrays_1.2.0 cellranger_1.1.0 Rhdf5lib_1.22.1 SparseArray_1.2.2
[21] rhdf5_2.44.0 pROC_1.18.5 plyr_1.8.9 whisker_0.4.1
[25] igraph_1.6.0 lifecycle_1.0.4 iterators_1.0.14 pkgconfig_2.0.3
[29] Matrix_1.6-5 R6_2.5.1 fastmap_1.1.1 GenomeInfoDbData_1.2.11
[33] MatrixGenerics_1.14.0 clue_0.3-65 digest_0.6.34 colorspace_2.1-0
[37] patchwork_1.2.0 DESeq2_1.40.2 pkgload_1.3.3 GenomicRanges_1.54.1
[41] labeling_0.4.3 spacesXYZ_1.2-1 fansi_1.0.6 tfruns_1.5.1
[45] timechange_0.2.0 abind_1.4-5 mgcv_1.9-1 compiler_4.3.1
[49] microbenchmark_1.4.10 remotes_2.4.2.1 bit64_4.0.5 withr_2.5.2
[53] doParallel_1.0.17 BiocParallel_1.36.0 ggstats_0.5.1 tensorflow_2.14.0
[57] MASS_7.3-60.0.1 bayesm_3.1-6 DelayedArray_0.28.0 rjson_0.2.21
[61] biomformat_1.28.0 ape_5.7-1 glue_1.7.0 nlme_3.1-164
[65] rhdf5filters_1.12.1 Rtsne_0.17 keras_2.13.0 cluster_2.1.6
[69] reshape2_1.4.4 ade4_1.7-22 generics_0.1.3 gtable_0.3.4
[73] microbiome_1.22.0 tzdb_0.4.0 data.table_1.14.10 hms_1.1.3
[77] utf8_1.2.4 XVector_0.42.0 foreach_1.5.2 pillar_1.9.0
[81] vroom_1.6.5 robustbase_0.99-1 circlize_0.4.15 splines_4.3.1
[85] bit_4.0.5 renv_1.0.3 survival_3.5-7 tidyselect_1.2.0
[89] locfit_1.5-9.8 Biostrings_2.68.1 knitr_1.45 gridExtra_2.3
[93] phyloseq_1.46.0 SummarizedExperiment_1.32.0 xfun_0.41 Biobase_2.62.0
[97] matrixStats_1.2.0 DEoptimR_1.1-3 stringi_1.8.3 yaml_2.3.8
[101] evaluate_0.23 codetools_0.2-19 BiocManager_1.30.22 cli_3.6.2
[105] reticulate_1.34.0 munsell_0.5.0 Rcpp_1.0.12 GenomeInfoDb_1.38.1
[109] zeallot_0.1.0 png_0.1-8 parallel_4.3.1 prettyunits_1.2.0
[113] bitops_1.0-7 scales_1.3.0 crayon_1.5.2 GetoptLong_1.0.5
[117] rlang_1.1.3 