Multi-Sample Comparison Analysis

Introduction

SCEVAN enables comparative analysis of copy number alterations across multiple samples. This is particularly useful for:

  • Longitudinal studies: Comparing primary tumor vs metastasis
  • Treatment response: Pre- and post-treatment samples
  • Patient cohorts: Identifying shared vs patient-specific alterations

Setup

library(SCEVAN)
library(ggplot2)
library(dplyr)

Preparing Multi-Sample Data

Data Structure

Multi-sample analysis requires a named list of count matrices:

# Example structure
listCountMtx <- list(
  "Sample1" = count_mtx_1,
  "Sample2" = count_mtx_2,
  "Sample3" = count_mtx_3
)

Download Example Data

# Load glioblastoma multi-sample data
load(url("https://www.dropbox.com/s/esqvnltucdqajg1/listCountMtx.RData?raw=1"))

# Examine structure
names(listCountMtx)

# Sample sizes
sapply(listCountMtx, ncol)

Running Multi-Sample Analysis

Basic Comparison

multiSampleComparisonClonalCN(
  listCountMtx,
  analysisName = "GBM_comparison",
  organism = "human",
  par_cores = 4
)

With Known Normal Cells

# Optionally provide known normal cells per sample
listNormCells <- list(
  "MGH102" = c("cell_a", "cell_b"),
  "MGH104" = c("cell_c", "cell_d"),
  "MGH105" = NULL,  # Auto-detect
  "MGH106" = NULL
)

multiSampleComparisonClonalCN(
  listCountMtx,
  listNormCells = listNormCells,
  analysisName = "GBM_with_normals",
  par_cores = 4
)

Output Interpretation

Generated Files

list.files("./output", pattern = "GBM_comparison")
File Description
*_allOncoHeat.png Combined OncoPrint across samples
*_comparison.png Side-by-side CN profiles
*_CloneTree.png Cross-sample phylogeny

Comparative Heatmap

The multi-sample comparison generates combined visualization files:

  • *_allOncoHeat.png - Combined OncoPrint showing shared and sample-specific alterations
  • *_CloneTree.png - Cross-sample phylogenetic tree

Visualization Functions

Plot All Clonal Profiles

# Generate combined clonal CN plot
plotAllClonalCN(
  sampleNames = names(listCountMtx),
  pathOutput = "./output"
)

Plot Subclonal Profiles

# Generate combined subclonal CN plot
plotAllSubclonalCN(
  sampleNames = names(listCountMtx),
  pathOutput = "./output"
)

Advanced Analysis

Identifying Shared Alterations

# Load individual results
results_list <- lapply(names(listCountMtx), function(s) {
  seg_file <- paste0("./output/", s, "_Clonal_CN.seg")
  if(file.exists(seg_file)) {
    read.table(seg_file, header = TRUE, sep = "\t")
  }
})
names(results_list) <- names(listCountMtx)

# Find alterations present in all samples
find_shared_alterations <- function(results_list) {
  # Get altered regions per sample
  altered_regions <- lapply(results_list, function(df) {
    if(!is.null(df)) {
      df[df$CN != 2, c("Chr", "Pos", "End", "CN")]
    }
  })
  
  # Find overlaps (simplified example)
  # In practice, use GenomicRanges for proper overlap detection
  altered_regions
}

shared <- find_shared_alterations(results_list)

Custom Comparison Plots

# Create custom comparison visualization
create_cn_comparison <- function(sample_names, output_path) {
  
  cn_data <- lapply(sample_names, function(s) {
    load(paste0(output_path, "/", s, "_CNAmtx.RData"))
    data.frame(
      sample = s,
      mean_cn = colMeans(CNA_mtx_relat)
    )
  })
  
  cn_df <- do.call(rbind, cn_data)
  
  ggplot(cn_df, aes(x = sample, y = mean_cn, fill = sample)) +
    geom_boxplot() +
    theme_minimal() +
    labs(
      title = "Global CNA Burden Comparison",
      x = "Sample",
      y = "Mean CNA Score"
    ) +
    theme(legend.position = "none")
}

# Generate plot
create_cn_comparison(names(listCountMtx), "./output")

Case Study: Head & Neck Cancer

Primary vs Lymph Node Metastasis

# Load HNSCC data
load(url("https://www.dropbox.com/s/6zns12amobs39g8/HNSCC26_data.RData?raw=1"))

# Examine samples
names(listCountMtx)  # Should show "Primary" and "LN"

# Run comparison
multiSampleComparisonClonalCN(
  listCountMtx,
  analysisName = "HNSCC26_comparison",
  organism = "human",
  par_cores = 4,
  plotTree = TRUE
)

Interpreting Primary vs Metastasis

Key questions to address:

  1. Clonal evolution: Which alterations are clonal (present in both)?
  2. Metastasis-specific: New alterations in lymph node
  3. Lost alterations: Present in primary but not metastasis

Statistical Considerations

Sample Size Requirements

Analysis Type Minimum Cells/Sample Recommendation
Cell classification 100 500+
Subclone detection 200 1000+
Cross-sample comparison 300 1000+

Batch Effect Considerations

When comparing samples:

  • Process with same protocol if possible
  • Consider batch correction methods
  • Verify normal cell detection consistency

Best Practices

Workflow Checklist

Common Pitfalls

Issue Cause Solution
No shared alterations Different tumor types Verify sample identity
All alterations shared Contamination Check for cross-sample mixing
Inconsistent segmentation Different cell counts Normalize comparison

Session Info

sessionInfo()
#> R version 4.6.1 (2026-06-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 26.04 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so;  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] rmarkdown_2.31
#> 
#> loaded via a namespace (and not attached):
#>  [1] digest_0.6.39    R6_2.6.1         fastmap_1.2.0    xfun_0.59       
#>  [5] maketools_1.3.2  cachem_1.1.0     knitr_1.51       htmltools_0.5.9 
#>  [9] buildtools_1.0.0 lifecycle_1.0.5  cli_3.6.6        sass_0.4.10     
#> [13] jquerylib_0.1.4  compiler_4.6.1   sys_3.4.3        tools_4.6.1     
#> [17] evaluate_1.0.5   bslib_0.11.0     yaml_2.3.12      otel_0.2.0      
#> [21] jsonlite_2.0.0   rlang_1.2.0