Skip to content

Commit

Permalink
Merge pull request #891 from drieslab/suite
Browse files Browse the repository at this point in the history
Catch up to suite
  • Loading branch information
Ed2uiz authored Feb 2, 2024
2 parents 47f3513 + 37df6f6 commit 73510e1
Show file tree
Hide file tree
Showing 82 changed files with 436 additions and 1,269 deletions.
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,3 @@ testdata
merfish_preoptic/

*.DS_Store
:temp:
*.wal

*.RDS
*.db
15 changes: 5 additions & 10 deletions R/auxiliary_giotto.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
}))
}


#' @title Normalize expression matrix for library size
#' @param mymatrix matrix object
#' @param scalefactor scalefactor
Expand All @@ -32,16 +31,15 @@
This will likely result in normalization problems.
filter (filterGiotto) or impute (imputeGiotto) spatial units.'))
}

norm_expr = t_flex(t_flex(mymatrix)/ libsizes)*scalefactor

norm_expr = t_flex(t_flex(mymatrix)/ libsizes)*scalefactor
return(norm_expr)
}

#' @title Log normalize expression matrix
#' @keywords internal
.log_norm_giotto = function(mymatrix, base, offset) {

if(methods::is(mymatrix, 'DelayedArray')) {
mymatrix = log(mymatrix + offset)/log(base)
# } else if(methods::is(mymatrix, 'DelayedMatrix')) {
Expand All @@ -50,9 +48,6 @@
mymatrix@x = log(mymatrix@x + offset)/log(base) # replace with sparseMatrixStats
} else if(methods::is(mymatrix, 'Matrix')) {
mymatrix@x = log(mymatrix@x + offset)/log(base)
} else if(methods::is(mymatrix, 'dbMatrix')) {
mymatrix[] = dplyr::mutate(mymatrix[], x = x + offset) # workaround for lack of @x slot
mymatrix = log(mymatrix)/log(base)
} else {
mymatrix = log(as.matrix(mymatrix) + offset)/log(base)
}
Expand Down Expand Up @@ -518,13 +513,13 @@ filterGiotto = function(gobject,
# 2. then remove cells that do not have sufficient detected genes

## filter features
filter_index_feats = GiottoClass::rowSums_flex(expr_values >= expression_threshold) >= feat_det_in_min_cells
filter_index_feats = rowSums_flex(expr_values >= expression_threshold) >= feat_det_in_min_cells
selected_feat_ids = names(filter_index_feats[filter_index_feats == TRUE])



## filter cells
filter_index_cells = GiottoClass::colSums_flex(expr_values[filter_index_feats, ] >= expression_threshold) >= min_det_feats_per_cell
filter_index_cells = colSums_flex(expr_values[filter_index_feats, ] >= expression_threshold) >= min_det_feats_per_cell
selected_cell_ids = names(filter_index_cells[filter_index_cells == TRUE])


Expand Down Expand Up @@ -652,7 +647,7 @@ filterGiotto = function(gobject,
## 1. library size normalize
if(library_size_norm == TRUE) {
norm_expr = .lib_norm_giotto(mymatrix = raw_expr[],
scalefactor = scalefactor)
scalefactor = scalefactor)
} else {
norm_expr = raw_expr[]
}
Expand Down
9 changes: 5 additions & 4 deletions R/spatial_genes.R
Original file line number Diff line number Diff line change
Expand Up @@ -1622,8 +1622,9 @@ silhouetteRank <- function(gobject,

# expression values
values = match.arg(expression_values, c('normalized', 'scaled', 'custom'))
expr_values = get_expression_values(gobject = gobject,
values = values)
expr_values = getExpression(gobject = gobject,
values = values,
output = "matrix")

# subset genes
if(!is.null(subset_genes)) {
Expand All @@ -1638,9 +1639,9 @@ silhouetteRank <- function(gobject,

# spatial locations
# spatlocs = as.matrix(gobject@spatial_locs[['cell']][['raw']][,.(sdimx, sdimy)])
spatlocs = get_spatial_locations(gobject,
spatlocs = getSpatialLocations(gobject,
spat_unit = 'cell',
spat_loc_name = 'raw',
name = 'raw',
output = 'data.table',
copy_obj = TRUE)
spatlocs = as.matrix(spatlocs[,.(sdimx, sdimy)])
Expand Down
3 changes: 0 additions & 3 deletions R/spatial_interaction_visuals.R
Original file line number Diff line number Diff line change
Expand Up @@ -2262,9 +2262,6 @@ plotRankSpatvsExpr = function(gobject,
midpoint = gradient_midpoint,
style = gradient_style,
type = 'color',
type_default = list(
pal = c('blue', 'yellow', 'red')
),
guide = guide_legend(title = '')
)
pl = pl + ggplot2::scale_size_continuous(range = size_range, guide = "none")
Expand Down
3 changes: 3 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ navbar:
href: articles/terra.html
- text: Docker
href: articles/docker.html
- text: Singularity
href: articles/singularity.html
articles:
text: Examples
menu:
Expand Down Expand Up @@ -210,6 +212,7 @@ articles:
contents:
- terra
- docker
- singularity
- title: Spatial Manipulation
navbar: ~
contents:
Expand Down
3 changes: 0 additions & 3 deletions tests/testthat/.gitignore

This file was deleted.

43 changes: 0 additions & 43 deletions tests/testthat/test-dbMatrix_filterGiotto.R

This file was deleted.

62 changes: 0 additions & 62 deletions tests/testthat/test-dbMatrix_libNorm.R

This file was deleted.

62 changes: 0 additions & 62 deletions tests/testthat/test-dbMatrix_logNorm.R

This file was deleted.

62 changes: 0 additions & 62 deletions tests/testthat/test-dbMatrix_scale.R

This file was deleted.

Loading

0 comments on commit 73510e1

Please sign in to comment.