Aggregate rows of a matrix for many:1 mappings, using a grouping vector.
aggregate_rows(
X,
groupings,
agg_fun = "sum",
agg_method = c("monocle3", "stats"),
as_sparse = TRUE,
as_DelayedArray = TRUE,
dropNA = TRUE,
verbose = TRUE
)
data("exp_mouse_enst")
X <- exp_mouse_enst
gene_map <- map_genes(genes = rownames(X),species = "mouse")
X_agg <- orthogene:::aggregate_rows(X = X,
groupings = gene_map$name)
sum(duplicated(rownames(exp_mouse))) # 0
sum(duplicated(rownames(X))) # 1215
sum(duplicated(rownames(X_agg))) # 0
Input matrix.
Gene groups of the same length as nrow(X)
.
Aggregation function.
Aggregation method.
Convert aggregated matrix to sparse matrix.
Convert aggregated matrix to DelayedArray.
Drop genes assigned to NA
in groupings
.
Print messages.
Aggregated matrix