Skip to content

Commit

Permalink
Merge pull request #1022 from jiajic/suite_dev
Browse files Browse the repository at this point in the history
chore: remove some deprecated functions and remove or shift dependencies to modules
  • Loading branch information
jiajic authored Sep 12, 2024
2 parents eeefba8 + efdf9c0 commit 15c4fb9
Show file tree
Hide file tree
Showing 40 changed files with 504 additions and 1,082 deletions.
10 changes: 3 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Giotto
Title: Spatial Single-Cell Transcriptomics Toolbox
Version: 4.1.1
Version: 4.1.2
Authors@R: c(
person("Ruben", "Dries", email = "rubendries@gmail.com",
role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7650-7754")),
Expand Down Expand Up @@ -36,18 +36,14 @@ Imports:
BiocParallel,
BiocSingular,
checkmate,
cowplot (>= 0.9.4),
data.table (>= 1.12.2),
dbscan (>= 1.1-3),
ggplot2 (>= 3.1.1),
GiottoUtils (>= 0.1.9),
GiottoVisuals (>= 0.2.4),
GiottoUtils (>= 0.1.12),
GiottoVisuals (>= 0.2.5),
igraph (>= 1.2.4.1),
jsonlite,
Matrix (>= 1.6-2),
MatrixGenerics,
progressr,
reshape2,
reticulate (>= 1.25),
scales (>= 1.0.0),
sparseMatrixStats,
Expand Down
6 changes: 0 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export("prov<-")
export("sankeyLabel<-")
export("sankeyRelate<-")
export("spatUnit<-")
export(PAGEEnrich)
export(activeFeatType)
export(activeSpatUnit)
export(addCellIntMetadata)
Expand Down Expand Up @@ -138,7 +137,6 @@ export(createSpatLocsObj)
export(createSpatNetObj)
export(createSpatialDefaultGrid)
export(createSpatialDelaunayNetwork)
export(createSpatialEnrich)
export(createSpatialFeaturesKNNnetwork)
export(createSpatialGenomicsObject)
export(createSpatialGrid)
Expand Down Expand Up @@ -262,10 +260,8 @@ export(giottoToSeuratV4)
export(giottoToSeuratV5)
export(giottoToSpatialExperiment)
export(heatmSpatialCorFeats)
export(heatmSpatialCorGenes)
export(hexVertices)
export(hist)
export(hyperGeometricEnrich)
export(identifyTMAcores)
export(importCosMx)
export(importVisiumHD)
Expand Down Expand Up @@ -339,7 +335,6 @@ export(print.combIcfObject)
export(print.icfObject)
export(processGiotto)
export(prov)
export(rankEnrich)
export(rankSpatialCorGroups)
export(read10xAffineImage)
export(readCellMetadata)
Expand Down Expand Up @@ -375,7 +370,6 @@ export(runGiottoHarmony)
export(runHyperGeometricEnrich)
export(runIntegratedUMAP)
export(runPAGEEnrich)
export(runPAGEEnrich_OLD)
export(runPCA)
export(runPCAprojection)
export(runPCAprojectionBatch)
Expand Down
18 changes: 18 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@

# Giotto 4.1.2

## Breaking changes
* remove deprecated `PAGEEnrich()`. Use `runPAGEEnrich()` instead
* remove deprecated `rankEnrich()`. Use `runRankEnrich()` instead
* remove deprecated `hyperGeometricEnrich()`. Use `runHyperGeometricEnrich()` instead
* remove deprecated `createSpatialEnrich()`. Use `runSpatialEnrich()` instead
* remove deprecated `heatmSpatialCorGenes()`. Use `heatmSpatialCorFeats()` instead
* remove deprecated `runPAGEEnrich_OLD()`. Use `runPAGEEnrich()` instead

## Changes
* `limma`, `plotly`, and `Rtsne` moved to Suggests
* move `progressr` and `jsonlite` dependencies to GiottoUtils v0.1.12
* remove `reshape2` dependency.

# Giotto 4.1.1

## Bug fixes
* Allow `giottoInstructions` passing for Xenium convenience functions

## Changes
* Deprecate `screePlot()` `name` in favor of `dim_reduction_name` param


# Giotto 4.1.0 (2024/07/31)

Expand Down
4 changes: 2 additions & 2 deletions R/ONTraC_wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ plotNicheClusterConnectivity <- function( # nolint: object_name_linter.
)
gpl <- gpl + ggraph::scale_edge_alpha(range = c(0.1, 1))
gpl <- gpl + ggraph::scale_edge_colour_gradientn(
colours = RColorBrewer::brewer.pal(9, "Reds"),
colours = getColors("Reds", 9, src = "RColorBrewer"),
name = "Value"
)

Expand Down Expand Up @@ -764,4 +764,4 @@ plotCellTypeNTScore <- function(gobject, # nolint: object_name_linter.
save_param = save_param,
else_return = NULL
))
}
}
38 changes: 9 additions & 29 deletions R/auxiliary_giotto.R
Original file line number Diff line number Diff line change
Expand Up @@ -933,19 +933,12 @@ filterGiotto <- function(
)

### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
gobject <- set_expression_values(
gobject = gobject,
values = norm_expr
)

gobject <- set_expression_values(
gobject = gobject,
values = norm_scaled_expr
)
gobject <- setGiotto(gobject, norm_expr, initialize = FALSE)
gobject <- setGiotto(gobject, norm_scaled_expr, initialize = FALSE)
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###

## 6. return Giotto object
return(gobject)
return(initialize(gobject))
}


Expand Down Expand Up @@ -991,13 +984,9 @@ filterGiotto <- function(
)

### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
gobject <- set_expression_values(
gobject = gobject,
values = norm_feats_cells
)
gobject <- setGiotto(giotto, norm_feats_cells)
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###


return(gobject)
}

Expand Down Expand Up @@ -1088,10 +1077,7 @@ filterGiotto <- function(
)

### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
gobject <- set_expression_values(
gobject = gobject,
values = z
)
gobject <- setGiotto(gobject, z)
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###

return(gobject)
Expand Down Expand Up @@ -1391,10 +1377,7 @@ adjustGiottoMatrix <- function(
)

### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
gobject <- set_expression_values(
gobject = gobject,
values = adjusted_matrix
)
gobject <- setGiotto(gobject, adjusted_matrix)
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###

## update parameters used ##
Expand Down Expand Up @@ -1456,14 +1439,14 @@ processGiotto <- function(
adjust_params = list(),
verbose = TRUE) {
# filter Giotto
if (verbose == TRUE) message("1. start filter step")
vmsg(.v = verbose, "1. start filter step")
if (!inherits(filter_params, "list")) {
stop("filter_params need to be a list of parameters for filterGiotto")
}
gobject <- do.call("filterGiotto", c(gobject = gobject, filter_params))

# normalize Giotto
if (verbose == TRUE) message("2. start normalization step")
vmsg(.v = verbose, "2. start normalization step")
if (!inherits(norm_params, "list")) {
stop("norm_params need to be a list of parameters for normalizeGiotto")
}
Expand Down Expand Up @@ -1623,10 +1606,7 @@ addFeatStatistics <- function(
"mean_expr_det"
) := NULL]
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
gobject <- set_feature_metadata(gobject,
metadata = feat_metadata,
verbose = FALSE
)
gobject <- setGiotto(gobject, feat_metadata, verbose = FALSE)
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
}

