Commit b4842b7c authored by smorabit's avatar smorabit
Browse files

error checking

parent 3efaabc3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
Package: hdWGCNA
Title: hdWGCNA
Version: 0.2.02
Version: 0.2.03
Authors@R: c(
    person("Sam", "Morabito", , "smorabit@uci.edu", role = c("aut", "cre"),
           comment = c(ORCID = "0000-0002-7768-4856")),
+9 −0
Original line number Diff line number Diff line
# hdWGCNA 0.2.03 (2022-11-010)
## Added
- None

## Changes
- New error checking in `MetaspotsByGroups`
- `MetacellsByGroups` now keeps track of which cells were merged.


# hdWGCNA 0.2.02 (2022-11-01)
## Added
- None
+14 −2
Original line number Diff line number Diff line
@@ -31,7 +31,19 @@ ConstructMetaspots <- function(

  # loop boundaries
  col_bounds <- col_range[1]:col_range[2]

  if(length(col_bounds) >= 4){
    col_bounds <- col_bounds[which(1:length(col_bounds) %% 4 == 0)]
  } else if(length(col_bounds) == 3){
    warning('The selected grouping is spatially constrained and might fail the metaspot aggregation step. You may wish to change the group.by parameter to form larger groups.')
    col_bounds <- col_bounds[2]
  } else if(length(col_bounds) >= 1){
    warning('The selected grouping is spatially constrained and might fail the metaspot aggregation step. You may wish to change the group.by parameter to form larger groups.')
    col_bounds <- col_bounds[1]
  } else{
    warning('No columns specified. Need to change the group.by parameter.')
    return()
  }

  # even or odd cols?
  if(all(col_bounds %% 2 == 0)){even = TRUE} else{even = FALSE}
@@ -102,7 +114,6 @@ ConstructMetaspots <- function(
    })

    if(length(tmp) <= 1){
      print('here')
      next
    }

@@ -130,6 +141,7 @@ ConstructMetaspots <- function(

  # combine expression results
  if(length(tmp) <= 1){
    warning('Metaspot aggregation failed for this grouping.')
    return(NULL)
  }
  agg_X <- do.call(rbind, lapply(1:length(tmp), function(k){tmp[[k]][[3]]}))
+4 −0
Original line number Diff line number Diff line
@@ -108,6 +108,10 @@ MetaspotsByGroups <- function(
    metaspot_list <- metaspot_list[-remove]
  }

  if(length(metaspot_list) == 0){
    stop('All metaspot aggregations failed.')
  }

  # combine density information:
  if(length(metaspot_list) > 1){
    density_agg <- unlist(lapply(metaspot_list, function(x){x@misc$density_agg}))
+8 −1
Original line number Diff line number Diff line
@@ -92,6 +92,11 @@ ConstructMetacells <- function(
  #
  # combs <- combn(nrow(cell_sample), 2)

  # get a list of the cell barcodes that have been merged:
  cells_merged <- apply(cell_sample, 1, function(x){
    paste0(colnames(seurat_obj)[x], collapse=',')
  })

  combs <- tryCatch(
    {combn(nrow(cell_sample), 2)},
    error = function(cond){return(NA)}
@@ -101,7 +106,6 @@ ConstructMetacells <- function(
    return(NULL)
  }


  shared <- apply(combs, 2, function(x) {
      k2 - length(unique(as.vector(cell_sample[x, ])))
  })
@@ -148,6 +152,9 @@ ConstructMetacells <- function(
    )
  }

  # add the cells merged info to the metacell obj
  metacell_obj$cells_merged <- as.character(cells_merged)

  # calculate stats:
  # shared <- shared[shared <= max_shared]
  max_shared <- max(shared)
Loading