Commit bc726104 authored by smorabit's avatar smorabit
Browse files

module customization tutorial

parent dd7fdbe7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ export(OverlapModulesMotifs)
export(PlotDendrogram)
export(ProjectModules)
export(ROCCurves)
export(ResetModuleColors)
export(ResetModuleNames)
export(RunEnrichr)
export(RunHarmonyMetacells)
export(RunModuleUMAP)
+3 −4
Original line number Diff line number Diff line
@@ -1619,9 +1619,8 @@ MotifTargetScore <- function(
#' Run UMAP on co-expression matrix using hub genes as features.
#'
#' @param seurat_obj A Seurat object
#' @param n_hubs
#' @param exclude_grey
#' @param
#' @param n_hubs number of hub genes to use in the UMAP computation
#' @param exclude_grey logical indicating whether to include grey module
#' @param wgcna_name The name of the scWGCNA experiment in the seurat_obj@misc slot
#' @param ... Additional parameters supplied to uwot::umap
#' @keywords scRNA-seq
@@ -1629,7 +1628,7 @@ MotifTargetScore <- function(
#' @examples
RunModuleUMAP <- function(
  seurat_obj,
  n_hubs = 50,
  n_hubs = 10,
  exclude_grey = TRUE,
  wgcna_name = NULL,
  n_neighbors= 25,
+25 −1
Original line number Diff line number Diff line
@@ -687,6 +687,17 @@ GetModuleTraitCorrelation <- function(seurat_obj, wgcna_name=NULL){
# Reset module names:
###########################


#' ResetModuleNames
#'
#' Reset the uname of each scWGCNA module
#'
#' @param seurat_obj A Seurat object
#' @param new_name string containing the base name to re-name the modules
#' @param wgcna_name The name of the scWGCNA experiment in the seurat_obj@misc slot
#' @keywords scRNA-seq
#' @export
#' @examples
ResetModuleNames <- function(
  seurat_obj,
  new_name = "M",
@@ -820,6 +831,16 @@ ResetModuleNames <- function(
# Reset module names:
###########################

#' ResetModuleColors
#'
#' Reset the unique color for each scWGCNA module
#'
#' @param seurat_obj A Seurat object
#' @param new_colors a character vector containing the new colors
#' @param wgcna_name The name of the scWGCNA experiment in the seurat_obj@misc slot
#' @keywords scRNA-seq
#' @export
#' @examples
ResetModuleColors <- function(
  seurat_obj,
  new_colors,
@@ -853,7 +874,6 @@ ResetModuleColors <- function(
  # set module table
  seurat_obj <- SetModules(seurat_obj, modules, wgcna_name)


  # update motif overlap
  overlap_df <- GetMotifOverlap(seurat_obj, wgcna_name)
  if(!is.null(overlap_df)){
@@ -868,6 +888,10 @@ ResetModuleColors <- function(
    seurat_obj <- SetModuleUMAP(seurat_obj, umap_df, wgcna_name)
  }

  # update scWGCNA dendrogram:
  net <- GetNetworkData(seurat_obj, wgcna_name)
  net$colors <- new_color_df[match(net$colors, new_color_df$old),'new']
  seurat_obj <- SetNetworkData(seurat_obj, net, wgcna_name)

  seurat_obj

+2 −2
Original line number Diff line number Diff line
@@ -377,7 +377,7 @@ ModuleFeaturePlot<- function(
      ggplot(aes_string(x=x_name, y=y_name, color="val")) +
      # ggplot(aes(x=umap1, y=umap2, color=val))
      geom_point(size=point_size, alpha=alpha) +
      ggtitle(cur_mod) + umap_theme +
      ggtitle(cur_mod) + umap_theme() +
      labs(color="")

    # UCell?
@@ -1508,7 +1508,7 @@ DoHubGeneHeatmap <- function(
  for(i in 1:nrow(mod_colors)){
    cbar_list[[i]] <- mod_colors[i,] %>% ggplot(aes(y=value, x=dummy)) +
      geom_bar(position='stack', stat='identity', fill=mod_colors[i,]$color) +
      umap_theme + theme(
      umap_theme() + theme(
        plot.margin=margin(0,0,0,0)
      )
  }
+9 −0
Original line number Diff line number Diff line
@@ -37,6 +37,10 @@ navbar:
    - text: Projecting modules onto new datasets
      href: articles/projecting_modules.html
    - text: -------
    - text: Other
    - text: Module customization
      href: articles/customization.html
    - text: -------
    - text: All vignettes
      href: articles/index.html

@@ -75,6 +79,11 @@ reference:
  - '`RunHarmonyMetacells`'
  - '`RunUMAPMetacells`'
  - '`DimPlotMetacells`'
- title: Other
  desc: Other functions
  contents:
    -'`ResetModuleColors`'
    -'`ResetModuleNames`'

deploy:
  install_metadata: true
Loading