Show feature or cell distribution after filtering on expression threshold.
General sum and mean statistics for the expression values can also be
plotted, however these are not affected by the expression_threshold
value.
filterDistributions(
gobject,
feat_type = NULL,
spat_unit = NULL,
expression_values = c("raw", "normalized", "scaled", "custom"),
method = c("threshold", "sum", "mean"),
expression_threshold = 1,
detection = c("feats", "cells"),
plot_type = c("histogram", "violin"),
nr_bins = 30,
fill_color = "lightblue",
scale_y = "identity",
scale_axis = "identity",
axis_offset = 0,
show_plot = NULL,
return_plot = NULL,
save_plot = NULL,
save_param = list(),
default_save_name = "filterDistributions"
)
giotto object
feature type (e.g. "rna", "dna", "protein")
spatial unit (e.g. "cell")
character. Name of set of expression values to use.
(default = "raw"
)
character. One of "threshold"
(default), "sum"
, "mean"
.
Method to create distribution (see details)
numeric (default = 1). Threshold to consider a
feature expressed. Applied only for method = "threshold"
character. One of "feats"
(default) or "cells"
.
Calculate statistics based on features (e.g. genes) or cells/observations
character. One of "histogram"
(default) or "violin"
.
Type of plot to create.
numeric. Number of bins for histogram plot
fill color for plots. (Default = "lightblue"
)
character. Scaling operation to apply on y-axis (e.g. "log"
)
character. ggplot2 transformation for axis
(e.g. "log2"
). This is passed to the transform
param of
ggplot2::scale_x_continuous()
numeric. offset to be used together with the scaling transformation
logical. show plot
logical. return ggplot object
logical. save the plot
list of saving parameters, see
showSaveParameters
default save name for saving, don't change, change save_name in save_param
ggplot object
The distribution to plot is calculated based on the detection
and method
params. detection
decides if values are computed rowwise ("feats"
) or
colwise ("cells"
) across the feature x cell expression matrix.
method
determines how the distribution is calculated:
"threshold"
- calculate number of features that cross the
expression_threshold
(default)
"sum"
- find the sum of the features, i.e. total of a feature across
all observations.
"mean"
- find the mean of the features, i.e. average expression
g <- GiottoData::loadGiottoMini("visium")
#> 1. read Giotto object
#> 2. read Giotto feature information
#> 3. read Giotto spatial information
#> 3.1 read Giotto spatial shape information
#> 3.2 read Giotto spatial centroid information
#> 3.3 read Giotto spatial overlap information
#> 4. read Giotto image information
#> python already initialized in this session
#> active environment : '/usr/bin/python3'
#> python version : 3.12
# visualize feature expression prevalence across observations (histogram)
filterDistributions(g)
# visualize with a threshold of 3
filterDistributions(g, expression_threshold = 3)
# visualize sum of feature expression across dataset
filterDistributions(g, method = "sum")
# visualize with a log scaling
filterDistributions(g, method = "sum", scale_axis = "log2")
# visualize as violinplot
filterDistributions(g, plot_type = "violin")
# visualize mean expression per cell
filterDistributions(g,
detection = "cell",
plot_type = "violin",
method = "mean",
scale_axis = "log2"
)