View source: R/calc-frequency.R
calc_frequency | R Documentation |
Calculate the frequency of each cell label present in the provided meta.data column. This is useful for comparing the proportion of cells belonging to different samples, cell types, clonotypes, isotypes, etc.
calc_frequency(
input,
data_col,
cluster_col = NULL,
prefix = paste0(data_col, "_"),
return_df = FALSE,
per_chain = FALSE,
chain = NULL,
chain_col = global$chain_col,
sep = global$sep
)
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_col |
meta.data column containing cell labels to use for calculating frequency. To calculate clonotype frequencies, provide the column containing clonotype IDs, to calculate isotype frequencies provide the column containing cell isotypes. By default the clonotype_id is used for calculations. |
cluster_col |
meta.data column containing cluster IDs to use for grouping cells when calculating clonotype abundance |
prefix |
Prefix to add to new columns |
return_df |
Return results as a data.frame. If set to |
per_chain |
If |
chain |
Chain(s) to use for calculating frequency. Set to |
chain_col |
meta.data column(s) containing chains for each cell |
sep |
Separator used for storing per-chain V(D)J data for each cell |
Single cell object or data.frame with clonotype frequencies
plot_frequency()
, plot_clone_frequency()
# Calculate clonotype abundance using all cells
res <- calc_frequency(
vdj_sce,
data_col = "clonotype_id"
)
head(slot(res, "colData"), 1)
# Group cells based on meta.data column before calculating abundance
res <- calc_frequency(
vdj_sce,
data_col = "clonotype_id",
cluster_col = "orig.ident"
)
head(slot(res, "colData"), 1)
# Add a prefix to the new columns
# this is useful if multiple abundance calculations are stored in the
# meta.data
res <- calc_frequency(
vdj_sce,
data_col = "clonotype_id",
prefix = "bcr_"
)
head(slot(res, "colData"), 1)
# Return a data.frame instead of adding the results to the input object
res <- calc_frequency(
vdj_sce,
data_col = "clonotype_id",
return_df = TRUE
)
head(res, 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.