Skip to contents

Add a tile matrix from fragment data

Usage

# S3 method for class 'MarchRDataset'
add_tile_matrix(
  proj,
  frags_name = character(0),
  output_assay_name = "TileMatrix",
  genome = NULL,
  ranges = NULL,
  blacklist = TRUE,
  chrom_sizes = NULL,
  exclude_chr = c("chrM", "chrY"),
  tile_size = 500,
  mode = c("insertions", "fragments"),
  overwrite = TRUE,
  binarize = FALSE,
  materialize = TRUE,
  return_matrix = FALSE,
  ...
)

# S3 method for class 'MarchRProject'
add_tile_matrix(
  proj,
  frags_name = character(0),
  dataset_names = character(0),
  output_assay_name = "TileMatrix",
  ranges = NULL,
  blacklist = TRUE,
  chrom_sizes = NULL,
  exclude_chr = c("chrM", "chrY"),
  tile_size = 500,
  mode = c("insertions", "fragments"),
  overwrite = TRUE,
  binarize = FALSE,
  materialize = TRUE,
  return_matrix = FALSE,
  ...
)

Arguments

proj

(MarchRProject or MarchRDataset) Object containing fragments.

frags_name

(character) Fragment assay name. Auto-selected if only one exists.

output_assay_name

(character) Assay name for the tile matrix. Default: "TileMatrix".

genome

(Genome; optional) Genome object for chromosome sizes and blacklist. Required for MarchRDataset when chrom_sizes or blacklist = TRUE are not provided explicitly.

ranges

(data.frame; optional) Genomic ranges for tiling. If provided, tile_size, blacklist, exclude_chr, and chrom_sizes are ignored.

blacklist

(logical, data.frame, or GRanges) Blacklist regions to exclude. TRUE retrieves from genome/project; FALSE skips.

chrom_sizes

(data.frame; optional) Chromosome sizes. If not provided, uses genome/project chromosome sizes.

exclude_chr

(character) Chromosomes to exclude. Default: c("chrM", "chrY").

tile_size

(numeric) Tile width in base pairs. Default: 500.

mode

(character) One of "insertions" or "fragments".

overwrite

(logical) If TRUE, overwrite an existing assay with the same name. Default: TRUE.

binarize

(logical) If TRUE, binarize the tile matrix to 0/1. Default: FALSE.

materialize

(logical) If TRUE, compute the tile matrix once and store it on disk; if FALSE, keep it lazy and recompute it from fragments on every read. Default: TRUE.

return_matrix

(logical) If TRUE, returns the lazy IterableMatrix computed from fragments, without adding it to the object.

...

Must be empty; other arguments are an error.

dataset_names

(character) Datasets to process. Defaults to all datasets with fragments.

Value

Modified object with the tile matrix assay, or the lazy IterableMatrix if return_matrix = TRUE.

Details

Wraps BPCells::tile_matrix() to produce a tiles x cells count matrix from fragment data. The matrix is written column-major (each cell stored contiguously) with BPCells::transpose_storage_order(). Writing needs temporary disk space next to the output, about the size of the matrix. With materialize = FALSE, IterativeLSI runs slower and its results can differ from those on a stored matrix.