matchBestIdentity: Match and Translate Best Identity

View source: R/Seurat.Utils.Metadata.R

matchBestIdentityR Documentation

Match and Translate Best Identity

Description

This function matches the best identity from ident_to_rename to reference_ident in an object, in other words, it replaces original categories with the most frequent ones from the reference, hence helps to filter out less important categories.

Usage

matchBestIdentity(
  obj,
  ident_to_rename,
  reference_ident = GetOrderedClusteringRuns(obj)[1],
  prefix = reference_ident,
  suffix = gsub(prefix, "", x = reference_ident),
  new_ident_name = kpp(prefix, ident_to_rename, "match.to", suffix),
  plot_suffix = prefix,
  barplot_match = TRUE,
  barplot_fractions = TRUE,
  rnd_colors = T,
  w = 12,
  h = 9,
  ...
)

Arguments

obj

The object to update. This object must have a meta.data attribute which is a data frame containing columns named as ident_to_rename and reference_ident.

ident_to_rename

A string. The name of the column in obj@meta.data that is used as the source of identities. There is no default value for this parameter.

reference_ident

A string. The name of the column in obj@meta.data that is used as the target of identities. There is no default value for this parameter.

prefix

A string to add to the new identity column name. Default is prefix = Reference.

suffix

...

new_ident_name

A string. The name for the newly created identity column in obj@meta.data. Default is a concatenation: kpp(prefix, ident_to_rename, "match.to", reference_ident) .

plot_suffix

A string. The suffix to add to the final UMAP.

barplot_match

Draw a barplot to show the % match between the original and new identities. Default: TRUE

barplot_fractions

Draw a barplot to show the % of each category in the original and new identities, using scBarplot.CellFractions(). Default: TRUE

w

Width for the saved image. Default: 9

h

Height for the saved image. Default: 12

...

Additional parameters to be passed to .replace_by_most_frequent_categories function.

Value

An updated version of obj with an additional column in obj@meta.data named as new_ident_name representing the new identity. The function also generates a UMAP plot based on this new identity.

See Also

clUMAP, kpp, FixPlotName, .replace_by_most_frequent_categories

Examples

## Not run: 
updated_obj <- matchBestIdentity(my_obj, "origin_identity", "target_identity")

## End(Not run)

vertesy/Seurat.utils documentation built on Dec. 4, 2024, 5:20 p.m.