Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Z
Zalpha
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computational Genetics
Zalpha
Commits
138ce99c
Commit
138ce99c
authored
4 years ago
by
Clare
Browse files
Options
Downloads
Patches
Plain Diff
Chnage to L_plus_R so that it will return zero rather than NA when n<2 in choose(n,2)
parent
09a03dcf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
R/L_plus_R.R
+2
-5
2 additions, 5 deletions
R/L_plus_R.R
tests/testthat/test-L_plus_R.R
+2
-2
2 additions, 2 deletions
tests/testthat/test-L_plus_R.R
with
4 additions
and
7 deletions
R/L_plus_R.R
+
2
−
5
View file @
138ce99c
...
@@ -66,11 +66,8 @@ L_plus_R <- function(pos, ws, X = NULL) {
...
@@ -66,11 +66,8 @@ L_plus_R <- function(pos, ws, X = NULL) {
## get L, R and L_plus_R
## get L, R and L_plus_R
noL
<-
length
(
pos
[
pos
>=
currentPos
-
ws
/
2
&
pos
<
currentPos
])
## Number of SNPs to the left of the current SNP
noL
<-
length
(
pos
[
pos
>=
currentPos
-
ws
/
2
&
pos
<
currentPos
])
## Number of SNPs to the left of the current SNP
noR
<-
length
(
pos
[
pos
<=
currentPos
+
ws
/
2
&
pos
>
currentPos
])
## Number of SNPs to the right of the current SNP
noR
<-
length
(
pos
[
pos
<=
currentPos
+
ws
/
2
&
pos
>
currentPos
])
## Number of SNPs to the right of the current SNP
if
(
noL
<
2
||
noR
<
2
){
#Must be at least 2 to calculate n choose 2
## if n < 2 then choose function will return 0
outputList
$
L_plus_R
[
i
]
<-
NA
outputList
$
L_plus_R
[
i
]
<-
choose
(
noL
,
2
)
+
choose
(
noR
,
2
)
}
else
{
outputList
$
L_plus_R
[
i
]
<-
choose
(
noL
,
2
)
+
choose
(
noR
,
2
)
}
}
}
return
(
outputList
)
return
(
outputList
)
}
}
This diff is collapsed.
Click to expand it.
tests/testthat/test-L_plus_R.R
+
2
−
2
View file @
138ce99c
...
@@ -12,7 +12,7 @@ test_that("L_plus_R calculates L_plus_R statistic correctly", {
...
@@ -12,7 +12,7 @@ test_that("L_plus_R calculates L_plus_R statistic correctly", {
expect_equal
(
L_plus_R
(
pos
=
df
$
POS
,
ws
=
3000
,
X
=
NULL
),
expect_equal
(
L_plus_R
(
pos
=
df
$
POS
,
ws
=
3000
,
X
=
NULL
),
list
(
list
(
position
=
c
(
100
,
200
,
300
,
400
,
500
,
600
,
700
,
800
,
900
,
1000
,
1100
,
1200
,
1300
,
1400
,
1500
),
position
=
c
(
100
,
200
,
300
,
400
,
500
,
600
,
700
,
800
,
900
,
1000
,
1100
,
1200
,
1300
,
1400
,
1500
),
L_plus_R
=
c
(
NA
,
NA
,
67
,
58
,
51
,
46
,
43
,
42
,
43
,
46
,
51
,
58
,
67
,
NA
,
NA
)
L_plus_R
=
c
(
91
,
78
,
67
,
58
,
51
,
46
,
43
,
42
,
43
,
46
,
51
,
58
,
67
,
78
,
91
)
))
))
})
})
...
@@ -23,7 +23,7 @@ test_that("L_plus_R calculates L_plus_R statistic correctly with a different win
...
@@ -23,7 +23,7 @@ test_that("L_plus_R calculates L_plus_R statistic correctly with a different win
expect_equal
(
L_plus_R
(
pos
=
df
$
POS
,
ws
=
1100
,
X
=
NULL
),
expect_equal
(
L_plus_R
(
pos
=
df
$
POS
,
ws
=
1100
,
X
=
NULL
),
list
(
list
(
position
=
c
(
100
,
200
,
300
,
400
,
500
,
600
,
700
,
800
,
900
,
1000
,
1100
,
1200
,
1300
,
1400
,
1500
),
position
=
c
(
100
,
200
,
300
,
400
,
500
,
600
,
700
,
800
,
900
,
1000
,
1100
,
1200
,
1300
,
1400
,
1500
),
L_plus_R
=
c
(
NA
,
NA
,
11
,
13
,
16
,
20
,
20
,
20
,
20
,
20
,
16
,
13
,
11
,
NA
,
NA
)
L_plus_R
=
c
(
10
,
10
,
11
,
13
,
16
,
20
,
20
,
20
,
20
,
20
,
16
,
13
,
11
,
10
,
10
)
))
))
})
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment