## -----------------------------------------------------------------------------
library(wompwomp)

set.seed(43)

## -----------------------------------------------------------------------------
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)

## -----------------------------------------------------------------------------
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)

## -----------------------------------------------------------------------------
clus_df_gather_tsp <- sort_to_uncross(clus_df_gather, cols = graphing_columns, wt = "value", method = "tsp")
print(clus_df_gather_tsp)

## -----------------------------------------------------------------------------
# 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)
# 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)

## -----------------------------------------------------------------------------
sessionInfo()

