### There are two ways to install onemap
###-------------------###
####Download and install Rtools in your computer before running this script
find_rtools(debug = TRUE)
###Install required packages
install.packages("devtools")
### The above installation is supposed to run in R version to 3.5 but I had issue with getting it to install.
devtools::install_github("Cristianetaniguti/onemap")
###-------------------###
### Option 2. If using R 5.6 this package is compatible with the CRAN version
#######Set working directory
setwd("/your/working/directory/")
#####Convert the vcf file into onemap format.
## BE SURE THE txt is removed from the end of the vcf file name
vcfR.object <- read.vcfR("imputed_loci_06052019.vcf")
example_out <- onemap_read_vcfR(vcfR.object = vcfR.object,
parent1 = "P230.sam.mapped.bam",
parent2 = "P255.sam.mapped.bam",
####Get the information on marker genotypes.
###Number of markers by segregation type
plot_by_segreg_type(example_out)
###Find redundant markers
bins <- find_bins(example_out, exact = FALSE)
###Create onemap file after removing redundant markers
bins_example <- create_data_bins(example_out, bins)
###testing segregation pattern of the markers
segreg_test <- test_segregation(bins_example)
#####to show the markers names with segregation distortion
select_segreg(segreg_test, distorted = TRUE)
###to show the markers numbers with segregation distortion
dist <- select_segreg(segreg_test, distorted = TRUE, numbers = TRUE)
#to show the markers numbers without segregation distortion
no_dist <- select_segreg(segreg_test, distorted = FALSE, numbers = TRUE)
####See the segregation test graphically
##calculate a suggested LOD score
LOD_sug <- suggest_lod(bins_example)
###Estimating two-point recombination fractions
twopts <- rf_2pts(bins_example, LOD = LOD_sug, max.rf = 0.3)
###Create the sequences of markers without segregation distortion
mark_no_dist <- make_seq(twopts, c(no_dist))
###Number of linkage groups
lg <- group(mark_no_dist, LOD=LOD_sug, max.rf = 0.3)
print(lg, detailed = FALSE)
###Estimate a genetic map
maps<-vector("list", lg$n.groups)
maps[[i]]<- make_seq(order_seq(input.seq= make_seq(lg,i),twopt.alg =
draw_map(maps, names = FALSE, grid = TRUE, cex.mrk = 0.7)
draw_map2(maps,output="maps.png")
####Name the map and extract it into external file
file.out<-"map_LOD=5.97,max.rf=0.3.csv"
write_map(map1, file.out)