Commit 03f045b2 authored by Marie Bourdon's avatar Marie Bourdon
Browse files

check homozygous in N2

parent ea06b0f1
......@@ -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"
#' @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)
......
......@@ -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.
......
No preview for this file type
No preview for this file type
......@@ -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
......
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