# Parallelize 'seriation' functions

+ =

The futurize package allows you to easily turn sequential code into parallel code by piping the sequential code to the `futurize()` function. Easy!

# TL;DR

    library(futurize)
    plan(multisession)
    library(seriation)

    o <- seriation::seriate_best(d_supreme) |> futurize()

# Introduction

The seriation package provides functions for ordering objects using seriation, ordination techniques for reordering matrices, dissimilarity matrices, and dendrograms.

## Example: Seriate best

Example adopted from `help("seriate_best", package = "seriation")`:

    library(futurize)
    plan(multisession)
    library(seriation)

    data(SupremeCourt)
    d_supreme <- as.dist(SupremeCourt)

    o <- seriate_best(d_supreme, criterion = "AR_events") |> futurize()
    print(o)

This will parallelize the computations, given that we have set up parallel workers, e.g.

    plan(multisession)

The built-in `multisession` backend parallelizes on your local computer and works on all operating systems. There are other parallel backends to choose from, including alternatives to parallelize locally as well as distributed across remote machines, e.g.

    plan(future.mirai::mirai_multisession)

and

    plan(future.batchtools::batchtools_slurm)

# Supported Functions

The following seriation functions are supported by `futurize()`:

- `seriate_best()`
- `seriate_rep()`