### Install ichorCNA Source: https://context7.com/broadinstitute/ichorcna/llms.txt Recommended installation via R devtools or manual installation of dependencies. ```r # Install ichorCNA from GitHub (Recommended) install.packages("devtools") library(devtools) install_github("broadinstitute/ichorCNA") # Manual installation - install dependencies first install.packages("plyr") if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install("HMMcopy") BiocManager::install("GenomeInfoDb") BiocManager::install("GenomicRanges") # Then from command line in the ichorCNA directory: # R CMD INSTALL ichorCNA ``` -------------------------------- ### Install ichorCNA package manually Source: https://github.com/broadinstitute/ichorcna/wiki/Installation Command line installation after cloning the repository. ```bash ## from the command line and in the directory where ichorCNA github was cloned. R CMD INSTALL ichorCNA ``` -------------------------------- ### Install ichorCNA via devtools Source: https://github.com/broadinstitute/ichorcna/wiki/Installation Recommended method for installing the package directly from GitHub using R. ```R install.packages("devtools") library(devtools) install_github("broadinstitute/ichorCNA") ``` -------------------------------- ### Launch ichorCNA R script Source: https://github.com/broadinstitute/ichorcna/blob/master/scripts/README.md Example command to execute the ichorCNA R script with specific input files, ploidy, and normal contamination parameters. ```bash Rscript ../runIchorCNA.R --libdir ../../R/ --datadir ../../inst/extdata/ \ --id tumor_sample1 --WIG results/readDepth/tumor_sample1.bin1000000.wig \ --ploidy "c(2,3)" --normal "c(0.5,0.6,0.7,0.8,0.9)" --maxCN 5 \ --includeHOMD False --chrs "c(1:22, \"X\")" --chrTrain "c(1:22)" \ --estimateNormal True --estimatePloidy True --estimateScPrevalence True \ --scStates "c(1,3)" --centromere ../../inst/extdata/GRCh37.p13_centromere_UCSC-gapTable.txt \ --exons.bed None --txnE 0.9999 --txnStrength 10000 --plotFileType png --plotYLim "c(-2,4)" \ --outDir results/ichorCNA/tumor_sample1/ > logs/ichorCNA/tumor_sample1.log 2> logs/ichorCNA/tumor_sample1.log ``` -------------------------------- ### Initialize Tumor Fraction Parameter for Low Tumor Content Source: https://github.com/broadinstitute/ichorcna/wiki/Parameter-tuning-and-settings Set initial non-tumor values to guide the EM step towards better global optima for low tumor fraction samples. Expected values range from 5% down to 0.1%. ```bash --normal "c(0.95, 0.99, 0.995, 0.999)" ``` -------------------------------- ### Install R dependencies Source: https://github.com/broadinstitute/ichorcna/wiki/Installation Required R packages for ichorCNA, including HMMcopy and GenomicRanges. ```R ## install from CRAN install.packages("plyr") ## install packages from source("https://bioconductor.org/biocLite.R") BiocManager::install("HMMcopy") BiocManager::install("GenomeInfoDb") BiocManager::install("GenomicRanges") ``` -------------------------------- ### Run HMMsegment in ichorCNA Source: https://context7.com/broadinstitute/ichorcna/llms.txt Runs the HMMsegment function in ichorCNA after initial setup. This function performs the core segmentation and copy number calling. Ensure that `tumour_copy`, `valid`, `param`, and `chrTrain` are properly defined before execution. ```r library(ichorCNA) # After running HMMsegment, correct integer copy numbers hmmResults <- HMMsegment(list(sample=tumour_copy), valid, dataType="copy", param=param, chrTrain=chrTrain, maxiter=50, estimateNormal=TRUE, estimatePloidy=TRUE, estimateSubclone=TRUE, verbose=TRUE) ``` -------------------------------- ### Display ichorCNA Help Options Source: https://github.com/broadinstitute/ichorcna/wiki/Usage Invoke the help flag to view all available configuration parameters and their default settings. ```bash Rscript runIchorCNA.R --help Usage: runIchorCNA.R [options] Options: --WIG=WIG Path to tumor WIG file. Required. --NORMWIG=NORMWIG Path to normal WIG file. Default: [NULL] --gcWig=GCWIG Path to GC-content WIG file; Required --mapWig=MAPWIG Path to mappability score WIG file. Default: [NULL] --normalPanel=NORMALPANEL Median corrected depth from panel of normals. Default: [NULL] --exons.bed=EXONS.BED Path to bed file containing exon regions. Default: [NULL] --id=ID Patient ID. Default: [test] --centromere=CENTROMERE File containing Centromere locations; if not provided then will use hg19 version from ichorCNA package. Default: [NULL] --rmCentromereFlankLength=RMCENTROMEREFLANKLENGTH Length of region flanking centromere to remove. Default: [1e+05] --normal=NORMAL Initial normal contamination; can be more than one value if additional normal initializations are desired. Default: [0.5] --scStates=SCSTATES Subclonal states to consider. Default: [NULL] --coverage=COVERAGE PICARD sequencing coverage. Default: [NULL] --lambda=LAMBDA Initial Student's t precision; must contain 4 values (e.g. c(1500,1500,1500,1500)); if not provided then will automatically use based on variance of data. Default: [NULL] --lambdaScaleHyperParam=LAMBDASCALEHYPERPARAM Hyperparameter (scale) for Gamma prior on Student's-t precision. Default: [3] --ploidy=PLOIDY Initial tumour ploidy; can be more than one value if additional ploidy initializations are desired. Default: [2] --maxCN=MAXCN Total clonal CN states. Default: [7] --estimateNormal=ESTIMATENORMAL Estimate normal. Default: [TRUE] --estimateScPrevalence=ESTIMATESCPREVALENCE Estimate subclonal prevalence. Default: [TRUE] --estimatePloidy=ESTIMATEPLOIDY Estimate tumour ploidy. Default: [TRUE] --maxFracCNASubclone=MAXFRACCNASUBCLONE Exclude solutions with fraction of subclonal events greater than this value. Default: [0.7] --maxFracGenomeSubclone=MAXFRACGENOMESUBCLONE Exclude solutions with subclonal genome fraction greater than this value. Default: [0.5] --minSegmentBins=MINSEGMENTBINS Minimum number of bins for largest segment threshold required to estimate tumor fraction; if below this threshold, then will be assigned zero tumor fraction. --altFracThreshold=ALTFRACTHRESHOLD Minimum proportion of bins altered required to estimate tumor fraction; if below this threshold, then will be assigned zero tumor fraction. Default: [0.05] --chrNormalize=CHRNORMALIZE Specify chromosomes to normalize GC/mappability biases. Default: [c(1:22)] --chrTrain=CHRTRAIN Specify chromosomes to estimate params. Default: [c(1:22)] --chrs=CHRS Specify chromosomes to analyze. Default: [c(1:22,"X")] --normalizeMaleX=NORMALIZEMALEX If male, then normalize chrX by median. Default: [TRUE] --fracReadsInChrYForMale=FRACREADSINCHRYFORMALE Threshold for fraction of reads in chrY to assign as male. Default: [0.001] --includeHOMD=INCLUDEHOMD If FALSE, then exclude HOMD state. Useful when using large bins (e.g. 1Mb). Default: [FALSE] --txnE=TXNE Self-transition probability. Increase to decrease number of segments. Default: [0.9999999] --txnStrength=TXNSTRENGTH Transition pseudo-counts. Exponent should be the same as the number of decimal places of --txnE. Default: [1e+07] --plotFileType=PLOTFILETYPE File format for output plots. Default: [pdf] --plotYLim=PLOTYLIM ylim to use for chromosome plots. Default: [c(-2,2)] --outDir=OUTDIR Output Directory. Default: [./] --libdir=LIBDIR Script library path. Usually exclude this argument unless custom modifications have been made to the ichorCNA R package code and the user would like to source those R files. Default: [NULL] ``` -------------------------------- ### Create WIG file for PoN sample Source: https://github.com/broadinstitute/ichorcna/wiki/Create-Panel-of-Normals Generates a WIG file from a BAM file using HMMcopy readCounter for use in a Panel of Normals. ```bash /path/to/HMMcopy/bin/readCounter --window 1000000 --quality 20 \ --chromosome "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,X,Y" \ /path/to/tumor.bam > /path/to/tumor.wig ``` -------------------------------- ### View ichorCNA help menu Source: https://github.com/broadinstitute/ichorcna/blob/master/scripts/README.md Command to display the usage instructions and available command-line arguments for the ichorCNA script. ```bash >Rscript runIchorCNA.R --help Usage: runIchorCNA.R [options] Options: -l LIBDIR, --libdir=LIBDIR Script library path --datadir=DATADIR Reference wig dir path -t WIG, --WIG=WIG Path to tumor WIG file. --NORMWIG=NORMWIG Path to normal WIG file. --normalPanel=NORMALPANEL Median corrected depth from panel of normals -e EXONS.BED, --exons.bed=EXONS.BED Path to bed file containing exon regions. --id=ID Patient ID. -n NORMAL, --normal=NORMAL Initial normal contamination --scStates=SCSTATES Subclonal states to consider -p PLOIDY, --ploidy=PLOIDY Initial tumour ploidy -m MAXCN, --maxCN=MAXCN Total clonal CN states --estimateNormal=ESTIMATENORMAL Estimate normal. --estimateScPrevalence=ESTIMATESCPREVALENCE Estimate subclonal prevalence. --estimatePloidy=ESTIMATEPLOIDY Estimate tumour ploidy. (plus more arguments) ``` -------------------------------- ### Set Initial Ploidy to Diploid for Low Tumor Content Source: https://github.com/broadinstitute/ichorcna/wiki/Parameter-tuning-and-settings For low tumor fraction cases, it can be challenging to predict the ploidy value, so initializing to diploid is recommended. ```bash --ploidy "c(2)" ``` -------------------------------- ### Create Panel of Normals (PoN) Source: https://context7.com/broadinstitute/ichorcna/llms.txt Generates a custom PoN from healthy donor cfDNA samples. Requires a file list of WIG files and corresponding GC/map/centromere reference files. ```bash # Create a file listing all normal WIG files (one per line) cat > normal_wigs.txt << EOF /path/to/normal1.wig /path/to/normal2.wig /path/to/normal3.wig /path/to/normal4.wig /path/to/normal5.wig EOF # Generate Panel of Normals for hg19 Rscript /path/to/ichorCNA/scripts/createPanelOfNormals.R \ --filelist normal_wigs.txt \ --gcWig /path/to/ichorCNA/inst/extdata/gc_hg19_1000kb.wig \ --mapWig /path/to/ichorCNA/inst/extdata/map_hg19_1000kb.wig \ --centromere /path/to/ichorCNA/inst/extdata/GRCh37.p13_centromere_UCSC-gapTable.txt \ --outfile my_custom_PoN # Generate Panel of Normals for hg38 Rscript /path/to/ichorCNA/scripts/createPanelOfNormals.R \ --filelist normal_wigs.txt \ --gcWig /path/to/ichorCNA/inst/extdata/gc_hg38_1000kb.wig \ --mapWig /path/to/ichorCNA/inst/extdata/map_hg38_1000kb.wig \ --centromere /path/to/ichorCNA/inst/extdata/GRCh38.GCA_000001405.2_centromere_acen.txt \ --genomeStyle UCSC \ --outfile my_custom_PoN_hg38 ``` -------------------------------- ### Configure GC and mappability wig files Source: https://github.com/broadinstitute/ichorcna/wiki/SnakeMake-pipeline-for-ichorCNA Required wig files for GC content and mappability, which must match the configured bin size. ```yaml # must use gc wig file corresponding to same binSize (required) ichorCNA_gcWig: ../../inst/extdata/gc_hg19_1000kb.wig # must use map wig file corresponding to same binSize (required) ichorCNA_mapWig: ../../inst/extdata/map_hg19_1000kb.wig ``` -------------------------------- ### Clone ichorCNA repository Source: https://github.com/broadinstitute/ichorcna/wiki/Installation Manual step to retrieve the source code from GitHub. ```bash git clone git@github.com:broadinstitute/ichorCNA.git ``` -------------------------------- ### Initialize HMM Parameters Source: https://context7.com/broadinstitute/ichorcna/llms.txt Configures default HMM parameters for segmentation. Use this to define copy number states and transition priors before running HMMsegment. ```r library(ichorCNA) # Load your log ratio data logR <- as.data.frame(tumour_copy$copy) chrInd <- as.character(seqnames(tumour_copy)) %in% c(1:22) valid <- tumour_copy$valid # Get default parameters with standard settings param <- getDefaultParameters(logR[valid & chrInd, , drop=FALSE], maxCN = 5, # Maximum copy number state ct.sc = c(1, 3), # Subclonal states ploidy = 2, # Initial ploidy e = 0.9999999, # Self-transition probability e.sameState = 10, # Transition modifier for same states strength = 10000000, # Transition pseudo-counts includeHOMD = FALSE) # Exclude homozygous deletion # Customize parameters for specific use cases ``` -------------------------------- ### Run Snakemake Workflow on Cluster Source: https://context7.com/broadinstitute/ichorcna/llms.txt Submits the Snakemake workflow to a cluster using qsub, with a maximum of 50 concurrent jobs. ```bash # Run on cluster with qsub (max 50 jobs) snakemake -s ichorCNA.snakefile --cluster-sync "qsub" -j 50 --jobscript config/cluster.sh ``` -------------------------------- ### Configure Low Tumor Fraction Settings Source: https://context7.com/broadinstitute/ichorcna/llms.txt Adjust parameters for samples with less than 5% tumor fraction to improve estimation accuracy. ```bash # Settings optimized for low tumor fraction samples Rscript /path/to/ichorCNA/scripts/runIchorCNA.R \ --id low_tf_sample \ --WIG /path/to/tumor.wig \ --gcWig /path/to/ichorCNA/inst/extdata/gc_hg19_1000kb.wig \ --mapWig /path/to/ichorCNA/inst/extdata/map_hg19_1000kb.wig \ --centromere /path/to/ichorCNA/inst/extdata/GRCh37.p13_centromere_UCSC-gapTable.txt \ --normalPanel /path/to/ichorCNA/inst/extdata/HD_ULP_PoN_1Mb_median_normAutosome_mapScoreFiltered_median.rds \ --normal "c(0.95, 0.99, 0.995, 0.999)" \ --ploidy "c(2)" \ --maxCN 3 \ --estimateScPrevalence FALSE \ --scStates "c()" \ --chrs "c(1:22)" \ --chrTrain "c(1:22)" \ --outDir ./results/ ``` -------------------------------- ### Preview Snakemake Workflow Source: https://context7.com/broadinstitute/ichorcna/llms.txt Performs a dry run of the Snakemake workflow to preview the execution plan without actually running any jobs. ```bash # Preview workflow (dry run) cd /path/to/ichorCNA/scripts/snakemake snakemake -s ichorCNA.snakefile -np ``` -------------------------------- ### Set chromosomes and bin size Source: https://github.com/broadinstitute/ichorcna/wiki/SnakeMake-pipeline-for-ichorCNA Defines the chromosomes to analyze and the window size for coverage computation. ```yaml chrs: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,X,Y binSize: 1000000 # set window size to compute coverage ``` -------------------------------- ### Generate Panel of Normals Source: https://github.com/broadinstitute/ichorcna/wiki/Create-Panel-of-Normals Executes the createPanelOfNormals.R script to compile a PoN from a list of WIG files. ```bash Rscript createPanelOfNormals.R --filelist /path/to/wig_files.txt --gcWig /path/to/gc.wig --mapWig /path/to/map.wig --centromere /path/to/centromeres_file.txt --outfile base_outfile_name ``` -------------------------------- ### Run ichorCNA Script Source: https://github.com/broadinstitute/ichorcna/wiki/Usage This section details how to run the ichorCNA analysis using the provided R script and explains key command-line arguments. ```APIDOC ## Run ichorCNA This section describes how to manually run ichorCNA using the `runIchorCNA.R` script. ### Method Command Line Execution ### Endpoint `/path/to/ichorCNA/scripts/runIchorCNA.R` ### Parameters #### Command-line Arguments - **--id** (string) - Required - Patient ID. Default: [test] - **--WIG** (string) - Required - Path to tumor WIG file. - **--NORMWIG** (string) - Optional - Path to normal WIG file. Default: [NULL] - **--gcWig** (string) - Required - Path to GC-content WIG file. - **--mapWig** (string) - Optional - Path to mappability score WIG file. Default: [NULL] - **--normalPanel** (string) - Optional - Median corrected depth from panel of normals. Default: [NULL] - **--exons.bed** (string) - Optional - Path to bed file containing exon regions. Default: [NULL] - **--centromere** (string) - Optional - File containing Centromere locations; if not provided then will use hg19 version from ichorCNA package. Default: [NULL] - **--rmCentromereFlankLength** (numeric) - Optional - Length of region flanking centromere to remove. Default: [1e+05] - **--normal** (numeric or vector) - Optional - Initial normal contamination; can be more than one value if additional normal initializations are desired. Default: [0.5] - **--scStates** (vector) - Optional - Subclonal states to consider. Default: [NULL] - **--coverage** (numeric) - Optional - PICARD sequencing coverage. Default: [NULL] - **--lambda** (vector) - Optional - Initial Student's t precision; must contain 4 values (e.g. c(1500,1500,1500,1500)); if not provided then will automatically use based on variance of data. Default: [NULL] - **--lambdaScaleHyperParam** (numeric) - Optional - Hyperparameter (scale) for Gamma prior on Student's-t precision. Default: [3] - **--ploidy** (numeric or vector) - Optional - Initial tumour ploidy; can be more than one value if additional ploidy initializations are desired. Default: [2] - **--maxCN** (numeric) - Optional - Total clonal CN states. Default: [7] - **--estimateNormal** (boolean) - Optional - Estimate normal. Default: [TRUE] - **--estimateScPrevalence** (boolean) - Optional - Estimate subclonal prevalence. Default: [TRUE] - **--estimatePloidy** (boolean) - Optional - Estimate tumour ploidy. Default: [TRUE] - **--maxFracCNASubclone** (numeric) - Optional - Exclude solutions with fraction of subclonal events greater than this value. Default: [0.7] - **--maxFracGenomeSubclone** (numeric) - Optional - Exclude solutions with subclonal genome fraction greater than this value. Default: [0.5] - **--minSegmentBins** (numeric) - Optional - Minimum number of bins for largest segment threshold required to estimate tumor fraction; if below this threshold, then will be assigned zero tumor fraction. - **--altFracThreshold** (numeric) - Optional - Minimum proportion of bins altered required to estimate tumor fraction; if below this threshold, then will be assigned zero tumor fraction. Default: [0.05] - **--chrNormalize** (vector) - Optional - Specify chromosomes to normalize GC/mappability biases. Default: [c(1:22)] - **--chrTrain** (vector) - Optional - Specify chromosomes to estimate params. Default: [c(1:22)] - **--chrs** (vector) - Optional - Specify chromosomes to analyze. Default: [c(1:22, "X")] - **--normalizeMaleX** (boolean) - Optional - If male, then normalize chrX by median. Default: [TRUE] - **--fracReadsInChrYForMale** (numeric) - Optional - Threshold for fraction of reads in chrY to assign as male. Default: [0.001] - **--includeHOMD** (boolean) - Optional - If FALSE, then exclude HOMD state. Useful when using large bins (e.g. 1Mb). Default: [FALSE] - **--txnE** (numeric) - Optional - Self-transition probability. Increase to decrease number of segments. Default: [0.9999999] - **--txnStrength** (numeric) - Optional - Transition pseudo-counts. Exponent should be the same as the number of decimal places of --txnE. Default: [1e+07] - **--plotFileType** (string) - Optional - File format for output plots. Default: [pdf] - **--plotYLim** (vector) - Optional - ylim to use for chromosome plots. Default: [c(-2,2)] - **--outDir** (string) - Optional - Output Directory. Default: [./] - **--libdir** (string) - Optional - Script library path. Usually exclude this argument unless custom modifications have been made to the ichorCNA R package code and the user would like to source those R files. Default: [NULL] ### Request Example ```bash Rscript /path/to/ichorCNA/scripts/runIchorCNA.R --id tumor_sample \ --WIG /path/to/tumor.wig --ploidy "c(2,3)" --normal "c(0.5,0.6,0.7,0.8,0.9)" --maxCN 5 \ --gcWig /path/to/ichorCNA/inst/extdata/gc_hg19_1000kb.wig \ --mapWig /path/to/ichorCNA/inst/extdata/map_hg19_1000kb.wig \ --centromere /path/to/ichorCNA/inst/extdata/GRCh37.p13_centromere_UCSC-gapTable.txt \ --normalPanel /path/to/ichorCNA/inst/extdata/HD_ULP_PoN_1Mb_median_normAutosome_mapScoreFiltered_median.rds \ --includeHOMD False --chrs "c(1:22, \"X\")" --chrTrain "c(1:22)" \ --estimateNormal True --estimatePloidy True --estimateScPrevalence True \ --scStates "c(1,3)" --txnE 0.9999 --txnStrength 10000 --outDir ./ ``` ### Help To view all available options, run the script with the `--help` flag: ```bash Rscript runIchorCNA.R --help ``` ``` -------------------------------- ### Run Snakemake Workflow Locally Source: https://context7.com/broadinstitute/ichorcna/llms.txt Executes the Snakemake workflow locally, utilizing up to 5 CPU cores. ```bash # Run locally with 5 cores snakemake -s ichorCNA.snakefile --cores 5 ``` -------------------------------- ### Set Initial Parameters for ichorCNA Source: https://context7.com/broadinstitute/ichorcna/llms.txt Sets initial values for tumor ploidy, normal contamination, and subclone prevalence. ```r # Set initial values param$phi_0 <- 2 # Initial tumor ploidy param$n_0 <- 0.5 # Initial normal contamination (1 - tumor fraction) param$sp_0 <- 0.5 # Initial subclone prevalence ``` -------------------------------- ### Configure ichorCNA model parameters Source: https://github.com/broadinstitute/ichorcna/wiki/SnakeMake-pipeline-for-ichorCNA Sets parameters for normal fraction, ploidy, and estimation flags. ```yaml ichorCNA_chrs: c(1:22, "X") # chrs used for training ichorCNA parameters, e.g. tumor fraction. ichorCNA_chrTrain: c(1:22) # non-tumor fraction parameter restart values; higher values should be included for cfDNA ichorCNA_normal: c(0.5,0.6,0.7,0.8,0.9,0.95) # ploidy parameter restart values ichorCNA_ploidy: c(2,3) ichorCNA_estimateNormal: TRUE ichorCNA_estimatePloidy: TRUE ``` -------------------------------- ### Generate Read Count WIG File Source: https://context7.com/broadinstitute/ichorcna/llms.txt Create WIG files from indexed BAM files using HMMcopy's readCounter utility. ```bash # Generate WIG file with 1Mb bins from a BAM file # BAM file must be indexed (.bam.bai in same directory) /path/to/HMMcopy/bin/readCounter --window 1000000 --quality 20 \ --chromosome "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,X,Y" \ /path/to/tumor.bam > /path/to/tumor.wig # For 500kb bins (higher resolution, requires more coverage) /path/to/HMMcopy/bin/readCounter --window 500000 --quality 20 \ --chromosome "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,X,Y" \ /path/to/tumor.bam > /path/to/tumor.500kb.wig ``` -------------------------------- ### Run ichorCNA Analysis Source: https://context7.com/broadinstitute/ichorcna/llms.txt Execute the main analysis script to process WIG files and estimate tumor fraction. ```bash # Basic ichorCNA analysis with essential parameters Rscript /path/to/ichorCNA/scripts/runIchorCNA.R \ --id tumor_sample \ --WIG /path/to/tumor.wig \ --gcWig /path/to/ichorCNA/inst/extdata/gc_hg19_1000kb.wig \ --mapWig /path/to/ichorCNA/inst/extdata/map_hg19_1000kb.wig \ --centromere /path/to/ichorCNA/inst/extdata/GRCh37.p13_centromere_UCSC-gapTable.txt \ --normalPanel /path/to/ichorCNA/inst/extdata/HD_ULP_PoN_1Mb_median_normAutosome_mapScoreFiltered_median.rds \ --ploidy "c(2,3)" \ --normal "c(0.5,0.6,0.7,0.8,0.9)" \ --maxCN 5 \ --includeHOMD False \ --chrs "c(1:22, \"X\")" \ --chrTrain "c(1:22)" \ --estimateNormal True \ --estimatePloidy True \ --estimateScPrevalence True \ --scStates "c(1,3)" \ --txnE 0.9999 \ --txnStrength 10000 \ --outDir ./results/ # For hg38 reference genome Rscript /path/to/ichorCNA/scripts/runIchorCNA.R \ --id tumor_sample_hg38 \ --WIG /path/to/tumor.wig \ --gcWig /path/to/ichorCNA/inst/extdata/gc_hg38_1000kb.wig \ --mapWig /path/to/ichorCNA/inst/extdata/map_hg38_1000kb.wig \ --centromere /path/to/ichorCNA/inst/extdata/GRCh38.GCA_000001405.2_centromere_acen.txt \ --normalPanel /path/to/ichorCNA/inst/extdata/HD_ULP_PoN_hg38_1Mb_median_normAutosome_median.rds \ --genomeBuild hg38 \ --genomeStyle UCSC \ --ploidy "c(2,3)" \ --normal "c(0.5,0.6,0.7,0.8,0.9)" \ --maxCN 5 \ --outDir ./results/ # View all available options Rscript /path/to/ichorCNA/scripts/runIchorCNA.R --help ``` -------------------------------- ### View ichorCNA Parameters Source: https://context7.com/broadinstitute/ichorcna/llms.txt Display the contents of the parameters file generated by ichorCNA. This file contains estimated tumor fraction, ploidy, and other relevant metrics. ```bash cat results/tumor_sample.params.txt ``` -------------------------------- ### Configure ichorCNA script and normal panel paths Source: https://github.com/broadinstitute/ichorcna/wiki/SnakeMake-pipeline-for-ichorCNA Specifies the path to the main R script and the optional normal panel for data normalization. ```yaml # included in GitHub repo ichorCNA_rscript: ../runIchorCNA.R # use panel matching same bin size (optional) ichorCNA_normalPanel: ../../inst/extdata/HD_ULP_PoN_1Mb_median_normAutosome_mapScoreFiltered_median.rds ``` -------------------------------- ### Configure targeted intervals and centromeres Source: https://github.com/broadinstitute/ichorcna/wiki/SnakeMake-pipeline-for-ichorCNA Optional configuration for targeted regions like exons and centromere locations. ```yaml # use bed file if sample has targeted regions, eg. exome data (optional) ichorCNA_exons: NULL ichorCNA_centromere: ../../inst/extdata/GRCh37.p13_centromere_UCSC-gapTable.txt ``` -------------------------------- ### Define Samples for Snakemake Workflow Source: https://context7.com/broadinstitute/ichorcna/llms.txt Defines the samples to be processed by the ichorCNA Snakemake workflow, mapping sample IDs to BAM file paths. ```yaml # config/samples.yaml - Define samples samples: tumor_sample_1: /path/to/bam/tumor1.bam tumor_sample_2: /path/to/bam/tumor2.bam tumor_sample_3: /path/to/bam/tumor3.bam ``` -------------------------------- ### Configure segmentation sensitivity Source: https://github.com/broadinstitute/ichorcna/wiki/SnakeMake-pipeline-for-ichorCNA Sets parameters for segmentation sensitivity and specificity. ```yaml # higher (e.g. 0.9999999) leads to higher specificity and fewer segments # lower (e.g. 0.99) leads to higher sensitivity and more segments ichorCNA_txnE: 0.9999 # higher (e.g. 10000000) leads to higher specificity and fewer segments ``` -------------------------------- ### Execute ichorCNA via Command Line Source: https://github.com/broadinstitute/ichorcna/wiki/Usage Use the runIchorCNA.R script to process tumor samples. Ensure all required paths for WIG, GC, mappability, and centromere files are correctly specified. ```bash Rscript /path/to/ichorCNA/scripts/runIchorCNA.R --id tumor_sample \ --WIG /path/to/tumor.wig --ploidy "c(2,3)" --normal "c(0.5,0.6,0.7,0.8,0.9)" --maxCN 5 \ --gcWig /path/to/ichorCNA/inst/extdata/gc_hg19_1000kb.wig \ --mapWig /path/to/ichorCNA/inst/extdata/map_hg19_1000kb.wig \ --centromere /path/to/ichorCNA/inst/extdata/GRCh37.p13_centromere_UCSC-gapTable.txt \ --normalPanel /path/to/ichorCNA/inst/extdata/HD_ULP_PoN_1Mb_median_normAutosome_mapScoreFiltered_median.rds \ --includeHOMD False --chrs "c(1:22, \"X\")" --chrTrain "c(1:22)" \ --estimateNormal True --estimatePloidy True --estimateScPrevalence True \ --scStates "c(1,3)" --txnE 0.9999 --txnStrength 10000 --outDir ./ ``` -------------------------------- ### Configure Snakemake Pipeline for ichorCNA Source: https://context7.com/broadinstitute/ichorcna/llms.txt Configures the ichorCNA pipeline for Snakemake, specifying paths to scripts, reference data, and analysis parameters. ```yaml # config/config.yaml - Pipeline configuration readCounterScript: /path/to/HMMcopy/bin/readCounter chrs: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,X,Y binSize: 1000000 ichorCNA_rscript: /path/to/ichorCNA/scripts/runIchorCNA.R ichorCNA_normalPanel: /path/to/ichorCNA/inst/extdata/HD_ULP_PoN_1Mb_median_normAutosome_mapScoreFiltered_median.rds ichorCNA_gcWig: /path/to/ichorCNA/inst/extdata/gc_hg19_1000kb.wig ichorCNA_mapWig: /path/to/ichorCNA/inst/extdata/map_hg19_1000kb.wig ichorCNA_centromere: /path/to/ichorCNA/inst/extdata/GRCh37.p13_centromere_UCSC-gapTable.txt ichorCNA_exons: NULL ichorCNA_chrs: c(1:22, "X") ichorCNA_chrTrain: c(1:22) ichorCNA_normal: c(0.5,0.6,0.7,0.8,0.9,0.95) ichorCNA_ploidy: c(2,3) ichorCNA_maxCN: 5 ichorCNA_includeHOMD: FALSE ichorCNA_estimateNormal: TRUE ichorCNA_estimatePloidy: TRUE ichorCNA_estimateClonality: TRUE ichorCNA_scStates: c(1,3) ichorCNA_txnE: 0.9999 ichorCNA_txnStrength: 10000 ichorCNA_genomeBuild: hg19 ichorCNA_genomeStyle: NCBI ichorCNA_plotFileType: pdf ichorCNA_plotYlim: c(-2,2) ``` -------------------------------- ### Invoke Snakemake workflow Source: https://github.com/broadinstitute/ichorcna/wiki/SnakeMake-pipeline-for-ichorCNA Commands to run the ichorCNA Snakemake workflow locally or on a cluster. ```bash # show commands and workflow snakemake -s ichorCNA.snakefile -np ``` ```bash # run the workflow locally using 5 cores snakemake -s ichorCNA.snakefile --cores 5 ``` ```bash # run the workflow on qsub using a maximum of 50 jobs. # Broad UGER cluster parameters can be set directly in config/cluster.sh. snakemake -s ichorCNA.snakefile --cluster-sync "qsub" -j 50 --jobscript config/cluster.sh ``` -------------------------------- ### Run ichorCNA on SLURM Cluster Source: https://context7.com/broadinstitute/ichorcna/llms.txt Execute the ichorCNA workflow on a SLURM cluster using Snakemake. Specify the Snakefile, cluster type, number of jobs, and cluster configuration file. ```bash snakemake -s ichorCNA.snakefile --cluster "sbatch" -j 50 --cluster-config config/cluster_slurm.yaml ``` -------------------------------- ### View Segment File Header Source: https://context7.com/broadinstitute/ichorcna/llms.txt Display the first few lines of the segment file generated by ichorCNA. This file contains segmented copy number information compatible with IGV. ```bash head results/tumor_sample.seg.txt ``` -------------------------------- ### Output Parameters to File with ichorCNA Source: https://context7.com/broadinstitute/ichorcna/llms.txt Writes the parameters used in the ichorCNA analysis to a specified file. ```r # Output parameters to file outputParametersToFile(hmmResults, file = "./results/tumor_sample.params.txt") ``` -------------------------------- ### Define cfDNA samples in YAML Source: https://github.com/broadinstitute/ichorcna/wiki/SnakeMake-pipeline-for-ichorCNA The samples field must be defined in the YAML configuration file to map sample names to their respective BAM files. ```yaml samples: tumor_sample_1: /path/to/bam/tumor.bam ``` -------------------------------- ### Configure ichorCNA genome style Source: https://github.com/broadinstitute/ichorcna/wiki/SnakeMake-pipeline-for-ichorCNA Sets the chromosome naming style for the output. ```yaml ichorCNA_genomeStyle: UCSC # sets output chromosome naming style ``` -------------------------------- ### Train and Analyze Autosomes Only Source: https://github.com/broadinstitute/ichorcna/wiki/Parameter-tuning-and-settings Exclude the X chromosome from analysis and training to simplify the process and reduce complexity for low tumor fraction samples. ```bash --chrs "c(1:22)" --chrTrain "c(1:22)" ``` -------------------------------- ### Extract Purity, Ploidy, and Cell Prevalence from HMM Results Source: https://context7.com/broadinstitute/ichorcna/llms.txt Extracts estimated purity, ploidy, and cell prevalence from the results of HMMsegment. ```r iter <- hmmResults$results$iter purity <- 1 - hmmResults$results$n[1, iter] ploidy <- hmmResults$results$phi[1, iter] cellPrev <- 1 - hmmResults$results$sp[1, iter] ``` -------------------------------- ### Perform HMM Segmentation Source: https://context7.com/broadinstitute/ichorcna/llms.txt Executes HMM-based segmentation to predict copy number states. Requires pre-processed read counts and initialized HMM parameters. ```r library(ichorCNA) library(HMMcopy) library(GenomicRanges) # Load and process WIG file tumour_reads <- wigToGRanges("/path/to/tumor.wig") gc <- wigToGRanges("/path/to/gc_hg19_1000kb.wig") map <- wigToGRanges("/path/to/map_hg19_1000kb.wig") # Define chromosomes and load centromere file chrs <- c(as.character(1:22), "X") centromere <- read.delim("/path/to/GRCh37.p13_centromere_UCSC-gapTable.txt", header=TRUE, stringsAsFactors=FALSE, sep="\t") # Load and correct read counts counts <- loadReadCountsFromWig(tumour_reads, chrs=chrs, gc=gc, map=map, centromere=centromere, flankLength=100000, genomeStyle="NCBI", chrNormalize=c(1:22)) tumour_copy <- counts$counts gender <- counts$gender # Normalize by panel of normals (optional) normal_panel <- "/path/to/HD_ULP_PoN_1Mb_median_normAutosome_mapScoreFiltered_median.rds" tumour_copy <- normalizeByPanelOrMatchedNormal(tumour_copy, chrs=chrs, normal_panel=normal_panel, gender=gender$gender) # Set up HMM parameters logR <- as.data.frame(tumour_copy$copy) chrTrain <- c(1:22) chrInd <- as.character(seqnames(tumour_copy)) %in% chrTrain valid <- tumour_copy$valid param <- getDefaultParameters(logR[valid & chrInd, , drop=FALSE], maxCN=5, includeHOMD=FALSE, ct.sc=c(1,3), ploidy=2, e=0.9999, strength=10000) param$phi_0 <- 2 # Initial ploidy param$n_0 <- 0.5 # Initial normal fraction # Run HMM segmentation hmmResults <- HMMsegment(list(sample=tumour_copy), valid, dataType="copy", param=param, chrTrain=chrTrain, maxiter=50, estimateNormal=TRUE, estimatePloidy=TRUE, estimateSubclone=TRUE, verbose=TRUE) # Access results tumor_fraction <- 1 - hmmResults$results$n[, hmmResults$results$iter] ploidy <- hmmResults$results$phi[, hmmResults$results$iter] segments <- hmmResults$results$segs[[1]] copy_number_bins <- hmmResults$cna[[1]] print(paste("Tumor Fraction:", round(tumor_fraction, 4))) print(paste("Ploidy:", round(ploidy, 2))) ``` -------------------------------- ### Configure subclonal copy number states Source: https://github.com/broadinstitute/ichorcna/wiki/SnakeMake-pipeline-for-ichorCNA Defines subclonal states and enables clonality estimation. ```yaml # states to use for subclonal CN ichorCNA_scStates: c(1,3) ichorCNA_estimateClonality: TRUE ``` -------------------------------- ### Configure copy number limits and homozygous deletion Source: https://github.com/broadinstitute/ichorcna/wiki/SnakeMake-pipeline-for-ichorCNA Sets the maximum copy number and toggles the inclusion of homozygous deletion states. ```yaml # set maximum copy number to use ichorCNA_maxCN: 5 # TRUE/FALSE to include homozygous deletion state ichorCNA_includeHOMD: FALSE ``` -------------------------------- ### Set Default Parameters for ichorCNA Source: https://context7.com/broadinstitute/ichorcna/llms.txt Sets default parameters for ichorCNA, with options for higher specificity (fewer segments) or higher sensitivity (more segments). ```r param_high_spec <- getDefaultParameters(logR[valid & chrInd, , drop=FALSE], maxCN = 5, e = 0.99999999, # Higher self-transition strength = 100000000) # Higher sensitivity (more segments): param_high_sens <- getDefaultParameters(logR[valid & chrInd, , drop=FALSE], maxCN = 5, e = 0.999, # Lower self-transition strength = 1000) ``` -------------------------------- ### Reduce Number of Copy Number States Source: https://github.com/broadinstitute/ichorcna/wiki/Parameter-tuning-and-settings Lowering the maximum number of copy number states (e.g., to 3) helps reduce complexity. Increase to 4 if high-level copy number events are known from prior samples. ```bash --maxCN 3 ``` -------------------------------- ### Access Corrected Results from ichorCNA Source: https://context7.com/broadinstitute/ichorcna/llms.txt Accesses the corrected segments and bin-level copy number data after running `correctIntegerCN`. ```r # Access corrected results corrected_segments <- correctedResults$segs corrected_bins <- correctedResults$cn ``` -------------------------------- ### Disable Subclonal Copy Number Event Estimation Source: https://github.com/broadinstitute/ichorcna/wiki/Parameter-tuning-and-settings Turn off subclonal event detection for low tumor fraction samples, as these are difficult to detect. Ensure the subclonal states list is empty. ```bash --estimateScPrevalence FALSE --scStates "c()" ``` -------------------------------- ### Access ichorCNA Parameter Information Source: https://context7.com/broadinstitute/ichorcna/llms.txt Accesses and prints various parameter details from an ichorCNA parameter object. ```r # Access parameter information print(param$ct) # Copy number states print(param$ct.sc.status) # Subclonal status for each state print(param$lambda) # Student's t precision print(param$jointCNstates) # Joint copy number states ``` -------------------------------- ### Output HMM Results with ichorCNA Source: https://context7.com/broadinstitute/ichorcna/llms.txt Writes HMM results, including segments and bin-level data, to output files. This function is used after running `HMMsegment` and `correctIntegerCN`. ```r library(ichorCNA) # After running HMMsegment and correctIntegerCN # Output results to files outputHMM( cna = hmmResults$cna, segs = hmmResults$results$segs, results = hmmResults$results, patientID = "tumor_sample", outDir = "./results/" ) ``` -------------------------------- ### View Corrected Copy Number Calls Source: https://context7.com/broadinstitute/ichorcna/llms.txt Prints the head of the corrected segments data frame to display copy number calls, including corrected values. ```r # View corrected calls print(head(corrected_segments[, c("chr", "start", "end", "copy.number", "Corrected_Copy_Number", "Corrected_Call")])) ``` -------------------------------- ### Correct Integer Copy Number with ichorCNA Source: https://context7.com/broadinstitute/ichorcna/llms.txt Corrects high-level amplifications in integer copy numbers using estimated purity and ploidy. This function is typically run after HMMsegment. ```r # Correct integer copy number correctedResults <- correctIntegerCN( cn = hmmResults$cna[[1]], segs = hmmResults$results$segs[[1]], purity = purity, ploidy = ploidy, cellPrev = cellPrev, maxCNtoCorrect.autosomes = 5, maxCNtoCorrect.X = 5, minPurityToCorrect = 0.1, gender = gender$gender, chrs = c(1:22, "X"), correctHOMD = FALSE ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.