Commit 0c2a19f1 authored by Marie  BOURDON's avatar Marie BOURDON
Browse files

Merge branch 'develop2' into 'develop'

Develop2

See merge request !2
parents 6145aaab 8629fd3f
{
"debugBreakpointsState" : {
"breakpoints" : [
]
}
}
\ No newline at end of file
{
"activeTab" : 2
"activeTab" : 0
}
\ No newline at end of file
{
"left" : {
"panelheight" : 689,
"splitterpos" : 290,
"panelheight" : 1271,
"splitterpos" : 533,
"topwindowstate" : "NORMAL",
"windowheight" : 727
"windowheight" : 1309
},
"right" : {
"panelheight" : 689,
"splitterpos" : 436,
"panelheight" : 1271,
"splitterpos" : 804,
"topwindowstate" : "NORMAL",
"windowheight" : 727
"windowheight" : 1309
}
}
\ No newline at end of file
{
"TabSet1" : 3,
"TabSet2" : 3,
"TabSet2" : 4,
"TabZoom" : {
}
}
\ No newline at end of file
build-last-errors="[]"
build-last-errors-base-dir="~/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\":\"** 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}]"
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\":\"** 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}]"
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/Rtmp3VMULh/preview-1ced414f7aab.dir/stuaRt.html
/private/var/folders/dn/j71yz2tn5_gdffs8fqxhddrr0000gn/T/Rtmp3VMULh/preview-1ced48fe920c.dir/stuaRt.html
/private/var/folders/dn/j71yz2tn5_gdffs8fqxhddrr0000gn/T/RtmpNme5vw/preview-4c4321234d03.dir/stuaRt.html
{
"cursorPosition" : "23,55",
"scrollLine" : "0"
}
\ No newline at end of file
{
"cursorPosition" : "9,51",
"scrollLine" : "0"
}
\ No newline at end of file
{
"cursorPosition" : "48,32",
"scrollLine" : "33"
"cursorPosition" : "84,18",
"scrollLine" : "94"
}
\ No newline at end of file
{
}
\ No newline at end of file
{
"cursorPosition" : "8,12",
"scrollLine" : "0"
}
\ No newline at end of file
{
"cursorPosition" : "20,46",
"scrollLine" : "0"
}
\ No newline at end of file
{
"cursorPosition" : "43,27",
"scrollLine" : "29",
"source_window_id" : ""
}
\ No newline at end of file
{
"cursorPosition" : "22,39",
"scrollLine" : "7"
}
\ No newline at end of file
{
"cursorPosition" : "2,104",
"scrollLine" : "0"
}
\ No newline at end of file
{
}
\ No newline at end of file
{
"cursorPosition" : "44,0",
"cursorPosition" : "135,15",
"last_setup_crc32" : "39B546A65bfca283",
"scrollLine" : "44"
"scrollLine" : "130"
}
\ No newline at end of file
~%2Fstuart_package%2Fstuart%2FDESCRIPTION="BEB7232"
~%2Fstuart_package%2Fstuart%2FNAMESPACE="AE613167"
~%2Fstuart_package%2Fstuart%2FR%2Fgeno_strains.R="8F7B714A"
~%2Fstuart_package%2Fstuart%2FR%2Fgenos-data.R="C10FF5C8"
~%2Fstuart_package%2Fstuart%2FR%2Fmark_allele.R="1416C0B5"
~%2Fstuart_package%2Fstuart%2FR%2Fmark_match.R="75F49619"
~%2Fstuart_package%2Fstuart%2FR%2Fmark_poly.R="3A328548"
~%2Fstuart_package%2Fstuart%2FR%2Fmark_prop.R="A609F054"
~%2Fstuart_package%2Fstuart%2FR%2Fstuart_tab-data.R="7411866"
~%2Fstuart_package%2Fstuart%2FR%2Ftab_mark.R="7FA3B215"
~%2Fstuart_package%2Fstuart%2FR%2Fwrite_rqtl.R="5B8691C7"
~%2Fstuart_package%2Fstuart%2Fdoc%2FstuaRt.R="65312719"
~%2Fstuart_package%2Fstuart%2Fvignettes%2FstuaRt.R="EBD625D2"
~%2Fstuart_package%2Fstuart%2Fvignettes%2FstuaRt.Rmd="D602FFE4"
{
"collab_server" : "",
"contents" : "",
"created" : 1622641774018.000,
"dirty" : false,
"encoding" : "UTF-8",
"folds" : "",
"hash" : "1203844341",
"id" : "1656F55",
"lastKnownWriteTime" : 1622640147,
"last_content_update" : 1622640147,
"path" : "~/stuart_package/stuart/R/geno_strains.R",
"project_path" : "R/geno_strains.R",
"properties" : {
"cursorPosition" : "22,39",
"scrollLine" : "7"
},
"read_only" : false,
"read_only_alternatives" : [
],
"relative_order" : 4,
"source_on_save" : false,
"source_window" : "",
"type" : "r_source"
}
\ No newline at end of file
#' @title Create haplotype for a new mouse strain into a reference dataframe
#'
#' @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.
#' 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".
#' @param ref data frame with the reference genotypes of mouse lines
#' @param geno data frame with the genotyping results for your cross from miniMUGA array
#' @param par1 first parental strain used in the cross, the name must be written as in the geno data frame
#' @param par2 second parental strain used in the cross, the name must be written as in the geno data frame
#' @param name1 name of the first parental strain to use as the column name in the ref data frame
#' @param name2 name of the second parental strain to use as the column name in the ref data frame
#'
#' @import dplyr
#' @import tidyr
#'
#' @export
#'
geno_strains <- function(ref,geno,par1,par2,name1,name2){
#rename df columns
geno <- geno %>% rename("marker"=1,
"id"=2,
"allele_1"=3,
"allele_2"=4)
#recode genotypes from 2 alleles to 1
geno <- geno %>% mutate_all(as.character)
geno <- geno %>% filter(id %in% c(par1,par2))
geno <- geno %>% mutate(Geno=case_when(allele_1 == "-" | allele_2 == "-" ~ "N",
allele_1 == allele_2 ~ allele_1,
allele_1 %in% c("A","T","G","C") & allele_2 %in% c("A","T","G","C") ~ "H"))
geno <- geno %>% select(marker,id,Geno) %>% pivot_wider(names_from = id, values_from = Geno)
#create consensus
if(length(par1)!=1){
geno <- geno %>% mutate(parent1 = ifelse(!!sym(par1[1])==!!sym(par1[2]),!!sym(par1[1]),"N"))
} else {
geno <- geno %>% rename(parent1=!!sym(par1[1]))
}
if(length(par2)!=1){
geno <- geno %>% mutate(parent2 = ifelse(!!sym(par2[1])==!!sym(par2[2]),!!sym(par2[1]),"N"))
} else {
geno <- geno %>% rename(parent2=!!sym(par2[1]))
}
geno <- geno %>% select(marker,parent1,parent2)
colnames(geno) <- c("marker",name1,name2)
#merge with ref file
ref <- full_join(ref,geno,by=c("marker"="marker"))
return(ref)
}
Markdown is supported
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