Skip to contents

Reads an extraction directory, applies the cell QC (cell_qc(); with a qc_pass column of cell_meta a cell must also have qc_pass TRUE; cells restricts the run to a set of cells instead, without QC), annotates arms, filters bins (default: bin_filter() on the kept cells, chr1-22 and chrX), normalises depth (normalise_depth(): celltype for normal tissue, model for tumours), builds the regions (region_set()), the depth features (depth_features()), the molecule votes (read_votes()) and the oriented allele features (allelic_features()), and joins them into the long features table (vignette("scphasedcn-outputs", package = "scphasedcn")).

Usage

cell_features(
  dir,
  cells = NULL,
  cell_meta = NULL,
  method = c("celltype", "model"),
  ref_cells = NULL,
  min_cells_type = 20,
  use = NULL,
  sex = NULL,
  centromeres = NULL,
  classes = c("arm", "chrom", "5Mb", "10Mb", "20Mb", "50Mb"),
  events = NULL,
  null_exclude = character(),
  phasing = "auto",
  groups = NULL,
  mol_gap = params$mol_gap,
  keep_votes = TRUE,
  layers = character(),
  qc = list(),
  params = caller_defaults(),
  verbose = FALSE,
  exclude_atoms = NULL
)

Arguments

dir

extraction directory (bins_100kb.h5ad, fragments.tsv.gz + .tbi, cells_qc.tsv)

cells

NULL (QC-pass cells) or the cells to use (no QC)

cell_meta

NULL or a data.table with cell and optional qc_pass, cell_type, flat, fold, group, stratum, n_frag (used as-is; NA cell_type = no type-matched reference; NA or missing stratum / n_frag keep the QC values). With cells NULL only cells of cell_meta are used, and with a qc_pass column (e.g. make_cell_meta()) only those with qc_pass TRUE that also pass cell_qc() with the qc arguments

method

depth normalisation, "celltype" or "model" (any normalise_depth() method is accepted)

ref_cells

reference cells of the normalisation (selector; NULL = all)

min_cells_type

celltype: minimal reference cells of a type

use

NULL or a logical bin filter

sex

"female" / "male" (case-insensitive, or "F" / "M"; any other value stops; NULL: the cells' sex column, whose non-missing values must all give the same sex)

centromeres

centromere table or path (Battenberg layout, see arm_table(); NULL: the hg38 table shipped with the package, hg38_centromeres())

classes

region classes

events

named events (see region_set())

null_exclude

chromosomes / regions without null rows (known events)

phasing

"auto", "chromosome", "block" (= "loo"), "loo" or "mirrored". auto = chromosome when detect_phasing() finds chromosome-wide phase sets, else loo. Chromosome-wide phasing is recommended for normal tissue (scphasedcn hybrid-phase; vignette("scphasedcn-inputs") for its limits): loo orients each block by the other cells, cannot show allelic events carried by few cells and aligns allelic bias shared by all cells

groups

NULL, the name of a cell_meta column, a vector named by cell, or one label per kept cell: the pseudobulk groups of the block orientation (NA = all-cell pseudobulk)

mol_gap

molecule gap (bp; default params$mol_gap, 2000); params$mol_split_ps and params$votes_clean set the molecule split by phase set and the blacklist filter of the votes (read_votes())

keep_votes

keep the votes table in the result

layers

bin layers to read (none are needed by the depth normalisation)

qc

named list of cell_qc() arguments

params

caller_defaults()

verbose

log each step (the run notes) as it happens

exclude_atoms

NULL or atom ids whose votes are left out of the allele features (see allelic_features())

Value

scn_features list: long (features, keyed by cell and region), regions, cells (row order = the votes' cell index), votes, atoms, win (window_matrices()), params, notes, use, phasing (detected, orientation), phasing_chrom (the per-chromosome regimes, phasing_by_chrom(); the notes name chromosomes whose regime differs from detected)