plot_cluster_network: Plot Iterative Differential Clustering network

View source: R/plotting.R

plot_cluster_networkR Documentation

Plot Iterative Differential Clustering network

Description

Plot Iterative Differential Clustering network

Plot Iterative Differential Clustering network

Plot Iterative Differential Clustering network

Usage

plot_cluster_network(object, ...)

## Default S3 method:
plot_cluster_network(
  object,
  IDC_summary,
  color_by = "IDcluster",
  cluster_col = "IDcluster",
  colors = NULL,
  node_size_factor = 7.5,
  edge_size_factor = 1,
  threshold_to_define_feature_active = 1,
  max_distanceToTSS = 1000,
  gene_col = "Gene",
  function_layout = function(g) igraph::layout_as_tree(g, root = 1, circular = TRUE,
    flip.y = FALSE),
  legend = TRUE,
  edge_df = NULL,
  ...
)

## S3 method for class 'Seurat'
plot_cluster_network(
  object,
  IDC_summary = NULL,
  color_by = "IDcluster",
  cluster_col = "IDcluster",
  colors = NULL,
  node_size_factor = 7.5,
  edge_size_factor = 1,
  threshold_to_define_feature_active = 2,
  function_layout = function(g) igraph::layout_as_tree(g, root = 1, circular = TRUE,
    flip.y = FALSE),
  assay = "RNA",
  legend = TRUE,
  edge_df = NULL,
  ...
)

Arguments

object

A Seurat object clustered with iterative_differential_clustering()

...

Additional parameters passed to the plot function.

IDC_summary

Optional. A data.frame of differential analyses summary outputed by iterative_differential_clustering() when saving option is TRUE. Use to determine the width of the edges based on the number of differential features of the given marker.

color_by

A character specifying the column of the Seurat to use for coloring the nodes.

cluster_col

A character specifying the column of the Seurat to use to store the iterative differential clusters.

colors

A character vector of colors. If NULL, will take R default color.

node_size_factor

A numeric specifying a multiplicator of the size of the nodes.

edge_size_factor

A numeric specifying a multiplicator of the size of the edges.

threshold_to_define_feature_active

If color_by is a gene, an integer specifying the threshold above which a gene is considered as active in any given cell.

max_distanceToTSS

If color_by is a gene, the maximum distance to TSS to consider a gene linked to a region. Used only if "color_by" is a gene name.

gene_col

If color_by is a gene, a character specifying the column in the rowData of the object

function_layout

A function of g for the layout of the graph.

legend

A logical indicating whether to plot the legend or not.

edge_df

(Optional). A data.frame obtained by top_enriched_pathways() containing the top 1 pathway enriched per cluster to display it on the edges.

assay

If color_by is a gene, the assay in which to retrieve the counts.

Value

A hierarchical network of cluster assignation:

  • Size of nodes reflects the number of cells

  • Width of edges reflects the number of differential features defining a cluster

  • Color of nodes reflects the repartition of cells according to 'color_by'

A hierarchical network of cluster assignation:

  • Size of nodes reflects the number of cells

  • Width of edges reflects the number of differential features defining a cluster

  • Color of nodes reflects the repartition of cells according to 'color_by'

Examples

# Plotting of Seurat scRNA object (Paired-Tag)
if(requireNamespace("Seurat", quietly=TRUE)){

data("Seu", package = "IDclust")
data("IDC_summary_scRNA", package = "IDclust")

plot_cluster_network(
    object = Seu,
    IDC_summary = IDC_summary_scRNA,
    color_by = "IDcluster",
    cluster_col = "IDcluster",
    colors = NULL,
    node_size_factor = 7.5,
    edge_size_factor = 1,
    function_layout = function(g) igraph::layout_as_tree(g, root = 1, circular = TRUE,
                                                         flip.y = FALSE)
)

# Plotting proportion of cells activating a specific gene in  Seurat scRNA 
# object (Paired-Tag)
plot_cluster_network(
    object = Seu,
    IDC_summary = IDC_summary_scRNA,
    color_by = "Erbb4", # a gene contained in the Seu object
    threshold_to_define_feature_active = 2,
    assay = "RNA",
    cluster_col = "IDcluster",
    colors = NULL,
    node_size_factor = 7.5,
    edge_size_factor = 1,
    function_layout = function(g) igraph::layout_as_tree(g, root = 1, circular = TRUE,
                                                         flip.y = FALSE)
)

# Plotting cluster networ with the pathway information on the edges:
data("IDC_DA_scRNA", package = "IDclust")
edge_df = top_enriched_pathways(
    IDC_DA_scRNA,
    top = 5,
    gene_col = "gene",
    qval.th = 0.1)

plot_cluster_network(
    object = Seu,
    IDC_summary = IDC_summary_scRNA,
    edge_df = edge_df
)
}

# Clustering of scExp scH3K27ac object (Paired-Tag)
if(requireNamespace("ChromSCape", quietly=TRUE)){

data("scExp", package = "IDclust")
data("IDC_summary_scEpigenomics", package = "IDclust")

plot_cluster_network(
    object = scExp,
    IDC_summary = IDC_summary_scEpigenomics,
    color_by = "IDcluster",
    cluster_col = "IDcluster",
    colors = NULL,
    node_size_factor = 7.5,
    edge_size_factor = 1,
    function_layout = function(g) igraph::layout_as_tree(g, root = 1, circular = TRUE,
                                                         flip.y = FALSE),
    edge_df = topmarkers
)

# Plotting proportion of cells activating a specific gene in  scExp scH3K27ac 
# object (Paired-Tag)
plot_cluster_network(
    object = scExp,
    IDC_summary = IDC_summary_scEpigenomics,
    color_by = "Tcf4", # a gene contained in the scExp object
    threshold_to_define_feature_active = 1,
    gene_col = "Gene",
    max_distanceToTSS = 1000,
    cluster_col = "IDcluster",
    colors = NULL,
    node_size_factor = 7.5,
    edge_size_factor = 1,
    function_layout = function(g) igraph::layout_as_tree(g, root = 1, circular = TRUE,
                                                         flip.y = FALSE)
)

# Adding on the edges the 3 top markers of each clusters in scExp H3K27ac
# object (Paired-Tag)

# Adding gene information in the IDC_DA
data("IDC_DA_scEpigenomics", package = "IDclust")
IDC_DA_scEpigenomics = add_gene_to_DA_list(
    scExp = scExp, 
    IDC_DA = IDC_DA_scEpigenomics
)

# Finding the 3 top markers per cluster
topmarkers = top_differential_markers(
    IDC_DA_scEpigenomics,
    top = 3,
    gene_col = "Gene",
    logFC_col = "logFC",
    qvalue_col = "qval",
    order_by = "logFC_col",
    pseudogene_pattern = "Rik|Vmn|Gm|AW"
)

# Concatenate top 3 markers per cluster/cluster_of_origin 
topmarkers = topmarkers %>% dplyr::group_by(cluster_of_origin, cluster) %>%
 dplyr::summarise(Term = paste(Gene, collapse = " "))

plot_cluster_network(
    object = scExp,
    IDC_summary = IDC_summary_scEpigenomics,
    edge_df = topmarkers
)

}

vallotlab/IDclust documentation built on Feb. 16, 2023, 8:58 a.m.