Learn R Programming

SomatiCA (version 2.2.0)

refineSegment: Refine the segmentation based on estimated somatic ratio.

Description

Neighbor segments with difference in somatic ratio less than certain threshold will be merged together.

Usage

refineSegment(segmentwithratio, data, threshold1 = 0.01, threshold2 = 0.05, adjust = FALSE, method = "mle")

Arguments

segmentwithratio
A GRanges object, segments with annotation of somatic ratio, usually the output of somaticRatio().
data
A GRanges object, input data from SomatiCAFormat().
threshold1
The threshold used to merge the segments based on median LAF. Default is 0.01.
threshold2
The threshold used to merge the segments based on somatic ratio. Default is 0.05.
method
Method used to estimate somatic ratio of given segments. For the "mle" method somatic ratio is estimated by a maximum likelihood approach. For the "mean" method, somatic ratio is estimated by the ratio between mean of tumor sample and normal sample. For the "geometric", somatic ratio is estimated by geometric mean of somatic ratios of all sites in a given segment.
adjust
Adjust the normal and tumor library and make their median equal.

Value

A GRanges object, refined segments with annotation of somatic ratio.

See Also

See Also somaticRatio.

Examples

Run this code

chr <- c("chr1", "chr1", "chr1", "chr2", "chr2", "chr2")
start <- c(1, 300, 600, 1, 200, 400) 
end <- c(300, 600, 800, 200, 400, 650)
medLAF <- c(0.2, 0.4, 0.3, 0.2, 0.3, 0.4)
gLAF <- rep(0.4, 6)
seg <- GRanges(seqnames=chr, 
                   ranges=IRanges(start=start, end=end), 
                   medLAF=medLAF, 
                   medgLAF=gLAF) 


rawLAF <- c(rnorm(300, 0.2, 0.05), rnorm(300, 0.4, 0.05), rnorm(200, 0.3, 0.05), 
            rnorm(200, 0.2, 0.05), rnorm(200, 0.3, 0.05), rnorm(250, 0.4, 0.05)) 
germLAF <- c(rnorm(800+650, 0.4, 0.05)) 
reads1 <- c(rpois(300, 25), rpois(300, 50), rpois(200, 60),  rpois(200, 25), 
            rpois(200, 40), rpois(250, 50))
reads2 <- rpois(800+650,50)
chr <- c(rep("chr1", 800), rep("chr2", 650))
position <- c(c(1:800), c(1:650))
zygo <- rep("het", 800+650)
data <- GRanges(seqnames=chr, 
                 ranges=IRanges(start=position, width=1), 
                 zygosity=zygo, 
                 tCount=reads1, 
                 LAF=rawLAF, 
                 tCountN=reads2, 
                 germLAF=germLAF) 
                 
x <- somaticRatio(seg, data, method = "mle")
y <- refineSegment(x, data)

Run the code above in your browser using DataLab