Skip to contents

This function performs CNV analysis by calculating genomic scores, applying optional denoising, and optionally scaling the results based on a reference population. It processes single-cell or spatial transcriptomics data, generating an additional assay with genomic scores and adding a new metadata column for CNV fractions.

Usage

CNVanalysis(
  object,
  referenceVar = NULL,
  referenceLabel = NULL,
  pooledReference = TRUE,
  scaleOnReferenceLabel = TRUE,
  denoise = TRUE,
  assay = NULL,
  thresholdPercentile = 0.01,
  geneMetadata = getGenes(),
  windowSize = 150,
  windowStep = 10,
  saveGenomicWindows = FALSE,
  topNGenes = 7000,
  chrArmsToForce = NULL,
  genesToForce = NULL,
  regionToForce = NULL
)

Arguments

object

A Seurat object or a list of Seurat objects containing the data for CNV analysis. Each object can be either single-cell or spatial transcriptomics data.

referenceVar

The name of the metadata column in the Seurat object that contains reference annotations.

referenceLabel

The label within referenceVar that specifies the reference population (can be any type of annotation).

pooledReference

Logical. If TRUE (default), builds a pooled reference across all samples.

scaleOnReferenceLabel

Logical. If TRUE (default), scales the results based on the reference population.

denoise

Logical. If TRUE (default), applies denoising to the data.

assay

Name of the assay to run the CNV analysis on. Defaults to the results of prepareCountsForCNVAnalysis if available.

thresholdPercentile

Numeric. Specifies the quantile range to consider (e.g., 0.01 keeps values between the 1st and 99th percentiles). Higher values filter out more background noise.

geneMetadata

A dataframe containing gene metadata, typically from Ensembl.

windowSize

Integer. Defines the size of genomic windows for CNV analysis.

windowStep

Integer. Specifies the step size between genomic windows.

saveGenomicWindows

Logical. If TRUE, saves genomic window information in the current directory (default = FALSE).

topNGenes

Integer. The number of top-expressed genes to retain in the analysis.

chrArmsToForce

A chromosome arm (e.g., "8p", "3q") or a list of chromosome arms (e.g., c("3q", "8p", "17p")) to force into the analysis. If specified, all genes within the given chromosome arm(s) will be included.

genesToForce

A list of genes to force into the analysis (e.g. c("FOXP3","MUC16","SAMD15")).

regionToForce

Chromosome region to force into the analysis (vector containing chr, start, end).

Value

If given a single Seurat object, returns the same object with:

  • An additional assay containing genomic scores per genomic window.

  • A new CNV fraction column added to the object’s metadata. If given a list of Seurat objects, returns the modified list.