Commit b5214a20 authored by smorabit's avatar smorabit
Browse files

working on cross-species

parent 1e2431c1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -13,3 +13,8 @@ LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
URL: https://smorabit.github.io/scWGCNA/
Imports:
  Seurat (>= 4.0),
  WGCNA,
  igraph,
  dplyr
+13 −7
Original line number Diff line number Diff line
@@ -1192,8 +1192,6 @@ TransferModuleGenome <- function(
  # subset modules
  modules <- subset(modules, gene_name %in% gene_mapping[,genome1_col])

  print('here')

  # match the order of the given gene list, and remove NA entries
  gene_match <- match(gene_list, gene_mapping[,genome1_col])
  gene_mapping <- na.omit(gene_mapping[gene_match,])
@@ -1201,11 +1199,6 @@ TransferModuleGenome <- function(
  # update modules table with the new gene names
  # modules <- na.omit(modules[gene_match,])

  print('here')
  print(dim(modules))
  print(dim(gene_mapping))
  print(length(gene_match))

  modules$gene_name <- gene_mapping[,genome2_col]

  modules
@@ -1899,6 +1892,9 @@ ModulePreservation <- function(
  n_permutations = 500,
  parallel = FALSE,
  seed = 12345,
  gene_mapping = NULL,
  genome1_col = NULL,
  genome2_col = NULL,
  return_raw = FALSE,
  wgcna_name = NULL,
  wgcna_name_ref = NULL,
@@ -1914,6 +1910,16 @@ ModulePreservation <- function(
  datExpr_ref <- GetDatExpr(seurat_ref, wgcna_name_ref)
  datExpr_query <- GetDatExpr(seurat_obj, wgcna_name)

  # change the gene names to match:
  if(!is.null(gene_mapping)){
    gene_match <- match(colnames(datExpr_query), gene_mapping[,genome2_col])
    gene_mapping <- na.omit(gene_mapping[gene_match,])
    colnames(datExpr_query)  <- gene_mapping[,genome1_col]

    print(head(colnames(datExpr_query)))
    print(head(GetModules(seurat_obj)$gene_name))
  }

  # set up multiExpr:
  setLabels <- c("ref", "query")
  multiExpr <- list(
+2 −3
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ GetWGCNAGenes <- function(seurat_obj, wgcna_name=NULL){
###########################


#' spr
#' SetDatExpr
#'
#' This function sets up the expression matrix from the metacell object.
#'
@@ -132,6 +132,7 @@ SetDatExpr <- function(
  # get parameters from seurat object
  params <- GetWGCNAParams(seurat_obj, wgcna_name)
  genes_use <- GetWGCNAGenes(seurat_obj, wgcna_name)
  modules <- GetModules(seurat_(bj, wgcna_name))
  assay <- params$metacell_assay

  print('n_genes:')
@@ -179,8 +180,6 @@ SetDatExpr <- function(
  # transpose data
  datExpr <- as.data.frame(t(datExpr))

  print(dim(datExpr))

  # only get good genes:
  if(is.null(multi.group.by)){
    gene_list = genes_use[WGCNA::goodGenes(datExpr, ...)]
+3 −3
Original line number Diff line number Diff line
@@ -243,7 +243,7 @@
  database <span class="op">=</span> <span class="st">"GO_Biological_Process_2021"</span>, <span class="co"># this has to be one of the lists we used above!!!</span>
  n_terms<span class="op">=</span><span class="fl">1</span> <span class="co"># number of terms for each module</span>
<span class="op">)</span></code></pre></div>
<p><img src="figures/enrichment/GO_dotplot.png"></p>
<p><img src="figures/enrichment/GO_dotplot.png" width="500" height="500"></p>
<p>In this plot, each dot is colored by the module’s unique color, and the size of each dot is scaled by the enrichment of the term.</p>
</div>
</div>
@@ -299,7 +299,7 @@

<span class="co"># stitch plots with patchwork</span>
<span class="fu"><a href="https://patchwork.data-imaginist.com/reference/wrap_plots.html" class="external-link">wrap_plots</a></span><span class="op">(</span><span class="va">plot_list</span>, ncol<span class="op">=</span><span class="fl">3</span><span class="op">)</span></code></pre></div>
<p><img src="figures/enrichment/overlap_barplot.png"></p>
<p><img src="figures/enrichment/overlap_barplot.png" width="500" height="500"></p>
<p>Next we use <code>OverlapDotPlot</code> to visualize the overlap results in a single plot.</p>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co"># plot odds ratio of the overlap as a dot plot</span>
@@ -307,7 +307,7 @@
  <span class="va">overlap_df</span>,
  plot_var <span class="op">=</span> <span class="st">'odds_ratio'</span><span class="op">)</span> <span class="op">+</span>
  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html" class="external-link">ggtitle</a></span><span class="op">(</span><span class="st">'Overlap of modules &amp; cell-type markers'</span><span class="op">)</span></code></pre></div>
<p><img src="figures/enrichment/overlap_dotplot.png"></p>
<p><img src="figures/enrichment/overlap_dotplot.png" width="600" height="600"></p>
<p>Each dot is colored by the scWGCNA module’s unique color, and the size of the dot is scaled by the overlap statistic. We show FDR significance levels as stars on top of the dots.</p>
<ul>
<li>’***’: 0 - 0.001</li>
+252 KiB
Loading image diff...
Loading