prep_SO: Prepare a somewhat standardized Seurat Object for further...

View source: R/prep_SO.R

prep_SOR Documentation

Prepare a somewhat standardized Seurat Object for further analyses

Description

Prepare a somewhat standardized Seurat Object for further analyses

Usage

prep_SO(
  SO_unprocessed,
  samples = NULL,
  cells = NULL,
  min_cells = 50,
  downsample = 1,
  export_prefix = NULL,
  reductions = c("umap", "som", "gqtsom", "tsne"),
  nhvf = 800,
  npcs = 20,
  normalization = c("SCT", "LogNormalize"),
  hvf_determination_before_merge = F,
  batch_corr = c("harmony", "integration", "none"),
  vars.to.regress = NULL,
  seeed = 42,
  save_path = NULL,
  celltype_refs = NULL,
  celltype_label = "label.main",
  celltype_ref_clusters = NULL,
  diet_seurat = F,
  var_feature_filter = NULL,
  verbose = F,
  FindVariableFeatures_args = list(),
  SCtransform_args = list(vst.flavor = "v2", method = "glmGamPoi"),
  RunPCA_args = list(),
  RunUMAP_args = list(),
  RunTSNE_args = list(theta = 0),
  FindNeighbors_args = list(),
  FindClusters_args = list(resolution = seq(0.1, 1, 0.1)),
  RunHarmony_args = list(),
  SOM_args = list(),
  GQTSOM_args = list(),
  EmbedSOM_args = list(),
  FindIntegrationAnchors_args = list(reduction = "rpca"),
  IntegrateData_args = list(),
  ...
)

Arguments

SO_unprocessed

named list of split Seurat objects

samples

names of SO_unprocessed that are to include; if missing all are used

cells

vector of cell names to include; if missint all cells are used

min_cells

min number of cells per object in SO_unprocessed; objects with lower cell number are excluded

downsample

downsample a fraction of cells from each object in SO_unprocessed (downsample < 0); or an absolute number of cells per object (downsample > 1 & downsample >= min_cells)

export_prefix

prefix to the output rds file

reductions

which reduction to calculate, tsne –> Seurat::RunTSNE, umap –> Seurat::RunUMAP

nhvf

number high variables features, passed to Seurat::SCTransform or Seurat::FindVariableFeatures or Seurat::SelectIntegrationFeatures

npcs

number of principle components in calculate in pca and to consider for downstream functions like tSNE or UMAP

normalization

algorithm for normalization of UMIs

hvf_determination_before_merge

determine variable features before or after merging multiple samples; either by the standard LogNormalize workflow or by SCTransform function; this is most important for deciding whether SCtransform is run on mulitple samples separately before merging (set to TRUE) or after merging (set to FALSE); in my experience and when the integration procedure is set to harmony setting it to FALSE yields better results; see: https://github.com/hbctraining/scRNA-seq_online/blob/master/lessons/06a_integration_harmony.md and subsequent links

batch_corr

procedure for batch correction between samples in SO_unprocessed; only relevant if more than 1 sample is passed

vars.to.regress

passed to Seurat::SCTransform or Seurat::ScaleData; will be applied independent of what is set for batch_corr; if batch_corr is set to 'none', then only vars.to.regress is used to regress out a variable in meta.data which may be sample-specific; other then that it may not be meaningful to regress a sample-specific variable and perform batch_corr; rather vars.to.regress may be used in combination with batch_corr to regress percent_mito or so

seeed

seed passed to several methods

save_path

folder to save the resulting Seurat object as rds-file to

celltype_refs

list(prim_cell_atlas = celldex::HumanPrimaryCellAtlasData(), MonacoImmune = celldex::MonacoImmuneData())

celltype_label

list of label names to use from the reference data set (one list entry per celltype_refs; each entry may contain a vector of labels)

celltype_ref_clusters

use a clustering as basis for grouped celltype annotation with SingleR. This will fundamentally speed up the calculation! e.g. if SCT assay is used and cluster_resolutions includes 0.8 then pass: SCT_snn_res.0.8. when integration procedure assay is used: integrated_snn_res.0.8. For RNA assay: RNA_snn_res.0.8.

diet_seurat

logical whether to run Seurat::DietSeurat

var_feature_filter

character vector of features which are to exclude from variable features; this will affect downstream PCA, dimension reduction and clustering; e.g.: var_feature_filter = grep("^TRABGDV", rownames(SOqc_split[1]), value = T)

verbose

print messages and progress bars from functions

IntegrateData_args

by default features.to.integrate = rownames(Seurat::GetAssayData(SO.list[1], assay = switch(normalization, SCT = "SCT", LogNormalize = "RNA")))

...

Value

Seurat Object, as R object and saved to disk as rds file


Close-your-eyes/scexpr documentation built on April 21, 2023, 10:27 a.m.