Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new generic function agglomerateByVariable #507

Merged
merged 28 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mia
Type: Package
Version: 1.13.2
Version: 1.13.3
Authors@R:
c(person(given = "Felix G.M.", family = "Ernst", role = c("aut"),
email = "[email protected]",
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export(addPerSampleDominantTaxa)
export(addTaxonomyTree)
export(agglomerateByPrevalence)
export(agglomerateByRank)
export(agglomerateByVariable)
export(bestDMNFit)
export(calculateDMN)
export(calculateDMNgroup)
Expand Down Expand Up @@ -124,6 +125,7 @@ exportMethods(addPerSampleDominantTaxa)
exportMethods(addTaxonomyTree)
exportMethods(agglomerateByPrevalence)
exportMethods(agglomerateByRank)
exportMethods(agglomerateByVariable)
exportMethods(bestDMNFit)
exportMethods(calculateCCA)
exportMethods(calculateDMN)
Expand Down Expand Up @@ -288,7 +290,6 @@ importFrom(SummarizedExperiment,rowRanges)
importFrom(ape,cophenetic.phylo)
importFrom(ape,drop.tip)
importFrom(ape,is.rooted)
importFrom(ape,keep.tip)
importFrom(ape,node.depth)
importFrom(ape,node.depth.edgelength)
importFrom(ape,prop.part)
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,4 @@ Changes in version 1.11.x
Changes in version 1.13.x
+ Added new functions getMediation and addMediation
+ replace getExperiment* and testExperiment* functions with getCrossAssociation
+ Replace mergeRows and mergeCols with new function agglomerateByVariable
246 changes: 153 additions & 93 deletions R/agglomerate.R

Large diffs are not rendered by default.

192 changes: 174 additions & 18 deletions R/deprecate.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,169 @@ setMethod("taxonomyTree", signature = c(x = "SummarizedExperiment"),
}
)

#' @rdname deprecate
#' @export
setGeneric("mergeRows",
signature = "x",
function(x, ...)
standardGeneric("mergeRows"))

#' @rdname deprecate
#' @export
setMethod("mergeRows", signature = c(x = "SummarizedExperiment"),
function(x, ...){
.Deprecated(msg = paste0("'mergeRows' is deprecated. ",
"Use 'agglomerateByVariable' with ",
"parameter MARGIN = 'rows' instead."))
agglomerateByVariable(x, MARGIN = "rows", ...)
}
)

#' @rdname deprecate
#' @export
setMethod("mergeRows", signature = c(x = "TreeSummarizedExperiment"),
function(x, ...){
.Deprecated(msg = paste0("'mergeRows' is deprecated. ",
"Use 'agglomerateByVariable' with ",
"parameter MARGIN = 'rows' instead."))
agglomerateByVariable(x, MARGIN = "rows", ...)
}
)

#' @rdname deprecate
#' @export
setGeneric("mergeCols",
signature = "x",
function(x, ...)
standardGeneric("mergeCols"))

#' @rdname deprecate
#' @export
setMethod("mergeCols", signature = c(x = "SummarizedExperiment"),
function(x, ...){
.Deprecated(msg = paste0("'mergeCols' is deprecated. ",
"Use 'agglomerateByVariable' with ",
"parameter MARGIN = 'cols' instead."))
agglomerateByVariable(x, MARGIN = "cols", ...)
}
)

#' @rdname deprecate
#' @export
setMethod("mergeCols", signature = c(x = "TreeSummarizedExperiment"),
function(x, ...){
.Deprecated(msg = paste0("'mergeCols' is deprecated. ",
"Use 'agglomerateByVariable' with ",
"parameter MARGIN = 'cols' instead."))
agglomerateByVariable(x, MARGIN = "cols", ...)
}
)

#' @rdname deprecate
#' @export
setGeneric("mergeFeatures",
signature = "x",
function(x, ...)
standardGeneric("mergeFeatures"))

#' @rdname deprecate
#' @export
setMethod("mergeFeatures", signature = c(x = "SummarizedExperiment"),
function(x, ...){
.Deprecated(msg = paste0("'mergeFeatures' is deprecated. ",
"Use 'agglomerateByVariable' with ",
"parameter MARGIN = 'rows' instead."))
agglomerateByVariable(x, MARGIN = "rows", ...)
}
)

#' @rdname deprecate
#' @export
setMethod("mergeFeatures", signature = c(x = "TreeSummarizedExperiment"),
function(x, ...){
.Deprecated(msg = paste0("'mergeFeatures' is deprecated. ",
"Use 'agglomerateByVariable' with ",
"parameter MARGIN = 'rows' instead."))
agglomerateByVariable(x, MARGIN = "rows", ...)
}
)

#' @rdname deprecate
#' @export
setGeneric("mergeSamples",
signature = "x",
function(x, ...)
standardGeneric("mergeSamples"))

#' @rdname deprecate
#' @export
setMethod("mergeSamples", signature = c(x = "SummarizedExperiment"),
function(x, ...){
.Deprecated(msg = paste0("'mergeSamples' is deprecated. ",
"Use 'agglomerateByVariable' with ",
"parameter MARGIN = 'cols' instead."))
agglomerateByVariable(x, MARGIN = "cols", ...)
}
)

#' @rdname deprecate
#' @export
setMethod("mergeSamples", signature = c(x = "TreeSummarizedExperiment"),
function(x, ...){
.Deprecated(msg = paste0("'mergeSamples' is deprecated. ",
"Use 'agglomerateByVariable' with ",
"parameter MARGIN = 'cols' instead."))
agglomerateByVariable(x, MARGIN = "cols", ...)
}
)

#' @rdname deprecate
#' @export
setGeneric("mergeFeaturesByRank",
signature = "x",
function(x, ...)
standardGeneric("mergeFeaturesByRank"))

#' @rdname deprecate
#' @export
setMethod("mergeFeaturesByRank", signature = c(x = "SummarizedExperiment"),
function(x, ...){
.Deprecated(msg = paste0("'mergeFeaturesByRank' is deprecated. ",
"Use 'agglomerateByRank' instead."))
x <- agglomerateByRank(x, ...)
x
}
)

#' @rdname deprecate
#' @export
setMethod("mergeFeaturesByRank", signature = c(x = "SingleCellExperiment"),
function(x, ...){
.Deprecated(msg = paste0("'mergeFeaturesByRank' is deprecated. ",
"Use 'agglomerateByRank' instead."))
x <- agglomerateByRank(x, ...)
x
}
)

#' @rdname deprecate
#' @export
setGeneric("mergeFeaturesByPrevalence", signature = "x",
function(x, ...)
standardGeneric("mergeFeaturesByPrevalence"))

#' @rdname deprecate
#' @export
setMethod("mergeFeaturesByPrevalence", signature = c(x = "SummarizedExperiment"),
function(x, ...){
.Deprecated(msg = paste0(
"'mergeFeaturesByPrevalence' is deprecated. ",
"Use agglomerateByPrevalence instead."))
x <- agglomerateByPrevalence(x, ...)
x
}
)

#' @rdname deprecate
#' @export
setGeneric("getExperimentCrossAssociation", signature = c("x"),
Expand Down Expand Up @@ -89,6 +252,17 @@ setMethod("getExperimentCrossAssociation", signature = "SummarizedExperiment",
}
)

#' @rdname deprecate
#' @export
setMethod("mergeFeaturesByRank", signature = c(x = "TreeSummarizedExperiment"),
function(x, ...){
.Deprecated(msg = paste0("'mergeFeaturesByRank' is deprecated. ",
"Use 'agglomerateByRank' instead."))
x <- agglomerateByRank(x, ...)
x
}
)

#' @rdname deprecate
#' @export
setGeneric("testExperimentCrossAssociation", signature = c("x"),
Expand Down Expand Up @@ -140,24 +314,6 @@ setMethod("getExperimentCrossCorrelation", signature = c(x = "ANY"),
}
)

#' @rdname deprecate
#' @export
setGeneric("mergeFeaturesByPrevalence", signature = "x",
function(x, ...)
standardGeneric("mergeFeaturesByPrevalence"))

#' @rdname deprecate
#' @export
setMethod("mergeFeaturesByPrevalence", signature = c(x = "SummarizedExperiment"),
function(x, ...){
.Deprecated(msg = paste0(
"'mergeFeaturesByPrevalence' is deprecated. ",
"Use agglomerateByPrevalence instead."))
x <- agglomerateByPrevalence(x, ...)
x
}
)

#' @rdname deprecate
#' @export
loadFromBiom <- function(...) {
Expand Down
4 changes: 3 additions & 1 deletion R/getPrevalence.R
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,9 @@ setMethod("agglomerateByPrevalence", signature = c(x = "SummarizedExperiment"),
pr <- getPrevalentTaxa(x, rank = NULL, ...)
f <- rownames(x) %in% pr
if(any(!f)){
other_x <- mergeRows(x[!f,], factor(rep(1L,sum(!f))), check_assays = FALSE)
other_x <- agglomerateByVariable(x[!f,], MARGIN = "rows",
factor(rep(1L,sum(!f))),
check_assays = FALSE)
rowData(other_x)[,colnames(rowData(other_x))] <- NA
# set the other label
rownames(other_x) <- other_label
Expand Down
Loading
Loading