Quick Start: An Introduction to wompwomp

library(wompwomp)

set.seed(43)

We create a toy data frame that maps tissues (BRAIN, STOMACH, HEART, T CELL, B CELL) to clustering (1-4)

df <- data.frame(
    tissue = c(
        "BRAIN", "BRAIN", "BRAIN",
        "STOMACH", "STOMACH", "STOMACH", "STOMACH", "STOMACH", "STOMACH",
        "HEART", "HEART", "HEART", "HEART", "HEART", "HEART", "HEART",
        "T CELL", "T CELL",
        "B CELL", "B CELL", "B CELL", "B CELL", "B CELL", "B CELL", "B CELL", "B CELL", "B CELL"
    ),
    cluster = c(
        1, 1, 2,
        1, 2, 2, 2, 2, 2,
        1, 3, 3, 3, 3, 3, 3,
        4, 4,
        4, 4, 4, 4, 4, 4, 4, 4, 4
    )
)
graphing_columns <- c("tissue", "cluster")

# write.csv(df, file = "vignette_intro_df_ungrouped.csv", row.names = FALSE, quote = FALSE)
print(df)
##     tissue cluster
## 1    BRAIN       1
## 2    BRAIN       1
## 3    BRAIN       2
## 4  STOMACH       1
## 5  STOMACH       2
## 6  STOMACH       2
## 7  STOMACH       2
## 8  STOMACH       2
## 9  STOMACH       2
## 10   HEART       1
## 11   HEART       3
## 12   HEART       3
## 13   HEART       3
## 14   HEART       3
## 15   HEART       3
## 16   HEART       3
## 17  T CELL       4
## 18  T CELL       4
## 19  B CELL       4
## 20  B CELL       4
## 21  B CELL       4
## 22  B CELL       4
## 23  B CELL       4
## 24  B CELL       4
## 25  B CELL       4
## 26  B CELL       4
## 27  B CELL       4

Group by tissue and cluster, counting the values in a new column value

clus_df_gather <- prep_for_lodes(df, cols = graphing_columns)

# write.csv(clus_df_gather, file = "vignette_intro_df_grouped.csv", row.names = FALSE, quote = FALSE)
print(clus_df_gather)
## # A tibble: 8 × 3
##   tissue  cluster value
##   <chr>   <chr>   <int>
## 1 B CELL  4           9
## 2 BRAIN   1           2
## 3 BRAIN   2           1
## 4 HEART   1           1
## 5 HEART   3           6
## 6 STOMACH 1           1
## 7 STOMACH 2           5
## 8 T CELL  4           2
clus_df_gather_tsp <- sort_to_uncross(clus_df_gather, cols = graphing_columns, wt = "value", method = "tsp")
print(clus_df_gather_tsp)
## # A tibble: 8 × 3
##   tissue  cluster value
##   <fct>   <fct>   <int>
## 1 B CELL  4           9
## 2 BRAIN   1           2
## 3 BRAIN   2           1
## 4 HEART   1           1
## 5 HEART   3           6
## 6 STOMACH 1           1
## 7 STOMACH 2           5
## 8 T CELL  4           2
# clus_df_gather_tsp <- clus_df_gather_tsp
stratum_to_color_mapping <- get_lode_clusters(clus_df_gather_tsp, cols = graphing_columns, wt = "value", method = "advanced")
print(stratum_to_color_mapping)
## $cluster
## $cluster$`4`
## [1] 1
## 
## $cluster$`1`
## [1] 2
## 
## $cluster$`2`
## [1] 2
## 
## $cluster$`3`
## [1] 3
## 
## 
## $tissue
## $tissue$`B CELL`
## [1] 1
## 
## $tissue$BRAIN
## [1] 2
## 
## $tissue$HEART
## [1] 3
## 
## $tissue$STOMACH
## [1] 2
## 
## $tissue$`T CELL`
## [1] 1
# jsonlite::toJSON(stratum_to_color_mapping, pretty = TRUE, auto_unbox = TRUE)
crossing_edges_out <- compute_crossing_objective(clus_df_gather_tsp, cols = graphing_columns, wt = "value")
print(crossing_edges_out$output_objective)
## [1] 1
sessionInfo()
## R version 4.6.1 (2026-06-24)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 26.04.1 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so;  LAPACK version 3.12.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: Etc/UTC
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] wompwomp_1.0.0    ggalluvial_0.12.6 ggplot2_4.0.3     dplyr_1.2.1      
## [5] rmarkdown_2.32   
## 
## loaded via a namespace (and not attached):
##  [1] sass_0.4.10        utf8_1.2.6         generics_0.1.4     tidyr_1.3.2       
##  [5] stringi_1.8.9      digest_0.6.39      magrittr_2.0.5     evaluate_1.0.5    
##  [9] grid_4.6.1         RColorBrewer_1.1-3 iterators_1.0.14   fastmap_1.2.0     
## [13] foreach_1.5.2      jsonlite_2.0.0     purrr_1.2.2        scales_1.4.0      
## [17] tweenr_2.0.3       codetools_0.2-20   jquerylib_0.1.4    cli_3.6.6         
## [21] rlang_1.3.0        polyclip_1.10-7    withr_3.0.3        cachem_1.1.0      
## [25] yaml_2.3.12        otel_0.2.0         tools_4.6.1        buildtools_1.0.0  
## [29] vctrs_0.7.3        TSP_1.2.7          R6_2.6.1           lifecycle_1.0.5   
## [33] stringr_1.6.0      MASS_7.3-66        pkgconfig_2.0.3    pillar_1.11.1     
## [37] bslib_0.12.0       gtable_0.3.6       glue_1.8.1         Rcpp_1.1.2        
## [41] ggforce_0.5.0      xfun_0.62          tibble_3.3.1       tidyselect_1.2.1  
## [45] sys_3.4.3          knitr_1.52         farver_2.1.2       htmltools_0.5.9   
## [49] igraph_2.3.4       maketools_1.3.2    labeling_0.4.3     compiler_4.6.1    
## [53] S7_0.2.2