Wrapper for FeaturePlot.
do_FeaturePlot(
sample,
features,
assay = NULL,
reduction = NULL,
slot = NULL,
order = FALSE,
group.by = NULL,
group.by.colors.use = NULL,
group.by.legend = NULL,
group.by.show.dots = TRUE,
group.by.dot.size = 8,
group.by.cell_borders = FALSE,
group.by.cell_borders.alpha = 0.1,
split.by = NULL,
idents.keep = NULL,
cells.highlight = NULL,
idents.highlight = NULL,
dims = c(1, 2),
enforce_symmetry = FALSE,
symmetry.type = "absolute",
symmetry.center = NA,
pt.size = 1,
font.size = 14,
font.type = "sans",
legend.title = NULL,
legend.type = "colorbar",
legend.position = "bottom",
legend.framewidth = 0.5,
legend.tickwidth = 0.5,
legend.length = 20,
legend.width = 1,
legend.framecolor = "grey50",
legend.tickcolor = "white",
legend.ncol = NULL,
legend.nrow = NULL,
legend.byrow = FALSE,
plot.title = NULL,
plot.subtitle = NULL,
plot.caption = NULL,
individual.titles = NULL,
individual.subtitles = NULL,
individual.captions = NULL,
ncol = NULL,
use_viridis = FALSE,
viridis.palette = "G",
viridis.direction = 1,
raster = FALSE,
raster.dpi = 1024,
plot_cell_borders = TRUE,
border.size = 2,
border.color = "black",
border.density = 1,
na.value = "grey75",
verbose = TRUE,
plot.axes = FALSE,
min.cutoff = rep(NA, length(features)),
max.cutoff = rep(NA, length(features)),
plot_density_contour = FALSE,
contour.position = "bottom",
contour.color = "grey90",
contour.lineend = "butt",
contour.linejoin = "round",
contour_expand_axes = 0.25,
label = FALSE,
label.color = "black",
label.size = 4,
number.breaks = 5,
diverging.palette = "RdBu",
diverging.direction = -1,
sequential.palette = "YlGnBu",
sequential.direction = 1,
plot.title.face = "bold",
plot.subtitle.face = "plain",
plot.caption.face = "italic",
axis.title.face = "bold",
axis.text.face = "plain",
legend.title.face = "bold",
legend.text.face = "plain"
)
A ggplot2 object containing a Feature Plot.
Seurat
| A Seurat object, generated by CreateSeuratObject.
character
| Features to represent.
character
| Assay to use. Defaults to the current assay.
character
| Reduction to use. Can be the canonical ones such as "umap", "pca", or any custom ones, such as "diffusion". If you are unsure about which reductions you have, use Seurat::Reductions(sample)
. Defaults to "umap" if present or to the last computed reduction if the argument is not provided.
character
| Data slot to use. Only one of: counts, data, scale.data. Defaults to "data".
logical
| Whether to order the cells based on expression.
character
| Metadata variable based on which cells are grouped. This will effectively introduce a big dot in the center of each cluster, colored using a categorical color scale or with the values provided by the user in group.by.colors.use
. It will also displays a legend.
character
| Colors to use for the group dots.
character
| Title for the legend when group.by
is used. Use NA
to disable it and NULL
to use the default column title provided in group.by
.
logical
| Controls whether to place in the middle of the groups.
numeric
| Size of the dots placed in the middle of the groups.
logical
| Plots another border around the cells displaying the same color code of the dots displayed with group.by
. Legend is shown always with alpha = 1 regardless of the alpha settings.
numeric
| Controls the transparency of the new borders drawn by group.by.cell_borders
.
character
| Secondary metadata variable to further group (split) the output by. Has to be a character of factor column.
character
| Vector of identities to plot. The gradient scale will also be subset to only the values of such identities.
character
| Vector of cells/identities to focus into. The identities have to much those in Seurat::Idents(sample)
The rest of the cells will be grayed out. Both parameters can be used at the same time.
numeric
| Vector of 2 numerics indicating the dimensions to plot out of the selected reduction. Defaults to c(1, 2) if not specified.
logical
| Return a symmetrical plot axes-wise or continuous color scale-wise, when applicable.
character
| Type of symmetry to be enforced. One of:
absolute
: The highest absolute value will be taken into a account to generate the color scale. Works after min.cutoff
and max.cutoff
.
centered
: Centers the scale around the provided value in symmetry.center
. Works after min.cutoff
and max.cutoff
.
numeric
| Value upon which the scale will be centered.
numeric
| Size of the dots.
numeric
| Overall font size of the plot. All plot elements will have a size relationship with this font size.
character
| Base font family for the plot. One of:
mono
: Mono spaced font.
serif
: Serif font family.
sans
: Default font family.
character
| Title for the legend.
character
| Type of legend to display. One of:
normal
: Default legend displayed by ggplot2.
colorbar
: Redefined colorbar legend, using guide_colorbar.
character
| Position of the legend in the plot. One of:
top
: Top of the figure.
bottom
: Bottom of the figure.
left
: Left of the figure.
right
: Right of the figure.
none
: No legend is displayed.
numeric
| Width of the lines of the box in the legend.
numeric
| Length and width of the legend. Will adjust automatically depending on legend side.
character
| Color of the lines of the box in the legend.
character
| Color of the ticks of the box in the legend.
numeric
| Number of columns in the legend.
numeric
| Number of rows in the legend.
logical
| Whether the legend is filled by row or not.
character
| Title, subtitle or caption to use in the plot.
character
| Titles or subtitles. for each feature if needed. Either NULL or a vector of equal length of features.
numeric
| Number of columns used in the arrangement of the output plot using "split.by" parameter.
logical
| Whether to use viridis color scales.
character
| A capital letter from A to H or the scale name as in scale_fill_viridis.
numeric
| Either 1 or -1. Controls how the gradient of viridis scale is formed.
logical
| Whether to raster the resulting plot. This is recommendable if plotting a lot of cells.
numeric
| Pixel resolution for rasterized plots. Defaults to 1024. Only activates on Seurat versions higher or equal than 4.1.0.
logical
| Whether to plot border around cells.
numeric
| Width of the border of the cells.
character
| Color for the border of the heatmap body.
numeric
| Controls the number of cells used when plot_cell_borders = TRUE
. Value between 0 and 1. It computes a 2D kernel density and based on this cells that have a density below the specified quantile will be used to generate the cluster contour. The lower this number, the less cells will be selected, thus reducing the overall size of the plot but also potentially preventing all the contours to be properly drawn.
character
| Color value for NA.
logical
| Whether to show extra comments, warnings,etc.
logical
| Whether to plot axes or not.
numeric
| Set the min/max ends of the color scale. Any cell/group with a value lower than min.cutoff will turn into min.cutoff and any cell with a value higher than max.cutoff will turn into max.cutoff. In FeaturePlots, provide as many values as features. Use NAs to skip a feature.
logical
| Whether to plot density contours in the UMAP.
character
| Whether to plot density contours on top or at the bottom of the visualization layers, thus overlapping the clusters/cells or not.
character
| Color of the density lines.
character
| Line end style (round, butt, square).
character
| Line join style (round, mitre, bevel).
numeric
| To make the contours fit the plot, the limits of the X and Y axis are expanding a given percentage from the min and max values for each axis. This controls such percentage.
logical
| Whether to plot the cluster labels in the UMAP. The cluster labels will have the same color as the cluster colors.
character
| Color of the labels in the plot.
numeric
| Size of the labels in the plot.
numeric
| Controls the number of breaks in continuous color scales of ggplot2-based plots.
character
| Type of symmetrical color palette to use. Out of the diverging palettes defined in brewer.pal
.
numeric
| Either 1 or -1. Direction of the divering palette. This basically flips the two ends.
character
| Type of sequential color palette to use. Out of the sequential palettes defined in brewer.pal
.
numeric
| Direction of the sequential color scale. Either 1 or -1.
character
| Controls the style of the font for the corresponding theme element. One of:
plain
: For normal text.
italic
: For text in itallic.
bold
: For text in bold.
bold.italic
: For text both in itallic and bold.
# \donttest{
# Check Suggests.
value <- SCpubr:::check_suggests(function_name = "do_FeaturePlot", passive = TRUE)
if (isTRUE(value)){
# Consult the full documentation in https://enblacar.github.io/SCpubr-book/
# Define your Seurat object.
sample <- readRDS(system.file("extdata/seurat_dataset_example.rds", package = "SCpubr"))
# Regular FeaturePlot.
p <- SCpubr::do_FeaturePlot(sample = sample,
features = "nCount_RNA")
# FeaturePlot with a subset of identities
# (in Seurat::Idents(sample)) maintaining the original UMAP shape.
idents.use <- levels(sample)[!(levels(sample) %in% c("2", "5", "8"))]
p <- SCpubr::do_FeaturePlot(sample = sample,
idents.highlight = idents.use,
features = c("EPC1"))
# Splitting the FeaturePlot by a variable and
# maintaining the color scale and the UMAP shape.
p <- SCpubr::do_FeaturePlot(sample = sample,
features = "EPC1",
split.by = "seurat_clusters")
} else if (base::isFALSE(value)){
message("This function can not be used without its suggested packages.")
message("Check out which ones are needed using `SCpubr::state_dependencies()`.")
}
# }
Run the code above in your browser using DataLab