R/plot_severity_vs_nphenotypes.R
plot_severity_vs_nphenotypes.RdPlot the mean composite GPT severity score of all all the phenotypes each cell type is significantly associated with vs. the number of phenotypes each cell types is significantly associated with.
plot_severity_vs_nphenotypes(
results,
gpt_annot = HPOExplorer::gpt_annot_codify(),
cl = get_cl(),
q_threshold = 0.5,
n_label = 3,
size = 3,
min.segment.length = 0,
remove_subtitle = FALSE,
remove_caption = TRUE,
point_fill = ggplot2::alpha("white", 0.75),
base_size = 8,
run_prune_ancestors = FALSE,
...
)The cell type-phenotype enrichment results generated by gen_results and merged together with merge_results
A data.table of GPT annotations.
Cell Ontology object.
The q value threshold to subset the results by.
The number of top and bottom cell types to label in the plot. Top/bottom terms are determined by sorting on both the x and y axes.
Label text size.
Skip drawing segments shorter than this, as unit or
number. Defaults to 0.5. (Default unit is lines, but other units can be
specified by passing unit(x, "units")).
Remove the formula in the subtitle. See ggscatterstats for details.
Remove the formula in the caption. See ggscatterstats for details.
Fill color of the points.
base font size, given in pts.
Prune redundant ancestral terms if any of their descendants are present. Passes to prune_ancestors.
Arguments passed on to ggstatsplot::ggscatterstats
dataA data frame (or a tibble) from which variables specified are to
be taken. Other data types (e.g., matrix,table, array, etc.) will not
be accepted. Additionally, grouped data frames from {dplyr} should be
ungrouped before they are entered as data.
xThe column in data containing the explanatory variable to be
plotted on the x-axis.
yThe column in data containing the response (outcome) variable to
be plotted on the y-axis.
typeA character specifying the type of statistical approach:
"parametric"
"nonparametric"
"robust"
"bayes"
You can specify just the initial letter.
conf.levelScalar between 0 and 1 (default: 95%
confidence/credible intervals, 0.95). If NULL, no confidence intervals
will be computed.
bf.priorA number between 0.5 and 2 (default 0.707), the prior
width to use in calculating Bayes factors and posterior estimates. In
addition to numeric arguments, several named values are also recognized:
"medium", "wide", and "ultrawide", corresponding to r scale values
of 1/2, sqrt(2)/2, and 1, respectively. In case of an ANOVA, this
value corresponds to scale for fixed effects.
bf.messageLogical that decides whether to display Bayes Factor in
favor of the null hypothesis. This argument is relevant only for
parametric test (Default: TRUE).
trTrim level for the mean when carrying out robust tests. In case
of an error, try reducing the value of tr, which is by default set to
0.2. Lowering the value might help.
digitsNumber of digits for rounding or significant figures. May also
be "signif" to return significant figures or "scientific"
to return scientific notation. Control the number of digits by adding the
value as suffix, e.g. digits = "scientific4" to have scientific
notation with 4 decimal places, or digits = "signif5" for 5
significant figures (see also signif()).
results.subtitleDecides whether the results of statistical tests are
to be displayed as a subtitle (Default: TRUE). If set to FALSE, only
the plot will be returned.
label.varVariable to use for points labels entered as a symbol (e.g.
var1).
label.expressionAn expression evaluating to a logical vector that
determines the subset of data points to label (e.g. y < 4 & z < 20).
While using this argument with purrr::pmap(), you will have to provide
a quoted expression (e.g. quote(y < 4 & z < 20)).
marginalDecides whether marginal distributions will be plotted on
axes using {ggside} functions. The default is TRUE. The package
{ggside} must already be installed by the user.
point.argsA list of additional aesthetic arguments to be passed to
the ggplot2::geom_point().
point.width.jitter,point.height.jitterDegree of jitter in x and y
direction, respectively. Defaults to 0 (0%) of the resolution of the
data. Note that the jitter should not be specified in the point.args
because this information will be passed to two different geoms: one
displaying the points and the other displaying the *labels for
these points.
point.label.argsA list of additional aesthetic arguments to be passed
to ggrepel::geom_label_repel()geom used to display the labels.
smooth.line.argsA list of additional aesthetic arguments to be passed
to geom_smooth geom used to display the regression line.
xsidehistogram.args,ysidehistogram.argsA list of arguments passed to
respective geom_s from the {ggside} package to change the marginal
distribution histograms plots.
xlabLabel for x axis variable. If NULL (default),
variable name for x will be used.
ylabLabels for y axis variable. If NULL (default),
variable name for y will be used.
titleThe text for the plot title.
subtitleThe text for the plot subtitle. Will work only if
results.subtitle = FALSE.
captionThe text for the plot caption. This argument is relevant only
if bf.message = FALSE.
ggthemeA {ggplot2} theme. Default value is
theme_ggstatsplot(). Any of the {ggplot2} themes (e.g.,
ggplot2::theme_bw()), or themes from extension packages are allowed
(e.g., ggthemes::theme_fivethirtyeight(), hrbrthemes::theme_ipsum_ps(),
etc.). But note that sometimes these themes will remove some of the details
that {ggstatsplot} plots typically contains. For example, if relevant,
ggbetweenstats() shows details about multiple comparison test as a
label on the secondary Y-axis. Some themes (e.g.
ggthemes::theme_fivethirtyeight()) will remove the secondary Y-axis and
thus the details as well.
ggplot.componentA ggplot component to be added to the plot prepared
by {ggstatsplot}. This argument is primarily helpful for grouped_
variants of all primary functions. Default is NULL. The argument should
be entered as a {ggplot2} function or a list of {ggplot2} functions.
results <- load_example_results()
out <- plot_severity_vs_nphenotypes(results=results)
#> Translating ontology terms to ids.
#> Reading cached RDS file: phenotype_to_genes.txt
#> + Version: v2025-05-06
#> 151 phenotypes do not have matching HPO IDs.
#> Reading in GPT annotations for 16,982 phenotypes.
#> Mapping cell types to cell ontology terms.
#> Adding stage information.
#> Registered S3 method overwritten by 'ggside':
#> method from
#> +.gg ggplot2