R/mean_expression.R
compute_mean_expression_many.Rd
For each given combination of phenotype and expression parameter, report the mean expression of the given marker in the specified cells.
compute_mean_expression_many(
csd,
phenotypes,
params,
tissue_categories = NULL,
percentile = NULL,
count = NULL,
.by = "Slide ID"
)
Cell seg data to use. This should already have been filtered
for the slides or fields of interest. It may already be nested by
!!.by and Tissue Category
.
A named list of phenotype selectors (see phenoptr::parse_phenotypes).
A named list matching phenotype names to expression column names.
Optional vector of tissue category names to include.
The percentile cutoff for top-expressing cells. For example, to measure the top quartile, the percentile is 0.75. Negative numbers will use low-expressing cells; to measure the bottom decile, use a percentile of -0.1.
The number of top expressing cells to use. Only one of
percentile
and count
can be provided. If both are omitted,
all cells matching the phenotype are used and the result is the
overall mean expression.
Column to aggregate by
A data frame with a column for mean for each param_pair
.
This is a very flexible function. If percentile
and count
are both
omitted, it will compute the mean expression for all cells in the
given phenotype. If either percentile
or count
is given, the mean
expression of the highest expressing cells is computed. If a negative
percentile
is given, the lowest percentile is used; for example
percentile=-.1
would give the expression of the lowest-expressing
decile.
By default, this function aggregates by Slide ID
and Tissue Category
.
To compute mean expression by a different aggregate, pass a column name in
the .by
parameter.
To aggregate over all cells, include "Total Cells"=NA
as one of the
phenotypes.
Other aggregation functions:
compute_density_from_cell_summary()
,
compute_density_from_table()
,
compute_h_score_from_score_data()
,
compute_h_score()
,
compute_mean_expression()
,
compute_positivity_many()
,
compute_positivity()
,
count_phenotypes()
,
counts_to_percents()