# NOT RUN {
    
# }
# NOT RUN {
    data.file <-  system.file("extdata", "example.seqz.txt.gz",
        package = "sequenza")
    # read all the chromosomes:
    seqz.data <- read.seqz(data.file)
    # Gather genome wide GC-stats from raw file:
    gc.stats <- gc.sample.stats(data.file)
    gc.normal.vect <- mean_gc(gc.stats$normal)
    gc.tumor.vect <- mean_gc(gc.stats$tumor)
    # Read only one chromosome:
    seqz.data <- read.seqz(data.file, chr_name = "1")
    # Correct the coverage of the loaded chromosome:
    seqz.data$adjusted.ratio <- round((seqz.data$depth.tumor /
        gc.tumor.vect[as.character(seqz.data$GC.percent)]) /
        (seqz.data$depth.normal /
        gc.normal.vect[as.character(seqz.data$GC.percent)]), 3)
    # Select the heterozygous positions
    seqz.hom <- seqz.data$zygosity.normal == 'hom'
    seqz.het <- seqz.data[!seqz.hom, ]
    # Detect breakpoints
    breaks <- find.breaks(seqz.het, gamma = 80, kmin = 10,
        baf.thres = c(0, 0.5))
    # use heterozygous and homozygous position to measure segment values
    seg.s1 <- segment.breaks(seqz.data, breaks = breaks)
    # filter out small ambiguous segments, and conveniently weight
    # the segments by size:
    seg.filtered <- seg.s1[(seg.s1$end.pos - seg.s1$start.pos) > 3e6, ]
    weights.seg  <- (seg.filtered$end.pos - seg.filtered$start.pos) / 1e6
    # Set the average depth ratio to 1:
    avg.depth.ratio <- 1
    # run the BAF model fit
    CP <- baf.model.fit(Bf = seg.filtered$Bf,
        depth.ratio = seg.filtered$depth.ratio, weight.ratio = weights.seg,
        weight.Bf = weights.seg, sd.ratio = seg.filtered$sd.ratio,
        sd.Bf = seg.filtered$sd.BAF, avg.depth.ratio = avg.depth.ratio,
        cellularity = seq(0.1, 1, 0.01), ploidy = seq(0.5, 3, 0.05))
    confint <- get.ci(CP)
    ploidy <- confint$max.ploidy
    cellularity <- confint$max.cellularity
    
# }
Run the code above in your browser using DataLab