### Install stable release of BadranSeq Source: https://github.com/wolf5996/badranseq/blob/main/README.md Installs the latest tagged version of the package using pak or devtools. ```r # pak (recommended) pak::pkg_install("wolf5996/BadranSeq@v1.3.1") # devtools devtools::install_github("wolf5996/BadranSeq", ref = "v1.3.1") ``` -------------------------------- ### Install development version of BadranSeq Source: https://github.com/wolf5996/badranseq/blob/main/README.md Installs the latest changes from the main branch, which may include unreleased features. ```r # pak pak::pkg_install("wolf5996/BadranSeq") # devtools devtools::install_github("wolf5996/BadranSeq") ``` -------------------------------- ### select_cells_interactive Source: https://context7.com/wolf5996/badranseq/llms.txt Launches a Shiny application for interactive cell selection. ```APIDOC ## select_cells_interactive ### Description Launches a Shiny application for interactive cell selection with additive/subtractive brush selection. ### Parameters - **object** (Seurat) - Required - The Seurat object. - **return_cells** (logical) - Optional - If TRUE, returns cell names; otherwise returns subsetted Seurat object. - **reduction** (string) - Optional - Reduction to use for plotting. - **color_by** (string) - Optional - Metadata column to color cells by. ``` -------------------------------- ### Create Publication-Ready UMAP Plots Source: https://context7.com/wolf5996/badranseq/llms.txt Use do_UmapPlot for UMAP visualization with enhanced aesthetics. It supports split-by conditions with silhouette backgrounds, cell borders, boxed labels, and automatic rasterization for large datasets. Requires the BadranSeq library. ```r library(BadranSeq) data(pbmc3k) # Basic UMAP plot with default styling p1 <- do_UmapPlot(pbmc3k) # Group by specific metadata column p2 <- do_UmapPlot(pbmc3k, group.by = "seurat_annotations") # Split by condition with silhouette background p3 <- do_UmapPlot(pbmc3k, split.by = "condition") # Customize appearance p4 <- do_UmapPlot( pbmc3k, group.by = "seurat_clusters", label = TRUE, label.size = 5, pt.size = 1.5, pt.alpha = 0.8, plot_cell_borders = TRUE, border.size = 2, border.color = "black", show.legend = TRUE, ncol = 2 # For split panels ) # Multiple grouping variables (returns patchwork) p5 <- do_UmapPlot(pbmc3k, group.by = c("seurat_clusters", "seurat_annotations")) ``` -------------------------------- ### Interactive Cell Selection Workflow Source: https://context7.com/wolf5996/badranseq/llms.txt Demonstrates a common workflow: interactively select cells, obtain their names, subset the Seurat object, and then perform downstream analysis like differential expression. ```r # Workflow: select cells, then analyze selected <- select_cells_interactive(pbmc3k, return_cells = TRUE) if (!is.null(selected)) { # Create subset pbmc_subset <- subset(pbmc3k, cells = selected) # Run differential expression markers <- Seurat::FindMarkers(pbmc3k, ident.1 = selected) } ``` -------------------------------- ### Interactive Cell Selection - Color by Metadata Source: https://context7.com/wolf5996/badranseq/llms.txt Launches the interactive cell selection tool, coloring cells in the visualization by a specified metadata column (e.g., 'seurat_annotations'). Aids in selecting cells based on biological groups. ```r # Color by specific metadata seu_subset <- select_cells_interactive( pbmc3k, reduction = "umap", color_by = "seurat_annotations" ) ``` -------------------------------- ### Create statistical violin plots Source: https://github.com/wolf5996/badranseq/blob/main/README.md Generates violin plots with integrated statistical testing using do_StatsViolinPlot. ```r do_StatsViolinPlot(pbmc3k, features = "CD3D", group.by = "seurat_annotations", group.levels = c("Naive CD4 T", "Memory CD4 T", "CD8 T")) ``` -------------------------------- ### Compare UMAP plots Source: https://github.com/wolf5996/badranseq/blob/main/README.md Demonstrates the visual difference between standard Seurat DimPlot and BadranSeq do_UmapPlot. ```r library(BadranSeq) library(Seurat) library(ggplot2) library(patchwork) data(pbmc3k) p1 <- DimPlot(pbmc3k, reduction = "umap") + ggtitle("Seurat::DimPlot()") p2 <- do_UmapPlot(pbmc3k) + ggtitle("BadranSeq::do_UmapPlot()") p1 + p2 ``` -------------------------------- ### Interactive Tools Source: https://github.com/wolf5996/badranseq/blob/main/NEWS.md Functions for interactive exploration of Seurat objects. ```APIDOC ## seurat_sleepwalk ### Description Launches an interactive sleepwalk session for exploring cell-to-cell distances in embedding space. ## select_cells_interactive ### Description Provides a Shiny app with brush selection for interactively selecting cells from embeddings. ``` -------------------------------- ### Generate split-panel UMAP plots Source: https://github.com/wolf5996/badranseq/blob/main/README.md Uses do_UmapPlot to render split-panel visualizations with grey silhouettes to preserve spatial context. ```r do_UmapPlot(pbmc3k, split.by = "condition") ``` -------------------------------- ### Fetch Cell Data with Metadata and PCA Source: https://context7.com/wolf5996/badranseq/llms.txt Fetches cell data including specified metadata columns and PCA reduction. Useful for integrating metadata with dimensionality reduction results. ```r df4 <- fetch_cell_data( pbmc3k, reductions = "pca", dims = 1:10, metadata = c("seurat_clusters", "condition") ) ``` -------------------------------- ### do_StatsViolinPlot Source: https://context7.com/wolf5996/badranseq/llms.txt Creates statistical violin plots using ggstatsplot for between-group comparisons with built-in Kruskal-Wallis tests and pairwise comparisons. ```APIDOC ## do_StatsViolinPlot ### Description Creates statistical violin plots for between-group comparisons with built-in Kruskal-Wallis tests and pairwise comparisons. Ideal for comparing gene expression across cell types or conditions. ### Parameters - **object** (Seurat) - Required - The Seurat object. - **features** (vector) - Required - Features to plot. - **group.by** (string) - Required - Metadata column to group by. - **group.levels** (vector) - Optional - Specific levels to include. - **ncol** (numeric) - Optional - Number of columns for multi-gene plots. - **type** (string) - Optional - Statistical test type ('parametric', 'nonparametric', 'robust', 'bayes'). - **p.adjust.method** (string) - Optional - Method for p-value adjustment. - **pairwise.display** (string) - Optional - Display mode for pairwise comparisons ('all', 'significant', 'none'). ``` -------------------------------- ### Interactive Cell Selection - Return Seurat Object Source: https://context7.com/wolf5996/badranseq/llms.txt Launches a Shiny application for interactive cell selection using brush tools. Returns a subsetted Seurat object based on the selected cells. ```r library(BadranSeq) data(pbmc3k) # Interactive selection, returns subsetted Seurat object seu_subset <- select_cells_interactive(pbmc3k) ``` -------------------------------- ### Compare PCA plots with variance annotation Source: https://github.com/wolf5996/badranseq/blob/main/README.md Shows how BadranSeq automatically computes and formats PCA variance labels on axes. ```r p1 <- DimPlot(pbmc3k, reduction = "pca") + ggtitle("Seurat::DimPlot(reduction = 'pca')") p2 <- do_PcaPlot(pbmc3k) + ggtitle("BadranSeq::do_PcaPlot()") p1 + p2 ``` -------------------------------- ### do_UmapPlot Source: https://context7.com/wolf5996/badranseq/llms.txt Creates a UMAP dimensionality reduction plot with publication-ready styling, including options for split panels with silhouette backgrounds, cell borders, boxed cluster labels, vivid colors, and automatic rasterization for large datasets. ```APIDOC ## do_UmapPlot ### Description Creates a UMAP dimensionality reduction plot with publication-ready styling. When `split.by` is used, shows each split category with a grey silhouette of all other cells in the background, preserving spatial context across panels. Features cell borders, boxed cluster labels, vivid colors, and automatic rasterization for large datasets. ### Method Not specified (assumed to be a function call within R) ### Endpoint N/A (R function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```r library(BadranSeq) data(pbmc3k) # Basic UMAP plot with default styling p1 <- do_UmapPlot(pbmc3k) # Group by specific metadata column p2 <- do_UmapPlot(pbmc3k, group.by = "seurat_annotations") # Split by condition with silhouette background p3 <- do_UmapPlot(pbmc3k, split.by = "condition") # Customize appearance p4 <- do_UmapPlot( pbmc3k, group.by = "seurat_clusters", label = TRUE, label.size = 5, pt.size = 1.5, pt.alpha = 0.8, plot_cell_borders = TRUE, border.size = 2, border.color = "black", show.legend = TRUE, ncol = 2 # For split panels ) # Multiple grouping variables (returns patchwork) p5 <- do_UmapPlot(pbmc3k, group.by = c("seurat_clusters", "seurat_annotations")) ``` ### Response #### Success Response (200) Returns a ggplot object representing the UMAP plot. #### Response Example (ggplot object, not directly representable as JSON) ``` -------------------------------- ### Interactive Cell Selection - Different Reduction Source: https://context7.com/wolf5996/badranseq/llms.txt Performs interactive cell selection using a specified reduction (e.g., 'pca') instead of the default 'umap'. Allows selection based on different embedding spaces. ```r # Use different reduction seu_subset <- select_cells_interactive(pbmc3k, reduction = "pca") ``` -------------------------------- ### Create Statistical Violin Plots with do_StatsViolinPlot Source: https://context7.com/wolf5996/badranseq/llms.txt Performs between-group statistical comparisons using ggstatsplot, supporting various test types and pairwise annotations. ```r library(BadranSeq) data(pbmc3k) # Basic statistical violin plot p1 <- do_StatsViolinPlot( pbmc3k, features = "CD3D", group.by = "seurat_annotations" ) # Compare specific clusters only p2 <- do_StatsViolinPlot( pbmc3k, features = "CD3D", group.by = "seurat_annotations", group.levels = c("Naive CD4 T", "Memory CD4 T", "CD8 T") ) # Multiple genes with patchwork composition p3 <- do_StatsViolinPlot( pbmc3k, features = c("CD3D", "CD8A"), group.by = "seurat_clusters", ncol = 2 ) # Customize statistical tests p4 <- do_StatsViolinPlot( pbmc3k, features = "CD3D", group.by = "condition", type = "parametric", # or "nonparametric", "robust", "bayes" p.adjust.method = "bonferroni", pairwise.display = "all" # or "significant", "none" ) # Hide pairwise brackets, keep omnibus test p5 <- do_StatsViolinPlot( pbmc3k, features = "CD3D", group.by = "seurat_annotations", pairwise.display = "none" ) ``` -------------------------------- ### Explore Embedding Distances with seurat_sleepwalk Source: https://context7.com/wolf5996/badranseq/llms.txt Launches the sleepwalk interactive explorer to visualize relationships between cell proximity in an embedding (default UMAP) and feature space (default PCA). ```r library(BadranSeq) data(pbmc3k) # Default: UMAP embedding, PCA features seurat_sleepwalk(pbmc3k) ``` -------------------------------- ### Create Sankey Diagrams with do_SankeyPlot Source: https://context7.com/wolf5996/badranseq/llms.txt Visualizes relationships between categorical metadata variables using alluvial flows. ```r library(BadranSeq) data(pbmc3k) # Two-way relationship: clusters to annotations p1 <- do_SankeyPlot( pbmc3k, columns = c("seurat_clusters", "seurat_annotations") ) # Three-way relationship p2 <- do_SankeyPlot( pbmc3k, columns = c("seurat_annotations", "condition", "Phase") ) # Customize label size p3 <- do_SankeyPlot( pbmc3k, columns = c("seurat_clusters", "seurat_annotations"), label.size = 4 ) ``` -------------------------------- ### do_ViolinPlot Source: https://context7.com/wolf5996/badranseq/llms.txt Creates publication-ready violin plots with optional boxplot overlay, jittered raw data points, and centrality markers. ```APIDOC ## do_ViolinPlot ### Description Creates publication-ready violin plots with optional boxplot overlay, jittered raw data points, and centrality markers (median/mean diamond with numeric label). Supports both gene expression and numeric metadata columns in the same plot. ### Parameters - **object** (Seurat) - Required - The Seurat object. - **features** (vector) - Required - Features (genes or metadata) to plot. - **group.by** (string) - Optional - Metadata column to group by. - **pt.size** (numeric) - Optional - Size of raw data points. - **pt.alpha** (numeric) - Optional - Alpha transparency of raw data points. - **violin.alpha** (numeric) - Optional - Alpha transparency of the violin plot. - **violin.width** (numeric) - Optional - Width of the violin plot. - **boxplot** (boolean) - Optional - Whether to include a boxplot overlay. - **boxplot.width** (numeric) - Optional - Width of the boxplot. - **centrality** (boolean) - Optional - Whether to include centrality markers. - **centrality.fn** (string) - Optional - Function to calculate centrality ('median' or 'mean'). ``` -------------------------------- ### Create Violin Plots with do_ViolinPlot Source: https://context7.com/wolf5996/badranseq/llms.txt Generates violin plots for gene expression or metadata with optional boxplot overlays and centrality markers. ```r library(BadranSeq) data(pbmc3k) # Single gene violin plot p1 <- do_ViolinPlot(pbmc3k, features = "CD3D") # Multiple genes p2 <- do_ViolinPlot(pbmc3k, features = c("CD3D", "CD8A", "CD14")) # Mix genes and metadata columns p3 <- do_ViolinPlot(pbmc3k, features = c("CD3D", "nCount_RNA", "percent.mt")) # Custom grouping and styling p4 <- do_ViolinPlot( pbmc3k, features = "CD3D", group.by = "seurat_annotations", pt.size = 2, pt.alpha = 0.3, violin.alpha = 0.3, violin.width = 0.6, boxplot = TRUE, boxplot.width = 0.2, centrality = TRUE, centrality.fn = "median" # or "mean" ) # Without boxplot and centrality markers p5 <- do_ViolinPlot( pbmc3k, features = "CD3D", boxplot = FALSE, centrality = FALSE ) ``` -------------------------------- ### Interactive Cell Selection - Return Cell Names Source: https://context7.com/wolf5996/badranseq/llms.txt Launches an interactive cell selection tool that returns only the character vector of selected cell names, rather than a subsetted Seurat object. ```r # Return cell names instead of Seurat object cell_names <- select_cells_interactive(pbmc3k, return_cells = TRUE) ``` -------------------------------- ### Custom ggplot2 Visualization with Fetched Cell Data Source: https://context7.com/wolf5996/badranseq/llms.txt Creates a custom ggplot2 scatter plot using fetched cell data, coloring points by 'seurat_clusters'. Requires the ggplot2 library and a 'theme_badranseq' theme. ```r library(ggplot2) df <- fetch_cell_data(pbmc3k, reductions = "umap") ggplot(df, aes(x = UMAP1, y = UMAP2, color = seurat_clusters)) + geom_point() + theme_badranseq() ``` -------------------------------- ### Visualisation Functions Source: https://github.com/wolf5996/badranseq/blob/main/NEWS.md Functions for generating publication-ready plots from Seurat objects. ```APIDOC ## do_DimPlot ### Description Provides a unified entry point for dimensionality reduction plots, routing to specialized handlers based on the reduction argument. ## do_UmapPlot ### Description Produces publication-ready UMAP plots with cell borders, boxed cluster labels, and a clean theme. ## do_PcaPlot ### Description Generates PCA plots with automatic variance-explained labels formatted as "PC1 (X.X%)". ## do_FeaturePlot ### Description Overlays gene expression on embeddings using a viridis color scale with cells ordered by expression. ## do_StatsViolinPlot ### Description Creates statistical violin plots using ggstatsplot::ggbetweenstats with Seurat-aware data extraction and nonparametric testing by default. ### Parameters - **group.levels** (vector) - Optional - Subset of groups to compare. - **pairwise.display** (boolean) - Optional - Controls bracket visibility. ``` -------------------------------- ### Create PCA Plots with Automatic Variance Labels Source: https://context7.com/wolf5996/badranseq/llms.txt Use do_PcaPlot to generate PCA plots with automatically computed and formatted variance explained percentages on axis labels. Supports split panels and custom grouping. Requires the BadranSeq library. ```r library(BadranSeq) data(pbmc3k) # Basic PCA plot with automatic variance labels p1 <- do_PcaPlot(pbmc3k) # Axes labeled as: "PC1 (12.5%)" and "PC2 (8.3%)" # Plot different PC dimensions p2 <- do_PcaPlot(pbmc3k, dims = c(2, 3)) # Group by metadata with custom variance precision p3 <- do_PcaPlot( pbmc3k, group.by = "seurat_annotations", variance_digits = 2, label = TRUE, label.size = 4 ) # Split panels with silhouette background p4 <- do_PcaPlot(pbmc3k, split.by = "condition", ncol = 2) # Custom colors custom_colors <- c("0" = "#E41A1C", "1" = "#377EB8", "2" = "#4DAF4A") p5 <- do_PcaPlot(pbmc3k, group.by = "seurat_clusters", colors.use = custom_colors) ``` -------------------------------- ### Combine theme_badranseq with Custom Colors Source: https://context7.com/wolf5996/badranseq/llms.txt Applies the BadranSeq theme and uses custom-defined colors for plot elements, ensuring both aesthetic consistency and specific color choices. ```r # Combine with BadranSeq colors colors <- generate_badranseq_colors(3) p4 <- ggplot(mtcars, aes(mpg, wt, color = factor(cyl))) + geom_point(size = 3) + scale_color_manual(values = colors) + theme_badranseq() ``` -------------------------------- ### do_SankeyPlot Source: https://context7.com/wolf5996/badranseq/llms.txt Creates a Sankey (alluvial) diagram showing relationships between 2-3 categorical metadata variables. ```APIDOC ## do_SankeyPlot ### Description Creates a Sankey (alluvial) diagram showing relationships between 2-3 categorical metadata variables. Each stratum is labeled and colored; flows connect cells across variables. ### Parameters - **object** (Seurat) - Required - The Seurat object. - **columns** (vector) - Required - Metadata columns to map (2-3 variables). - **label.size** (numeric) - Optional - Size of the labels. ``` -------------------------------- ### Generate BadranSeq Colors with Custom Override Source: https://context7.com/wolf5996/badranseq/llms.txt Generates a BadranSeq color palette, allowing for custom colors to be provided as an override. Useful for enforcing specific brand or experimental colors. ```r # Override with custom colors custom <- c("#E41A1C", "#377EB8", "#4DAF4A") colors <- generate_badranseq_colors(3, custom.colors = custom) ``` -------------------------------- ### Visualize metadata relationships with do_SankeyPlot Source: https://github.com/wolf5996/badranseq/blob/main/README.md Generates a Sankey diagram to visualize the distribution of cells across categorical metadata variables. ```r do_SankeyPlot(pbmc3k, columns = c("seurat_clusters", "seurat_annotations")) ``` -------------------------------- ### Create Feature Expression Plots Source: https://context7.com/wolf5996/badranseq/llms.txt Use do_FeaturePlot for visualizing gene expression on dimensionality reduction plots with viridis color scales and publication-ready styling. Supports multiple features, custom cutoffs, and split panels. Requires the BadranSeq library. ```r library(BadranSeq) data(pbmc3k) # Single gene expression p1 <- do_FeaturePlot(pbmc3k, features = "CD3D") # Multiple genes (returns patchwork) p2 <- do_FeaturePlot(pbmc3k, features = c("CD3D", "CD8A", "CD14", "MS4A1")) # Customize viridis palette and cutoffs p3 <- do_FeaturePlot( pbmc3k, features = "CD3D", viridis.palette = "C", # Options: A-H viridis.direction = -1, # Reverse scale min.cutoff = "q10", # 10th percentile max.cutoff = "q90", # 90th percentile order = TRUE # High values on top ) # PCA with variance labels p4 <- do_FeaturePlot(pbmc3k, features = "CD3D", reduction = "pca") # Split by condition p5 <- do_FeaturePlot( pbmc3k, features = c("CD3D", "CD14"), split.by = "condition", pt.size = 0.8, plot_cell_borders = TRUE, ncol = 2 ) ``` -------------------------------- ### do_DimPlot Source: https://context7.com/wolf5996/badranseq/llms.txt A unified wrapper for dimensionality reduction plots that routes to specialized functions for PCA and UMAP, while handling other reductions (harmony, tsne) directly. Provides a single entry point for all reduction types with consistent parameter handling. ```APIDOC ## do_DimPlot ### Description Unified wrapper for dimensionality reduction plots that routes to specialized functions for PCA and UMAP, while handling other reductions (harmony, tsne) directly. Provides a single entry point for all reduction types with consistent parameter handling. ### Method Not specified (assumed to be a function call within R) ### Endpoint N/A (R function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```r library(BadranSeq) data(pbmc3k) # UMAP (default) p1 <- do_DimPlot(pbmc3k) # PCA with automatic variance labels p2 <- do_DimPlot(pbmc3k, reduction = "pca") # Other reductions (harmony, tsne, etc.) p3 <- do_DimPlot(pbmc3k, reduction = "harmony") # Full customization p4 <- do_DimPlot( pbmc3k, reduction = "umap", dims = c(1, 2), group.by = "seurat_annotations", split.by = "condition", label = TRUE, label.box = TRUE, pt.size = 1, shuffle = TRUE, plot_cell_borders = TRUE, legend.title = "Cell Type", show.legend = TRUE ) ``` ### Response #### Success Response (200) Returns a ggplot object representing the dimensionality reduction plot. #### Response Example (ggplot object, not directly representable as JSON) ``` -------------------------------- ### Customize theme_badranseq with Base Font Size Source: https://context7.com/wolf5996/badranseq/llms.txt Applies the BadranSeq theme with a customized base font size. Useful for adjusting text legibility in plots. ```r # Customize base font size p2 <- ggplot(mtcars, aes(mpg, wt, color = factor(cyl))) + geom_point() + theme_badranseq(base_size = 16) ``` -------------------------------- ### Generate BadranSeq Color Palette Source: https://context7.com/wolf5996/badranseq/llms.txt Generates a categorical color palette matching SCpubr's default. Uses the 'Dark 3' colorspace with adjusted saturation and value for vivid colors. ```r library(BadranSeq) library(ggplot2) # Generate 5 colors colors <- generate_badranseq_colors(5) ``` -------------------------------- ### do_FeaturePlot Source: https://context7.com/wolf5996/badranseq/llms.txt Creates feature expression plots overlaid on dimensionality reductions with viridis color scales and publication-ready styling. Supports multiple features with automatic patchwork composition, expression cutoffs, and cell borders. ```APIDOC ## do_FeaturePlot ### Description Creates feature expression plots overlaid on dimensionality reductions with viridis color scales and publication-ready styling. Supports multiple features with automatic patchwork composition, expression cutoffs, and cell borders. ### Method Not specified (assumed to be a function call within R) ### Endpoint N/A (R function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```r library(BadranSeq) data(pbmc3k) # Single gene expression p1 <- do_FeaturePlot(pbmc3k, features = "CD3D") # Multiple genes (returns patchwork) p2 <- do_FeaturePlot(pbmc3k, features = c("CD3D", "CD8A", "CD14", "MS4A1")) # Customize viridis palette and cutoffs p3 <- do_FeaturePlot( pbmc3k, features = "CD3D", viridis.palette = "C", # Options: A-H viridis.direction = -1, # Reverse scale min.cutoff = "q10", # 10th percentile max.cutoff = "q90", # 90th percentile order = TRUE # High values on top ) # PCA with variance labels p4 <- do_FeaturePlot(pbmc3k, features = "CD3D", reduction = "pca") # Split by condition p5 <- do_FeaturePlot( pbmc3k, features = c("CD3D", "CD14"), split.by = "condition", pt.size = 0.8, plot_cell_borders = TRUE, ncol = 2 ) ``` ### Response #### Success Response (200) Returns a ggplot object representing the feature expression plot. #### Response Example (ggplot object, not directly representable as JSON) ``` -------------------------------- ### seurat_sleepwalk with UMAP Embedding and Harmony Features Source: https://context7.com/wolf5996/badranseq/llms.txt Visualizes cell relationships in a UMAP embedding based on distances in the 'harmony' feature space. Useful for exploring batch-corrected data structures. ```r # UMAP embedding with different feature reduction seurat_sleepwalk(pbmc3k, embedding = "umap", features = "harmony") ``` -------------------------------- ### theme_badranseq Source: https://context7.com/wolf5996/badranseq/llms.txt Applies a publication-ready ggplot2 theme to visualizations. ```APIDOC ## theme_badranseq ### Description Publication-ready theme function providing consistent SCpubr-like aesthetics. ### Parameters - **base_size** (numeric) - Optional - Base font size. - **plot.axes** (logical) - Optional - Whether to display axes. ``` -------------------------------- ### generate_badranseq_colors Source: https://context7.com/wolf5996/badranseq/llms.txt Generates a categorical color palette matching SCpubr's default palette. ```APIDOC ## generate_badranseq_colors ### Description Generates a categorical color palette using colorspace "Dark 3" with adjusted saturation and value. ### Parameters - **n** (numeric) - Required - Number of colors to generate. - **custom.colors** (vector) - Optional - Custom colors to override default palette. ``` -------------------------------- ### Unified Dimensionality Reduction Plotting Source: https://context7.com/wolf5996/badranseq/llms.txt Use do_DimPlot as a single entry point for UMAP, PCA, and other dimensionality reduction plots (harmony, tsne). It ensures consistent parameter handling across different reduction types. Requires the BadranSeq library. ```r library(BadranSeq) data(pbmc3k) # UMAP (default) p1 <- do_DimPlot(pbmc3k) # PCA with automatic variance labels p2 <- do_DimPlot(pbmc3k, reduction = "pca") # Other reductions (harmony, tsne, etc.) p3 <- do_DimPlot(pbmc3k, reduction = "harmony") # Full customization p4 <- do_DimPlot( pbmc3k, reduction = "umap", dims = c(1, 2), group.by = "seurat_annotations", split.by = "condition", label = TRUE, label.box = TRUE, pt.size = 1, shuffle = TRUE, plot_cell_borders = TRUE, legend.title = "Cell Type", show.legend = TRUE ) ``` -------------------------------- ### seurat_sleepwalk with PCA Embedding and Features Source: https://context7.com/wolf5996/badranseq/llms.txt Explores cell relationships using PCA as both the embedding space and the feature space. Useful for understanding structure within the primary components of variation. ```r # Explore PCA embedding with PCA features seurat_sleepwalk(pbmc3k, embedding = "pca", features = "pca") ``` -------------------------------- ### Custom ggplot2 Visualization with Fetched Feature Data Source: https://context7.com/wolf5996/badranseq/llms.txt Generates a custom ggplot2 scatter plot using fetched feature data, mapping gene expression ('data') to color on a UMAP embedding. Requires ggplot2 and theme_badranseq. ```r # Custom ggplot2 with fetched data library(ggplot2) df <- fetch_feature_data(pbmc3k, features = "CD3D", reductions = "umap") ggplot(df, aes(x = UMAP1, y = UMAP2, color = data)) + geom_point() + scale_color_viridis_c() + theme_badranseq() ``` -------------------------------- ### seurat_sleepwalk Source: https://context7.com/wolf5996/badranseq/llms.txt Wrapper for sleepwalk interactive embedding distance explorer. ```APIDOC ## seurat_sleepwalk ### Description Allows exploration of how cells that are close in the embedding relate to their distances in feature space. ### Parameters - **object** (Seurat) - Required - The Seurat object. - **embedding** (string) - Optional - Embedding to explore. - **features** (string) - Optional - Feature reduction to compare against. ``` -------------------------------- ### Fetch Feature Data - Normalized Expression Source: https://context7.com/wolf5996/badranseq/llms.txt Extracts normalized expression data for specified features in a tidy, long format. Requires the BadranSeq library and loaded data. ```r library(BadranSeq) data(pbmc3k) # Basic usage - normalized expression df1 <- fetch_feature_data(pbmc3k, features = c("CD3D", "CD8A")) ``` -------------------------------- ### Fetch Feature Data - Explicit Assay Source: https://context7.com/wolf5996/badranseq/llms.txt Extracts feature data from a specific assay (e.g., 'RNA') and layer ('counts'). Ensures data is retrieved from the intended source. ```r # Explicit assay df4 <- fetch_feature_data( pbmc3k, features = "CD3D", assay = "RNA", layer = "counts" ) ``` -------------------------------- ### do_PcaPlot Source: https://context7.com/wolf5996/badranseq/llms.txt Creates a PCA dimensionality reduction plot with variance explained percentages automatically added to axis labels. Supports the same silhouette split approach as UMAP plots and allows for custom colors. ```APIDOC ## do_PcaPlot ### Description Creates a PCA dimensionality reduction plot with variance explained percentages automatically added to axis labels. Computes and formats variance for each principal component without manual calculation. Supports the same silhouette split approach as UMAP plots. ### Method Not specified (assumed to be a function call within R) ### Endpoint N/A (R function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```r library(BadranSeq) data(pbmc3k) # Basic PCA plot with automatic variance labels p1 <- do_PcaPlot(pbmc3k) # Axes labeled as: "PC1 (12.5%)" and "PC2 (8.3%)" # Plot different PC dimensions p2 <- do_PcaPlot(pbmc3k, dims = c(2, 3)) # Group by metadata with custom variance precision p3 <- do_PcaPlot( pbmc3k, group.by = "seurat_annotations", variance_digits = 2, label = TRUE, label.size = 4 ) # Split panels with silhouette background p4 <- do_PcaPlot(pbmc3k, split.by = "condition", ncol = 2) # Custom colors custom_colors <- c("0" = "#E41A1C", "1" = "#377EB8", "2" = "#4DAF4A") p5 <- do_PcaPlot(pbmc3k, group.by = "seurat_clusters", colors.use = custom_colors) ``` ### Response #### Success Response (200) Returns a ggplot object representing the PCA plot. #### Response Example (ggplot object, not directly representable as JSON) ``` -------------------------------- ### Apply theme_badranseq to ggplot Source: https://context7.com/wolf5996/badranseq/llms.txt Applies the publication-ready BadranSeq theme to a standard ggplot2 plot. Ensures consistent aesthetics across visualizations. ```r library(BadranSeq) library(ggplot2) # Apply to any ggplot p1 <- ggplot(mtcars, aes(mpg, wt)) + geom_point() + theme_badranseq() ``` -------------------------------- ### Fetch Feature Data - Multiple Layers Source: https://context7.com/wolf5996/badranseq/llms.txt Extracts feature data for a single feature across multiple layers (e.g., counts and normalized data). Useful for comparing different data representations. ```r # Multiple layers (counts and normalized) df2 <- fetch_feature_data( pbmc3k, features = "CD3D", layer = c("counts", "data") ) ``` -------------------------------- ### Fetch Cell Data with fetch_cell_data Source: https://context7.com/wolf5996/badranseq/llms.txt Extracts cell metadata and dimensionality reduction embeddings into a tidy tibble format. ```r library(BadranSeq) data(pbmc3k) # All metadata, no embeddings df1 <- fetch_cell_data(pbmc3k) # With UMAP coordinates df2 <- fetch_cell_data(pbmc3k, reductions = "umap") # With multiple reductions df3 <- fetch_cell_data(pbmc3k, reductions = c("umap", "pca")) ``` -------------------------------- ### Fetch Cell Data without Metadata Source: https://context7.com/wolf5996/badranseq/llms.txt Fetches cell data including only cell IDs and embeddings, with metadata explicitly excluded. Use when only positional or embedding information is needed. ```r df5 <- fetch_cell_data(pbmc3k, reductions = "umap", metadata = FALSE) ``` -------------------------------- ### fetch_cell_data Source: https://context7.com/wolf5996/badranseq/llms.txt Extracts cell metadata and embedding coordinates into a tidy tibble for visualization. ```APIDOC ## fetch_cell_data ### Description Extracts cell metadata and embedding coordinates into a tidy tibble for visualization. ### Parameters - **object** (Seurat) - Required - The Seurat object to extract data from. - **reductions** (string) - Optional - The name of the reduction to include (e.g., "pca", "umap"). - **dims** (numeric) - Optional - Dimensions to include from the reduction. - **metadata** (vector/logical) - Optional - Metadata columns to include or FALSE to exclude all. ### Request Example fetch_cell_data(pbmc3k, reductions = "pca", dims = 1:10, metadata = c("seurat_clusters", "condition")) ``` -------------------------------- ### Fetch Feature Data with Embeddings and Metadata Source: https://context7.com/wolf5996/badranseq/llms.txt Extracts feature expression data along with UMAP embeddings and specified metadata. Useful for visualizing gene expression in the context of cell clusters and embeddings. ```r # With embeddings and specific metadata df3 <- fetch_feature_data( pbmc3k, features = c("CD3D", "CD14"), reductions = "umap", metadata = c("seurat_clusters", "condition") ) ``` -------------------------------- ### Data Extraction Functions Source: https://github.com/wolf5996/badranseq/blob/main/NEWS.md Functions for extracting data from Seurat objects into tidy tibble formats. ```APIDOC ## fetch_cell_data ### Description Extracts cell-level metadata and embeddings from Seurat objects as a tidy tibble. ## fetch_feature_data ### Description Extracts feature expression data as a tidy tibble with one row per cell per feature. ### Parameters - **assay** (string) - Optional - Explicit assay selection. - **layer** (string) - Optional - Explicit layer selection. ``` -------------------------------- ### Generate Enhanced Elbow Plots with EnhancedElbowPlot Source: https://context7.com/wolf5996/badranseq/llms.txt Provides an improved version of the Seurat ElbowPlot with additional aesthetic and variance-related customization options. ```r library(BadranSeq) data(pbmc3k) # Basic elbow plot with variance explained p1 <- EnhancedElbowPlot(pbmc3k) # Mark cutoff at specific PC p2 <- EnhancedElbowPlot(pbmc3k, cutoff_pc = 10) # Plot standard deviation instead of variance p3 <- EnhancedElbowPlot(pbmc3k, variance = FALSE) # Full customization p4 <- EnhancedElbowPlot( pbmc3k, ndims = 30, cutoff_pc = 15, variance = TRUE, title = "PCA Variance Explained", point_size = 4, point_color = "darkblue", line_color = "darkblue", cutoff_color = "red", base_size = 16 ) ``` -------------------------------- ### Customize theme_badranseq to Hide Axes Source: https://context7.com/wolf5996/badranseq/llms.txt Applies the BadranSeq theme while hiding the plot axes. Ideal for visualizations like cell embeddings where axes are not informative. ```r # Hide axes (useful for embeddings) p3 <- ggplot(mtcars, aes(mpg, wt)) + geom_point() + theme_badranseq(plot.axes = FALSE) ``` -------------------------------- ### EnhancedElbowPlot Source: https://context7.com/wolf5996/badranseq/llms.txt An improved version of Seurat's ElbowPlot with enhanced aesthetics and customizable options. ```APIDOC ## EnhancedElbowPlot ### Description An improved version of Seurat's ElbowPlot with enhanced aesthetics, customizable titles, optional cutoff lines, and variance explained options. ### Parameters - **object** (Seurat) - Required - The Seurat object. - **ndims** (numeric) - Optional - Number of dimensions to plot. - **cutoff_pc** (numeric) - Optional - PC number to draw a cutoff line. - **variance** (boolean) - Optional - Whether to plot variance explained instead of standard deviation. - **title** (string) - Optional - Plot title. - **point_size** (numeric) - Optional - Size of points. - **point_color** (string) - Optional - Color of points. - **line_color** (string) - Optional - Color of lines. - **cutoff_color** (string) - Optional - Color of the cutoff line. - **base_size** (numeric) - Optional - Base font size. ``` -------------------------------- ### Generate Named BadranSeq Color Vector Source: https://context7.com/wolf5996/badranseq/llms.txt Generates a BadranSeq color palette and assigns names to the colors, typically corresponding to cluster IDs. Essential for mapping specific colors to specific groups. ```r # Named color vector for specific groups n_clusters <- 8 cluster_colors <- generate_badranseq_colors(n_clusters) names(cluster_colors) <- as.character(0:(n_clusters - 1)) ``` -------------------------------- ### fetch_cell_data Source: https://context7.com/wolf5996/badranseq/llms.txt Extracts a tidy tibble with one row per cell containing cell identifiers, embeddings, and metadata. ```APIDOC ## fetch_cell_data ### Description Extracts a tidy tibble with one row per cell containing cell identifiers, optional dimensionality reduction embeddings, and optional metadata. ### Parameters - **object** (Seurat) - Required - The Seurat object. - **reductions** (vector) - Optional - Dimensionality reduction names to include. ``` -------------------------------- ### Extract PCA Variance with get_pca_variance Source: https://context7.com/wolf5996/badranseq/llms.txt Retrieves PCA variance metrics from a Seurat object as a data frame for programmatic analysis. ```r library(BadranSeq) data(pbmc3k) # Get all PCs variance_df <- get_pca_variance(pbmc3k) # Returns: PC, variance_explained, cumulative_variance # Get top 10 PCs top10 <- get_pca_variance(pbmc3k, n_pcs = 10) # Find PC where cumulative variance reaches 80% variance_df <- get_pca_variance(pbmc3k) pc_80 <- min(which(variance_df$cumulative_variance >= 80)) print(paste("80% variance at PC:", pc_80)) ``` -------------------------------- ### Use BadranSeq Colors with ggplot2 Source: https://context7.com/wolf5996/badranseq/llms.txt Applies a BadranSeq-generated color palette to a ggplot2 plot using scale_color_manual. Ensures consistent and publication-ready colors. ```r # Use with ggplot2 ggplot(mtcars, aes(mpg, wt, color = factor(cyl))) + geom_point(size = 3) + scale_color_manual(values = generate_badranseq_colors(3)) + theme_badranseq() ``` -------------------------------- ### fetch_feature_data Source: https://context7.com/wolf5996/badranseq/llms.txt Extracts a tidy tibble with one row per cell per feature in long format, including expression values and optional metadata. ```APIDOC ## fetch_feature_data ### Description Extracts a tidy tibble with one row per cell per feature in long format. Expression values are provided as one column per requested layer. ### Parameters - **object** (Seurat) - Required - The Seurat object. - **features** (vector) - Required - Features (genes) to extract. - **layer** (vector) - Optional - Layers to extract (e.g., "counts", "data"). - **reductions** (string) - Optional - Reduction to include. - **metadata** (vector) - Optional - Metadata columns to include. - **assay** (string) - Optional - Assay to use. ``` -------------------------------- ### get_pca_variance Source: https://context7.com/wolf5996/badranseq/llms.txt Helper function to extract variance explained information from a Seurat object as a data.frame. ```APIDOC ## get_pca_variance ### Description Extracts variance explained information from a Seurat object. Returns PC number, variance explained percentage, and cumulative variance. ### Parameters - **object** (Seurat) - Required - The Seurat object. - **n_pcs** (numeric) - Optional - Number of top PCs to return. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.