View source: R/CNVMetricsLog2ratioInternalMethods.R
calculateWeightedEuclideanDistanceFor2Samples | R Documentation |
The weighted Euclidean distance-based metric corresponds to the euclidean distance between 2 samples multiplied by the natural logarithm of the number of bases of the analyzed segment. The final metric is 1 over 1 added to the squared sum of the values obtained for all segments that are not excluded of the analysis.
calculateWeightedEuclideanDistanceFor2Samples(segmentData, minThreshold)
segmentData |
a |
minThreshold |
a single |
The weighted euclidean distance is
1/(1 + (\sum((x_i - y_i)^2 * log2(nbrBases_i))^0.5)
where x
and y
are the
values of 2 samples for a specific segment i
and nbrBases
the
number of bases of the segment i
.
a numeric
representing the weighted euclidean distance
between the two samples. If the distance cannot be calculated as the two
samples don't share any segments with log2ratio value, the value NA is
assigned.
Astrid DeschĂȘnes
## Load required package to generate the two samples
require(GenomicRanges)
# Create first Granges representing first sample
sample01 <- GRanges(seqnames="chr1",
ranges=IRanges(start=c(100, 201, 400), end=c(200, 350, 500)),
strand="*", log2ratio=c(0.3091175, 0.4582058, -0.3798390))
# Create second Granges representing second sample
sample02 <- GRanges(seqnames="chr1",
ranges=IRanges(start=c(150, 200, 450), end=c(250, 350, 500)),
strand="*", log2ratio=c(0.222174, 0.3282156, -0.2728292))
# Create disjoint segment using the 2 samples and without any region
# excluded from the analysis (parameter bedExclusion set to null)
disjoinGRange <- CNVMetrics:::createDisjoinSegmentsForTwoSamples(
segmentDataSample1=sample01, segmentDataSample2=sample02,
bedExclusion=NULL)
## Calculate the weighted ecucidean distance between the two samples
CNVMetrics:::calculateWeightedEuclideanDistanceFor2Samples(
segmentData=disjoinGRange, minThreshold=0.2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.