group_cell: Group cells according to subject IDs

View source: R/group_cell.R

group_cellR Documentation

Group cells according to subject IDs

Description

Reorders the count matrix, subject IDs, predictors, and offset factors so that cells are grouped by subject ID. If cells are already grouped, returns NULL.

Usage

group_cell(count, id, pred = NULL, offset = NULL)

Arguments

count

A raw count matrix of the single-cell data. The rows are the genes, and the columns are the cells. The matrix can be a matrix object or a sparse dgCMatrix object.

id

A vector of subject IDs. The length should be the same as the number of columns of the count matrix.

pred

A design matrix of the predictors. The rows are the cells and the columns are the predictors. If not specified, an intercept column will be generated by default.

offset

A vector of the scaling factor. The values must be strictly positive. If not specified, a vector of all ones will be generated by default.

Details

Group cells according to subject IDs

Value

count: A reordered count matrix. If the cells are already grouped, the function returns NULL.

id: A reordered subject ID vector.

pred: A reordered design matrix of the predictors.

offset: A reordered vector of the scaling factor.

Examples

library(nebula)
data(sample_data)
pred = model.matrix(~X1+X2+cc,data=sample_data$pred)
df_order = group_cell(count=sample_data$count,id=sample_data$sid,pred=pred)


nebula documentation built on July 12, 2026, 9:06 a.m.