metrics_to_fractions: Calculate fractions from a set of tidycyte metrics

Description Usage Arguments Details Value Examples

View source: R/metrics_to_fractions.R

Description

Accepts as arguments multiple sets of metrics and then calculates the proportion that each metric represents out of the total sum. Effectively assumes that each metric is an object count, and returns the proportion of objects from each set.

Usage

1
metrics_to_fractions(.df, ..., .prefix = "", .suffix = "")

Arguments

.df

A data frame containing tidycyte data.

...

<data-masking> The masked names of the metrics to use for calculating each fraction.

.prefix

An optional character string containing a prefix if you wish to assign the fraction to new metric names.

.suffix

An optional character string containing a suffix if you wish to assign the fraction to new metric names.

Details

Note that in practice, this assumes that each count is mutually exclusive. For example, if you count green, red, and yellow (green and red) objects, then ensure that the yellow objects do not contain green-only or red-only objects. Depending on the type of data, you may (or may not) be able to subtract these off as needed.

Value

A data frame containing updated or new metrics containing fractions.

Examples

1
2
3
df %>% metrics_to_fractions(Confluence,mAzalea,`h2-3`) # updates metrics in place
df %>% metrics_to_fractions(Confluence,mAzalea,`h2-3`, .prefix="fraction_", .suffix="_of_all")
df %>% metrics_to_fractions(mAzalea,`h2-3`, .prefix="fraction_", .suffix="_of_fluorescent")

hodgeslab/tidycyte documentation built on Dec. 20, 2021, 4:47 p.m.