Skip to contents

as.genclone will create a genclone object from a genind object OR anything that can be passed to the genind initializer.

Usage

bootgen2genind(bg)

as.genclone(x, ..., mlg, mlgclass = TRUE)

genclone2genind(x)

as.genambig(x)

Arguments

bg

a bootgen object

x

a genind or genclone object

...

arguments passed on to the genind constructor

mlg

an optional vector of multilocus genotypes as integers

mlgclass

should the mlg slot be of class MLG?

Details

genclone2genind will remove the mlg slot from the genclone object, creating a genind object.

as.genambig will convert a genind or genclone object to a polysat genambig class.

Author

Zhian N. Kamvar

Examples

data(Aeut)
Aeut
#> /// GENIND OBJECT /////////
#> 
#>  // 187 individuals; 56 loci; 56 alleles; size: 68.9 Kb
#> 
#>  // Basic content
#>    @tab:  187 x 56 matrix of allele counts
#>    @loc.n.all: number of alleles per locus (range: 56-56)
#>    @ploidy: ploidy of each individual  (range: 2-2)
#>    @type:  PA
#>    @call: old2new_genind(object = x, donor = new(class(x)))
#> 
#>  // Optional content
#>    @pop: population of each individual (group size range: 90-97)
#>    @other: a list containing: population_hierarchy 
#> 

# Conversion to genclone --------------------------------------------------
Aeut.gc <- as.genclone(Aeut)
Aeut.gc
#> 
#> This is a genclone object
#> -------------------------
#> Genotype information:
#> 
#>    119 original multilocus genotypes 
#>    187 diploid individuals
#>     56 dominant loci
#> 
#> Population information:
#> 
#>      0 strata. 
#>      2 populations defined - Athena, Mt. Vernon

# Conversion to genind ----------------------------------------------------
Aeut.gi <- genclone2genind(Aeut.gc)
Aeut.gi
#> /// GENIND OBJECT /////////
#> 
#>  // 187 individuals; 56 loci; 56 alleles; size: 68.2 Kb
#> 
#>  // Basic content
#>    @tab:  187 x 56 matrix of allele counts
#>    @loc.n.all: number of alleles per locus (range: 56-56)
#>    @ploidy: ploidy of each individual  (range: 2-2)
#>    @type:  PA
#>    @call: genclone2genind(x = Aeut.gc)
#> 
#>  // Optional content
#>    @pop: population of each individual (group size range: 90-97)
#>    @other: a list containing: population_hierarchy 
#> 

# Conversion to polysat's "genambig" class --------------------------------
if (require("polysat")) {
  data(Pinf)
  Pinf.gb <- as.genambig(Pinf)
  summary(Pinf.gb)
}
#> Loading required package: polysat
#> Dataset with allele copy number ambiguity.
#> Insert dataset description here.
#> Number of missing genotypes: 10
#> 86 samples, 11 loci.
#> 2 populations.
#> Ploidies: 2 3 NA
#> Length(s) of microsatellite repeats: NA

data(nancycats)

