Skip to contents

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,
  prefix = "",
  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.

prefix

a prefix to add to the column names.

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.

Value

A mistyR view composition with added juxtaview.

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.

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)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union

# 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)
#> 
#> Computing triangulation
#> 
#> Generating juxtaview

# preview
str(misty.views[["juxtaview.1.5"]])
#> List of 2
#>  $ abbrev: chr "juxta.1.5"
#>  $ data  :'data.frame':	4205 obs. of  11 variables:
#>   ..$ ECM  : num [1:4205] 0.116 0.105 1.395 1.315 1.395 ...
#>   ..$ ligA : num [1:4205] 1.3988 0.0653 0.5141 0.965 0.5141 ...
#>   ..$ ligB : num [1:4205] 0.0394 0.0188 0.0629 0.1578 0.0629 ...
#>   ..$ ligC : num [1:4205] 0.53 0.856 0.825 0.89 0.825 ...
#>   ..$ ligD : num [1:4205] 1.9261 0.0577 0.4646 0.8604 0.4646 ...
#>   ..$ protE: num [1:4205] 0.779 0 1.617 3.286 1.617 ...
#>   ..$ protF: num [1:4205] 4.31 0.25 0.988 1.851 0.988 ...
#>   ..$ prodA: num [1:4205] 0.455 0 0 0.472 0 ...
#>   ..$ prodB: num [1:4205] 0 0 0 0.16 0 ...
#>   ..$ prodC: num [1:4205] 0.433 0.548 0.418 0 0.418 ...
#>   ..$ prodD: num [1:4205] 0.536 0 0 0.379 0 ...