add_juxtaview {mistyR} | R Documentation

## Generate and add a juxtaview to the current view composition

### Description

The juxtaview captures the expression of all markers within the immediate neighborhood of a spatial unit.

### Usage

    add_juxtaview(
      current.views,
      positions,
      neighbor.thr = 15,
      cached = FALSE,
      verbose = TRUE
    )

### Arguments

`current.views` | the current view composition.
`positions` | a `data.frame`, `tibble` or a `matrix` with named coordinates in columns and rows for each spatial unit ordered as in the intraview.
`neighbor.thr` | a threshold value used to indicate the largest distance between two spatial units that can be considered as neighboring.
`cached` | a `logical` indicating whether to cache the calculated view after the first calculation and to reuse a previously cached view if it already exists for this sample.
`verbose` | a `logical` controlling the verbosity of the output of the function during execution.

### Details

The neighborhood of each spatial unit is estimated by constructing a graph by 2D Delaunay triangulation following by removal of edges with length larger than `neighbor.thr`. For each spatial unit the juxtaview contains the sum of expressions across its estimated neighbors for each marker.

### Value

A mistyR view composition with added juxtaview.

### See Also

`create_initial_view()` for starting a view composition with an intraview only.

Other view composition functions: `add_paraview()`, `add_views()`, `create_initial_view()`, `create_view()`, `remove_views()`

### Examples

    # Create a view composition of an intraview and a juxtaview.

    library(dplyr)

    # get the expression data
    data("synthetic")
    expr <- synthetic[[1]] %>% select(-c(row, col, type))
    # get the coordinates for each cell
    pos <- synthetic[[1]] %>% select(row, col)

    # compose
    misty.views <- create_initial_view(expr) %>% add_juxtaview(pos, neighbor.thr = 1.5)

    # preview
    str(misty.views[["juxtaview.1.5"]])

[Package mistyR version 1.2.1 Index]