diff --git a/.Rproj.user/shared/notebooks/paths b/.Rproj.user/shared/notebooks/paths
index 63b87f60b490fabe6fade435ffb96cbfd531e4c4..a68c4f6117f52e4b4130c6af6e151b7733125f14 100644
--- a/.Rproj.user/shared/notebooks/paths
+++ b/.Rproj.user/shared/notebooks/paths
@@ -1,5 +1,8 @@
 /home/marie/Documents/HB_CC011/F2/Geno/Maestro/F2_geno_estmap1.R="42B0AE06"
 /home/marie/Documents/stuart/stuart_package/stuart/DESCRIPTION="55556B0B"
+/home/marie/Documents/stuart/stuart_package/stuart/R/geno_strains.R="68944065"
 /home/marie/Documents/stuart/stuart_package/stuart/R/mark_estmap.R="F759F000"
 /home/marie/Documents/stuart/stuart_package/stuart/README.Rmd="4E06E7DC"
+/home/marie/Documents/stuart/stuart_package/stuart/doc/stuart.R="A03ACF3D"
+/home/marie/Documents/stuart/stuart_package/stuart/man/genos.Rd="75E7412F"
 /home/marie/Documents/stuart/stuart_package/stuart/vignettes/stuart.Rmd="01396A37"
diff --git a/R/geno_strains.R b/R/geno_strains.R
index 0dabcc3233177ece240933386a15300e6344a822..74b98e43aff51dc37dfafb3da0ffb3a551255e18 100755
--- a/R/geno_strains.R
+++ b/R/geno_strains.R
@@ -1,8 +1,10 @@
-#' @title Create haplotype for inbred strains into a dataframe
+#' @title Summarizes genotypes of multiple individuals
 #'
-#' @description This functions adds columns for parental strains used in the cross in the annotation data frame, from the genotype data frame in which one or several animal of the parental strains were genotyped.
+#' @description This functions formats genotypes of genotyped individuals from a two letters encoding to a one letter encoding.
 #' If several animals of one strain were genotyped, a consensus is created from these animals.
-#' The consensus is created as follow : if the indivuals carry the same allele, this allele is kept, otherwise, the allele is noted as "N". If individuals show residual heterozygosity, it is encoded as "H".
+#' The one letter encoding is made as follow: if the individual is homozygous, the letter of the allele (A, T, G or C) is kept. If the individual show residual heterozygosity, it is encoded as "H". If the genotype is missing, it is encoded as "N".
+#' The consensus is created as follow : if the indivuals carry the same allele, this allele is kept. If one or several individuals are heterozygous, the genotype is encoded as "H". If one individual has a missing genotypes but another was correctly genotyped, its genotype is kept.
+#' If the genotypes are completely discordant (i.e. if two individuals are both homozygous but for different alleles), the genotype is encoded as "D".
 #' @param annot data frame with the annotation of the array used
 #' @param geno data frame with the genotyping results for your cross from miniMUGA array
 #' @param strn tibble or dataframe with the strains to analyse. Columns names are the name of the strains and the values in rows of each column are the IDs of the individuals genotyped for each strain.
@@ -33,18 +35,28 @@ geno_strains <- function(annot,geno,strn,cols){
   #pivoting
   geno <- geno %>% select(marker,id,Geno) %>% tidyr::pivot_wider(names_from = id, values_from = Geno)
 
+
   #create consensus
   for(i in colnames(strn)){
 
-    inds <- na.omit(strn[,i]) %>%pull()
+    inds <- na.omit(strn[,i]) %>% pull()
     geno <- geno %>% rename(!!sym(i):=!!sym(inds[1]))
 
+
     if(length(inds) > 1){
       for(j in 2:length(inds)){
-        geno <- geno %>% mutate(!!sym(i) := ifelse(!!sym(i)==!!sym(inds[j]),!!sym(i),"N"))
+        geno <- geno %>% mutate(!!sym(i) := case_when(!!sym(i)==!!sym(inds[j]) ~ !!sym(i),
+                                                      !!sym(i) %in% c("A","T","G","C") & !!sym(inds[j]) == "H" ~ "H",
+                                                      !!sym(inds[j]) %in% c("A","T","G","C") & !!sym(i) == "H" ~ "H",
+                                                      !!sym(i) %in% c("A","T","G","C") & !!sym(inds[j]) == "N" ~ !!sym(i),
+                                                      !!sym(inds[j]) %in% c("A","T","G","C") & !!sym(i) == "N" ~ !!sym(inds[j]),
+                                                      !!sym(i) %in% c("A","T","G","C") & !!sym(inds[j]) %in% c("A","T","G","C") ~ "D"
+        )
+        )
       }
     }
   }
+
   geno <- geno %>% select(marker,colnames(strn))
 
   #merge with annot file
diff --git a/data/genos.rda b/data/genos.rda
index 12084dd7868a7d8a93967ea3bd3f63b78b181ffb..1d40163b3c61e4e035bc4af8739d1414c76521f4 100755
Binary files a/data/genos.rda and b/data/genos.rda differ
diff --git a/stuart_1.0.7.pdf b/stuart_1.0.7.pdf
index e2164e738ffaa12321cf9cb78d6cf9a25358400c..70522494431bc2abaf9cebe05fd9b604966ee7ef 100644
Binary files a/stuart_1.0.7.pdf and b/stuart_1.0.7.pdf differ
diff --git a/vignettes/stuart.Rmd b/vignettes/stuart.Rmd
index 6bb97e68f9f2604fa204355eb86450f086f7bda0..973633b9a754193bc7804917bbf407b6d483cca9 100755
--- a/vignettes/stuart.Rmd
+++ b/vignettes/stuart.Rmd
@@ -81,7 +81,6 @@ This is done with the `geno_strains()` function. If parental genotypes was in an
 parental_strains <- tibble::tibble(parent1 = c("StrainsA_1","StrainsA_2"),
                                    parent2 = c("StrainsB_1","StrainsB_2"))
 
-
 strains <- geno_strains(annot=annot_mini,geno=genos,
                         strn=parental_strains,cols=c("chr","cM_cox"))
 head(strains) %>% print.data.frame()