Commit be25cda8 authored by smorabit's avatar smorabit
Browse files

added new error checks

parent 9ed9084d
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
Package: hdWGCNA
Package: hdWGCNA
Title: hdWGCNA
Title: hdWGCNA
Version: 0.1.1.9014
Version: 0.1.1.9015
Authors@R: c(
Authors@R: c(
    person("Sam", "Morabito", , "smorabit@uci.edu", role = c("aut", "cre"),
    person("Sam", "Morabito", , "smorabit@uci.edu", role = c("aut", "cre"),
           comment = c(ORCID = "0000-0002-7768-4856")),
           comment = c(ORCID = "0000-0002-7768-4856")),
+12 −2
Original line number Original line Diff line number Diff line
# hdWGCNA 0.1.1.9012 (2022-08-26)
# hdWGCNA 0.1.1.9015 (2022-09-06)
## Added
- None

## Changes
- New data format check in `MetacellsByGroups` to ensure that the selected slot is present in the selected assay.
- `SetDatExpr` now backs up to the full dataset if the metacell dataset isn't found.
- Changed some text to clarify some points in the Module Preservation tutorial.


# hdWGCNA 0.1.1.9014 (2022-08-26)
## Added
## Added
- None
- None


@@ -6,7 +16,7 @@
- Bugfix in `ModuleConnectivity` that caused kMEs to be out of order.
- Bugfix in `ModuleConnectivity` that caused kMEs to be out of order.




# hdWGCNA 0.1.1.9012 (2022-08-25)
# hdWGCNA 0.1.1.9013 (2022-08-25)
## Added
## Added
- Tutorial for using SCTransform normalized data.
- Tutorial for using SCTransform normalized data.


+11 −6
Original line number Original line Diff line number Diff line
@@ -109,14 +109,15 @@ GetMetacellObject <- function(seurat_obj, wgcna_name=NULL){


  # get data from active assay if wgcna_name is not given
  # get data from active assay if wgcna_name is not given
  if(is.null(wgcna_name)){wgcna_name <- seurat_obj@misc$active_wgcna}
  if(is.null(wgcna_name)){wgcna_name <- seurat_obj@misc$active_wgcna}

  input_class <- class(seurat_obj@misc[[wgcna_name]]$wgcna_metacell_obj)
  if(class(seurat_obj@misc[[wgcna_name]]$wgcna_metacell_obj) == "Seurat"){
  if(input_class == "Seurat"){
    return(seurat_obj@misc[[wgcna_name]]$wgcna_metacell_obj)
    return(seurat_obj@misc[[wgcna_name]]$wgcna_metacell_obj)
  } else{
  } else if(input_class == "character") {
    metacell_location <- seurat_obj@misc[[wgcna_name]]$wgcna_metacell_obj
    metacell_location <- seurat_obj@misc[[wgcna_name]]$wgcna_metacell_obj
    return(seurat_obj@misc[[metacell_location]]$wgcna_metacell_obj)
    return(seurat_obj@misc[[metacell_location]]$wgcna_metacell_obj)
  } else{
    return(NULL)
  }
  }

}
}


############################
############################
@@ -197,10 +198,14 @@ SetDatExpr <- function(
  genes_use <- GetWGCNAGenes(seurat_obj, wgcna_name)
  genes_use <- GetWGCNAGenes(seurat_obj, wgcna_name)
  modules <- GetModules(seurat_obj, wgcna_name)
  modules <- GetModules(seurat_obj, wgcna_name)


  # get metacell object
  m_obj <- GetMetacellObject(seurat_obj, wgcna_name)

  # use metacells or whole seurat object?
  # use metacells or whole seurat object?
  if(use_metacells){
  if(use_metacells & !is.null(m_obj)){
    s_obj <- GetMetacellObject(seurat_obj, wgcna_name)
    s_obj <- m_obj
  } else{
  } else{
    if(is.null(m_obj)){warning("Metacell Seurat object not found. Using full Seurat object instead.")}
    s_obj <- seurat_obj
    s_obj <- seurat_obj
  }
  }


+12 −0
Original line number Original line Diff line number Diff line
@@ -261,6 +261,18 @@ MetacellsByGroups <- function(
    stop(paste0('Assay ', assay, ' not found in seurat_obj. Select a valid assay: ', paste0(names(seurat_obj@assays), collapse = ', ')))
    stop(paste0('Assay ', assay, ' not found in seurat_obj. Select a valid assay: ', paste0(names(seurat_obj@assays), collapse = ', ')))
  }
  }


  # check slot:
  if(!(slot %in% c('counts', 'data', 'scale.data'))){
    stop('Invalid input for slot. Valid choices are counts, data, scale.data.')
  } else{

    # check the shape of the slot
    slot_dim <- dim(GetAssayData(seurat_obj, assay=assay, slot=slot))
    if(any(slot_dim) == 0){
      stop(paste(c("Selected slot ", slot, " not found in this assay.")))
    }
  }

  # subset seurat object by seleted cells:
  # subset seurat object by seleted cells:
  if(!is.null(cells.use)){
  if(!is.null(cells.use)){
    seurat_full <- seurat_obj
    seurat_full <- seurat_obj
+1 −1
Original line number Original line Diff line number Diff line
@@ -39,7 +39,7 @@
      </button>
      </button>
      <span class="navbar-brand">
      <span class="navbar-brand">
        <a class="navbar-link" href="https://smorabit.github.io/hdWGCNA/index.html">hdWGCNA</a>
        <a class="navbar-link" href="https://smorabit.github.io/hdWGCNA/index.html">hdWGCNA</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.1.1.9014</span>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.1.1.9015</span>
      </span>
      </span>
    </div>
    </div>


Loading