diff --git a/.Rproj.user/shared/notebooks/paths b/.Rproj.user/shared/notebooks/paths index 1d8c157013cb2edfe8baabe96e6f7ecaf0710755..7e87f342bc406ce58dc45ffce61dc48bb30c04eb 100644 --- a/.Rproj.user/shared/notebooks/paths +++ b/.Rproj.user/shared/notebooks/paths @@ -22,3 +22,4 @@ /mnt/gaia/gaia_mouselab/Marie/Package_stuaRt/Article/Figures/Maestro/map_before_neogen/map_before_neogen.R="36D40A63" /mnt/zeus/zeus_mouselab/anais/newmap_perm_anais.R="545E1544" /mnt/zeus/zeus_mouselab/marie/map_after/map_after.R="697AFFBF" +/mnt/zeus/zeus_mouselab/marie/stuart_estmap/stuart_estmap.R="A702EAAC" diff --git a/R/mark_allele.R b/R/mark_allele.R index 83f4a70e835e097ce9c54f0e256860c043a4fabe..3abbcee969bff9ba6492cebf333569407f9b70f9 100755 --- a/R/mark_allele.R +++ b/R/mark_allele.R @@ -1,16 +1,17 @@ #' @title Exclude markers that have different alleles in the individuals of the cross and in parental strains #' #' @description This functions uses the dataframe produced by the tab_mark function and fills the "exclude" column for all the markers which have alleles observed in the individuals of the cross that do not correspond to the alleles observed in the parental strains. For example, a marker which is not polymorphic between the two parental strains but which has two alleles in the cross individuals will be excluded. -#' @param tab data frame obtained with tab_mark function -#' @param ref data frame with the reference genotypes of mouse lines -#' @param par1 first parental strain used in the cross, the name must be written as in the "ref" data frame -#' @param par2 second parental strain used in the cross, the name must be written as in the "ref" data frame +#' @param tab data frame obtained with tab_mark function. +#' @param ref data frame with the reference genotypes of mouse lines. +#' @param cross cross type, either "F2" or "N2". +#' @param par1 first parental strain used in the cross, the name must be written as in the "ref" data frame. For a backcross the strain used to backcross F1 individuals must be indicated as par1. +#' @param par2 second parental strain used in the cross, the name must be written as in the "ref" data frame. #' #' @import dplyr #' #' @export #' -mark_allele <- function(tab,ref,par1,par2,parNH=TRUE){ +mark_allele <- function(tab,ref,cross,par1,par2,parNH=TRUE){ #markers of ref df as characters ref$marker <- as.character(ref$marker) @@ -42,6 +43,16 @@ mark_allele <- function(tab,ref,par1,par2,parNH=TRUE){ T ~ 0) ) + #for backcross: check that homozygous individuals are homozygous for the allele of the backcrossed parent + if(cross=="N2"){ + tab <- tab %>% mutate(exclude_allele = case_when((n_HM1>n_HM2) & (allele_1 != !!sym(par1)) ~ 1, + (n_HM2>=n_HM1) & (allele_1 != !!sym(par2)) ~ 1, + T ~ exclude_allele + ) + ) + } + + tab <- tab %>% select(-c(!!sym(par1),!!sym(par2))) return(tab) diff --git a/man/mark_allele.Rd b/man/mark_allele.Rd index c4c1be236ad93741de0e458d5d9cd20bcf1a4885..8131b8618057be89f6d0e50c0f8b2dd184eebf45 100755 --- a/man/mark_allele.Rd +++ b/man/mark_allele.Rd @@ -4,16 +4,18 @@ \alias{mark_allele} \title{Exclude markers that have different alleles in the individuals of the cross and in parental strains} \usage{ -mark_allele(tab, ref, par1, par2, parNH = TRUE) +mark_allele(tab, ref, cross, par1, par2, parNH = TRUE) } \arguments{ -\item{tab}{data frame obtained with tab_mark function} +\item{tab}{data frame obtained with tab_mark function.} -\item{ref}{data frame with the reference genotypes of mouse lines} +\item{ref}{data frame with the reference genotypes of mouse lines.} -\item{par1}{first parental strain used in the cross, the name must be written as in the "ref" data frame} +\item{cross}{cross type, either "F2" or "N2".} -\item{par2}{second parental strain used in the cross, the name must be written as in the "ref" data frame} +\item{par1}{first parental strain used in the cross, the name must be written as in the "ref" data frame. For a backcross the strain used to backcross F1 individuals must be indicated as par1.} + +\item{par2}{second parental strain used in the cross, the name must be written as in the "ref" data frame.} } \description{ This functions uses the dataframe produced by the tab_mark function and fills the "exclude" column for all the markers which have alleles observed in the individuals of the cross that do not correspond to the alleles observed in the parental strains. For example, a marker which is not polymorphic between the two parental strains but which has two alleles in the cross individuals will be excluded. diff --git a/stuart_1.0.3.9000.pdf b/stuart_1.0.3.9000.pdf index f73c11f6354d02bcdc80df8099b12eab3771c0e9..5959a609b5698a37725340268b59e96b37c87d35 100644 Binary files a/stuart_1.0.3.9000.pdf and b/stuart_1.0.3.9000.pdf differ diff --git a/stuart_1.0.3.9000.tar.gz b/stuart_1.0.3.9000.tar.gz index 9c60309bfe6312beb5c1ad305f6b7c405003048a..56ccea5f23abd2d56a2d0b388d52050d090b4c1b 100644 Binary files a/stuart_1.0.3.9000.tar.gz and b/stuart_1.0.3.9000.tar.gz differ diff --git a/vignettes/stuart.Rmd b/vignettes/stuart.Rmd index 75a039d28f2461052660359f88279a100e4e441e..127a4ea3d8707df69921e7fdca3a72092ca07fd4 100755 --- a/vignettes/stuart.Rmd +++ b/vignettes/stuart.Rmd @@ -137,10 +137,10 @@ mark_prop(tab2,cross="F2",pval=0.05) %>% head() %>% print.data.frame() ### mark_allele -Last, we can use the `mark_allele()` function. This very helpful function excludes markers for which the alleles found in the F2/N2 individuals do not correspond to the alleles found in the parental strains. For example, if a marker is not polymorphic in the parental strains but we found two alleles in the F2/N2 individuals, it will be excluded. +Last, we can use the `mark_allele()` function. This function excludes markers for which the alleles found in the F2/N2 individuals do not correspond to the alleles found in the parental strains. For example, if a marker is not polymorphic in the parental strains but we found two alleles in the F2/N2 individuals, it will be excluded. Moreover, for a backcross, this function will verify that the homozygous N2 individuals are homozygous for the allele of the strain used to backcross F1 individuals. This strain must be indicated as par1. ```{r mark_allele} -tab2 <- mark_allele(tab=tab2,ref=strains,par1="parent1",par2="parent2") +tab2 <- mark_allele(tab=tab2,ref=strains,cross="F2",par1="parent1",par2="parent2") tab2 %>% arrange(desc(exclude_allele)) %>% head() %>% print.data.frame() ``` @@ -174,6 +174,9 @@ library(qtl) data(stuart_cross) summary(stuart_cross) +stuart_cross <- calc.genoprob(stuart_cross, step=2.0, off.end=0.0, + error.prob=1.0E-4, map.function="haldane", stepwidth="fixed") + ##### TO RUN ##### # stuart_newmap <- est.map(cross=stuart_cross,error.prob=0.01) # save the map as data in the package