Skip to content

Commit

Permalink
Need to use match when setting both rows and cols of the sparse Matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
rfriedman22 committed Dec 20, 2024
1 parent 2a27eab commit f02532f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/cluster_genes.R
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,12 @@ aggregate_gene_expression <- function(cds,
gene_group_df[[1]] <- geneids
}

# browser()
unique_gene_ids <- unique(gene_group_df[, 1])
agg_mat <- agg_mat[unique_gene_ids, , drop = FALSE]
gene_groups <- unique(gene_group_df[, 2])
X <- Matrix::sparseMatrix(
i = gene_group_df[, 2],
i = match(gene_group_df[, 2], gene_groups),
j = match(gene_group_df[, 1], unique_gene_ids),
x = 1,
dims = c(length(gene_groups), length(unique_gene_ids)),
Expand Down

0 comments on commit f02532f

Please sign in to comment.