Skip to contents

Wraps the full inferCNV workflow: gene-order table generation (via AnnotateFeatures() / GetGeneOrder()), downsampling, object creation, inference, post-processing of map_metadata_from_infercnv.txt, and standard figure output. Returns the Seurat object with new metadata columns: CNV_score, CNV_Prediction, infercnv_subcluster, and one proportion_cnv_chrN column per chromosome.

Usage

RunInferCNV(
  seurat_object,
  cell_type_col = "Assignment",
  ref_group_names,
  output_dir = NULL,
  species = NULL,
  chromosomes = NULL,
  gene_biotype = "protein_coding",
  annotation_file = NULL,
  downsample = 200L,
  cutoff = 0.1,
  HMM = FALSE,
  denoise = TRUE,
  scale_data = TRUE,
  cluster_by_groups = TRUE,
  num_threads = 4L,
  cnv_score_threshold = "auto",
  cnv_k = 2,
  resume = FALSE,
  caffeinate = FALSE
)

Arguments

seurat_object

A Seurat object.

cell_type_col

Character. Metadata column containing cell-type labels used to split cells and define reference groups. Default "Assignment".

ref_group_names

Character vector. Cell-type labels treated as the normal (diploid) reference — typically immune or stromal populations.

output_dir

Character or NULL. Directory for inferCNV output and saved figures. Walks up from PrepObject() settings when NULL.

species

Character. "mouse", "human", or "zebrafish". Used to auto-generate gene order via AnnotateFeatures() if not yet annotated.

chromosomes

Character or numeric vector of chromosomes to analyze. NULL uses species-appropriate autosomes (mouse 1–19, human 1–22, zebrafish 1–25).

gene_biotype

Character. Biotype filter for the gene order table. Default "protein_coding".

annotation_file

Character or NULL. Passed to AnnotateFeatures() when manual gene annotation is preferred over the automatic sources.

downsample

Integer. Maximum cells per identity class. NULL uses all cells (not recommended for large objects). Default 200L.

cutoff

Numeric. inferCNV expression cutoff. Use 0.1 for 10x Genomics and 1 for Smart-seq2. Default 0.1.

HMM

Logical. Run inferCNV's HMM for subclonal CNV calls? Dramatically increases runtime. Default FALSE.

denoise

Logical. Apply inferCNV denoising. Default TRUE.

scale_data

Logical. Scale expression data before inference. Default TRUE.

cluster_by_groups

Logical. Cluster cells within their annotation groups. Default TRUE.

num_threads

Integer. Threads for inferCNV. Default 4L.

cnv_score_threshold

Numeric or "auto". When "auto" (default), the threshold is set to mean(ref_scores) + cnv_k × sd(ref_scores) using the reference cells' CNV score distribution — this is the data-driven approach from Tirosh et al. 2016. Pass a numeric value to override.

cnv_k

Numeric. Number of standard deviations above the reference mean used for the auto threshold. Higher values = more conservative (fewer malignant calls). Default 2.

resume

Logical. If TRUE and output files already exist, skip re-running inferCNV and go straight to post-processing. Default FALSE.

caffeinate

Logical. Prevent the machine from sleeping during the run. Default FALSE.

Value

The input Seurat object with additional metadata columns.