Skip to contents

This is the bixverse-based meta cell class. It is generated by running meta-cell generating functions on top of the main class. Due to the aggregation of the count matrices to a way smaller number of meta cells, the data is held in memory for this class specifically. Additional methods that make specific usage of meta cells (especially co-expression module detection ones will be made available).

Usage

MetaCells(
  meta_cell_data,
  var_data,
  meta_cell_method,
  obs_ids = NULL,
  cells_to_keep = NULL
)

Arguments

meta_cell_data

Named list. Output of meta-cell generation Rust functions. Will contain the aggregated raw and normalised counts, plus additional information on the origin of the meta cells.

var_data

data.table with the variable/feature informations.

meta_cell_method

String describing the origin of the metacell.

obs_ids

Optional character vector of length n_metacells with the meta cell identifiers. Defaults to meta_cell_0001, meta_cell_0002, ... Used by merge_meta_cells() so that the count matrices get their final row names at construction time rather than via a rownames<- that would duplicate them.

cells_to_keep

Optional integer vector. The source's get_cells_to_keep(), i.e. 0-indexed positions in its full obs table, in the row order its cached artefacts use. Recorded so that the meta cell memberships, which are positions in the full obs space, can be resolved against embeddings, kNN graphs and diffusion maps, whose rows only cover the QC-passing cells.

Value

Returns the MetaCells class for further operations.

Properties

obs_table

The meta cell observation table.

var_table

The meta cell variable table.

data

List with the raw and normalised counts.

sc_cache

Class with embeddings, kNN/sNN graphs, etc. Shared with SingleCells().

original_assignment

List with original assignment information.

dims

Dimensions of the new meta cell matrices.

other_data

Potential other data returned from the meta-cell generating methods.

is_merged

Boolean. TRUE for objects returned by merge_meta_cells(). Methods that need to resolve original_cell_idx against the source single cell data use this to bail out early.

Examples

# the class is produced by the aggregation functions, not built by hand
sc <- demo_single_cells()
mc <- generate_bt_meta_cells_sc(
  sc,
  sc_meta_cell_params = params_sc_bt_metacells(target_no_metacells = 50L),
  .verbose = FALSE
)
mc
#> Single cell experiment (Meta Cells).
#>   Meta cell method: meta_cells_hdwgcna
#>   Merged: FALSE
#>   No meta cells: 50
#>   No genes: 50
#>   No cells aggregated: 366
#>   No obs rows in source: 500
#>   HVG calculated: FALSE
#>   PCA calculated: FALSE
#>   Other embeddings: none
#>   KNN generated: FALSE
#>   SNN generated: FALSE
#>   Stale artefacts: none

unlink(sc@dir_data, recursive = TRUE, force = TRUE)