Commit 9e9e9002 authored by mariefbourdon's avatar mariefbourdon
Browse files

modifs na prop + vignette

parent a412292d
{
"activeTab" : 6
"activeTab" : 2
}
\ No newline at end of file
{
"left" : {
"panelheight" : 762,
"splitterpos" : 199,
"panelheight" : 1402,
"splitterpos" : 366,
"topwindowstate" : "NORMAL",
"windowheight" : 800
"windowheight" : 1440
},
"right" : {
"panelheight" : 762,
"splitterpos" : 479,
"panelheight" : 1402,
"splitterpos" : 882,
"topwindowstate" : "NORMAL",
"windowheight" : 800
"windowheight" : 1440
}
}
\ No newline at end of file
{
"TabSet1" : 3,
"TabSet2" : 0,
"TabSet1" : 1,
"TabSet2" : 3,
"TabZoom" : {
}
}
\ No newline at end of file
build-last-errors="[]"
build-last-errors-base-dir="~/Documents/PhD/stuart_package/stuart/"
build-last-outputs="[{\"output\":\"==> R CMD INSTALL --no-multiarch --with-keep.source stuart\\n\\n\",\"type\":0},{\"output\":\"* installing to library ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library’\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"* installing *source* package ‘stuart’ ...\\n\",\"type\":1},{\"output\":\"** using staged installation\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** R\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** data\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"*** moving datasets to lazyload DB\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** inst\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** byte-compile and prepare package for lazy loading\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** help\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"*** installing help indices\\n\",\"type\":1},{\"output\":\"** building package indices\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** installing vignettes\\n\",\"type\":1},{\"output\":\"** testing if installed package can be loaded from temporary location\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** testing if installed package can be loaded from final location\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** testing if installed package keeps a record of temporary installation path\\n\",\"type\":1},{\"output\":\"* DONE (stuart)\\n\",\"type\":1},{\"output\":\"\",\"type\":1}]"
build-last-outputs="[{\"output\":\"==> R CMD INSTALL --no-multiarch --with-keep.source stuart\\n\\n\",\"type\":0},{\"output\":\"* installing to library ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library’\\n\",\"type\":1},{\"output\":\"* installing *source* package ‘stuart’ ...\\n\",\"type\":1},{\"output\":\"** using staged installation\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** R\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** data\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"*** moving datasets to lazyload DB\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** inst\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** byte-compile and prepare package for lazy loading\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** help\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"*** installing help indices\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** building package indices\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** installing vignettes\\n\",\"type\":1},{\"output\":\"** testing if installed package can be loaded from temporary location\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** testing if installed package can be loaded from final location\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** testing if installed package keeps a record of temporary installation path\\n\",\"type\":1},{\"output\":\"* DONE (stuart)\\n\",\"type\":1},{\"output\":\"\",\"type\":1}]"
compile_pdf_state="{\"errors\":[],\"output\":\"\",\"running\":false,\"tab_visible\":false,\"target_file\":\"\"}"
files.monitored-path=""
find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":true,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOff\":[],\"matchOn\":[]},\"running\":false}"
......
/private/var/folders/dn/j71yz2tn5_gdffs8fqxhddrr0000gn/T/RtmpZZZ4WE/preview-31873a42c16d.dir/stuaRt.html
/private/var/folders/dn/j71yz2tn5_gdffs8fqxhddrr0000gn/T/Rtmp3VMULh/preview-1ced48fe920c.dir/stuaRt.html
/private/var/folders/dn/j71yz2tn5_gdffs8fqxhddrr0000gn/T/RtmpbddlPL/preview-1b515493e142.dir/stuart.html
/private/var/folders/dn/j71yz2tn5_gdffs8fqxhddrr0000gn/T/RtmpNme5vw/preview-4c4321234d03.dir/stuaRt.html
/private/var/folders/dn/j71yz2tn5_gdffs8fqxhddrr0000gn/T/RtmpZZZ4WE/preview-3187564b41ab.dir/stuaRt.html
......
%2FVolumes%2F%40Mouselab%2FZika%2FBackcross%2FGeno%2FBC_01.71_stuart.Rmd="73DD6D1F"
%2FVolumes%2F%40Mouselab%2FZika%2FF2%2FF2_B6.CC001%2FQUGA%2FQUGA.Rmd="D7285907"
~%2FDocuments%2FPhD%2Fstuart_R%2Fstuart%2FDESCRIPTION="A58355B1"
~%2FDocuments%2FPhD%2Fstuart_R%2Fstuart%2FR%2Fgeno_strains.R="430FE7D7"
~%2FDocuments%2FPhD%2Fstuart_R%2Fstuart%2FR%2Fmark_allele.R="58D83345"
......
......@@ -10,3 +10,4 @@
/Users/mariebourdon/Documents/PhD/stuart_package/stuart/man/mark_prop.Rd="893B273D"
/Users/mariebourdon/Documents/PhD/stuart_package/stuart/vignettes/stuaRt.Rmd="DA6206CB"
/Users/mariebourdon/Documents/PhD/stuart_package/stuart/vignettes/stuart.Rmd="54D793B9"
/Volumes/@Mouselab/Zika/F2/F2_B6.CC001/QUGA/QUGA.Rmd="7EACFFBF"
......@@ -26,7 +26,7 @@
#### mark_prop ####
## excludes markers depending on proportions of homo/hetorozygous
mark_prop <- function(tab,cross,homo=NA,hetero=NA,pval=NA,homo1X=NULL,homo2X=NULL,heteroX=NULL,na=0.5){
mark_prop <- function(tab,cross,homo=NA,hetero=NA,pval=NA,homo1X=NULL,homo2X=NULL,heteroX=NULL){
#calculate total number of individuals genotyped for each marker
tab <- tab %>% mutate(n_geno = (n_HM1 + n_HM2 + n_HT))
......@@ -59,8 +59,7 @@ mark_prop <- function(tab,cross,homo=NA,hetero=NA,pval=NA,homo1X=NULL,homo2X=NUL
tab <- tab %>% mutate(p_NA = n_NA/(n_geno+n_NA))
tab <- tab %>%
mutate(exclude_prop=case_when(p_NA > na ~ 1,
T ~ 0))
mutate(exclude_prop=0)
#stock colnames to join
names <- colnames(tab)
......@@ -73,8 +72,7 @@ mark_prop <- function(tab,cross,homo=NA,hetero=NA,pval=NA,homo1X=NULL,homo2X=NUL
tab <- tab %>% mutate(p_HT = n_HT/n_geno)
tab <- tab %>%
mutate(exclude_prop=case_when(p_NA > na ~ 1,
!chr %in% c("X","Y","M") & cross=="F2" & (p_HM1 < homo | p_HM2 < homo | p_HT < hetero) ~ 1,
mutate(exclude_prop=case_when(!chr %in% c("X","Y","M") & cross=="F2" & (p_HM1 < homo | p_HM2 < homo | p_HT < hetero) ~ 1,
!chr %in% c("X","Y","M") & cross=="N2" & ((p_HM2 == 0 & p_HM1 < homo) |
(p_HM1 == 0 & p_HM2 < homo) |
(p_HT < hetero) |
......@@ -88,8 +86,8 @@ mark_prop <- function(tab,cross,homo=NA,hetero=NA,pval=NA,homo1X=NULL,homo2X=NUL
mutate(exclude_prop=case_when(chr == "X" & p_HM1 >= p_HM2 & !between(p_HM1,homo1X[1],homo1X[2]) ~ 1,
chr == "X" & p_HM2 > p_HM1 & !between(p_HM2,homo1X[1],homo1X[2]) ~ 1,
T ~ exclude_prop
)
)
)
)
}
if(is.null(homo2X)==FALSE){
......@@ -97,16 +95,16 @@ mark_prop <- function(tab,cross,homo=NA,hetero=NA,pval=NA,homo1X=NULL,homo2X=NUL
mutate(exclude_prop=case_when(chr == "X" & p_HM1 >= p_HM2 & !between(p_HM2,homo2X[1],homo2X[2]) ~ 1,
chr == "X" & p_HM2 > p_HM1 & !between(p_HM1,homo2X[1],homo2X[2]) ~ 1,
T ~ exclude_prop
)
)
)
)
}
if(is.null(heteroX)==FALSE){
tab <- tab %>%
mutate(exclude_prop=case_when(chr == "X" & p_HM1 >= p_HM2 & !between(p_HT,heteroX[1],heteroX[2]) ~ 1,
T ~ exclude_prop
)
)
)
)
}
#exclude with pval chisq.test
......
No preview for this file type
......@@ -52,7 +52,19 @@ Here, we will present an example of the use of stuart with results of a F2 cross
The genotype data frame must contain a first column with marker names, a second column with sample IDs, a third column with the first allele and a fourth column with the second allele. This format corresponds to the MUGA results. If your data differ, make sure to have these columns in this order.
We load the result of Neogen genotyping: `genos` (only useful columns with marker name, sample ID and alleles were kept) and the phenotype dataset produced by the lab: `phenos`.
You can load your genotype data with base R function `read.table()` or with `readr::read_tsv()` function. You have to skip the first lines with the header.
* `read.table("path/to/genotype_data.txt",sep = "\t",skip=9,header=TRUE)`
* `readr::read_tsv("path/to/genotype_data.txt",skip=9)`
The phenotype data produced by the lab must have the following format: one line per individual, one column per phenotype. The first column must be the identification number of each individual.
You can load your phenotype data depending on its format with `read.table()` or `readr::read_tsv()` for txt files, `read.table()` or `readr::read_csv()` for csv files, `read_excel::read_xls` or `read_excel::read_xlsx` for excel files.
Here, we load the result of Neogen genotyping: `genos` (only useful columns with marker name, sample ID and alleles were kept) and the phenotype dataset produced by the lab: `phenos`, directly available in the package.
```{r load}
......@@ -118,7 +130,7 @@ tab2 <- mark_na(stuart_tab)
Then, we can use `mark_match()` function. Here, the parental strains were genotyped with the F2 individuals, but it can happen that you use previous genotyping results for the parental strains. `mark_match()` function excludes markers that are in your genotype file but not in the reference genotype dataset. We recomend using this function as the chip used for genotyping may change.
```{r mark_match}
tab2 <- mark_match(stuart_tab,ref=strains)
tab2 <- mark_match(tab2,ref=strains)
tab2 %>% filter(exclude_match==1) %>% print.data.frame()
```
......@@ -135,7 +147,7 @@ head(tab2) %>% print.data.frame()
### mark_prop
The `mark_prop()` function can be used to filter markers depending on the proportion of each genotype. Here, we have a F2 and we use `homo=0.1, hetero=0.1` so the function will exclude all markers with less than 10% of each genotype. Moreover, this function allows to filter marker depending on the proportion on non genotyped animals. By defaults, markers for which more than 50% of individuals were not genotyped. For chromosome X, we use the `homo=0.1, hetero=0.1`
The `mark_prop()` function can be used to filter markers depending on the proportion of each genotype. Here, we have a F2 and we use `homo=0.1, hetero=0.1` so the function will exclude all markers with less than 10% of each genotype. For chromosome X, we use the `homo=0.1, hetero=0.1`
```{r mark_prop_ex_homo}
tab2 <- mark_prop(tab2,cross="F2",homo=0.1,hetero=0.1,homo1X=c(0.1,1),homo2X=c(0.1,1),heteroX=c(0.1,1))
......@@ -222,6 +234,12 @@ To avoid the issues with these situations, you can use the `parNH=FALSE` argumen
We rather advise you to keep these markers and identify possible problematic markers with `mark_estmap()` and exlude them.
If there are still some markers that need to be excluded after all these steps, you have two possibilities to exclude them. First, you can drop these markers in the cross object with `qtl::drop.markers()`, or if you prefere to have a correct CSV object that can always be used for QTL analysis, you can delete these markers in the marker tab and create a new cross file with `write_rqtl()`:
If there are still some markers that need to be excluded after all these steps, you have two possibilities to exclude them. First, you have to identify the name of these markers by looking at the `newmap` object as follow : in RStudio, click on this objectin the Environment to view it, then click on the arrow on the left of the desired chromosome. Each chromosome is a named vector that is visible here in two columns: one with the name of the marker, and one with the calculated position of the marker. This is how you can detect markers that present a huge gap with the previous and the following marker.
You can see an example for the stuart_newmap object in the following screen shot:
![screenchot_newmap](screenshot_newmap.png)
You can drop these markers in the cross object with `qtl::drop.markers()`, or if you prefere to have a correct CSV object that can always be used for QTL analysis, you can delete these markers in the marker tab and create a new cross file with `write_rqtl()`.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment