.replace_by_most_frequent_categories | R Documentation |
Used for mapping identity columns across objects. This function replaces each category in a query column of a data frame with the most frequently corresponding category in a reference column. It calculates the assignment quality, reports it, and optionally plots it.
.replace_by_most_frequent_categories(
df,
query_col = colnames(df)[1],
ref_col = colnames(df)[2],
show_plot = TRUE,
suffix_barplot = NULL,
ext = "png",
min.thr = 0.5,
...
)
df |
A data frame containing the data. |
query_col |
The name of the column in 'df' whose categories are to be replaced. By default, the first column of 'df' is used. |
ref_col |
The name of the column in 'df' used as reference for replacement. By default, the second column of 'df' is used. |
show_plot |
Logical, whether to plot assignment quality. Defaults to TRUE. |
suffix_barplot |
Suffix for barplot. |
... |
Additional parameters passed to the qbarplot function. |
A data frame with categories in 'query_col' replaced by the most frequent match from 'ref_col'.
## Not run:
.replace_by_most_frequent_categories(df = my_data)
(MXX <- as.tibble(structure(
c(
"Adjut", "Adjut", "Yearn", "Adjut", "Dwarf", "Adjut",
"Dwarf", "Adjut", "Dwarf", "Yearn", "Dwarf", "Dwarf", "Dwarf",
"Yearn", "Dwarf", "Dwarf", "Dwarf", "Zebra", "Yucca", "Plyer",
"Blaze", "Blaze", "Dazed", "Blaze", "Swept", "Bold", "Vixen",
"Bold", "Swept", "Dazed", "Mirth", "Witch", "Vixen", "Dazed",
"Swept", "Mirth", "Swept", "Vexed", "Query", "Yolk"
),
.Dim = c(20L, 2L), .Dimnames =
list(NULL, c("RNA_snn_res.0.1.ordered", "RNA_snn_res.0.3.ordered"))
)))
z <- .replace_by_most_frequent_categories(df = MXX)
head(cbind(MXX[, 1], z[, 1]))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.