MetricFactory: MetricFactory object

Description Usage Format Value Constructor Author(s) See Also Examples

Description

An object which is a interface to calculate all available metrics separately.

The MetricFactory object is inspired from the factory design pattern. Only one instance of MetricFactory object is necessary to calculate all available metrics for different profiles, as long as the thresholds set in the MetricFactory instance are appropriate for the calculation. The thresholds are set during the MetricFactory object creation and cannot be changed afterwards. If different thresholds are needed, a new MetricFactory object, with the new thresholds, must be instantiated.

Usage

1

Format

An object of class R6ClassGenerator of length 24.

Value

The MetricFactory$new function returns a MetricFactory object which contains the information about the thresholds used to calculate each metric. It can be used, as many times needed, to calculate the specified metrics.

Constructor

Create a MetricFactory object.

MetricFactory$new(ratioAreaThreshold=1, ratioMaxMaxThreshold=1, ratioIntersectThreshold=1, ratioNormalizedIntersectThreshold=1, diffPosMaxThresholdMinValue=1, diffPosMaxThresholdMaxDiff=100, diffPosMaxTolerance=0.01, spearmanCorrSDThreashold=1e-8)

Author(s)

Astrid Deschenes

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## Initialized the factory object
factory = MetricFactory$new(ratioAreaThreshold=100,
    ratioIntersectThreshold=20,
    diffPosMaxTolerance=0.04)
    
## Define 2 ChIP-Seq profiles
profile1 <- c(1,59,6,24,65,34,15,4,53,22)
profile2 <- c(15,9,46,44,9,39,27,34,34,4)

## Use the factory object to calculate each metric separatly
ratio_max_max <- factory$createMetric(metricType="RATIO_MAX_MAX", 
    profile1, profile2)
ratio_max_max

diff_pos_max <- factory$createMetric(metric="DIFF_POS_MAX", profile1, 
    profile2)
diff_pos_max
    
## Example using ChIP-Seq profiles of H3K27ac (DCC accession: ENCFF000ASG) 
## and H3K4me1 (DCC accession: ENCFF000ARY) from the Encyclopedia of DNA  
## Elements (ENCODE) for the region 
data(demoProfiles)

## Visualize ChIP-Seq profiles 
plot(demoProfiles$chr3.73159773.73160145$H3K27ac, type="l", col="blue",
    xlab="", ylab="", ylim=c(0, 125), main="chr3:73159773-73160145")
par(new=TRUE)
plot(demoProfiles$chr3.73159773.73160145$H3K4me1, type="l", col="darkgreen", 
    xlab="Position", ylab="Coverage in reads per million (RPM)",  
    ylim=c(0, 125))
legend("topright", c("H3K27ac","H3K4me1"), cex=1.2, 
    col=c("blue","darkgreen"), lty=1)
    
## Calculate metrics using factory object 
ratio_norm_intersect <- factory$createMetric(metricType = 
    "RATIO_NORMALIZED_INTERSECT", 
    profile1=demoProfiles$chr3.73159773.73160145$H3K4me1, 
    profile2=demoProfiles$chr3.73159773.73160145$H3K27ac)
ratio_norm_intersect

ratio_area <- factory$createMetric(metricType="RATIO_AREA",
    profile1=demoProfiles$chr3.73159773.73160145$H3K4me1, 
    profile2=demoProfiles$chr3.73159773.73160145$H3K27ac)
ratio_area

similaRpeak documentation built on Nov. 8, 2020, 6:56 p.m.