Commit a1cfbcf4 authored by smorabit's avatar smorabit
Browse files

added new check for module eigengenes

parent b8ef25b4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
Package: hdWGCNA
Title: WGCNA
Version: 0.1.1.9001
Title: hdWGCNA
Version: 0.1.1.9002
Authors@R: c(
    person("Sam", "Morabito", , "smorabit@uci.edu", role = c("aut", "cre"),
           comment = c(ORCID = "0000-0002-7768-4856")),
+7 −0
Original line number Diff line number Diff line
# hdWGCNA 0.1.1.9002 (2022-5-24)
## Added
- `ModuleEigengenes` checks to make sure the data has been scaled.

## Changes
- None

# hdWGCNA 0.1.1.9001 (2022-05-09)
## Added
- Wrote docstring for `PlotKMEs` so it would actually be included in the package.
+11 −2
Original line number Diff line number Diff line
@@ -300,6 +300,7 @@ ConstructNetwork <- function(

    multiExpr <- GetMultiExpr(seurat_obj)
    checkSets(multiExpr) # check data size
    print('here')

  # constructing network on a single dataset
  } else{
@@ -335,17 +336,20 @@ ConstructNetwork <- function(
  if(!dir.exists(tom_outdir)){
    dir.create(tom_outdir)
  }
  print('here')

  if(is.null(soft_power) & !consensus){
    soft_power <- GetPowerTable(seurat_obj) %>% subset(SFT.R.sq >= 0.8) %>% .$Power %>% min
    cat(paste0("Soft power not provided. Automatically using the lowest power that meets 0.8 scale-free topology fit. Using soft_power = ", soft_power, "\n"))
  } else if(consensus){
  } else if(is.null(soft_power)){
    power_tables <- GetPowerTable(seurat_obj) %>% dplyr::group_split(group)
    soft_power <- sapply(power_tables, function(power_table){
      power_table %>% subset(SFT.R.sq >= 0.8) %>% .$Power %>% min
    })
    cat(paste0("Soft power not provided. Automatically using the lowest power that meets 0.8 scale-free topology fit. Using soft_power = c(", paste0(soft_power, collapse=','), ")\n"))
  }
  print('here')


  # construct the network
  net <- WGCNA::blockwiseConsensusModules(
@@ -572,6 +576,10 @@ ModuleEigengenes <- function(
  # are we going to run Harmony?
  harmonized = !is.null(group.by.vars)

  if(harmonized & !any(grepl("ScaleData", seurat_obj@commands))){
      stop('Need to run ScaleData before running ModuleEigengenes with group.by.vars option.')
  }

  me_list <- list()
  harmonized_me_list <- list()

@@ -1019,7 +1027,8 @@ ProjectModules <- function(
  group.by.vars=NULL,
  gene_mapping=NULL, # table mapping genes from species 1 to species 2
  genome1_col=NULL, genome2_col=NULL,
  scale_genes = FALSE,
  vars.to.regress = NULL,
  scale.model.use = 'linear',
  wgcna_name=NULL, wgcna_name_proj=NULL,
  ...
){
+10 −2
Original line number Diff line number Diff line
@@ -103,7 +103,6 @@ ConstructMetacells <- function(
    counts = new_exprs
  )

  print('here')
  print(meta)
  print(names(meta))

@@ -176,6 +175,10 @@ MetacellsByGroups <- function(
    stop('Invalid character # found in group.by, please re-name the group.')
  }

  if(!(ident.group %in% group.by)){
    stop('ident.group must be in group.by')
  }

  # subset seurat object by seleted cells:
  if(!is.null(cells.use)){
    seurat_full <- seurat_obj
@@ -226,12 +229,14 @@ MetacellsByGroups <- function(
    MoreArgs = list(k=k, reduction=reduction, assay=assay, slot=slot, return_metacell=TRUE, wgcna_name=wgcna_name)
  )
  names(metacell_list) <- groupings

  print('done making metacells')
  # combine metacell objects
  metacell_obj <- merge(metacell_list[[1]], metacell_list[2:length(metacell_list)])
  print('done merging seurat objc')

  # set idents for metacell object:
  Idents(metacell_obj) <- metacell_obj@meta.data[[ident.group]]
  print('set idents')

  # revert to full seurat object if we subsetted earlier
  if(!is.null(cells.use)){
@@ -240,6 +245,7 @@ MetacellsByGroups <- function(

  # add seurat metacell object to the main seurat object:
  seurat_obj <- SetMetacellObject(seurat_obj, metacell_obj, wgcna_name)
  print('update seurat')

  # add other info
  seurat_obj <- SetWGCNAParams(
@@ -251,5 +257,7 @@ MetacellsByGroups <- function(
    ),
    wgcna_name
  )
  print('set params')

  seurat_obj
}
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="https://smorabit.github.io/scWGCNA/index.html">hdWGCNA</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.1.1.9001</span>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.1.1.9002</span>
      </span>
    </div>

Loading