Skip to content

Commit a2030f2

Browse files
committed
clean up
1 parent af78f35 commit a2030f2

24 files changed

+215
-208
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.Rproj.user
22
.Rhistory
33
.RData
4+
.lintr
45
vignettes/webimg/
56
inst/doc/
67
#!vignettes/webimg/rectangles-1.png

R/colorlegend.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ colorlegend = function(
3434
addlabels = TRUE,
3535
...)
3636
{
37+
3738
if (is.null(at) && addlabels) {
3839
at = seq(0L, 1L, length = length(labels))
3940
}
@@ -106,7 +107,7 @@ colorlegend = function(
106107
}
107108

108109
if(align == 'c') {
109-
text(x = at, y = ylim[1], labels = labels, pos = 2, ...)
110+
text(x = at, y = ylim[1], labels = labels, pos = 2, ...)
110111
}
111112

112113
if(align == 'r') {

R/colors.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ COL2 = function(diverging = c('RdBu', 'BrBG', 'PiYG', 'PRGn', 'PuOr', 'RdYlBu'),
3131
'#D9F0D3', '#A6DBA0', '#5AAE61', '#1B7837', '#00441B'),
3232
PuOr = c('#7F3B08', '#B35806', '#E08214', '#FDB863', '#FEE0B6', '#FFFFFF',
3333
'#D8DAEB', '#B2ABD2', '#8073AC', '#542788', '#2D004B'),
34-
RdYlBu = c('#a50026','#d73027','#f46d43','#fdae61','#fee090','#FFFFFF',
35-
'#e0f3f8','#abd9e9','#74add1','#4575b4','#313695')
34+
RdYlBu = c('#A50026', '#D73027', '#F46D43', '#FDAE61', '#FEE090', '#FFFFFF',
35+
'#E0F3F8', '#ABD9E9', '#74ADD1', '#4575B4', '#313695')
3636
)
3737

3838
return(colorRampPalette(colors)(n))

R/cor-mtest.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ cor.mtest = function(mat, ...) {
2727
for (i in 1:(n - 1)) {
2828
for (j in (i + 1):n) {
2929

30-
tmp = cor.test(x = mat[,i], y = mat[,j], ...)
31-
p.mat[i,j] = p.mat[j,i] = tmp$p.value
30+
tmp = cor.test(x = mat[, i], y = mat[, j], ...)
31+
p.mat[i, j] = p.mat[j, i] = tmp$p.value
3232

3333
# only 'pearson' method provides confidence intervals
3434
if (!is.null(tmp$conf.int)) {
35-
lowCI.mat[i,j] = lowCI.mat[j,i] = tmp$conf.int[1]
36-
uppCI.mat[i,j] = uppCI.mat[j,i] = tmp$conf.int[2]
35+
lowCI.mat[i, j] = lowCI.mat[j, i] = tmp$conf.int[1]
36+
uppCI.mat[i, j] = uppCI.mat[j, i] = tmp$conf.int[2]
3737
}
3838
}
3939
}

R/corrMatOrder.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ corrMatOrder = function(
3737
corr,
3838
order = c('AOE', 'FPC', 'hclust', 'alphabet'),
3939
hclust.method = c('complete', 'ward', 'ward.D', 'ward.D2', 'single',
40-
'average', 'mcquitty', 'median', 'centroid') )
40+
'average', 'mcquitty', 'median', 'centroid'))
4141
{
42+
4243
order = match.arg(order)
4344
hclust.method = match.arg(hclust.method)
4445

R/corrRect.R

+16-15
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
#' @author Taiyun Wei
3232
#' @export
3333
corrRect = function(corrRes = NULL, index = NULL, name = NULL, namesMat = NULL,
34-
col = 'black', lwd = 2, ...) {
34+
col = 'black', lwd = 2, ...)
35+
{
3536

3637
if((as.integer(!is.null(index)) + as.integer(!is.null(name)) +
3738
as.integer(!is.null(namesMat))) > 1) {
@@ -81,20 +82,20 @@ corrRect = function(corrRes = NULL, index = NULL, name = NULL, namesMat = NULL,
8182
y2 = nrow(corr) - index[-1] + 0.5
8283
St = S = cbind(c(x1, x1, x2, x2), c(y1, y1, y2, y2),
8384
c(x2, x1, x2, x1), c(y1, y2, y1, y2))
84-
St[,2] = abs(St[,2] - nrow(corr) - 1)
85-
St[,4] = abs(St[,4] - nrow(corr) - 1)
85+
St[, 2] = abs(St[, 2] - nrow(corr) - 1)
86+
St[, 4] = abs(St[, 4] - nrow(corr) - 1)
8687

8788
if(type=='upper') {
88-
i = which((St[,1] - St[,2]) > -0.1 & (St[,3] - St[,4]) > -0.1)
89-
S = S[i,]
89+
i = which((St[, 1] - St[, 2]) > -0.1 & (St[, 3] - St[, 4]) > -0.1)
90+
S = S[i, ]
9091
}
9192

9293
if(type=='lower') {
93-
i = which((St[,2] - St[,1]) > -0.1 & (St[,4] - St[,3]) > -0.1)
94-
S = S[i,]
94+
i = which((St[, 2] - St[, 1]) > -0.1 & (St[, 4] - St[, 3]) > -0.1)
95+
S = S[i, ]
9596
}
9697

97-
segments(S[,1], S[,2], S[,3], S[,4], col=col, lwd = lwd, ...)
98+
segments(S[, 1], S[, 2], S[, 3], S[, 4], col = col, lwd = lwd, ...)
9899
}
99100

100101
if(!is.null(namesMat)) {
@@ -108,10 +109,10 @@ corrRect = function(corrRes = NULL, index = NULL, name = NULL, namesMat = NULL,
108109

109110
xy = cbind(xy1, xy2)
110111

111-
x1 = apply(xy[, c(1,3), drop=FALSE], 1, min) - 0.5
112-
y1 = apply(xy[, c(2,4), drop=FALSE], 1, min) - 0.5
113-
x2 = apply(xy[, c(1,3), drop=FALSE], 1, max) + 0.5
114-
y2 = apply(xy[, c(2,4), drop=FALSE], 1, max) + 0.5
112+
x1 = apply(xy[, c(1, 3), drop=FALSE], 1, min) - 0.5
113+
y1 = apply(xy[, c(2, 4), drop=FALSE], 1, min) - 0.5
114+
x2 = apply(xy[, c(1, 3), drop=FALSE], 1, max) + 0.5
115+
y2 = apply(xy[, c(2, 4), drop=FALSE], 1, max) + 0.5
115116

116117
rect(x1, y1, x2, y2, border = col, lwd = lwd, ...)
117118
}
@@ -123,13 +124,13 @@ corrRect = function(corrRes = NULL, index = NULL, name = NULL, namesMat = NULL,
123124

124125
#' @note pure function
125126
#' @noRd
126-
getCharXY = function(x, dat){
127+
getCharXY = function(x, dat) {
127128

128-
res = apply(x, 1, function(n, d=dat) d[d[,1]==n[1]&d[,2]==n[2], 3:4])
129+
res = apply(x, 1, function(n, d=dat) d[d[, 1]==n[1]&d[, 2]==n[2], 3:4])
129130

130131
f = which(unlist(lapply(res, nrow))==0)
131132
if(length(f) > 0) {
132-
error = paste(toString(unique(x[f,])), 'paired X-Y names were not found!')
133+
error = paste(toString(unique(x[f, ])), 'paired X-Y names were not found!')
133134
stop(error)
134135
}
135136

R/corrRect.hclust.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ corrRect.hclust = function(
2828
col = 'black',
2929
lwd = 2,
3030
method = c('complete', 'ward', 'ward.D', 'ward.D2', 'single', 'average',
31-
'mcquitty', 'median', 'centroid') )
31+
'mcquitty', 'median', 'centroid'))
3232
{
33+
3334
n = nrow(corr)
3435
method = match.arg(method)
3536
tree = hclust(as.dist(1 - corr), method = method)

0 commit comments

Comments
 (0)