-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormatForJoinMap.R
More file actions
45 lines (33 loc) · 1.11 KB
/
FormatForJoinMap.R
File metadata and controls
45 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# code written by Paul Tanger, Brook Moyers or John Lovell. Please cite appropriately.
FormatForJoinMap = function(qtlobject) {
# extract genotype data from object to use for joinmap, MSTmap, or our CS tool
genos = as.data.frame(qtlobject$geno[[1]]$data)
i = 1
for (i in 2:length(qtlobject$geno)) {
genos = cbind(as.matrix(genos), qtlobject$geno[[i]]$data)
}
# change back to A and B
genos[genos == 1] = "A"
genos[genos == 2] = "B"
genos[is.na(genos)] = "-"
genos = as.data.frame(genos)
# add line names back
finalgenos = cbind(qtlobject$pheno[1], genos)
geno_joinmap = finalgenos
# transpose
geno.t = t(geno_joinmap)
# add col names
colnames(geno.t) <- geno_joinmap[,1]
# remove first row
geno.t = geno.t[-1,]
# make row.names into column
geno.t2 = as.data.frame(cbind(line = rownames(geno.t), geno.t))
# add dumb column for joinmap
geno_joinmap = cbind(marker = geno.t2[,1], class="(a,b)", geno.t2[,2:ncol(geno.t2)])
# check stuff
individuals = ncol(geno_joinmap)-2
individuals
loci = nrow(geno_joinmap)
loci
return(geno_joinmap)
}