arrange_as_polygon | R Documentation |
Arranges spatial observations by angle to the center in order to deal with them as a polygon. Works under the assumptions that observations are vertices of a polygon and that the outline of the tissue section is roughly circular.
arrange_as_polygon(input_df, use = "angle")
input_df |
Data.frame with at least two numeric variables named x and y. |
library(tidyverse)
object <- downloadPubExample("313_T")
pt_size <- getDefault(object, "pt_size")
outline_df <- getTissueOutlineDf(object, remove = FALSE)
print(outline_df)
plotSurface(outline_df, color_by = "outline")
outline_only <- filter(outline_df, outline)
print(outline_only)
plotSurface(object) +
geom_point_fixed(data = outline_only, mapping = aes(x = x, y = y), color = "red", size = pt_size)
# fails due to inadequate sorting of observations
plotSurface(object) +
geom_polygon(data = outline_only, mapping = aes(x = x, y = y), color = "red", alpha = 0.4)
# calculate (and arrange by) angle to center
outline_only_arr <- arrange_as_polygon(input_df = outline_only)
plotSurface(object) +
geom_point_fixed(
data = outline_only_arr,
mapping = aes(x = x, y = y, color = atc),
size = pt_size
)
# works
plotSurface(object) +
geom_polygon(data = outline_only_arr, mapping = aes(x = x, y = y), color = "red", alpha = 0.4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.