Filter and subset your Seurat object based on metadata column

filterSeuratObjectByMetadata(
  object,
  samples.to.include,
  sample.name,
  category.to.filter,
  values.to.filter,
  keep.or.remove = TRUE,
  greater.less.than = "greater than",
  seed = 10,
  cut.off = 0.5,
  legend.position = "top",
  reduction = "umap",
  plot.as.interactive.plot = FALSE,
  legend.symbol.size = 2,
  colors = c("aquamarine3", "salmon1", "lightskyblue3", "plum3", "darkolivegreen3",
    "goldenrod1", "burlywood2", "gray70", "firebrick2", "steelblue", "palegreen4",
    "orchid4", "darkorange1", "yellow", "sienna", "palevioletred1", "gray60", "cyan4",
    "darkorange3", "mediumpurple3", "violetred2", "olivedrab", "darkgoldenrod2",
    "darkgoldenrod", "gray40", "palegreen3", "thistle3", "khaki1", "deeppink2",
    "chocolate3", "paleturquoise3", "wheat1", "lightsteelblue", "salmon", "sandybrown",
    "darkolivegreen2", "thistle2", 
     "gray85", "orchid3", "darkseagreen1",
    "lightgoldenrod1", "lightskyblue2", "dodgerblue3", "darkseagreen3", "forestgreen",
    "lightpink2", "mediumpurple4", "lightpink1", "thistle", "navajowhite",
    "lemonchiffon", "bisque2", "mistyrose", "gray95", "lightcyan3", "peachpuff2",
    "lightsteelblue2", "lightyellow2", "moccasin", "gray80", "antiquewhite2",
    "lightgrey"),
  dot.size = 0.1,
  number.of.legend.columns = 1,
  dot.size.highlighted.cells = 0.5,
  use.cite.seq.data = FALSE
)

Arguments

object

A dataset containing your SingleR annotated/merged seurat object

samples.to.include

Select which samples to include

sample.name

Sample Name Column

category.to.filter

What kind of metadata you want to subset by. This should be one column in your Metadata table

values.to.filter

One or more values where you want to filter

keep.or.remove

TRUE to filter down to selected values, FALSE to filter out selected values. Default is TRUE

greater.less.than

Decide if you want to keep cells above or below the threshold. Default is "greater than"

seed

Set seed for colors

cut.off

The cut-off you want to use for your greater than/less than filter. Default os 0.5

legend.position

Select "none" if legend takes up too much space in plot. Default is "top"

reduction

What kind of clustering visualization you would like to use for summary plot (umap, tsne, pca, protein_tsne, protein_umap, protein_pca). Default is "umap"

plot.as.interactive.plot

TRUE for interactive, FALSE for static

legend.symbol.size

Your legend symbol size. Default is 2

colors

User-selected colors from palette of 62 unique colors from ColorBrewer.

dot.size

Size of dots on TSNE/UMAP projection plot. Default is 0.1

number.of.legend.columns

Default is 1. If legend is too long, provide more legend columns

dot.size.highlighted.cells

Dot size for cells in the after-filter plot which have been highlighted. Default is 0.5

use.cite.seq.data

TRUE if you would like to plot Antibody clusters from CITEseq instead of scRNA.

Value

a subset Seurat object

Details

This is a downstream template that should be loaded after Step 5 of the pipeline (SingleR Annotations on Seurat Object)