# Conversion to bootgen for random sampling of loci -----------------------
nan.bg  <- new("bootgen", nancycats[pop = 9])
nan.bg
#> An object of class "bootgen"
#> Slot "type":
#> [1] "codom"
#> 
#> Slot "ploidy":
#> [1] 2 2 2 2 2 2 2 2 2
#> 
#> Slot "names":
#> [1] "N104" "N105" "N106" "N107" "N108" "N109" "N111" "N112" "N113"
#> 
#> Slot "alllist":
#> [[1]]
#>  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
#> 
#> [[2]]
#>  [1] 17 18 19 20 21 22 23 24 25 26 27
#> 
#> [[3]]
#>  [1] 28 29 30 31 32 33 34 35 36 37
#> 
#> [[4]]
#> [1] 38 39 40 41 42 43 44 45 46
#> 
#> [[5]]
#>  [1] 47 48 49 50 51 52 53 54 55 56 57 58
#> 
#> [[6]]
#> [1] 59 60 61 62 63 64 65 66
#> 
#> [[7]]
#>  [1] 67 68 69 70 71 72 73 74 75 76 77 78
#> 
#> [[8]]
#>  [1] 79 80 81 82 83 84 85 86 87 88 89 90
#> 
#> [[9]]
#>  [1]  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108
#> 
#> 
#> Slot "tab":
#>      fca8.117 fca8.119 fca8.121 fca8.123 fca8.127 fca8.129 fca8.131 fca8.133
#> N104        0        0      0.5      0.0        0        0        0        0
#> N105        0        0      0.0      0.0        0        0        0        0
#> N106        0        0      0.0      0.0        0        0        0        0
#> N107        0        0      0.5      0.0        0        0        0        0
#> N108        0        0      0.0      0.0        0        0        0        0
#> N109        0        0      0.0      0.0        0        0        0        0
#> N111        0        0      0.0      0.0        0        0        0        0
#> N112        0        0      0.5      0.0        0        0        0        0
#> N113        0        0      0.0      0.5        0        0        0        0
#>      fca8.135 fca8.137 fca8.139 fca8.141 fca8.143 fca8.145 fca8.147 fca8.149
#> N104      0.5      0.0        0        0        0        0        0        0
#> N105      0.0      1.0        0        0        0        0        0        0
#> N106      1.0      0.0        0        0        0        0        0        0
#> N107      0.5      0.0        0        0        0        0        0        0
#> N108      1.0      0.0        0        0        0        0        0        0
#> N109      0.0      1.0        0        0        0        0        0        0
#> N111      1.0      0.0        0        0        0        0        0        0
#> N112      0.0      0.5        0        0        0        0        0        0
#> N113      0.0      0.5        0        0        0        0        0        0
#>      fca23.128 fca23.130 fca23.132 fca23.136 fca23.138 fca23.140 fca23.142
#> N104         0         0       0.0       0.5       0.0       0.5       0.0
#> N105         0         0       0.0       0.5       0.0       0.5       0.0
#> N106         0         0       0.5       0.5       0.0       0.0       0.0
#> N107         0         0       0.5       0.5       0.0       0.0       0.0
#> N108         0         0       0.5       0.5       0.0       0.0       0.0
#> N109         0         0       0.0       0.5       0.0       0.5       0.0
#> N111         0         0       0.0       0.0       0.5       0.0       0.0
#> N112         0         0       0.5       0.5       0.0       0.0       0.0
#> N113         0         0       0.0       0.5       0.0       0.0       0.5
#>      fca23.144 fca23.146 fca23.148 fca23.150 fca43.133 fca43.135 fca43.137
#> N104         0       0.0         0         0         0         0         0
#> N105         0       0.0         0         0         0         0         0
#> N106         0       0.0         0         0         0         0         0
#> N107         0       0.0         0         0         0         0         0
#> N108         0       0.0         0         0         0         0         0
#> N109         0       0.0         0         0         0         0         0
#> N111         0       0.5         0         0         0         0         0
#> N112         0       0.0         0         0         0         0         0
#> N113         0       0.0         0         0         0         0         0
#>      fca43.139 fca43.141 fca43.143 fca43.145 fca43.147 fca43.149 fca43.157
#> N104       1.0       0.0         0       0.0         0         0         0
#> N105       0.0       0.0         0       1.0         0         0         0
#> N106       0.5       0.0         0       0.5         0         0         0
#> N107       0.5       0.0         0       0.5         0         0         0
#> N108       0.5       0.0         0       0.5         0         0         0
#> N109       0.5       0.0         0       0.5         0         0         0
#> N111       1.0       0.0         0       0.0         0         0         0
#> N112       0.0       0.5         0       0.5         0         0         0
#> N113       1.0       0.0         0       0.0         0         0         0
#>      fca45.116 fca45.118 fca45.120 fca45.122 fca45.126 fca45.128 fca45.130
#> N104       0.0       0.0       0.0       0.0       0.0       1.0       0.0
#> N105       0.0       0.0       0.5       0.0       0.5       0.0       0.0
#> N106       0.0       0.0       0.0       0.5       0.5       0.0       0.0
#> N107       0.0       0.0       0.0       0.5       0.0       0.5       0.0
#> N108       0.0       0.0       0.0       0.5       0.0       0.5       0.0
#> N109       0.0       0.0       0.5       0.0       0.5       0.0       0.0
#> N111       0.0       0.0       0.0       0.5       0.0       0.0       0.0
#> N112       0.0       0.0       0.0       0.5       0.0       0.0       0.5
#> N113       0.5       0.5       0.0       0.0       0.0       0.0       0.0
#>      fca45.132 fca45.134 fca77.132 fca77.142 fca77.144 fca77.146 fca77.148
#> N104       0.0         0         0         0       0.0         0         0
#> N105       0.0         0         0         0       0.0         0         0
#> N106       0.0         0         0         0       0.0         0         0
#> N107       0.0         0         0         0       0.0         0         0
#> N108       0.0         0         0         0       0.0         0         0
#> N109       0.0         0         0         0       0.5         0         0
#> N111       0.5         0         0         0       0.0         0         0
#> N112       0.0         0         0         0       0.0         0         0
#> N113       0.0         0         0         0       0.0         0         0
#>      fca77.150 fca77.152 fca77.154 fca77.156 fca77.158 fca77.160 fca77.162
#> N104       0.5         0       0.5       0.0       0.0         0         0
#> N105       1.0         0       0.0       0.0       0.0         0         0
#> N106       0.5         0       0.0       0.5       0.0         0         0
#> N107       0.5         0       0.5       0.0       0.0         0         0
#> N108       0.5         0       0.0       0.0       0.5         0         0
#> N109       0.5         0       0.0       0.0       0.0         0         0
#> N111       0.0         0       0.0       0.0       1.0         0         0
#> N112       1.0         0       0.0       0.0       0.0         0         0
#> N113       0.0         0       0.0       0.0       1.0         0         0
#>      fca78.138 fca78.140 fca78.142 fca78.144 fca78.146 fca78.148 fca78.150
#> N104         0         0       0.5         0         0       0.0       0.5
#> N105         0         0       0.5         0         0       0.0       0.5
#> N106         0         0       0.5         0         0       0.0       0.5
#> N107         0         0       0.5         0         0       0.0       0.5
#> N108         0         0       0.5         0         0       0.0       0.5
#> N109         0         0       0.5         0         0       0.0       0.5
#> N111         0         0       1.0         0         0       0.0       0.0
#> N112         0         0       0.5         0         0       0.0       0.5
#> N113         0         0       0.5         0         0       0.5       0.0
#>      fca78.152 fca90.181 fca90.185 fca90.187 fca90.189 fca90.191 fca90.193
#> N104         0         0       0.0       0.5         0         0       0.0
#> N105         0         0       0.0       0.0         0         0       0.0
#> N106         0         0       0.0       0.5         0         0       0.0
#> N107         0         0       0.0       0.5         0         0       0.0
#> N108         0         0       0.0       0.0         0         0       0.5
#> N109         0         0       0.0       0.5         0         0       0.0
#> N111         0         0       0.5       0.0         0         0       0.0
#> N112         0         0       0.0       0.0         0         0       0.5
#> N113         0         0       0.0       0.0         0         0       0.0
#>      fca90.195 fca90.197 fca90.199 fca90.201 fca90.203 fca90.205 fca96.091
#> N104         0         0       0.5       0.0         0         0       0.0
#> N105         0         0       1.0       0.0         0         0       0.0
#> N106         0         0       0.5       0.0         0         0       0.0
#> N107         0         0       0.5       0.0         0         0       0.0
#> N108         0         0       0.5       0.0         0         0       0.0
#> N109         0         0       0.5       0.0         0         0       0.0
#> N111         0         0       0.0       0.5         0         0       0.5
#> N112         0         0       0.5       0.0         0         0       0.0
#> N113         0         0       1.0       0.0         0         0       0.5
#>      fca96.101 fca96.103 fca96.105 fca96.107 fca96.109 fca96.111 fca96.113
#> N104       0.0       0.5         0         0         0         0       0.5
#> N105       0.5       0.5         0         0         0         0       0.0
#> N106       0.5       0.0         0         0         0         0       0.5
#> N107       0.0       0.5         0         0         0         0       0.5
#> N108       0.0       0.5         0         0         0         0       0.5
#> N109       0.0       0.5         0         0         0         0       0.0
#> N111       0.0       0.0         0         0         0         0       0.5
#> N112       0.0       1.0         0         0         0         0       0.0
#> N113       0.5       0.0         0         0         0         0       0.0
#>      fca96.115 fca96.117 fca96.119 fca96.121 fca37.182 fca37.184 fca37.186
#> N104       0.0         0         0         0       0.0         0         0
#> N105       0.0         0         0         0       1.0         0         0
#> N106       0.0         0         0         0       0.5         0         0
#> N107       0.0         0         0         0       0.5         0         0
#> N108       0.0         0         0         0       0.0         0         0
#> N109       0.5         0         0         0       0.5         0         0
#> N111       0.0         0         0         0       0.0         0         0
#> N112       0.0         0         0         0       0.5         0         0
#> N113       0.0         0         0         0       0.0         0         0
#>      fca37.192 fca37.194 fca37.200 fca37.202 fca37.204 fca37.206 fca37.208
#> N104         0         0         0         0         0       0.0       1.0
#> N105         0         0         0         0         0       0.0       0.0
#> N106         0         0         0         0         0       0.0       0.5
#> N107         0         0         0         0         0       0.0       0.5
#> N108         0         0         0         0         0       0.0       1.0
#> N109         0         0         0         0         0       0.0       0.5
#> N111         0         0         0         0         0       0.0       0.5
#> N112         0         0         0         0         0       0.5       0.0
#> N113         0         0         0         0         0       0.0       0.5
#>      fca37.210 fca37.212 fca37.214 fca37.216 fca37.218 fca37.220 fca37.224
#> N104         0         0       0.0         0         0         0         0
#> N105         0         0       0.0         0         0         0         0
#> N106         0         0       0.0         0         0         0         0
#> N107         0         0       0.0         0         0         0         0
#> N108         0         0       0.0         0         0         0         0
#> N109         0         0       0.0         0         0         0         0
#> N111         0         0       0.5         0         0         0         0
#> N112         0         0       0.0         0         0         0         0
#> N113         0         0       0.5         0         0         0         0
#>      fca37.226
#> N104         0
#> N105         0
#> N106         0
#> N107         0
#> N108         0
#> N109         0
#> N111         0
#> N112         0
#> N113         0
#> 
#> Slot "loc.fac":
#>   [1] fca8  fca8  fca8  fca8  fca8  fca8  fca8  fca8  fca8  fca8  fca8  fca8 
#>  [13] fca8  fca8  fca8  fca8  fca23 fca23 fca23 fca23 fca23 fca23 fca23 fca23
#>  [25] fca23 fca23 fca23 fca43 fca43 fca43 fca43 fca43 fca43 fca43 fca43 fca43
#>  [37] fca43 fca45 fca45 fca45 fca45 fca45 fca45 fca45 fca45 fca45 fca77 fca77
#>  [49] fca77 fca77 fca77 fca77 fca77 fca77 fca77 fca77 fca77 fca77 fca78 fca78
#>  [61] fca78 fca78 fca78 fca78 fca78 fca78 fca90 fca90 fca90 fca90 fca90 fca90
#>  [73] fca90 fca90 fca90 fca90 fca90 fca90 fca96 fca96 fca96 fca96 fca96 fca96
#>  [85] fca96 fca96 fca96 fca96 fca96 fca96 fca37 fca37 fca37 fca37 fca37 fca37
#>  [97] fca37 fca37 fca37 fca37 fca37 fca37 fca37 fca37 fca37 fca37 fca37 fca37
#> Levels: fca8 fca23 fca43 fca45 fca77 fca78 fca90 fca96 fca37
#> 
#> Slot "loc.n.all":
#>  fca8 fca23 fca43 fca45 fca77 fca78 fca90 fca96 fca37 
#>    16    11    10     9    12     8    12    12    18 
#> 
#> Slot "all.names":
#> $fca8
#>  [1] "117" "119" "121" "123" "127" "129" "131" "133" "135" "137" "139" "141"
#> [13] "143" "145" "147" "149"
#> 
#> $fca23
#>  [1] "128" "130" "132" "136" "138" "140" "142" "144" "146" "148" "150"
#> 
#> $fca43
#>  [1] "133" "135" "137" "139" "141" "143" "145" "147" "149" "157"
#> 
#> $fca45
#> [1] "116" "118" "120" "122" "126" "128" "130" "132" "134"
#> 
#> $fca77
#>  [1] "132" "142" "144" "146" "148" "150" "152" "154" "156" "158" "160" "162"
#> 
#> $fca78
#> [1] "138" "140" "142" "144" "146" "148" "150" "152"
#> 
#> $fca90
#>  [1] "181" "185" "187" "189" "191" "193" "195" "197" "199" "201" "203" "205"
#> 
#> $fca96
#>  [1] "091" "101" "103" "105" "107" "109" "111" "113" "115" "117" "119" "121"
#> 
#> $fca37
#>  [1] "182" "184" "186" "192" "194" "200" "202" "204" "206" "208" "210" "212"
#> [13] "214" "216" "218" "220" "224" "226"
#> 
#> 
#> Slot "other":
#> NULL
#> 
#> Slot "call":
#> NULL
#> 

# Conversion back to genind -----------------------------------------------
nan.gid <- bootgen2genind(nan.bg)
nan.gid
#> /// GENIND OBJECT /////////
#> 
#>  // 9 individuals; 9 loci; 108 alleles; size: 25.7 Kb
#> 
#>  // Basic content
#>    @tab:  9 x 108 matrix of allele counts
#>    @loc.n.all: number of alleles per locus (range: 8-18)
#>    @loc.fac: locus factor for the 108 columns of @tab
#>    @all.names: list of allele names for each locus
#>    @ploidy: ploidy of each individual  (range: 2-2)
#>    @type:  codom
#>    @call: .local(.Object = .Object, tab = ..1)
#> 
#>  // Optional content
#>    - empty -