Skip to contents

This function adds an assay to a Seurat object based on Souporcell clustering results. The assay contains log-transformed and normalized cluster probabilities from the Souporcell clusters.tsv file. Principal Component Analysis (PCA) is performed on these probabilities, and the resulting components are added as a dimensionality reduction object. The Souporcell 'assignment' is added to the Seurat object's metadata under the specified label. Optionally, assignments can be renamed to be 1-indexed and multiplets collapsed into a single category.

Usage

add_souporcell_seurat(
  seurat_obj,
  souporcell_file,
  prefix = NULL,
  assay_name = "GENO",
  key = "gpca_",
  meta_data_label = "geno",
  rd_label = "gpca",
  rename_assignments = TRUE
)

Arguments

seurat_obj

A Seurat object.

souporcell_file

Path to the Souporcell clusters.tsv file.

prefix

Optional prefix to prepend to cell barcodes.

assay_name

Name of the assay to add to the Seurat object. Default is "GENO".

key

Key for the dimensionality reduction. Default is "gpca_".

meta_data_label

Name of the metadata column to store Souporcell assignments. Default is "geno".

rd_label

Name of the dimensionality reduction object to store PCA results. Default is "gpca".

rename_assignments

Logical indicating whether to rename Souporcell assignments to be 1-indexed and collapse multiplets. Default is TRUE.

Value

A Seurat object with the added assay, dimensionality reduction, and updated metadata.

Examples

# Assuming 'seurat_obj' is your Seurat object and 'clusters.tsv' is your Souporcell output file:
seurat_obj <- add_souporcell_seurat(seurat_obj, "path/to/clusters.tsv")
#> Error in add_souporcell_seurat(seurat_obj, "path/to/clusters.tsv"): Souporcell file does not exist!