Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mouselab
stuart
Commits
2054450f
Commit
2054450f
authored
Jun 07, 2021
by
mariefbourdon
Browse files
modif mark_prop chi
parent
716a1393
Changes
73
Expand all
Hide whitespace changes
Inline
Side-by-side
.Rhistory
View file @
2054450f
This diff is collapsed.
Click to expand it.
.Rproj.user/9DAE6990/pcs/source-pane.pper
View file @
2054450f
{
"activeTab" :
6
"activeTab" :
1
}
\ No newline at end of file
.Rproj.user/9DAE6990/pcs/windowlayoutstate.pper
View file @
2054450f
{
"left" : {
"panelheight" :
1271
,
"splitterpos" :
533
,
"topwindowstate" : "
NORMAL
",
"windowheight" :
1309
"panelheight" :
583
,
"splitterpos" :
244
,
"topwindowstate" : "
MAXIMIZE
",
"windowheight" :
621
},
"right" : {
"panelheight" : 1271,
"splitterpos" : 80
4
,
"splitterpos" : 80
3
,
"topwindowstate" : "NORMAL",
"windowheight" : 1309
}
...
...
.Rproj.user/9DAE6990/pcs/workbench-pane.pper
View file @
2054450f
{
"TabSet1" :
3
,
"TabSet1" :
0
,
"TabSet2" : 4,
"TabZoom" : {
}
...
...
.Rproj.user/9DAE6990/sources/prop/52B275C1
View file @
2054450f
{
"cursorPosition" : "
16
,2
8
",
"scrollLine" : "0"
"cursorPosition" : "
70
,2
9
",
"scrollLine" : "
4
0"
}
\ No newline at end of file
.Rproj.user/9DAE6990/sources/prop/63BDD9CA
0 → 100644
View file @
2054450f
{
}
\ No newline at end of file
.Rproj.user/9DAE6990/sources/prop/B92E179B
View file @
2054450f
{
"cursorPosition" : "1
35,15
",
"last_setup_crc32" : "",
"scrollLine" : "11
1
"
"cursorPosition" : "1
14,53
",
"last_setup_crc32" : "
E69463565bfca283
",
"scrollLine" : "11
0
"
}
\ No newline at end of file
.Rproj.user/9DAE6990/sources/prop/INDEX
View file @
2054450f
...
...
@@ -22,3 +22,4 @@
~%2Fstuart_package%2Fstuart%2Fdoc%2FstuaRt.R="65312719"
~%2Fstuart_package%2Fstuart%2Fvignettes%2FstuaRt.R="EBD625D2"
~%2Fstuart_package%2Fstuart%2Fvignettes%2FstuaRt.Rmd="D602FFE4"
~%2Fstuart_package%2Fstuart_old%2FR%2Fmark_prop.R="63BDD9CA"
.Rproj.user/9DAE6990/sources/
per/t
/1656F55
→
.Rproj.user/9DAE6990/sources/
s-E6946356
/1656F55
View file @
2054450f
...
...
@@ -5,10 +5,10 @@
"dirty" : false,
"encoding" : "UTF-8",
"folds" : "",
"hash" : "
1203844341
",
"hash" : "
0
",
"id" : "1656F55",
"lastKnownWriteTime" : 162
2640147
,
"last_content_update" : 162
2640147
,
"lastKnownWriteTime" : 162
3060553
,
"last_content_update" : 162
3060553
,
"path" : "~/Documents/PhD/stuart_R/stuart/R/geno_strains.R",
"project_path" : "R/geno_strains.R",
"properties" : {
...
...
.Rproj.user/9DAE6990/sources/
per/t
/1656F55-contents
→
.Rproj.user/9DAE6990/sources/
s-E6946356
/1656F55-contents
View file @
2054450f
File moved
.Rproj.user/9DAE6990/sources/
per/t
/42D37312
→
.Rproj.user/9DAE6990/sources/
s-E6946356
/42D37312
View file @
2054450f
...
...
@@ -5,20 +5,20 @@
"dirty" : false,
"encoding" : "UTF-8",
"folds" : "",
"hash" : "
309497246
0",
"hash" : "0",
"id" : "42D37312",
"lastKnownWriteTime" : 16230
61718
,
"last_content_update" : 16230
61718577
,
"lastKnownWriteTime" : 16230
86204
,
"last_content_update" : 16230
86204670
,
"path" : "~/Documents/PhD/stuart_R/stuart/R/mark_prop.R",
"project_path" : "R/mark_prop.R",
"properties" : {
"cursorPosition" : "
16
,2
8
",
"scrollLine" : "0"
"cursorPosition" : "
70
,2
9
",
"scrollLine" : "
4
0"
},
"read_only" : false,
"read_only_alternatives" : [
],
"relative_order" :
9
,
"relative_order" :
2
,
"source_on_save" : false,
"source_window" : "",
"type" : "r_source"
...
...
.Rproj.user/9DAE6990/sources/
per/t
/42D37312-contents
→
.Rproj.user/9DAE6990/sources/
s-E6946356
/42D37312-contents
View file @
2054450f
...
...
@@ -14,10 +14,9 @@
#### mark_prop ####
## excludes markers depending on proportions of homo/hetorozygous
## to modify with chisq.test
mark_prop <- function(tab,cross,homo=NA,hetero=NA,na=0.5){
mark_prop <- function(tab,cross,homo=NA,hetero=NA,pval=NA,na=0.5){
#calculate total number of individuals genotyped for each marker
tab <- tab %>% mutate(n_geno =
tab %>% select
(n_HM1
,
n_HM2
,n_HT) %>% rowSums(na.rm=TRUE
))
tab <- tab %>% mutate(n_geno = (n_HM1
+
n_HM2
+ n_HT
))
#calculate proportion of each genotype
tab <- tab %>% mutate(p_HM1 = n_HM1/n_geno)
...
...
@@ -25,27 +24,50 @@ mark_prop <- function(tab,cross,homo=NA,hetero=NA,na=0.5){
tab <- tab %>% mutate(p_HT = n_HT/n_geno)
tab <- tab %>% mutate(p_NA = n_NA/(n_geno+n_NA))
#stock colnames to join
names <- colnames(tab)
#stop if cross != "F2" or "N2"
if(!cross %in% c("F2","N2")){
stop("Cross must be F2 or N2")
}
#stop
if no value for "homo" for F2 cross
if(
cross=="F2" &
(is.na(homo)==TRUE | is.na(hetero)==TRUE)){
stop("Arguments homo and hetero must be specified
for F2 crosses
")
#stop
of homo&hetero or pval not specified
if((is.na(homo)==TRUE | is.na(hetero)==TRUE)
& is.na(pval)==TRUE
){
stop("Arguments homo and hetero
or argument pval
must be specified")
}
#stop if no value for "homo" and "hetero" for N2 cross
if(cross=="N2" & (is.na(homo)==TRUE | is.na(hetero)==TRUE)){
stop("Arguments homo and hetero must be specified for N2 crosses")
#stop with prop of na
tab <- tab %>%
mutate(exclude_prop=case_when(p_NA > na ~ 1,
T ~ 0))
#stop with prop of homo/hetero
if(is.na(pval)==TRUE){
tab <- tab %>%
mutate(exclude_prop=case_when(p_NA > na ~ 1,
cross=="F2" & (p_HM1 < homo | p_HM2 < homo | p_HT < hetero) ~ 1,
cross=="N2" & (p_HM1 < homo | p_HT < hetero) ~ 1,
T ~ exclude_prop
))
}
#exclude markers according to proportion of na
tab <- tab %>% mutate(exclude_prop=case_when(p_NA > na ~ 1, #exclude markers according to proportion of na
cross=="F2" & (p_HM1 < homo | p_HM2 < homo | p_HT < hetero) ~ 1, #exclude markers according to proportion of homozygous individuals for F2 cross
cross=="N2" & (p_HM1 < homo | p_HT < hetero) ~ 1, #exclude markers according to proportion of homozygous and heterozygous individuals for N2 cross
T ~ 0))
#stop with pval chisq.test
## NEED TO ADD THIS FILTER IF CROSS = N2
if(is.na(pval)==FALSE){
tab <- tab %>% filter(p_NA != 1) %>% rowwise() %>%
mutate(.,chi_pval = tibble(n_HM1,n_HM2,n_HT) %>%
chisq.test(p=c(0.25,0.25,0.5)) %>% .$p.value) %>%
full_join(.,tab,by=names)
tab <- tab %>% mutate(exclude_prop=case_when(chi_pval < pval ~ 1,
T ~ exclude_prop))
}
tab <- tab %>% select(
-c(p_HM1,p_HM2,p_HT,p_NA,n_geno)
)
tab <- tab %>% select(
names
)
return(tab)
}
.Rproj.user/9DAE6990/sources/
per/t
/45D91D58
→
.Rproj.user/9DAE6990/sources/
s-E6946356
/45D91D58
View file @
2054450f
...
...
@@ -5,7 +5,7 @@
"dirty" : false,
"encoding" : "UTF-8",
"folds" : "",
"hash" : "
1139135974
",
"hash" : "
0
",
"id" : "45D91D58",
"lastKnownWriteTime" : 1622648301,
"last_content_update" : 1622648301329,
...
...
@@ -18,7 +18,7 @@
"read_only" : false,
"read_only_alternatives" : [
],
"relative_order" :
11
,
"relative_order" :
9
,
"source_on_save" : false,
"source_window" : "",
"type" : "r_source"
...
...
.Rproj.user/9DAE6990/sources/
per/t
/45D91D58-contents
→
.Rproj.user/9DAE6990/sources/
s-E6946356
/45D91D58-contents
View file @
2054450f
File moved
.Rproj.user/9DAE6990/sources/
per/t
/65C9B72B
→
.Rproj.user/9DAE6990/sources/
s-E6946356
/65C9B72B
View file @
2054450f
...
...
@@ -5,10 +5,10 @@
"dirty" : false,
"encoding" : "UTF-8",
"folds" : "",
"hash" : "
1762622592
",
"hash" : "
0
",
"id" : "65C9B72B",
"lastKnownWriteTime" : 162
2642120
,
"last_content_update" : 162
264212078
3,
"lastKnownWriteTime" : 162
3060553
,
"last_content_update" : 162
306055
3,
"path" : "~/Documents/PhD/stuart_R/stuart/R/tab_mark.R",
"project_path" : "R/tab_mark.R",
"properties" : {
...
...
.Rproj.user/9DAE6990/sources/
per/t
/65C9B72B-contents
→
.Rproj.user/9DAE6990/sources/
s-E6946356
/65C9B72B-contents
View file @
2054450f
File moved
.Rproj.user/9DAE6990/sources/s-E6946356/6DCC955A
0 → 100644
View file @
2054450f
{
"collab_server" : "",
"contents" : "",
"created" : 1623083300385.000,
"dirty" : false,
"encoding" : "",
"folds" : "",
"hash" : "0",
"id" : "6DCC955A",
"lastKnownWriteTime" : 140320379993736,
"last_content_update" : 1623083300385,
"path" : null,
"project_path" : null,
"properties" : {
"cacheKey" : "FFFA47E6",
"caption" : "test_tab",
"contentUrl" : "grid_resource/gridviewer.html?env=&obj=test_tab&cache_key=FFFA47E6",
"displayedObservations" : "20",
"environment" : "",
"expression" : "test_tab",
"object" : "test_tab",
"preview" : "0",
"totalObservations" : "20",
"variables" : "9"
},
"read_only" : false,
"read_only_alternatives" : [
],
"relative_order" : 12,
"source_on_save" : false,
"source_window" : "",
"type" : "r_dataframe"
}
\ No newline at end of file
.Rproj.user/9DAE6990/sources/s-E6946356/6DCC955A-contents
0 → 100644
View file @
2054450f
.Rproj.user/9DAE6990/sources/
per/t
/76AC3EC
→
.Rproj.user/9DAE6990/sources/
s-E6946356
/76AC3EC
View file @
2054450f
...
...
@@ -5,7 +5,7 @@
"dirty" : false,
"encoding" : "UTF-8",
"folds" : "",
"hash" : "
14386964
0",
"hash" : "0",
"id" : "76AC3EC",
"lastKnownWriteTime" : 1623060553,
"last_content_update" : 1623060553,
...
...
@@ -18,7 +18,7 @@
"read_only" : false,
"read_only_alternatives" : [
],
"relative_order" :
7
,
"relative_order" :
6
,
"source_on_save" : false,
"source_window" : "",
"type" : "r_source"
...
...
.Rproj.user/9DAE6990/sources/
per/t
/76AC3EC-contents
→
.Rproj.user/9DAE6990/sources/
s-E6946356
/76AC3EC-contents
View file @
2054450f
File moved
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment