From 10b28e06d2a73206cd509d1ecfccd9f471132b4b Mon Sep 17 00:00:00 2001 From: dimalvovs Date: Tue, 12 Dec 2023 12:30:57 -0500 Subject: [PATCH] add plotting function examples --- R/plot_fxns.R | 47 ++++++++++++++++++++++++++++++- man/circos_ligand_receptor.Rd | 9 ++++++ man/cor_heatmap.Rd | 9 ++++++ man/cor_scatter.Rd | 5 ++++ man/feat_heatmap.Rd | 7 +++++ man/gene_network.Rd | 8 ++++++ man/incoming_signaling_heatmap.Rd | 5 ++++ man/signaling_heatmap.Rd | 9 ++++++ man/signaling_network.Rd | 8 ++++++ 9 files changed, 106 insertions(+), 1 deletion(-) diff --git a/R/plot_fxns.R b/R/plot_fxns.R index 4b60a5a..3aa3be0 100644 --- a/R/plot_fxns.R +++ b/R/plot_fxns.R @@ -21,7 +21,15 @@ NULL #' @param ... Other parameters to pass to [ComplexHeatmap::Heatmap()] #' @return a Heatmap rendered to the active graphics device #' @export signaling_heatmap -#' +#' @examples +#' #basic usage +#' signaling_heatmap(dom) +#' #scale +#' signaling_heatmap(dom, scale = "sqrt") +#' #normalize +#' signaling_heatmap(dom, normalize = "rec_norm") +#' + signaling_heatmap <- function(dom, clusts = NULL, min_thresh = -Inf, max_thresh = Inf, scale = "none", normalize = "none", ...) { if (!dom@misc[["build"]]) { @@ -76,6 +84,9 @@ signaling_heatmap <- function(dom, clusts = NULL, min_thresh = -Inf, max_thresh #' @param ... Other parameters to pass to [ComplexHeatmap::Heatmap()]. Note that to use the 'column_title' parameter of [ComplexHeatmap::Heatmap()] you must set title = FALSE #' @return a Heatmap rendered to the active graphics device #' @export incoming_signaling_heatmap +#' @examples +#' #incoming signaling of the CD8 T cells +#' incoming_signaling_heatmap(dom, "CD8_T_cell") #' incoming_signaling_heatmap <- function(dom, rec_clust, clusts = NULL, min_thresh = -Inf, max_thresh = Inf, scale = "none", normalize = "none", title = TRUE, ...) { @@ -164,6 +175,12 @@ incoming_signaling_heatmap <- function(dom, rec_clust, clusts = NULL, min_thresh #' @param ... Other parameters to be passed to plot when used with an `{igraph}` object. #' @return an igraph rendered to the active graphics device #' @export signaling_network +#' @examples +#' #basic usage +#' signaling_network(dom) +#' # scaling, thresholds, layouts, selecting clusters +#' signaling_network(dom, showOutgoingSignalingClusts = "CD14_monocyte", scale = "none", +#' norm = "none", layout = "fr", scale_by = "none", vert_scale = 5) #' signaling_network <- function(dom, cols = NULL, edge_weight = 0.3, clusts = NULL, showOutgoingSignalingClusts = NULL, showIncomingSignalingClusts = NULL, min_thresh = -Inf, max_thresh = Inf, normalize = "none", scale = "sq", @@ -296,6 +313,12 @@ signaling_network <- function(dom, cols = NULL, edge_weight = 0.3, clusts = NULL #' @param ... Other parameters to pass to plot() with an [igraph] object. See [igraph] manual for options. #' @return an igraph rendered to the active graphics device #' @export gene_network +#' @examples +#' #basic usage +#' gene_network(dom, clust = "CD16_monocyte", OutgoingSignalingClust = "CD14_monocyte") +#' #scaling and coloring +#' gene_network(dom, clust = "CD16_monocyte", OutgoingSignalingClust = "CD14_monocyte", +#' cols = c("CD1D" = "violet", "LILRB2" = "violet", "FOSB" = "violet"), lig_scale = 10) #' gene_network <- function(dom, clust = NULL, OutgoingSignalingClust = NULL, class_cols = c(lig = "#FF685F", rec = "#47a7ff", feat = "#39C740"), cols = NULL, lig_scale = 1, layout = "grid", ...) { @@ -451,6 +474,11 @@ gene_network <- function(dom, clust = NULL, OutgoingSignalingClust = NULL, class #' @param ... Other parameters to pass to [ComplexHeatmap::Heatmap()] . Note that to use the 'main' parameter of [ComplexHeatmap::Heatmap()] you must set title = FALSE and to use 'annCol' or 'annColors' ann_cols must be FALSE. #' @return a Heatmap rendered to the active graphics device #' @export feat_heatmap +#' @examples +#' #basic usage +#' feat_heatmap(dom) +#' #using thresholds +#' feat_heatmap(dom, min_thresh = 0.1, max_thresh = 0.6, norm = TRUE, bool = FALSE) #' feat_heatmap <- function(dom, feats = NULL, bool = FALSE, bool_thresh = 0.2, title = TRUE, norm = FALSE, cols = NULL, ann_cols = TRUE, min_thresh = NULL, max_thresh = NULL, ...) { @@ -566,6 +594,13 @@ feat_heatmap <- function(dom, feats = NULL, bool = FALSE, bool_thresh = 0.2, tit #' @param ... Other parameters to pass to [ComplexHeatmap::Heatmap()] . Note that to use the 'main' parameter of [ComplexHeatmap::Heatmap()] you must set title = FALSE and to use 'annCol' or 'annColors' ann_cols must be FALSE. #' @return a Heatmap rendered to the active graphics device #' @export cor_heatmap +#' @examples +#' #basic usage +#' cor_heatmap(dom, title = "PBMC R-TF Correlations") +#' #show correlations above a specific value +#' cor_heatmap(dom, bool = TRUE, bool_thresh = 0.25) +#' #identify combinations that are connected +#' cor_heatmap(dom, bool = FALSE, mark_connections = TRUE) #' cor_heatmap <- function(dom, bool = FALSE, bool_thresh = 0.15, title = TRUE, feats = NULL, recs = NULL, mark_connections = FALSE, ...) { @@ -653,6 +688,9 @@ cor_heatmap <- function(dom, bool = FALSE, bool_thresh = 0.15, title = TRUE, fea #' @param ... Other parameters to pass to ggscatter. #' @return a ggplot object #' @export cor_scatter +#' @examples +#' #basic usage +#' cor_scatter(dom, "FOSB", "CD74") #' cor_scatter <- function(dom, tf, rec, remove_rec_dropout = TRUE, ...) { if (remove_rec_dropout) { @@ -679,6 +717,13 @@ cor_scatter <- function(dom, tf, rec, remove_rec_dropout = TRUE, ...) { #' @param cell_colors Named vector of color names or hex codes where names correspond to the plotted cell types and the color values #' @return renders a circos plot to the active graphics device #' @export circos_ligand_receptor +#' @examples +#' #basic usage +#' circos_ligand_receptor(dom, receptor = "CD74") +#' #specify colors +#' cols = c("red", "orange", "green", "blue", "pink", "purple", "slategrey", "firebrick", "hotpink") +#' names(cols) = levels(dom@clusters) +#' circos_ligand_receptor(dom, receptor = "CD74", cell_colors = cols) #' circos_ligand_receptor <- function(dom, receptor, ligand_expression_threshold = 0.01, cell_idents = NULL, cell_colors = NULL) { diff --git a/man/circos_ligand_receptor.Rd b/man/circos_ligand_receptor.Rd index 878a279..5bb1864 100644 --- a/man/circos_ligand_receptor.Rd +++ b/man/circos_ligand_receptor.Rd @@ -30,3 +30,12 @@ renders a circos plot to the active graphics device Creates a chord plot of expression of ligands that can activate a specified receptor where chord widths correspond to mean ligand expression by the cluster. } +\examples{ +#basic usage +circos_ligand_receptor(dom, receptor = "CD74") +#specify colors +cols = c("red", "orange", "green", "blue", "pink", "purple", "slategrey", "firebrick", "hotpink") +names(cols) = levels(dom@clusters) +circos_ligand_receptor(dom, receptor = "CD74", cell_colors = cols) + +} diff --git a/man/cor_heatmap.Rd b/man/cor_heatmap.Rd index b66ee53..689b897 100644 --- a/man/cor_heatmap.Rd +++ b/man/cor_heatmap.Rd @@ -39,3 +39,12 @@ a Heatmap rendered to the active graphics device Creates a heatmap of correlation values between receptors and transcription factors either with boolean threshold or with continuous values displayed } +\examples{ +#basic usage +cor_heatmap(dom, title = "PBMC R-TF Correlations") +#show correlations above a specific value +cor_heatmap(dom, bool = TRUE, bool_thresh = 0.25) +#identify combinations that are connected +cor_heatmap(dom, bool = FALSE, mark_connections = TRUE) + +} diff --git a/man/cor_scatter.Rd b/man/cor_scatter.Rd index aaaf721..f16534d 100644 --- a/man/cor_scatter.Rd +++ b/man/cor_scatter.Rd @@ -23,3 +23,8 @@ a ggplot object \description{ Create a correlation plot between transcription factor activation score and receptor } +\examples{ +#basic usage +cor_scatter(dom, "FOSB", "CD74") + +} diff --git a/man/feat_heatmap.Rd b/man/feat_heatmap.Rd index 7e11a61..e5cfef2 100644 --- a/man/feat_heatmap.Rd +++ b/man/feat_heatmap.Rd @@ -48,3 +48,10 @@ a Heatmap rendered to the active graphics device Creates a heatmap of feature expression (typically transcription factor activation scores) by cells organized by cluster. } +\examples{ +#basic usage +feat_heatmap(dom) +#using thresholds +feat_heatmap(dom, min_thresh = 0.1, max_thresh = 0.6, norm = TRUE, bool = FALSE) + +} diff --git a/man/gene_network.Rd b/man/gene_network.Rd index c98b34c..69a8789 100644 --- a/man/gene_network.Rd +++ b/man/gene_network.Rd @@ -41,3 +41,11 @@ selected cluster acts as the receptor for the gene association network, so only ligands, receptors, and features associated with the receptor cluster will be included in the plot. } +\examples{ +#basic usage +gene_network(dom, clust = "CD16_monocyte", OutgoingSignalingClust = "CD14_monocyte") +#scaling and coloring +gene_network(dom, clust = "CD16_monocyte", OutgoingSignalingClust = "CD14_monocyte", + cols = c("CD1D" = "violet", "LILRB2" = "violet", "FOSB" = "violet"), lig_scale = 10) + +} diff --git a/man/incoming_signaling_heatmap.Rd b/man/incoming_signaling_heatmap.Rd index 5243dde..6515f65 100644 --- a/man/incoming_signaling_heatmap.Rd +++ b/man/incoming_signaling_heatmap.Rd @@ -46,3 +46,8 @@ ligands. A list of all cluster incoming signaling matrices can be found in the cl_signaling_matrices slot of a domino option as an alternative to this plotting function. } +\examples{ +#incoming signaling of the CD8 T cells +incoming_signaling_heatmap(dom, "CD8_T_cell") + +} diff --git a/man/signaling_heatmap.Rd b/man/signaling_heatmap.Rd index db3b46c..44d2ac1 100644 --- a/man/signaling_heatmap.Rd +++ b/man/signaling_heatmap.Rd @@ -36,3 +36,12 @@ a Heatmap rendered to the active graphics device Creates a heatmap of the signaling network. Alternatively, the network matrix can be accessed directly in the signaling slot of a domino object. } +\examples{ +#basic usage +signaling_heatmap(dom) +#scale +signaling_heatmap(dom, scale = "sqrt") +#normalize +signaling_heatmap(dom, normalize = "rec_norm") + +} diff --git a/man/signaling_network.Rd b/man/signaling_network.Rd index 07a28c3..04e79f6 100644 --- a/man/signaling_network.Rd +++ b/man/signaling_network.Rd @@ -61,3 +61,11 @@ Creates a network diagram of signaling between clusters. Nodes are clusters and directed edges indicate signaling from one cluster to another. Edges are colored based on the color scheme of the ligand expressing cluster. } +\examples{ +#basic usage +signaling_network(dom) +# scaling, thresholds, layouts, selecting clusters +signaling_network(dom, showOutgoingSignalingClusts = "CD14_monocyte", scale = "none", + norm = "none", layout = "fr", scale_by = "none", vert_scale = 5) + +}