Browse code

Refactored package.

fortinj2 authored on 27/11/2022 18:46:13
Showing 1 changed files
... ...
@@ -1,31 +1,57 @@
1 1
 ### To plot the internal controls
2
-plotInternalControls <- function(y, col, main, sampleNames, bty="o"){
2
+#' @importFrom graphics abline grid
3
+plotInternalControls <- function(y,
4
+                                 col,
5
+                                 main,
6
+                                 sampleNames,
7
+                                 bty="o"
8
+){
3 9
     n <- length(y)
4 10
     slideNames <- substr(sampleNames, 1, 10)
5
-    plot(1:n, y, pch=20, cex=0.7, main = main, xlab = "Sample",
6
-         ylab = "Control intensity", ylim = c(0, 1.3*max(y)),
7
-         col = col, bty = bty)
11
+    plot(seq_len(n),
12
+         y,
13
+         pch=20,
14
+         cex=0.7,
15
+         main=main,
16
+         xlab="Sample",
17
+         ylab="Control intensity",
18
+         ylim=c(0, 1.3*max(y)),
19
+         col=col,
20
+         bty=bty)
8 21
     grid()
9 22
     abline(h=0, lty=3)
10 23
 }
11 24
 
12 25
 ### To add the selected array to the internal controls plot
13
-addHoverPoints <- function(y, sampleNames, selectedSamples=c()){
26
+#' @importFrom graphics points
27
+addHoverPoints <- function(y,
28
+                           sampleNames,
29
+                           selectedSamples=c()
30
+){
14 31
     ## To put a circle around the last entry: 
15 32
     n <- length(selectedSamples)
16 33
     if (n>=1){
17
-        points(selectedSamples[n], y[selectedSamples[n]], pch = 1,
18
-               cex = 3, lwd = 3)
19
-        points(selectedSamples[1:n], y[selectedSamples[1:n]],
20
-               pch = 17, cex = 1, lwd = 3)
34
+        points(selectedSamples[n],
35
+               y[selectedSamples[n]],
36
+               pch = 1,
37
+               cex = 3,
38
+               lwd = 3)
39
+        points(selectedSamples[seq_len(n)],
40
+               y[selectedSamples[seq_len(n)]],
41
+               pch = 17,
42
+               cex = 1,
43
+               lwd = 3)
21 44
     }
22 45
 }
23 46
 
24
-returnControlStat <- function(controlType, greenControls,
25
-                              redControls, controlNames){
47
+returnControlStat <- function(controlType,
48
+                              greenControls,
49
+                              redControls,
50
+                              controlNames
51
+){
26 52
     index <- match(controlType, controlNames)
27 53
     greenControls.current <- greenControls[[index]]
28
-    redControls.current <- redControls[[index]]
54
+    redControls.current   <- redControls[[index]]
29 55
     
30 56
     if (controlType=="BISULFITE CONVERSION I"){
31 57
         controlStat <- (apply(greenControls.current[1:3,], 2, mean) +
Browse code

Adds oposSOM/ pepStat/ Polyfit/ pRolocGUI/ Pviz/ shinyMethyl/ to the repos.

git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/shinyMethyl@92064 bc3139a8-67e5-0310-9ffc-ced21a209358

m.carlson authored on 01/07/2014 20:38:11
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,54 @@
1
+### To plot the internal controls
2
+plotInternalControls <- function(y, col, main, sampleNames, bty="o"){
3
+    n <- length(y)
4
+    slideNames <- substr(sampleNames, 1, 10)
5
+    plot(1:n, y, pch=20, cex=0.7, main = main, xlab = "Sample",
6
+         ylab = "Control intensity", ylim = c(0, 1.3*max(y)),
7
+         col = col, bty = bty)
8
+    grid()
9
+    abline(h=0, lty=3)
10
+}
11
+
12
+### To add the selected array to the internal controls plot
13
+addHoverPoints <- function(y, sampleNames, selectedSamples=c()){
14
+    ## To put a circle around the last entry: 
15
+    n <- length(selectedSamples)
16
+    if (n>=1){
17
+        points(selectedSamples[n], y[selectedSamples[n]], pch = 1,
18
+               cex = 3, lwd = 3)
19
+        points(selectedSamples[1:n], y[selectedSamples[1:n]],
20
+               pch = 17, cex = 1, lwd = 3)
21
+    }
22
+}
23
+
24
+returnControlStat <- function(controlType, greenControls,
25
+                              redControls, controlNames){
26
+    index <- match(controlType, controlNames)
27
+    greenControls.current <- greenControls[[index]]
28
+    redControls.current <- redControls[[index]]
29
+    
30
+    if (controlType=="BISULFITE CONVERSION I"){
31
+        controlStat <- (apply(greenControls.current[1:3,], 2, mean) +
32
+                        apply(redControls.current[7:9,], 2, mean))/2 
33
+    } else {
34
+        if (controlType=="BISULFITE CONVERSION II"){
35
+            controlStat <- apply(redControls.current, 2, mean)
36
+        } else {
37
+            if (controlType=="EXTENSION"){
38
+                controlStat <- (apply(greenControls.current[3:4,], 2, mean) +
39
+                                apply(redControls.current[1:2,], 2, mean))/2 
40
+            } else {
41
+                if (controlType=="NEGATIVE"){
42
+                    controlStat <- (apply(greenControls.current, 2, mean) +
43
+                                    apply(redControls.current, 2, mean))/2 
44
+                } else {
45
+                    if (controlType=="HYBRIDIZATION"){
46
+                        controlStat <- apply(greenControls.current, 2, mean)
47
+                    } else {controlStat <- apply(greenControls.current, 2, mean)
48
+                        }
49
+                }
50
+            }
51
+        }
52
+    }
53
+    return(controlStat)
54
+}