Getting started with scatterbars

knitr::opts_chunk$set(echo = TRUE)

Getting started with scatterbars

Below is how to use scatterbar from the provided spatial transcriptomic data from the mouse olfactory bulb tissue sample.

library(scatterbar)
data("mOB")

plot(mOB$xy)
head(mOB$data)

start.time <- Sys.time()
scatterbar::scatterbar(mOB$data, mOB$xy) + ggplot2::coord_fixed()
end.time <- Sys.time()
print(end.time - start.time)

We can change the order of how each bar is laid out by changing the order of the cell-type proportion matrix of spatial transcriptomic data. We can also combine scatterbar with other ggplot geoms and customization!

library(ggplot2)
start.time <- Sys.time()
scatterbar::scatterbar(mOB$data[, c(2,3,4,5,6,7,8,1)], mOB$xy, size_x = 1, size_y = 1, padding_x = 0.1, padding_y = 0.1) +
  geom_point(data=mOB$xy, mapping=aes(x=x, y=y)) +
  theme_bw() + ylab('y') + ggplot2::coord_fixed()
end.time <- Sys.time()
print(end.time - start.time)


Try the scatterbar package in your browser

Any scripts or data that you put into this service are public.

scatterbar documentation built on April 4, 2025, 5:23 a.m.