-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit IMLS Safeguarding with 4 data files and code
- Loading branch information
Showing
13 changed files
with
2,899 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
####################### | ||
#---#DETERMINE WHAT ALLELES FALL IN WHAT CATEGORIES---# | ||
####################### | ||
|
||
get.allele.cat<-function(UK_genpop, region_makeup, N_REGIONS, n_ind_p_pop, n_drop=2,glob_only=F){ | ||
|
||
n_pops<-length(n_ind_p_pop) | ||
#--Set up categories for GLOBAL ALLELES | ||
allele_freqs<-colSums(UK_genpop@tab)/(sum(n_ind_p_pop)*2) | ||
min_freq<-(n_drop/(2*sum(n_ind_p_pop))) | ||
glob<-as.vector(which(allele_freqs>min_freq)) | ||
glob_v_com<-as.vector(which(allele_freqs>0.10)) | ||
glob_com<-as.vector(which(allele_freqs>0.05)) | ||
glob_lowfr<-as.vector(which(allele_freqs<0.10&allele_freqs>0.01)) | ||
glob_rare<-as.vector(which((allele_freqs<0.01)&(allele_freqs>min_freq))) | ||
|
||
if (!(glob_only)) { | ||
|
||
#--REGIONAL ALLELES--# #NOT USED IN WHITE ASH MANUSCRIPT- USED IN OTHER PROJECTS | ||
reg_com<-vector(length=length(allele_freqs)); reg_rare<-vector(length=length(allele_freqs)) | ||
reg_com_int<-NULL #These are the interesting ones- common in one region, rare in others | ||
allele_freq_by_reg<-matrix(nrow=N_REGIONS,ncol=length(allele_freqs)) | ||
|
||
#this will go region by region and determine allele frequencies in that region | ||
#then it determines for which regions the allele frequency is >0.20 | ||
#then it gives each allele a "+1" when it is at >0.20 in a region | ||
#alleles for which this count==1 at the end, are only present at >0.20 for one region | ||
for (nr in 1:N_REGIONS){ | ||
#get the number of individuals in the region (sum across populations in the region) | ||
n_ind_this_region<- sum(n_ind_p_pop[region_makeup[nr][[1]]]) #note that the "1" just gets us the list item, its ok | ||
#divide allele counts by number of individuals (times 2 because diploid) | ||
allele_freq_by_reg[nr,]<-colSums(UK_genpop[region_makeup[[nr]],]@tab)/(n_ind_this_region*2) | ||
#record if above threshold for common | ||
reg_com<- as.numeric(reg_com) + as.numeric(allele_freq_by_reg[nr,]>=0.20) | ||
#check: print(as.vector(which((allele_freq_by_reg[nr,]>=thresh_freq_H)))) | ||
#record if below threshold for rare | ||
reg_rare<- as.numeric(reg_rare) + as.numeric(allele_freq_by_reg[nr,]<0.10) | ||
} | ||
#this is the number of alleles that are regionally common | ||
#check: which(reg_com==1); which(reg_rare==N_REGIONS) | ||
#check: ((reg_com==1)|(reg_com==2)|(reg_com==3))&((reg_rare==5)|(reg_rare==4)) | ||
reg_com_int<-which((reg_com==1)&(reg_rare>=(N_REGIONS-3))) | ||
#check: allele_freq_by_reg[,reg_com_int] | ||
|
||
|
||
#--LOCAL ALLELES--# | ||
#get the populations having alleles which occur at frequency greater than a given frequency in focal pop'n | ||
#and not more than another frequency in more than two other populations | ||
local_freqs<-UK_genpop@tab/as.vector(n_ind_p_pop*2) | ||
#identify columns (alleles) for which at least one population exceeds min threshold | ||
loc_com_d1<-as.vector(which((colMax(as.data.frame((local_freqs)))>=0.20)&(apply(local_freqs,2,sort)[(n_pops*.95),]<0.10),arr.ind=F)) | ||
loc_com_d2<-as.vector(which((colMax(as.data.frame((local_freqs)))>=0.15)&(apply(local_freqs,2,sort)[(n_pops*.90),]<0.05),arr.ind=F)) | ||
loc_rare<-as.vector(which((colMax(as.data.frame((local_freqs)))<0.10)&(colMax(as.data.frame((local_freqs)))>min_freq))) | ||
} else reg_com_int<-NA; loc_com_d1<-NA; loc_com_d2<-NA; loc_rare<-NA | ||
list(glob, glob_v_com, glob_com, glob_lowfr, glob_rare, reg_com_int, loc_com_d1, loc_com_d2, loc_rare) | ||
} | ||
|
||
|
||
##################### | ||
#--GENERAL SAMPLING FUNCTION--# | ||
##################### | ||
|
||
#we pass it a vector of populations and a vector of sample sizes, as well as the genind object | ||
sample.pop<-function(genind_obj,vect_pop_ID,vect_samp_sizes){ | ||
for (p in 1:length(vect_pop_ID)) | ||
alleles[p,]<-colSums(genind_obj[[vect_pop_ID[p]]]@tab[sample(1:nrow(genind_obj[[vect_pop_ID[p]]]@tab), vect_samp_sizes[p]),]) | ||
alleles | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
"Magnolia pyramidata, wild and then garden" | ||
mpy85 | ||
mpy93 | ||
mpy83 | ||
mpy78(2) | ||
mpy81(2) | ||
mpy15 | ||
mpy17 | ||
mpy96b | ||
mpy72(2) | ||
M6D3 | ||
M8D8 | ||
POP | ||
IMLS071 , 178188 120120 197201 167169 183189 103111 212224 178192 203207 119129 202202 | ||
IMLS072 , 157178 118118 197201 167169 181189 092103 218224 178180 207216 123129 204204 | ||
IMLS073 , 162178 117117 197197 169169 181189 103103 218224 178178 202206 127131 000000 | ||
IMLS074 , 184186 117120 197201 167167 181189 090103 218222 176176 205205 123133 178190 | ||
IMLS075 , 180184 117120 197201 167167 181191 090106 222224 190192 205214 125133 190190 | ||
IMLS076 , 166184 119120 197201 167167 191195 090106 218224 184186 204214 119125 190208 | ||
IMLS077 , 164170 117119 197201 165165 181189 090090 216226 178180 201204 119125 190210 | ||
IMLS078 , 170176 118118 197197 167169 000000 103108 208230 178188 206216 121125 178196 | ||
IMLS079 , 164166 118119 197201 167167 187189 106106 226226 178192 205216 119125 182190 | ||
IMLS080 , 164184 120120 197201 167169 189195 103111 222224 184186 206216 113123 192192 | ||
IMLS081 , 174182 120120 197197 169169 181195 106111 210218 178186 205216 125131 186208 | ||
IMLS082 , 162164 118118 197201 167167 187195 085092 218218 168174 203203 125131 184210 | ||
IMLS083 , 162172 118120 197197 167169 189195 092106 206218 164168 205205 125125 184200 | ||
IMLS084 , 162164 118120 197201 167169 187189 085092 218218 164174 202205 125156 184206 | ||
IMLS085 , 164172 118118 197197 169169 189195 092114 218218 168174 203206 125156 184206 | ||
IMLS086 , 180194 117119 197201 167167 179189 094106 210218 174178 205205 125131 192200 | ||
IMLS087 , 164186 121121 197201 167169 175181 106106 218226 168192 205207 121138 196204 | ||
IMLS088 , 164166 117117 197201 167167 191191 106111 216218 170174 206206 123131 198198 | ||
IMLS089 , 162164 120120 197197 167167 189191 090106 222222 184192 205207 127127 178192 | ||
IMLS090 , 170178 119119 000000 169169 189193 106118 220224 164182 204216 117117 178212 | ||
IMLS091 , 166174 118118 197197 167169 185193 090100 214214 178194 202204 151154 172188 | ||
IMLS443 , 160174 118118 197197 167169 173173 106118 218220 180182 206206 125136 176180 | ||
POP | ||
IMLS092 , 168170 117118 197197 167177 173187 109109 220222 174174 202216 125142 178186 | ||
IMLS093 , 164170 117117 197197 171175 173197 109111 196220 170180 203203 119123 168186 | ||
IMLS094 , 164182 117117 197197 167171 175183 103106 220220 168174 198203 121125 168186 | ||
IMLS095 , 168168 118118 197197 169177 175183 103106 206216 170170 198216 127127 176186 | ||
IMLS096 , 164168 117117 197197 169175 173175 109111 196220 174188 203203 123123 176186 | ||
IMLS097 , 170170 117117 197197 171171 183200 106109 206206 170174 203203 125127 168186 | ||
IMLS098 , 164164 121121 197197 167167 189189 109109 220220 174186 203203 121125 168186 | ||
IMLS099 , 164164 121121 197197 167167 183189 106109 220220 186186 198203 121125 168186 | ||
IMLS100 , 166166 118121 197197 167171 183183 109109 198222 174174 198203 127142 176188 | ||
IMLS101 , 138138 000000 000000 000000 163163 000000 202208 000000 000000 123129 164164 | ||
IMLS102 , 138138 000000 000000 000000 163163 000000 204204 000000 000000 000000 178200 | ||
IMLS103 , 166176 117121 197201 167175 187191 103106 206206 170180 201215 121125 188192 | ||
IMLS104 , 166180 117119 197201 167167 173187 090100 214214 170190 205205 115133 000000 | ||
IMLS105 , 166172 117117 197201 167167 173189 090108 216222 170172 203207 113115 204204 | ||
IMLS106 , 164168 117118 197201 167167 191191 083090 210214 170174 207207 121133 196204 | ||
IMLS107 , 164170 117117 197201 167167 191195 109114 224224 170174 203207 111115 194202 | ||
IMLS108 , 172176 117117 197201 167167 195195 090109 206224 156170 203203 115127 186202 | ||
IMLS109 , 164172 117117 197201 167167 187191 083100 208210 170174 205205 117121 192202 | ||
IMLS110 , 172174 119119 197201 167167 173195 083083 202210 170192 205205 125129 192192 | ||
IMLS111 , 166176 117118 197201 167167 189195 083111 204222 170170 202202 111111 202202 | ||
IMLS112 , 168172 118118 197201 167167 193195 111111 210216 170178 207216 111111 202202 | ||
IMLS113 , 172172 118118 197201 167167 193195 083109 220222 178178 207207 111138 202202 | ||
IMLS114 , 168178 117117 197197 167167 187195 108111 210222 174186 201216 131138 184196 | ||
IMLS115 , 164164 117117 197201 167167 193195 083103 204210 178206 201204 125131 188202 | ||
IMLS116 , 166168 117119 197201 167167 193195 090103 204220 200206 207207 111129 192202 | ||
IMLS117 , 172176 117117 197201 167167 191197 109111 000000 182188 201216 117119 166192 | ||
IMLS118 , 164168 117119 197201 167167 173195 083090 210220 170206 201207 111125 196202 | ||
IMLS119 , 164166 117117 197201 167167 173191 083111 210224 170180 207207 129138 198202 | ||
IMLS120 , 168176 117117 197201 167167 173173 108109 204222 170180 207207 113127 190200 | ||
IMLS121 , 168174 117119 197201 167167 173193 108111 204222 170180 203207 127129 186190 | ||
IMLS122 , 164176 119199 197201 167167 173177 106108 206222 170170 207207 125129 190204 | ||
IMLS123 , 164166 117119 197201 167167 179191 106109 206222 170170 207216 125129 190190 | ||
IMLS124 , 164164 117118 197201 167167 173193 109111 218222 170170 207207 125129 190204 | ||
IMLS125 , 168176 117118 197201 167167 177191 106108 218222 174176 203207 113125 190204 | ||
IMLS126 , 164164 117118 197201 167167 179191 090094 204210 176176 207207 113125 188188 | ||
IMLS127 , 164164 117117 197201 167167 189191 090111 204222 170176 207207 129131 192202 | ||
IMLS128 , 164168 117119 197201 167167 173191 109109 210222 170170 201203 125129 188188 | ||
IMLS129 , 168176 119119 197201 167167 173193 109111 204222 170180 207207 129129 190204 | ||
IMLS130 , 162164 117118 197201 167167 191191 094108 210222 170176 201207 125129 188192 | ||
IMLS390 , 162168 117118 197201 167167 173195 108111 204214 176190 207207 129133 198206 | ||
IMLS391 , 164174 117117 197201 167167 173191 106106 204218 156200 201201 129138 190190 | ||
IMLS392 , 176184 117117 197201 167167 173185 111111 214222 170170 207207 125133 198204 | ||
IMLS393 , 168168 117117 197201 167169 187204 090111 216216 174176 203207 115129 190190 | ||
IMLS394 , 164168 117118 197197 167167 187187 090090 216222 174176 203207 111127 200206 | ||
IMLS395 , 164168 117117 197201 167169 187204 090111 224224 176198 207207 125129 190206 | ||
IMLS396 , 170178 117117 197201 167169 191204 083111 216216 170170 207207 115131 190190 | ||
IMLS397 , 174176 118118 197197 167167 187195 090111 204230 176176 201207 123158 200200 | ||
IMLS398 , 166174 117119 197201 167171 187208 090100 206224 170174 207207 111133 202202 | ||
IMLS399 , 164178 117119 197201 167167 187195 090111 204210 156176 203216 000000 200200 | ||
IMLS400 , 174181 117117 197201 167167 175187 090100 216226 170176 201207 000000 204204 | ||
IMLS401 , 162170 117118 195199 165165 187211 088090 210210 170176 201207 129138 202202 | ||
IMLS402 , 174174 117119 197201 167167 187189 090109 204226 170190 207216 111158 186192 | ||
IMLS403 , 164166 119119 197201 169169 189197 083090 204204 170186 207216 123144 202204 | ||
IMLS404 , 174174 117117 197201 167167 173187 090111 204218 156180 207207 111125 190204 | ||
IMLS405 , 164172 117118 197201 167167 179197 090100 218218 186188 202207 123129 168190 | ||
IMLS406 , 164164 117117 197201 167167 177193 090100 218229 188194 203207 119133 186202 | ||
IMLS407 , 164164 119119 197201 167167 197197 090106 216222 190190 198207 119119 190202 | ||
IMLS408 , 166174 119119 197201 169169 189197 106109 210222 170178 207207 119129 168198 | ||
IMLS409 , 166174 119119 197201 167167 187197 106111 220222 170170 207207 111123 198202 | ||
IMLS410 , 164166 117118 197201 167167 197197 090109 216222 170188 198207 119119 190202 | ||
IMLS442 , 162164 117119 197201 167167 187187 108116 214222 172194 202215 133140 190202 | ||
POP | ||
IMLS411 , 168168 117117 197197 167167 189191 090100 196222 176180 203205 123123 188196 | ||
IMLS412 , 172172 118120 197197 167167 181191 103106 196222 189192 203212 119123 178198 | ||
IMLS413 , 166172 117120 197197 167167 191200 106106 220222 174176 204204 119123 188198 | ||
IMLS414 , 166172 121121 197197 169169 181189 106106 222229 176189 203212 119119 188188 | ||
IMLS415 , 168184 118120 197201 167167 177193 106108 216220 180186 203203 121131 188188 | ||
IMLS416 , 164168 119119 197201 167167 185185 085090 210220 182186 203217 119123 170188 | ||
IMLS417 , 168168 119119 197201 167167 191193 085090 216220 180182 204207 125131 184188 | ||
IMLS418 , 168184 117119 197201 167167 191193 094100 216220 180180 203203 123125 184188 | ||
IMLS419 , 184188 119119 197197 167167 173173 090090 210220 180180 203206 121133 184194 | ||
IMLS420 , 168180 119119 197197 167169 173177 090108 210216 182186 203217 121127 188194 | ||
POP | ||
IMLS421 , 170170 117118 197201 169169 177185 103108 222224 176176 217217 119125 178178 | ||
IMLS422 , 170170 118118 197201 169169 185185 103108 224224 186194 217217 125125 178178 | ||
IMLS423 , 170170 118118 197201 169169 185185 116116 218224 176176 217217 119119 178178 | ||
IMLS424 , 170170 117118 197201 169169 185185 108108 220224 176176 217217 121127 178178 | ||
IMLS425 , 170170 117117 197201 169169 185185 108108 220224 176176 217217 000000 178178 | ||
IMLS426 , 170170 117117 197201 169169 185185 108116 224224 176176 217217 119119 178178 | ||
IMLS427 , 170170 117117 197201 169169 177177 116116 224224 176176 203217 121125 178178 | ||
IMLS428 , 170170 117117 197201 169169 177185 108116 218224 176176 203217 121127 178178 | ||
IMLS429 , 172174 117118 197201 167169 185185 103108 220220 176188 217217 121121 178178 | ||
IMLS430 , 170172 117118 197201 167169 185185 103108 218220 176182 217217 121127 178178 | ||
IMLS431 , 170174 117119 197201 167167 185185 103109 218220 186194 203216 121121 178178 | ||
IMLS432 , 160170 117118 197201 167167 185189 103108 218220 176196 217217 127133 178178 | ||
IMLS433 , 160174 117118 197201 167167 177189 106106 218220 176176 217217 121144 178178 | ||
IMLS434 , 174186 117118 197201 167167 185189 108116 218220 176196 203217 121121 178198 | ||
IMLS435 , 170170 117117 197201 167169 185185 108108 218220 186196 203203 121142 178178 | ||
IMLS436 , 170170 117117 197197 167169 185185 116116 218220 176176 217217 133133 178198 | ||
IMLS437 , 170186 117118 197201 167169 177183 106108 218220 186186 203217 121121 178178 | ||
IMLS438 , 160170 117118 197201 167169 177177 106108 218220 176176 203217 121121 178178 | ||
IMLS439 , 170174 117119 197201 167169 177185 103108 220224 186192 203203 127133 178178 | ||
IMLS440 , 160170 117117 197197 169169 185189 106106 216220 176176 203217 121136 178178 | ||
IMLS441 , 160170 118118 197201 167169 185185 108108 218220 176196 217217 121142 178178 | ||
POP | ||
IMLS445 , 170170 118118 197201 169169 185185 106106 220224 176196 217217 127133 178198 | ||
IMLS446 , 170174 117118 197197 167169 177185 116116 220220 176176 217217 133133 178178 | ||
IMLS447 , 166170 119119 197201 167167 175197 103108 216218 174184 202202 111119 196202 | ||
IMLS449 , 168168 120120 197197 167167 183191 103103 206212 154180 201201 133133 198202 | ||
IMLS453 , 170170 117118 197201 167169 185185 116116 216218 176196 203217 121121 178178 | ||
IMLS454 , 170170 117117 197201 169169 185185 108116 218220 176176 217217 125127 178178 | ||
IMLS456 , 164168 119119 197201 167167 191195 083111 210216 170178 201216 111125 196202 | ||
IMLS457 , 168174 117119 197197 167167 191191 108109 210212 180182 205217 136136 170170 | ||
IMLS458 , 168170 120120 197197 167169 191200 114114 210232 162168 203212 121146 184198 | ||
IMLS459 , 168178 120120 197197 169169 191191 106114 200216 162168 212212 121146 180180 | ||
IMLS460 , 174178 120120 197201 165165 185191 106116 210220 154176 212217 121127 178198 | ||
IMLS461 , 164164 119119 197201 167169 185197 100116 212220 176190 201217 133142 178186 | ||
IMLS462 , 164178 118118 197201 167171 189211 090111 204206 176178 203207 127131 196204 | ||
IMLS463 , 162162 121121 197197 167167 193195 114114 220220 158174 198203 125125 182182 | ||
IMLS464 , 170170 118118 197201 169169 185185 108108 216218 174176 203217 127142 178178 | ||
IMLS465 , 174174 118118 197197 000000 189189 108109 210210 176176 203214 115115 186192 | ||
IMLS466 , 162162 115121 197197 167167 193193 114114 220220 158158 204204 125156 182206 | ||
IMLS467 , 162164 119121 197201 167167 173195 108114 218220 170174 203216 125127 192206 | ||
IMLS468 , 164170 117118 197201 167169 185189 090116 204220 176196 207217 121133 166198 | ||
IMLS469 , 170170 000000 197197 167167 175191 116116 206224 154194 201205 119142 180196 | ||
IMLS470 , 164170 118118 197201 167167 187187 090108 218220 170170 207216 125125 192192 | ||
IMLS471 , 170170 117119 197201 169169 193193 106111 218218 182182 215215 151151 000000 | ||
IMLS472 , 164170 117117 197201 167167 191193 083109 220222 170170 207207 127127 196196 | ||
IMLS473 , 000000 119119 197201 167167 177206 109116 222226 192192 212216 119121 184190 | ||
IMLS474 , 164170 117117 197201 167167 191191 083109 216218 170170 207207 121127 192192 | ||
IMLS475 , 164170 117117 197201 167167 193193 083109 218222 170170 207207 000000 192196 | ||
IMLS476 , 164164 117117 197201 000000 191193 109109 218222 170170 207207 127127 192196 | ||
IMLS477 , 164170 117117 197201 167167 191193 083109 218218 170170 207207 127127 192192 | ||
IMLS478 , 170170 117119 197201 169169 193193 106111 218218 182182 215215 151151 000000 | ||
IMLS479 , 168170 119122 197201 169169 193193 106108 214218 172188 212212 117125 200200 | ||
IMLS480 , 164168 119122 197201 169169 173193 109111 214218 186188 216216 117125 188188 | ||
IMLS481 , 168170 119122 197201 169169 173193 106111 214218 182188 212215 117125 200200 | ||
IMLS482 , 164192 117122 197201 169169 173193 106111 218226 172182 212215 125151 200200 | ||
IMLS483 , 164168 117119 197201 169169 193193 106109 216218 174188 216216 113117 198198 | ||
IMLS484 , 164164 117119 197201 169169 173173 106106 218218 188188 212215 113117 000000 | ||
IMLS203 , 170174 117118 197197 169169 177185 116116 220220 176176 217217 133133 178198 | ||
IMLS205 , 170170 117118 197201 169169 177185 116116 218220 176180 217217 125127 178178 | ||
IMLS206 , 166168 117118 197197 167169 193193 090114 206208 154186 205207 123131 180180 | ||
IMLS207 , 164174 118118 197201 171171 177189 109109 210222 176176 214214 115119 192192 | ||
IMLS208 , 164168 117117 197201 167167 183183 090108 216218 156182 207207 111111 190196 |
Oops, something went wrong.