View source: R/view-composers.R
create_view | R Documentation |
Create a custom view from a data.frame
or a tibble
.
create_view(name, data, abbrev = name)
name |
Name of the view. A character vector. |
data |
A |
abbrev |
Abbreviated name. A character vector. |
Creating a custom view does not add it to the current view composition.
A new mistyR view. A list with a single name
d item described by
the provided abbrev
iation and data containing the provided
data
.
add_views()
for adding created views
to a view composition.
Other view composition functions:
add_juxtaview()
,
add_paraview()
,
add_views()
,
create_initial_view()
,
remove_views()
# Create a view from the mean expression of the 10 nearest neighbors of
# each cell.
library(dplyr)
library(purrr)
library(distances)
# 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)
# find the 10 nearest neighbors
neighbors <- nearest_neighbor_search(distances(as.matrix(pos)), k = 11)[-1, ]
# calculate the mean expression of the nearest neighbors for all markers
# for each cell in expr
nnexpr <- seq_len(nrow(expr)) %>%
map_dfr(~ expr %>%
slice(neighbors[, .x]) %>%
colMeans())
create_view("nearest", nnexpr, "nn")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.