Title: | Scattered Stacked Bar Chart Plots |
---|---|
Description: | Provides a powerful and flexible tool for visualizing proportional data across spatially resolved contexts. By combining the concepts of scatter plots and stacked bar charts, 'scatterbar' allows users to create scattered bar chart plots, which effectively display the proportions of different categories at each (x, y) location. This visualization is particularly useful for applications where understanding the distribution of categories across spatial coordinates is essential. This package features automatic determination of optimal scaling factors based on data, customizable scaling and padding options for both x and y axes, flexibility to specify custom colors for each category, options to customize the legend title, and integration with 'ggplot2' for robust and high-quality visualizations. For more details, see Velazquez et al. (2024) <doi:10.1101/2024.08.14.606810>. |
Authors: | Dee Velazquez [aut, cre] , Jean Fan [aut, rev] |
Maintainer: | Dee Velazquez <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0 |
Built: | 2024-11-25 19:33:19 UTC |
Source: | CRAN |
Deconvolved cell-type proportions from STdeconvolve for a Visium data from the adult mouse brain along with the positions of their respective spots
data(adult_mouse_brain_ffpe)
data(adult_mouse_brain_ffpe)
A list of 2 objects, each of 2264 rows and 2 columns: prop, which contains the 12 deconvolved cell-types proportions for each 2264 spots/pixels in a spatial transcriptomics experiment performed on adult mouse brain tissue tissue and pos, which contains the x and y-coordinates for each 2264 spots/pixels on an adult mouse brain tissue slide.
https://www.10xgenomics.com/datasets/adult-mouse-brain-ffpe-1-standard-1-3-0
Deconvolved cell-type proportions from STdeconvolve for a Spatial Transcriptomic dataset of the mouse olfactory bulb along with the positions of their respective spots
data(mOB)
data(mOB)
A list of 2 objects, each of 260 rows and 2 columns: data, which contains the 8 deconvolved cell-types proportions for each 260 spots/pixels in a spatial transcriptomics experiment performed on mouse olfactory bulb tissue and xy, which contains the x and y-coordinates for each 260 spots/pixels on a mouse olfactory bulb tissue slide.
https://www.science.org/doi/10.1126/science.aaf2403
This function creates a scatterbar plot using ggplot2, where the bars are stacked based on the different proportions of groups in each 2-D location/spot. A scatterbar plot is a combination of a scatter plot and a stacked bar chart, allowing for the visualization of proportional data across spatial coordinates. The function allows for customized scaling factors and padding when creating the plot. If no scaling factors are specified, the function automatically determines the optimal scaling factors based on the data.
scatterbar( data, xy, size_x = NULL, size_y = NULL, padding_x = 0, padding_y = 0, show_legend = TRUE, legend_title = "Group", colors = NULL, verbose = TRUE )
scatterbar( data, xy, size_x = NULL, size_y = NULL, padding_x = 0, padding_y = 0, show_legend = TRUE, legend_title = "Group", colors = NULL, verbose = TRUE )
data |
A data frame containing the proportions of different categories for each location. Each row represents a location, and each column (except the row names) represents a category. |
xy |
A data frame containing the positional information for each location. This data frame includes the x and y coordinates for each location/spot (the respective row names). |
size_x |
X-axis scaling factor (default is NULL). If not provided, it will be automatically calculated based on the data. |
size_y |
Y-axis scaling factor (default is NULL). If not provided, it will be automatically calculated based on the data. |
padding_x |
Padding for x-axis (default is 0). |
padding_y |
Padding for y-axis (default is 0). |
show_legend |
Boolean indicating whether to display the plot legend (default is TRUE). |
legend_title |
Custom title for the legend (default is "Group"). |
colors |
Optional vector of colors to use for each category (default is NULL). If not provided, a default palette will be used. |
verbose |
Boolean indicating whether to print the calculated scaling and padding values (default is TRUE). |
A ggplot object representing the scattered stacked bar chart plot.
data(mOB) scatterbar(mOB$data, mOB$xy, padding_x = 0.3, padding_y = 0.3, legend_title = "Cell Types") data(adult_mouse_brain_ffpe) scatterbar( adult_mouse_brain_ffpe$prop, adult_mouse_brain_ffpe$pos, size_x = 220, size_y = 220, legend_title = "Cell Types")
data(mOB) scatterbar(mOB$data, mOB$xy, padding_x = 0.3, padding_y = 0.3, legend_title = "Cell Types") data(adult_mouse_brain_ffpe) scatterbar( adult_mouse_brain_ffpe$prop, adult_mouse_brain_ffpe$pos, size_x = 220, size_y = 220, legend_title = "Cell Types")