## ----options, echo=FALSE, results='hide', message=FALSE, eval=TRUE------- options(fig.width=120) library(AneuFinder) ## ----eval=FALSE---------------------------------------------------------- ## Aneufinder(inputfolder='folder-with-BAM', outputfolder='output-directory', ## format='bam', numCPU=2) ## ----eval=TRUE----------------------------------------------------------- ?Aneufinder ## ----eval=FALSE---------------------------------------------------------- ## Aneufinder(..., configfile='AneuFinder.config') ## ----eval=FALSE---------------------------------------------------------- ## files <- list.files('output-directory/binned', full.names=TRUE) ## binned.data <- loadGRangesFromFiles(files) ## ----eval=FALSE---------------------------------------------------------- ## files <- list.files('output-directory/hmms', full.names=TRUE) ## hmms <- loadHmmsFromFiles(files) ## cl <- clusterByQuality(hmms) ## heatmapGenomewide(cl$classification[[1]]) ## ----eval=TRUE, message=FALSE, warning=FALSE----------------------------- ## Load human genome library(BSgenome.Hsapiens.UCSC.hg19) ## Get a BAM file for the estimation of quality scores (adjust this to your experiment) bamfile <- system.file("extdata", "BB150803_IV_074.bam", package="AneuFinderData") ## Simulate reads of length 51bp for human genome # We simulate reads every 5000bp for demonstration purposes, for a real # application you should use a much denser spacing (e.g. 500bp or less) simulatedReads.file <- tempfile() # replace this with your destination file simulateReads(BSgenome.Hsapiens.UCSC.hg19, readLength=51, bamfile=bamfile, file=simulatedReads.file, every.X.bp=5000) ## ----eval=TRUE, warning=FALSE, message=FALSE, fig.height=3--------------- ## Get a euploid reference (adjust this to your experiment) bedfile <- system.file("extdata", "hg19_diploid.bam.bed.gz", package="AneuFinderData") ## Make 100kb fixed-width bins bins <- binReads(bedfile, format='bed', assembly='hg19', binsizes=100e3, chromosomes=c(1:22,'X'))[[1]] ## Make a plot for visual inspection and get the blacklist lcutoff <- quantile(bins$counts, 0.05) ucutoff <- quantile(bins$counts, 0.999) p <- plot(bins) + coord_cartesian(ylim=c(0,50)) p <- p + geom_hline(aes(yintercept=lcutoff), color='red') p <- p + geom_hline(aes(yintercept=ucutoff), color='red') print(p) blacklist <- bins[bins$counts < ucutoff & bins$counts > lcutoff] ## Write blacklist to file blacklist.file <- tempfile() exportGRanges(blacklist, filename=blacklist.file, header=FALSE, chromosome.format='NCBI') ## ----eval=TRUE----------------------------------------------------------- ## First, get some data and reference files (adjust this to your experiment) var.width.ref <- system.file("extdata", "hg19_diploid.bam.bed.gz", package="AneuFinderData") blacklist <- system.file("extdata", "blacklist-hg19.bed.gz", package="AneuFinderData") datafolder <- system.file("extdata", "B-ALL-B", package = "AneuFinderData") list.files(datafolder) # only 3 cells for demonstration purposes ## Library for GC correction library(BSgenome.Hsapiens.UCSC.hg19) ## Produce output files cnv.states <- c('zero-inflation', paste0(1:10, '-somy')) outputfolder <- tempdir() Aneufinder(inputfolder = datafolder, outputfolder = outputfolder, format = 'bed', numCPU = 3, binsizes = c(5e5, 1e6), variable.width.reference = var.width.ref, chromosomes = c(1:22,'X','Y'), blacklist = blacklist, states = cnv.states, correction.method = 'GC', GC.BSgenome = BSgenome.Hsapiens.UCSC.hg19, num.trials = 1, assembly = 'hg19') ## ----eval=TRUE, message=FALSE-------------------------------------------- ## Get some pre-produced results (adjust this to your experiment) results <- system.file("extdata", "primary-lung", "hmms", package="AneuFinderData") files <- list.files(results, full.names=TRUE) ## Cluster by quality cl <- clusterByQuality(files) plot(cl$Mclust, what='classification') print(cl$parameters) ## Apparently, the third cluster corresponds to failed libraries ## while the first cluster contains high-quality libraries ## Select the best cluster and plot it selected.files <- unlist(cl$classification[[1]]) heatmapGenomewide(selected.files) ## ----eval=TRUE, message=FALSE-------------------------------------------- ## Get some pre-produced results (adjust this to your experiment) results <- system.file("extdata", "primary-lung", "hmms", package="AneuFinderData") files.lung <- list.files(results, full.names=TRUE) results <- system.file("extdata", "metastasis-liver", "hmms", package="AneuFinderData") files.liver <- list.files(results, full.names=TRUE) ## Get karyotype measures k.lung <- karyotypeMeasures(files.lung) k.liver <- karyotypeMeasures(files.liver) ## Print the scores in one data.frame df <- rbind(lung = k.lung$genomewide, liver = k.liver$genomewide) print(df) ## While the aneuploidy is similar between both cancers, the heterogeneity is ## nearly twice as high for the primary lung cancer. ## ----eval=TRUE----------------------------------------------------------- sessionInfo() warnings()