fetch_vdj: Fetch V(D)J data from object

View source: R/mutate-vdj.R

fetch_vdjR Documentation

Fetch V(D)J data from object

Description

Fetch per-chain V(D)J data from object. Within the object meta.data, each row represents a single cell and can include information for multiple chains. This function can return a data.frame where each row represents a single chain. This is useful for plotting per-chain metrics such as CDR3 length or the number of insertions/deletions.

Usage

fetch_vdj(
  input,
  data_cols = NULL,
  clonotype_col = NULL,
  filter_cells = FALSE,
  per_chain = TRUE,
  unnest = TRUE,
  sep = global$sep
)

Arguments

input

Single cell object or data.frame containing V(D)J data. If a data.frame is provided, the cell barcodes should be stored as row names.

data_cols

meta.data columns containing per-chain V(D)J data to unnest. If NULL, V(D)J data are automatically selected by identifying columns that have NAs in the same rows as clonotype_col.

clonotype_col

meta.data column containing clonotype IDs. This column is used to determine which columns have V(D)J data. If both clonotype_col and data_cols are NULL, all columns are included.

filter_cells

Remove cells that do not have V(D)J data, clonotype_col must be provided to determine which cells to filter.

per_chain

If TRUE return per-chain data, i.e. each row represents a chain.

unnest

If FALSE, a nested data.frame is returned where each row represents a cell and V(D)J data is stored as list-cols. If TRUE, columns are unnested so each row represents a single chain.

sep

Separator used for storing per cell V(D)J data. This is used to identify columns containing per-chain data that can be unnested.

Value

data.frame containing V(D)J data

Examples

# Fetch per-chain V(D)J data
fetch_vdj(vdj_sce)

# To increase performance, specify which columns to return per-chain data,
# per-cell data will be returned for all other columns
fetch_vdj(
  vdj_sce,
  data_cols = c("chains", "reads")
)

# Only include cells that have V(D)J data
# clonotype_col must be specified to identify cells with V(D)J data
fetch_vdj(
  vdj_sce,
  filter_cells = TRUE,
  clonotype_col = "clonotype_id"
)


rnabioco/AVIDtools documentation built on Oct. 28, 2023, 10:23 a.m.