### Install SCpubr from GitHub (Development Version) Source: https://enblacar.github.io/SCpubr-book/00_getting_started/01_installation.html Install the latest stable development version of SCpubr directly from GitHub. Ensure the 'devtools' package is installed first. ```r # If not installed. if(!requireNamespace("devtools", quietly = TRUE)){ install.packages("devtools") } devtools::install_github("enblacar/SCpubr", ref = "v3.0.0") ``` -------------------------------- ### Check SCpubr Dependencies and Function Availability Source: https://enblacar.github.io/SCpubr-book/00_getting_started/01_installation.html Run this function to get a detailed report on your installed dependencies, their status, and which SCpubr functions are ready to use. It also flags outdated packages. ```r SCpubr::do_PackageReport(extended = TRUE) ``` -------------------------------- ### Compute TF activities with decoupleR Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/03_tfactivityheatmap.html Before generating the heatmap, compute TF activities using decoupleR. This example shows how to get the DoRothEA prior knowledge for humans and run the weighted mean activity calculation. ```r # Run decoupleR with DoRothEA prior knowledge net <- decoupleR::get_dorothea(organism = "human", levels = c("A", "B", "C")) activities <- decoupleR::run_wmean(mat = as.matrix(sample["RNA"]$data), net = net) ``` -------------------------------- ### Install SCpubr from CRAN Source: https://enblacar.github.io/SCpubr-book/00_getting_started/01_installation.html Use this command to install the latest official release of SCpubr from the Comprehensive R Archive Network (CRAN). ```r install.packages("SCpubr") ``` -------------------------------- ### Select Specific PCs for Loadings Heatmap Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/10_loadingsheatmap.html This example demonstrates how to select specific principal components (PCs) to display in the loadings heatmap using the 'dims' argument. ```r p <- SCpubr::do_LoadingsHeatmap(sample = sample, dims = 1:2) p ``` -------------------------------- ### Basic Ligand-Receptor Plot Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/09_ligandreceptorplot.html Generates a basic dot plot of ligand-receptor interactions after running liana. Ensure liana is installed and the output is aggregated. ```r liana_output <- liana::liana_wrap(sample) %>% liana::liana_aggregate() p <- SCpubr::do_LigandReceptorPlot(liana_output = liana_output) p ``` -------------------------------- ### Group Loadings Heatmap by Cell Type Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/10_loadingsheatmap.html This example demonstrates grouping the loadings heatmap by a specific metadata column, such as 'subtype', using the 'group.by' argument. ```r p <- SCpubr::do_LoadingsHeatmap(sample = sample, group.by = "subtype") p ``` -------------------------------- ### Get SCpubr Package Version and Citation in R Source: https://enblacar.github.io/SCpubr-book/07_appendix/01_citation.html Use these R commands to retrieve the package version and citation information programmatically. ```r citation("SCpubr") packageVersion("SCpubr") ``` -------------------------------- ### Basic Package Report Source: https://enblacar.github.io/SCpubr-book/06_accessories/05_packagereport.html Generates a basic status report for SCpubr and its dependencies. Use this for a quick overview of installed packages and available functions. ```r SCpubr::do_PackageReport() ``` -------------------------------- ### Adjust Color Scales for Loadings and Expression Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/10_loadingsheatmap.html This example demonstrates how to adjust the color scales for both the loadings scores and gene expression levels using cutoff parameters. ```r p <- SCpubr::do_LoadingsHeatmap(sample = sample, min.cutoff.loadings = -0.1, max.cutoff.loadings = 0.1, min.cutoff.expression = 0, max.cutoff.expression = 3) p ``` -------------------------------- ### do_ColorPalette() - Color Palette Generation Source: https://enblacar.github.io/SCpubr-book/06_accessories/01_colorpalette.html This utility function generates harmonious color palettes based on color theory principles. Provide a base color and get complementary, triadic, tetradic, or other color schemes. ```APIDOC ## do_ColorPalette() ### Description Generates harmonious color palettes based on color theory principles. This function can produce various color schemes like complementary, triadic, tetradic, square, and split complementary, or evenly spaced colors around a color wheel. ### Method `SCpubr::do_ColorPalette()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Examples #### Color Wheel ```R colors <- SCpubr::do_ColorPalette(colors.use = "#E63946", n = 8) print(colors) ``` #### Opposite (Complementary) ```R colors <- SCpubr::do_ColorPalette(colors.use = "#E63946", opposite = TRUE) print(colors) ``` #### Adjacent Colors ```R colors <- SCpubr::do_ColorPalette(colors.use = "#E63946", adjacent = TRUE) print(colors) ``` #### Triadic Scheme ```R colors <- SCpubr::do_ColorPalette(colors.use = "#E63946", triadic = TRUE) print(colors) ``` #### Tetradic Scheme ```R colors <- SCpubr::do_ColorPalette(colors.use = "#E63946", tetradic = TRUE) print(colors) ``` #### Square Scheme ```R colors <- SCpubr::do_ColorPalette(colors.use = "#E63946", square = TRUE) print(colors) ``` #### Split Complementary ```R colors <- SCpubr::do_ColorPalette(colors.use = "#E63946", split_complementary = TRUE) print(colors) ``` #### Generate Plot ```R p <- SCpubr::do_ColorPalette(colors.use = "#E63946", triadic = TRUE, plot = TRUE) print(p) ``` ### Parameter Reference * `colors.use` (character or HEX) - Base color (name or HEX). Default is not specified, but examples use HEX. * `n` (integer) - Number of colors to generate for the color wheel. Default is `12`. * `opposite` (boolean) - If TRUE, generates the complementary color. Default is `FALSE`. * `adjacent` (boolean) - If TRUE, generates adjacent colors. Default is `FALSE`. * `triadic` (boolean) - If TRUE, generates a triadic color scheme. Default is `FALSE`. * `split_complementary` (boolean) - If TRUE, generates a split complementary color scheme. Default is `FALSE`. * `tetradic` (boolean) - If TRUE, generates a tetradic color scheme. Default is `FALSE`. * `square` (boolean) - If TRUE, generates a square color scheme. Default is `FALSE`. * `plot` (boolean) - If TRUE, returns a plot object. Default is `FALSE`. ### See Also * `do_ColorBlindCheck()` — Test accessibility * `Shared features` — Color scales ``` -------------------------------- ### Clamp Expression Values in DotPlot Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/04_dotplot.html Set the minimum and maximum expression values to display using `min.cutoff` and `max.cutoff`. This example clamps expression values between 0 and 3. ```R p <- SCpubr::do_DotPlot(sample = sample, features = genes, min.cutoff = 0, max.cutoff = 3) p__ ``` -------------------------------- ### Adjust Dot Size in DotPlot Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/04_dotplot.html Control the maximum size of the dots using the `dot.scale` parameter. This example sets the maximum dot size to 12. ```R p <- SCpubr::do_DotPlot(sample = sample, features = genes, dot.scale = 12) p__ ``` -------------------------------- ### Chord Diagram Plot with Custom Arrow Type Source: https://enblacar.github.io/SCpubr-book/03_proportions/04_chorddiagramplot.html Sets a custom arrow type for the links in a chord diagram, using 'triangle' as an example. ```R p <- SCpubr::do_ChordDiagramPlot(sample = sample, from = "Annotation", to = "subtype", link.arr.type = "triangle") p__ ``` -------------------------------- ### Load necessary packages and perform enrichment analysis Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/06_termenrichmentplot.html This snippet demonstrates how to load required packages and perform GO enrichment analysis using `clusterProfiler`. The results are then passed to `do_TermEnrichmentPlot` for visualization. ```R Loading required package: AnnotationDbi Loading required package: stats4 Loading required package: BiocGenerics Loading required package: generics Attaching package: 'generics' The following objects are masked from 'package:base': as.difftime, as.factor, as.ordered, intersect, is.element, setdiff, setequal, union Attaching package: 'BiocGenerics' The following objects are masked from 'package:stats': IQR, mad, sd, var, xtabs The following objects are masked from 'package:base': anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep, grepl, is.unsorted, lapply, Map, mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank, rbind, Reduce, rownames, sapply, saveRDS, table, tapply, unique, unsplit, which.max, which.min Loading required package: Biobase Welcome to Bioconductor Vignettes contain introductory material; view with 'browseVignettes()'. To cite Bioconductor, see 'citation("Biobase")', and for packages 'citation("pkgname")'. Loading required package: IRanges Loading required package: S4Vectors Attaching package: 'S4Vectors' The following object is masked from 'package:utils': findMatches The following objects are masked from 'package:base': expand.grid, I, unname Attaching package: 'IRanges' The following object is masked from 'package:sp': %over% # Using clusterProfiler enrichment_result <- clusterProfiler::enrichGO( gene = Seurat::VariableFeatures(sample)[1:100], OrgDb = org.Hs.eg.db, keyType = "SYMBOL", ont = "BP" ) p <- SCpubr::do_TermEnrichmentPlot(mat = enrichment_result@result) p ``` -------------------------------- ### Basic Usage of do_LoadingsHeatmap Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/10_loadingsheatmap.html This snippet shows the basic usage of the do_LoadingsHeatmap function with a sample object. It generates a heatmap of PCA loadings. ```r p <- SCpubr::do_LoadingsHeatmap(sample = sample) p ``` -------------------------------- ### Generate basic TF activity heatmap Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/03_tfactivityheatmap.html Generate a basic TF activity heatmap using the computed activities. This requires the SCpubr package and the sample object. ```r p <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = activities) p ``` -------------------------------- ### Display R Session Information Source: https://enblacar.github.io/SCpubr-book/07_appendix/04_session_info.html Use the `sessionInfo()` function to capture the R version, platform, locale, time zone, attached base packages, other attached packages, and loaded namespaces. This is crucial for ensuring reproducibility of analyses and book builds. ```R sessionInfo() #> R version 4.5.2 (2025-10-31) #> Platform: aarch64-apple-darwin20 #> Running under: macOS Tahoe 26.1 #> #> Matrix products: default #> BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib #> LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1 #> #> locale: #> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 #> #> time zone: Europe/Berlin #> tzcode source: internal #> #> attached base packages: #> [1] stats graphics grDevices utils datasets #> [6] methods base #> #> other attached packages: #> [1] patchwork_1.3.2 ggplot2_4.0.1 SCpubr_3.0.1 #> [4] Seurat_5.4.0 SeuratObject_5.3.0 sp_2.2-0 #> #> loaded via a namespace (and not attached): #> [1] deldir_2.0-4 pbapply_1.7-4 #> [3] gridExtra_2.3 rlang_1.1.6 #> [5] magrittr_2.0.4 RcppAnnoy_0.0.22 #> [7] otel_0.2.0 spatstat.geom_3.6-1 #> [9] matrixStats_1.5.0 ggridges_0.5.7 #> [11] compiler_4.5.2 png_0.1-8 #> [13] vctrs_0.6.5 reshape2_1.4.5 #> [15] stringr_1.6.0 pkgconfig_2.0.3 #> [17] fastmap_1.2.0 promises_1.5.0 #> [19] rmarkdown_2.30 purrr_1.2.0 #> [21] xfun_0.55 jsonlite_2.0.0 #> [23] goftest_1.2-3 later_1.4.4 #> [25] spatstat.utils_3.2-0 irlba_2.3.5.1 #> [27] parallel_4.5.2 cluster_2.1.8.1 #> [29] R6_2.6.1 ica_1.0-3 #> [31] stringi_1.8.7 RColorBrewer_1.1-3 #> [33] spatstat.data_3.1-9 reticulate_1.44.1 #> [35] parallelly_1.46.0 spatstat.univar_3.1-5 #> [37] lmtest_0.9-40 scattermore_1.2 #> [39] Rcpp_1.1.0 knitr_1.51 #> [41] tensor_1.5.1 future.apply_1.20.1 #> [43] zoo_1.8-15 sctransform_0.4.2 #> [45] httpuv_1.6.16 Matrix_1.7-4 #> [47] splines_4.5.2 igraph_2.2.1 #> [49] tidyselect_1.2.1 rstudioapi_0.17.1 #> [51] abind_1.4-8 yaml_2.3.12 #> [53] spatstat.random_3.4-3 codetools_0.2-20 #> [55] miniUI_0.1.2 spatstat.explore_3.6-0 #> [57] listenv_0.10.0 lattice_0.22-7 #> [59] tibble_3.3.0 plyr_1.8.9 #> [61] withr_3.0.2 shiny_1.12.1 #> [63] S7_0.2.1 ROCR_1.0-11 #> [65] evaluate_1.0.5 Rtsne_0.17 #> [67] future_1.68.0 fastDummies_1.7.5 #> [69] survival_3.8-3 polyclip_1.10-7 #> [71] fitdistrplus_1.2-4 pillar_1.11.1 #> [73] KernSmooth_2.23-26 plotly_4.11.0 #> [75] generics_0.1.4 RcppHNSW_0.6.0 #> [77] scales_1.4.0 globals_0.18.0 #> [79] xtable_1.8-4 glue_1.8.0 #> [81] lazyeval_0.2.2 tools_4.5.2 #> [83] data.table_1.18.0 RSpectra_0.16-2 #> [85] RANN_2.6.2 dotCall64_1.2 #> [87] cowplot_1.2.0 grid_4.5.2 #> [89] tidyr_1.3.2 nlme_3.1-168 #> [91] cli_3.6.5 spatstat.sparse_3.1-0 #> [93] spam_2.11-1 viridisLite_0.4.2 #> [95] dplyr_1.1.4 uwot_0.2.4 #> [97] gtable_0.3.6 digest_0.6.39 #> [99] progressr_0.18.0 ggrepel_0.9.6 #> [101] htmlwidgets_1.6.4 farver_2.1.2 #> [103] htmltools_0.5.9 lifecycle_1.0.4 #> [105] httr_1.4.7 mime_0.13 #> [107] MASS_7.3-65__ ``` -------------------------------- ### Control X-axis Text Angle in DotPlot Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/04_dotplot.html Adjust the rotation angle of the x-axis labels using the `axis.text.x.angle` parameter. This example rotates the labels by 90 degrees. ```R p <- SCpubr::do_DotPlot(sample = sample, features = genes, axis.text.x.angle = 90) p__ ``` -------------------------------- ### Metadata Heatmap with Sample Clustering Source: https://enblacar.github.io/SCpubr-book/06_accessories/03_metadataheatmap.html Creates a metadata heatmap with hierarchical clustering applied to samples. This helps in identifying patterns and relationships between samples based on their metadata. ```r p <- SCpubr::do_MetadataHeatmap(sample = sample, group.by = "ID", metadata = c("technology", "gender", "subtype"), legend.ncol = 1, flip = FALSE, cluster = TRUE) p__ ``` -------------------------------- ### Filter Low Expression in DotPlot Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/04_dotplot.html Use the `dot.min` parameter to remove dots where a gene is expressed in less than the specified percentage of cells. This example shows dots only where >= 50% of cells express the gene. ```R # Only show dots where >= 50% of cells express the gene p <- SCpubr::do_DotPlot(sample = sample, features = genes, dot.min = 50) p__ ``` -------------------------------- ### Sequential Color Palettes Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/01_featureplot.html Applies sequential color palettes from RColorBrewer. Use 'use_viridis = FALSE' and specify the palette name with 'sequential.palette' and direction with 'sequential.direction'. ```r # RColorBrewer sequential palette p1 <- SCpubr::do_FeaturePlot(sample = sample, features = "PC_1", use_viridis = FALSE, sequential.palette = "YlOrRd", sequential.direction = 1) p1 ``` -------------------------------- ### Generate Chord Diagrams from Ligand-Receptor Data Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/09_ligandreceptorplot.html Generates both a dot plot and chord diagrams to visualize cell-cell communication. Chord diagrams provide a circular flow visualization of interactions. ```r p <- SCpubr::do_LigandReceptorPlot(liana_output = liana_output, compute_ChordDiagrams = TRUE) p$DotPlot p$ChordDiagram ``` -------------------------------- ### Basic Metadata Heatmap Source: https://enblacar.github.io/SCpubr-book/06_accessories/03_metadataheatmap.html Generates a basic heatmap of specified metadata columns across samples, grouped by a specified ID. Useful for an initial overview of sample annotations. ```r p <- SCpubr::do_MetadataHeatmap(sample = sample, group.by = "ID", metadata = c("technology", "gender", "subtype"), flip = FALSE, legend.ncol = 1) p__ ``` -------------------------------- ### Split TF activity heatmap by a condition Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/03_tfactivityheatmap.html Create separate heatmaps for different conditions by specifying a metadata variable in the 'split.by' parameter. This is useful for analyzing TF activity differences between experimental groups. ```r p <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = activities, split.by = "condition") p ``` -------------------------------- ### Colorblind Check with Flipped Orientation Source: https://enblacar.github.io/SCpubr-book/06_accessories/02_colorblindcheck.html This snippet demonstrates how to flip the orientation of the colorblind check output by setting the `flip` argument to TRUE. This can be useful for different display preferences. ```r p <- SCpubr::do_ColorBlindCheck(colors.use = colors, flip = TRUE) p__ ``` -------------------------------- ### Basic Dot Plot for Marker Genes Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/04_dotplot.html Generates a basic dot plot to visualize the expression of specified marker genes across cell clusters. Requires the 'sample' object and a vector of gene names. ```r p <- SCpubr::do_DotPlot(sample = sample, features = c("CDC25C", "KIF18B", "KIF14", "CENPE")) p__ ``` -------------------------------- ### Subsample Cells for Loadings Heatmap Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/10_loadingsheatmap.html This snippet shows how to subsample a specified number of cells for generating the loadings heatmap using the 'subsample' argument, which can be useful for large datasets. ```r p <- SCpubr::do_LoadingsHeatmap(sample = sample, subsample = 1000) p ``` -------------------------------- ### Basic Chord Diagram Plot Source: https://enblacar.github.io/SCpubr-book/03_proportions/04_chorddiagramplot.html Generates a basic chord diagram to visualize transitions between two categorical variables. Requires the 'sample' object and specifies the 'from' and 'to' categorical columns. ```R p <- SCpubr::do_ChordDiagramPlot(sample = sample, from = "Annotation", to = "subtype") p__ ``` -------------------------------- ### do_ColorBlindCheck() Source: https://enblacar.github.io/SCpubr-book/06_accessories/02_colorblindcheck.html Simulates colorblind vision to verify your color palette is accessible. Shows how your colors appear under different types of color vision deficiency. ```APIDOC ## do_ColorBlindCheck() ### Description Simulates colorblind vision to verify your color palette is accessible. Shows how your colors appear under different types of color vision deficiency. ### Method N/A (R function) ### Endpoint N/A (R function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```R colors <- c("#E63946", "#F1FAEE", "#A8DADC", "#457B9D", "#1D3557") p <- SCpubr::do_ColorBlindCheck(colors.use = colors) p ``` ### Response #### Success Response N/A (R function returns a plot object) #### Response Example N/A ### Simulated conditions - **Normal** — Typical color vision - **Protanopia** — Red-green (less common) - **Deuteranopia** — Red-green (most common) - **Tritanopia** — Blue-yellow ### Parameter reference - `colors.use` (character vector) - Colors to check - - `flip` (logical) - Flip orientation - `FALSE` ``` -------------------------------- ### Basic Colorblind Check Source: https://enblacar.github.io/SCpubr-book/06_accessories/02_colorblindcheck.html Use this snippet to perform a basic check of your color palette. Provide a vector of colors to the `colors.use` argument. ```r colors <- c("#E63946", "#F1FAEE", "#A8DADC", "#457B9D", "#1D3557") p <- SCpubr::do_ColorBlindCheck(colors.use = colors) p__ ``` -------------------------------- ### Custom Colors for Multiple Metadata Variables in Heatmaps Source: https://enblacar.github.io/SCpubr-book/00_getting_started/03_shared_features.html Use a named list to define custom colors for multiple metadata variables, suitable for heatmaps like SCpubr::do_SCExpressionHeatmap. ```r # Multiple metadata variables (for heatmaps) colors <- list( "seurat_clusters" = c("0" = "#001219", "1" = "#005f73", "2" = "#0a9396"), "cell_type" = c("A" = "#ca6702", "B" = "#0a9396") ) SCpubr::do_SCExpressionHeatmap(sample, features = genes, metadata = names(colors), metadata.colors = colors) ``` -------------------------------- ### Basic CNV Heatmap Generation Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/08_cnvheatmap.html Generates a basic CNV heatmap using inferCNV output. Requires chromosome location data. Ensure inferCNV object and sample data are loaded. ```r # Load chromosome locations data("human_chr_locations", package = "SCpubr") p <- SCpubr::do_CNVHeatmap(sample = sample, infercnv_object = infercnv_obj, chromosome_locations = human_chr_locations) p ``` -------------------------------- ### Generate Split Complementary Color Scheme Source: https://enblacar.github.io/SCpubr-book/06_accessories/01_colorpalette.html Generates a split complementary color scheme from a base color. This scheme uses the base color and the two colors adjacent to its complement, offering strong visual contrast with less tension than a direct complementary pair. ```r colors <- SCpubr::do_ColorPalette(colors.use = "#E63946", split_complementary = TRUE) colors #> [1] "#E63946" "#39E683" "#399DE6" ``` -------------------------------- ### Customizing Color Scale Limits Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/01_featureplot.html Controls the color scale limits by clamping outlier values using 'min.cutoff' and 'max.cutoff'. This helps in compressing the color range for better visualization. ```r p <- SCpubr::do_FeaturePlot(sample = sample, features = "PC_1", min.cutoff = -10, max.cutoff = 10) p ``` -------------------------------- ### Metadata Heatmap with Adjusted Row Gaps Source: https://enblacar.github.io/SCpubr-book/06_accessories/03_metadataheatmap.html Generates a metadata heatmap with custom spacing between the metadata rows. Adjusting `heatmap.gap` can improve readability for complex heatmaps. ```r p <- SCpubr::do_MetadataHeatmap(sample = sample, group.by = "ID", metadata = c("technology", "gender", "subtype"), flip = FALSE, legend.ncol = 1, heatmap.gap = 5) p__ ``` -------------------------------- ### Generate and Plot Triadic Color Palette Source: https://enblacar.github.io/SCpubr-book/06_accessories/01_colorpalette.html Generates a triadic color scheme and returns it as a plot. This is useful for visualizing the generated palette directly. ```r p <- SCpubr::do_ColorPalette(colors.use = "#E63946", triadic = TRUE, plot = TRUE) p ``` -------------------------------- ### Fixed Scale Limits Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/01_featureplot.html Sets fixed color scale limits using 'scale.limits', which is useful for comparing scales across different samples. Cannot be used with 'min.cutoff' or 'max.cutoff'. ```r p <- SCpubr::do_FeaturePlot(sample = sample, features = "PC_1", scale.limits = c(-50, 50)) p ``` -------------------------------- ### Split Feature Plot by Variable Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/01_featureplot.html Generates faceted FeaturePlots split by a specified metadata variable. Use the 'split.by' parameter with the column name. Assumes 'sample' is defined. ```r p <- SCpubr::do_FeaturePlot(sample = sample, features = "PC_1", split.by = "subtype") ``` -------------------------------- ### Chord Diagram Plot with Direction Visualization (Height Difference and Arrows) Source: https://enblacar.github.io/SCpubr-book/03_proportions/04_chorddiagramplot.html Configures the direction visualization in a chord diagram to use height difference and arrows, which is the default setting. ```R p <- SCpubr::do_ChordDiagramPlot(sample = sample, from = "Annotation", to = "subtype", direction.type = c("diffHeight", "arrows")) p__ ``` -------------------------------- ### Generate Complementary Colors Source: https://enblacar.github.io/SCpubr-book/06_accessories/01_colorpalette.html Generates the complementary color to a given base color. This is useful for creating high-contrast color pairs. ```r colors <- SCpubr::do_ColorPalette(colors.use = "#E63946", opposite = TRUE) colors #> [1] "#E63946" "#39E6D9" ``` -------------------------------- ### Chord Diagram Plot with Directional Links (To -> From) Source: https://enblacar.github.io/SCpubr-book/03_proportions/04_chorddiagramplot.html Visualizes directional links from the 'to' category to the 'from' category in a chord diagram by setting directional to -1. ```R p <- SCpubr::do_ChordDiagramPlot(sample = sample, from = "Annotation", to = "subtype", directional = -1) p__ ``` -------------------------------- ### Chord Diagram Plot with Directional Links (From -> To) Source: https://enblacar.github.io/SCpubr-book/03_proportions/04_chorddiagramplot.html Visualizes directional links from the 'from' category to the 'to' category in a chord diagram. This is the default behavior. ```R p <- SCpubr::do_ChordDiagramPlot(sample = sample, from = "Annotation", to = "subtype", directional = 1) p__ ``` -------------------------------- ### Basic BeeSwarm Plot Source: https://enblacar.github.io/SCpubr-book/04_distributions/05_beeswarmplot.html Generates a basic beeswarm plot by ranking cells based on the 'nCount_RNA' feature. This is useful for visualizing the distribution of a specific metric across individual cells. ```r p <- SCpubr::do_BeeSwarmPlot(sample = sample, feature_to_rank = "nCount_RNA") p__ ``` -------------------------------- ### Metadata Heatmap from Data Frame Source: https://enblacar.github.io/SCpubr-book/06_accessories/03_metadataheatmap.html Generates a metadata heatmap directly from a data frame. This is useful when metadata is already organized in a tabular format. ```r df <- data.frame( Patient1 = c("Healthy", "Male"), Patient2 = c("Disease", "Female"), row.names = c("Condition", "Sex") ) p <- SCpubr::do_MetadataHeatmap(from_df = TRUE, df = df) p__ ``` -------------------------------- ### SCpubr BibTeX Entry Source: https://enblacar.github.io/SCpubr-book/07_appendix/01_citation.html The BibTeX entry for citing SCpubr in LaTeX documents. ```bibtex @article{blanco2022scpubr, title={Generating publication ready visualizations for Single Cell transcriptomics using SCpubr}, author={Blanco-Carmona, Enrique}, journal={bioRxiv}, year={2022}, doi={10.1101/2022.02.28.482303} } ``` -------------------------------- ### Dot Plot with Multiple Marker Genes Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/04_dotplot.html Visualizes expression for an extended list of marker genes. Ensure the 'sample' object and the 'genes' vector are correctly defined. ```r genes <- c("CDC25C", "KIF18B", "KIF14", "CENPE", "DNAAF1", "ADGB", "CFAP61", "CFAP157", "KCNQ5", "MEOX2", "MBP", "SNTG1", "S100A1", "MGP", "TNNT1", "H2AFJ") p <- SCpubr::do_DotPlot(sample = sample, features = genes) p__ ``` -------------------------------- ### Select specific TFs for heatmap Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/03_tfactivityheatmap.html Display only a specific set of transcription factors by providing a character vector to the 'tfs.use' parameter. This allows for targeted visualization of known TFs. ```r p <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = activities, tfs.use = c("PAX5", "STAT3", "NF-kB")) p ``` -------------------------------- ### Group Overlay Feature Plot with Dots Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/01_featureplot.html Displays categorical group information by adding dots at cluster centers. Use 'group.by' to specify the metadata column. Assumes 'sample' is defined. ```r p <- SCpubr::do_FeaturePlot(sample = sample, features = "PC_1", group.by = "Annotation") ``` -------------------------------- ### Basic Strip Plot Source: https://enblacar.github.io/SCpubr-book/04_distributions/04_stripplot.html Generates a basic strip plot showing the distribution of a specified feature (e.g., nCount_RNA) across samples. This is the default usage. ```r p <- SCpubr::do_StripPlot(sample = sample, features = "nCount_RNA") p__ ``` -------------------------------- ### Display numeric values on TF activity heatmap Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/03_tfactivityheatmap.html Show the actual numeric TF activity scores on the heatmap cells by setting 'values.show' to TRUE. The size of the text can be adjusted with 'values.size'. ```r p <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = activities, values.show = TRUE, values.size = 4) p ``` -------------------------------- ### Group TF activity heatmap by a variable Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/03_tfactivityheatmap.html Group the cells in the heatmap based on a specific metadata variable by using the 'group.by' parameter. This helps in comparing TF activity across different cell populations. ```r p <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = activities, group.by = "cell_type") p ``` -------------------------------- ### Generate Square Color Scheme Source: https://enblacar.github.io/SCpubr-book/06_accessories/01_colorpalette.html Generates a square color scheme from a base color. This scheme uses four colors evenly spaced around the color wheel, creating a balanced and harmonious palette. ```r colors <- SCpubr::do_ColorPalette(colors.use = "#E63946", square = TRUE) colors #> [1] "#E63946" "#9DE639" "#39E6D9" "#8239E6" ``` -------------------------------- ### Control term text wrapping Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/06_termenrichmentplot.html This snippet demonstrates how to adjust the line wrapping for term labels using the `n.chars` argument, allowing for shorter lines. ```R p <- SCpubr::do_TermEnrichmentPlot(mat = enrichment_result@result, n.chars = 30) # Shorter lines p ``` -------------------------------- ### Basic Groupwise DE Heatmap Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/05_groupwisedeheatmap.html Generates a basic groupwise differential expression heatmap using Seurat's FindAllMarkers output. Ensure FindAllMarkers has been run prior to this function. ```r de_genes <- Seurat::FindAllMarkers(sample, only.pos = TRUE) p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes) p ``` -------------------------------- ### Chord Diagram Plot with Equally Scaled Nodes Source: https://enblacar.github.io/SCpubr-book/03_proportions/04_chorddiagramplot.html Ensures all groups in the chord diagram have the same width, regardless of their cell count, by setting scale to TRUE. ```R p <- SCpubr::do_ChordDiagramPlot(sample = sample, from = "Annotation", to = "subtype", scale = TRUE) p__ ``` -------------------------------- ### Generate 8 Colors Evenly Spaced Around Color Wheel Source: https://enblacar.github.io/SCpubr-book/06_accessories/01_colorpalette.html Generates n colors evenly spaced around the color wheel using a base color. This is useful for creating a diverse set of related colors for visualizations. ```r colors <- SCpubr::do_ColorPalette(colors.use = "#E63946", n = 8) colors #> [1] "#E63946" "#E6AE39" "#9DE639" "#39E657" "#39E6D9" #> [6] "#3971E6" "#8239E6" "#E639C8" ``` -------------------------------- ### Three-Variable Cellular States Plot (Butterfly Plot) Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/03_cellularstatesplot.html Creates a butterfly plot by adding a second X-axis variable, allowing for comparison of three gene signatures. The X-axis displays enrichment for x1 on the right and x2 on the left, while the Y-axis shows enrichment for y1. Requires defining three gene signatures and specifying x1, x2, and y1 parameters. ```R gene_lists <- list( "IPC.like" = c("CDC25C", "KIF18B", "KIF14", "CENPE"), "Cilia.like" = c("DNAAF1", "ADGB", "CFAP61", "CFAP157"), "OPC.like" = c("KCNQ5", "MEOX2", "DNER3", "SNTG1") ) p <- SCpubr::do_CellularStatesPlot( sample = sample, input_gene_list = gene_lists, x1 = "Cilia.like", x2 = "OPC.like", y1 = "IPC.like" ) p ``` -------------------------------- ### Group Overlay Feature Plot with Cell Borders Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/01_featureplot.html Adds a colored shadow around cells to indicate group membership. Set 'group.by.cell_borders' to TRUE and optionally adjust transparency with 'group.by.cell_borders.alpha'. Requires a pre-defined 'sample' object. ```r p <- SCpubr::do_FeaturePlot(sample = sample, features = "PC_1", group.by = "Annotation", group.by.cell_borders = TRUE, group.by.cell_borders.alpha = 0.1) ``` -------------------------------- ### Order Cells by Expression in Feature Plot Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/01_featureplot.html Plots cells with higher expression values on top of the FeaturePlot. Use the 'order = TRUE' parameter. Assumes 'sample' is defined. ```r p <- SCpubr::do_FeaturePlot(sample = sample, features = "KIF14", order = TRUE) ``` -------------------------------- ### Highlight Specific Cells by Identity Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/01_featureplot.html Highlights cells belonging to specified identities. Use the 'idents.highlight' parameter with a vector of identity names. Requires a pre-defined 'sample' object. ```r # Highlight by identity p2 <- SCpubr::do_FeaturePlot(sample = sample, features = "PC_1", idents.highlight = c("IPC-like")) ``` -------------------------------- ### Basic Volcano Plot Generation Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/07_volcanoplot.html Generates a basic volcano plot using differential expression results. Ensure differential expression analysis has been performed prior to using this function. ```r de_genes <- Seurat::FindMarkers(sample, ident.1 = "IPC-like", ident.2 = "Cilia-like") p <- SCpubr::do_VolcanoPlot(sample = sample, de_genes = de_genes) p ``` -------------------------------- ### Generate Adjacent Colors Source: https://enblacar.github.io/SCpubr-book/06_accessories/01_colorpalette.html Generates adjacent colors to a given base color on the color wheel. This is useful for creating analogous color schemes. ```r colors <- SCpubr::do_ColorPalette(colors.use = "#E63946", adjacent = TRUE) colors #> [1] "#E63946" "#E68239" "#E6399C" ``` -------------------------------- ### BeeSwarm Plot with Ordered Groups Source: https://enblacar.github.io/SCpubr-book/04_distributions/05_beeswarmplot.html Creates a beeswarm plot where the groups are ordered by their median value for the 'nCount_RNA' feature. This facilitates easier comparison of distributions across groups. ```r p <- SCpubr::do_BeeSwarmPlot(sample = sample, feature_to_rank = "nCount_RNA", order = TRUE) p__ ``` -------------------------------- ### BeeSwarm Plot with Continuous Coloring Source: https://enblacar.github.io/SCpubr-book/04_distributions/05_beeswarmplot.html Creates a beeswarm plot where cells are ranked by 'nCount_RNA' and colored based on the same continuous feature. This helps in visualizing the distribution and variation of a continuous metric across cells. ```r p <- SCpubr::do_BeeSwarmPlot(sample = sample, feature_to_rank = "nCount_RNA", continuous_feature = TRUE) p__ ``` -------------------------------- ### Adjust dot size for visualization Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/06_termenrichmentplot.html This snippet illustrates how to modify the scale of the dots representing enriched terms using the `dot.scale` argument. ```R p <- SCpubr::do_TermEnrichmentPlot(mat = enrichment_result@result, dot.scale = 6) p ``` -------------------------------- ### Sorting Options for Ligand-Receptor Plot Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/09_ligandreceptorplot.html Applies different sorting methods to the ligand-receptor interactions displayed in the plot, including sorting by specificity, magnitude, or a combination thereof. ```r # Sort by specificity p <- SCpubr::do_LigandReceptorPlot(liana_output = liana_output, sort.by = "A") # Sort by magnitude p <- SCpubr::do_LigandReceptorPlot(liana_output = liana_output, sort.by = "B") # Sort by specificity then magnitude p <- SCpubr::do_LigandReceptorPlot(liana_output = liana_output, sort.by = "C") # Sort by magnitude then specificity p <- SCpubr::do_LigandReceptorPlot(liana_output = liana_output, sort.by = "D") # Equal weight (default) p <- SCpubr::do_LigandReceptorPlot(liana_output = liana_output, sort.by = "E") p ``` -------------------------------- ### Highlight Specific Cells by Barcode Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/01_featureplot.html Highlights a subset of cells based on their barcodes. First, select a number of cells to use, then call do_FeaturePlot with the cells.use parameter. Assumes 'sample' is defined. ```r # Highlight by cell barcodes cells.use <- sample(colnames(sample), 500) p1 <- SCpubr::do_FeaturePlot(sample = sample, features = "PC_1", cells.highlight = cells.use) ``` -------------------------------- ### Dot Plot with Grouped Features Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/04_dotplot.html Organizes and visualizes genes into distinct categories using a named list. Each category will be represented in a separate faceted panel. ```r genes <- list( "IPC.like" = c("CDC25C", "KIF18B", "KIF14", "CENPE"), "Cilia.like" = c("DNAAF1", "ADGB", "CFAP61", "CFAP157"), "OPC.like" = c("KCNQ5", "MEOX2", "MBP", "SNTG1"), "Mesenchymal.like" = c("S100A1", "MGP", "TNNT1", "H2AFJ") ) p <- SCpubr::do_DotPlot(sample = sample, features = genes) p__ ``` -------------------------------- ### Feature Plot with Density Contours Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/01_featureplot.html Overlays density contours on the FeaturePlot. Set 'plot_density_contour' to TRUE and customize contour appearance with 'contour.color' and 'contour.position'. Requires a pre-defined 'sample' object. ```r p <- SCpubr::do_FeaturePlot(sample = sample, features = "PC_1", plot_density_contour = TRUE, contour.color = "grey50", contour.position = "bottom") ``` -------------------------------- ### Adjust Number of Top Loadings Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/10_loadingsheatmap.html This snippet shows how to adjust the number of top and bottom contributing genes displayed for each principal component using the 'top_loadings' argument. ```r p <- SCpubr::do_LoadingsHeatmap(sample = sample, top_loadings = 2) p ``` -------------------------------- ### CNV Heatmap with Numeric Values Displayed Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/08_cnvheatmap.html Generates a CNV heatmap with the numeric CNV scores displayed directly on the heatmap cells. Useful for precise value inspection. Requires chromosome location data. ```r p <- SCpubr::do_CNVHeatmap(sample = sample, infercnv_object = infercnv_obj, chromosome_locations = human_chr_locations, values.show = TRUE) p ``` -------------------------------- ### Color Cellular States Plot by Metadata Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/03_cellularstatesplot.html Color cells in the plot based on a specified metadata variable using the `group.by` parameter. This helps in visualizing the distribution of different cell populations or states. ```r gene_lists <- list( "IPC.like" = c("CDC25C", "KIF18B", "KIF14", "CENPE"), "Cilia.like" = c("DNAAF1", "ADGB", "CFAP61", "CFAP157"), "OPC.like" = c("KCNQ5", "MEOX2", "DNER3", "SNTG1"), "Mesenchymal.like" = c("S100A1", "MGP", "TNNT1", "H2AFJ") ) p <- SCpubr::do_CellularStatesPlot( sample = sample, input_gene_list = gene_lists, x1 = "IPC.like", x2 = "Mesenchymal.like", y1 = "OPC.like", y2 = "Cilia.like", group.by = "subtype" ) p__ ``` -------------------------------- ### Generate Triadic Color Scheme Source: https://enblacar.github.io/SCpubr-book/06_accessories/01_colorpalette.html Generates a triadic color scheme from a base color. This creates three colors evenly spaced around the color wheel, offering vibrant and balanced palettes. ```r colors <- SCpubr::do_ColorPalette(colors.use = "#E63946", triadic = TRUE) colors #> [1] "#E63946" "#46E639" "#3946E6" ``` -------------------------------- ### Strip Plot Colored by Continuous Value Source: https://enblacar.github.io/SCpubr-book/04_distributions/04_stripplot.html Generates a strip plot where points are colored according to a continuous variable. This allows for visualizing the intensity or magnitude of a feature across the plot. ```r p <- SCpubr::do_StripPlot(sample = sample, features = "nCount_RNA", scale_type = "continuous") p__ ``` -------------------------------- ### Split DotPlot by Condition Source: https://enblacar.github.io/SCpubr-book/02_gene_expression/04_dotplot.html Use the `split.by` parameter to create separate facets for each condition. Note that `split.by` cannot be combined with named feature lists, clustering, or z-scoring. ```R p <- SCpubr::do_DotPlot(sample = sample, features = c("CDC25C", "KIF18B", "KIF14", "CENPE"), split.by = "subtype") p__ ``` -------------------------------- ### CNV Heatmap Including Chromosome Arms Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/08_cnvheatmap.html Generates a CNV heatmap that includes both p and q arms of chromosomes. This provides a more granular view of CNV distribution. Requires chromosome location data. ```r p <- SCpubr::do_CNVHeatmap(sample = sample, infercnv_object = infercnv_obj, chromosome_locations = human_chr_locations, include_chr_arms = TRUE) p ``` -------------------------------- ### Adjust Top Interactions for Ligand-Receptor Plot Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/09_ligandreceptorplot.html Customizes the number of top ligand-receptor interactions displayed in the plot. Useful for focusing on the most significant interactions. ```r p <- SCpubr::do_LigandReceptorPlot(liana_output = liana_output, top_interactions = 50) p ``` -------------------------------- ### Faceting Ligand-Receptor Plot Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/09_ligandreceptorplot.html Splits the ligand-receptor interaction plot into facets based on either the ligand or the receptor complex. This helps in analyzing interactions from a specific perspective. ```r # Facet by ligand p <- SCpubr::do_LigandReceptorPlot(liana_output = liana_output, split.by = "ligand.complex") # Facet by receptor p <- SCpubr::do_LigandReceptorPlot(liana_output = liana_output, split.by = "receptor.complex") p ``` -------------------------------- ### Volcano Plot Using Text Labels Source: https://enblacar.github.io/SCpubr-book/05_downstream_analyses/07_volcanoplot.html Uses text labels instead of points for genes on the volcano plot. This can improve readability for certain datasets. ```r p <- SCpubr::do_VolcanoPlot(sample = sample, de_genes = de_genes, use_labels = TRUE) p ```