Expand Down
28 changes: 14 additions & 14 deletions R/clustering.R
Original file line number Diff line number Diff line change
Expand Up @@ -1223,8 +1223,8 @@ doSNNCluster <- function(
#' @param set_seed set seed (default = TRUE)
#' @param seed_number number for seed
#' @returns if return_gobject = TRUE: giotto object with new clusters appended to cell metadata
#' @details The default settings will use dimension reduction results as input.
#' Set dim_reduction_to_use = NULL if you want to directly use expression values as input.
#' @details The default settings will use dimension reduction results as input.
#' Set dim_reduction_to_use = NULL if you want to directly use expression values as input.
#' By providing a feature vector to feats_to_use you can subset the expression matrix.
#' @seealso \code{\link[stats]{kmeans}}
#' @examples
Expand Down Expand Up @@ -1254,7 +1254,7 @@ doKmeans <- function(
return_gobject = TRUE,
set_seed = TRUE,
seed_number = 1234) {

# Set feat_type and spat_unit
spat_unit <- set_default_spat_unit(
gobject = gobject,
Expand All @@ -1276,9 +1276,9 @@ doKmeans <- function(

## using dimension reduction ##
if(!is.null(dim_reduction_to_use)) {

# use only available dimensions if dimensions < dimensions_to_use
dim_coord <- get_dimReduction(
dim_coord <- getDimReduction(
gobject = gobject,
spat_unit = spat_unit,
feat_type = feat_type,
Expand All @@ -1287,14 +1287,14 @@ doKmeans <- function(
name = dim_reduction_name,
output = "dimObj"
)

dimensions_to_use <- dimensions_to_use[
dimensions_to_use %in% seq_len(ncol(dim_coord[]))
]
matrix_to_use <- dim_coord[][, dimensions_to_use]

} else {

## using original matrix ##
expr_values <- getExpression(
gobject = gobject,
Expand All @@ -1303,21 +1303,21 @@ doKmeans <- function(
values = expression_values,
output = "exprObj"
)

# subset expression matrix
if (!is.null(feats_to_use)) {
expr_values[] <- expr_values[][
rownames(expr_values[]) %in% feats_to_use,
]
}

# features as columns
# cells as rows
matrix_to_use <- t_flex(expr_values[])

}


## distance
if (distance_method == "original") {
celldist <- matrix_to_use
Expand Down Expand Up @@ -2817,7 +2817,7 @@ getClusterSimilarity <- function(

# correlation matrix
cormatrix <- cor_flex(x = testmatrix, method = cor)
cor_table <- data.table::as.data.table(reshape2::melt(cormatrix))
cor_table <- melt_matrix(cormatrix)
data.table::setnames(
cor_table,
old = c("Var1", "Var2"), c("group1", "group2")
Expand Down
15 changes: 7 additions & 8 deletions R/convenience_cosmx.R
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,8 @@ setMethod("$<-", signature("CosmxReader"), function(x, name, value) {
)

fovs <- fovs %null% .cosmx_imgname_fovparser(path) # ALL if NULL
progressr::with_progress({
p <- progressr::progressor(along = fovs)
with_pbar({
p <- pbar(along = fovs)

gpolys <- lapply(fovs, function(f) {
segfile <- Sys.glob(paths = sprintf("%s/*F%03d*", path, f))
Expand Down Expand Up @@ -925,8 +925,8 @@ setMethod("$<-", signature("CosmxReader"), function(x, name, value) {
fovs <- fovs %null% .cosmx_imgname_fovparser(path) # ALL if NULL
verbose <- verbose %null% TRUE

progressr::with_progress({
p <- progressr::progressor(along = fovs)
with_pbar({
p <- pbar(along = fovs)

gimg_list <- lapply(fovs, function(f) {
imgfile <- Sys.glob(paths = sprintf("%s/*F%03d*", path, f))
Expand Down Expand Up @@ -1645,7 +1645,7 @@ createGiottoCosMxObject <- function(
provenance = "cell_agg"
)

cosmx_gobject <- set_expression_values(cosmx_gobject, values = s4_expr)
cosmx_gobject <- setGiotto(cosmx_gobject, s4_expr)

# Add spatial locations
if (isTRUE(verbose)) wrap_msg(
Expand All @@ -1669,9 +1669,8 @@ createGiottoCosMxObject <- function(
provenance = "cell_agg"
)

cosmx_gobject <- set_spatial_locations(cosmx_gobject, spatlocs = locsObj)
cosmx_gobject <- set_spatial_locations(cosmx_gobject,
spatlocs = locsObj_fov)
cosmx_gobject <- setGiotto(cosmx_gobject, locsObj, initialize = FALSE)
cosmx_gobject <- setGiotto(cosmx_gobject, locsObj_fov, initialize = FALSE)

# initialize cell and feat IDs and metadata slots for 'cell_agg' spat_unit
agg_cell_ID <- colnames(s4_expr[])
Expand Down
2 changes: 1 addition & 1 deletion R/convenience_general.R
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ addVisiumPolygons <- function(gobject,
return(NULL)
}

json_scalefactors <- jsonlite::read_json(json_path)
json_scalefactors <- read_json(json_path)

# Intial assertion that json dimensions are appropriate
checkmate::assert_list(
Expand Down
2 changes: 1 addition & 1 deletion R/convenience_visiumHD.R
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ setMethod("$<-", signature("VisiumHDReader"), function(x, name, value) {
json_path = file.path(path, 'scalefactors_json.json')
checkmate::assert_file_exists(json_path)

json_scalefactors <- jsonlite::read_json(json_path)
json_scalefactors <- read_json(json_path)

expected_json_names <- c(
"regist_target_img_scalef", # NEW as of 2023
Expand Down
8 changes: 4 additions & 4 deletions R/convenience_xenium.R
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ setMethod(
# decide micron scaling
if (length(obj@micron) == 0) { # if no value already set
if (!is.null(experiment_info_path)) {
obj@micron <- jsonlite::fromJSON(
obj@micron <- fromJSON(
experiment_info_path)$pixel_size
} else {
warning(wrap_txt("No .xenium file found.
Expand Down Expand Up @@ -914,7 +914,7 @@ importXenium <- function(
gene_ids <- match.arg(gene_ids, c("symbols", "ensembl"))

# tested on v1.6
j <- jsonlite::fromJSON(path)
j <- fromJSON(path)
# j$metadata # dataset meta
# j$payload # main content
# j$payload$chemistry # panel chemistry used
Expand Down Expand Up @@ -1102,8 +1102,8 @@ importXenium <- function(
# micron
checkmate::assert_numeric(micron)

progressr::with_progress({
p <- progressr::progressor(along = path)
with_pbar({
p <- pbar(along = path)

gimg_list <- lapply(seq_along(path), function(img_i) {
gimg <- .xenium_image_single(
Expand Down
Loading

0 comments on commit 15c4fb9

Please sign in to comment.