<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1" bgcolor="#FFFFFF">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;"><font size="2">Hi there,
<br>
yes, sorry there was a typo - the one you flagged. Fixed now.<br>
Cheers<br>
Thibaut<br>
</font>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF56853"><font size="2" color="#000000" face="Tahoma"><b>From:</b> Benjamin Alric [benjamin.alric@univ-lyon1.fr]<br>
<b>Sent:</b> 23 February 2015 15:28<br>
<b>To:</b> Jombart, Thibaut<br>
<b>Subject:</b> Re: [adegenet-forum] Simulated hybridization from same locus but different alleles with hybridize function and<br>
</font><br>
</div>
<div></div>
<div>Dear Thibault,<br>
<br>
Thanks a lot for your response.<br>
<div class="moz-cite-prefix">I load the new version of hybridize function by the patch founde here:<br>
<pre><a class="moz-txt-link-freetext" href="https://github.com/thibautjombart/adegenet/blob/master/pkg/R/hybridize.R" target="_blank">https://github.com/thibautjombart/adegenet/blob/master/pkg/R/hybridize.R</a></pre>
<br>
However, the function does not work and there was the followinf error message: <br>
<br>
hybrids<-hybridize(Dg,Dl,n=100,pop="hybrids")<br>
Erreur dans nLoc(x) : <br>
  erreur d'évaluation de l'argument 'x' lors de la sélection d'une méthode pour la fonction 'nLoc' : Erreur : objet 'x' introuvable<br>
<br>
In the source code there is:<br>
<table class="highlight tab-size-8 js-file-line-container">
<tbody>
<tr>
<td id="LC22" class="blob-code js-file-line"><span class="pl-c">## used variables</span></td>
</tr>
<tr>
<td id="LC23" class="blob-code js-file-line"><span class="pl-vo">n1</span> <span class="pl-k">
<-</span> nInd(<span class="pl-vo">x1</span>)</td>
</tr>
<tr>
<td id="LC24" class="blob-code js-file-line"><span class="pl-vo">n2</span> <span class="pl-k">
<-</span> nInd(<span class="pl-vo">x2</span>)</td>
</tr>
<tr>
<td id="LC25" class="blob-code js-file-line"><span class="pl-vo">k</span> <span class="pl-k">
<-</span> nLoc(<span class="pl-vo">x</span>)</td>
</tr>
</tbody>
</table>
I found no specification of "x" in your command.<br>
nLoc corresponds to number of loci, is it right?<br>
But, we should specify where go search the number of loci, is it right?<br>
Therefore, I replaced x by x1 in k<-nLoc(x1) and I run the analysis.<br>
Now, it works with the results below:<br>
<br>
hybrids<-hybridize(Dg,Dl,n=100,pop="hybrids")<br>
g1<-genind2df(hybrids)<br>
g1<br>
         pop  10_14  Dp512 SwiD10  SwiD1 SwiD12 SwiD14 SwiD15  SwiD5<br>
h001 hybrids 223226 129137 184201 134150 112116 185187 080089 129153<br>
h002 hybrids 223226 129138 184194 138138 114119 185185 076098 129161<br>
h003 hybrids 223226 129133 191201 126150 112114 175183 076093 137163<br>
h004 hybrids 226226 129138 184194 138138 114119 179187 076093 129165<br>
h005 hybrids 223226 129133 184194 118138 116123 181187 076093 129161<br>
h006 hybrids 223226 129138 190201 118134 114123 183185 076093 129161<br>
h007 hybrids 226226 129133 190201 143150 114123 181185 076089 129161<br>
h008 hybrids 223226 129133 190201 118136 114123 181185 076093 129161<br>
h009 hybrids 223226 129138 184201 138143 114123 185185 076093 129163<br>
h010 hybrids 223226 129137 182201 138138 114119 179187 076089 129163<br>
<br>
So, I don't know if you have leave deliberately x instead of x1 but could you tell me if put x1 instead fo x in the function is right.<br>
<br>
Sorry for the goings and comings.<br>
<br>
Best regards,<br>
<br>
Benjamin<br>
<br>
<br>
Le 23/02/2015 14:30, Jombart, Thibaut a écrit :<br>
</div>
<blockquote type="cite">
<pre>Hi there, 

it was indeed a bug - fixed now. It will be part of the next release, but meanwhile a patch can be found here:
<a class="moz-txt-link-freetext" href="https://github.com/thibautjombart/adegenet/blob/master/pkg/R/hybridize.R" target="_blank">https://github.com/thibautjombart/adegenet/blob/master/pkg/R/hybridize.R</a>

Alternatively, you can install the devel version on github using:
library(devtools)
install_github("thibautjombart/adegenet/pkg")

BTW, you probably know this already but Sebastien Devillard, in your department, is the expert of hybridization & STRUCTURE. He can usually be bribed by coffee.

Cheers
Thibaut

________________________________________
From: Benjamin Alric [<a class="moz-txt-link-abbreviated" href="mailto:benjamin.alric@univ-lyon1.fr" target="_blank">benjamin.alric@univ-lyon1.fr</a>]
Sent: 23 February 2015 12:41
To: Jombart, Thibaut
Subject: Re: [adegenet-forum] Simulated hybridization from same locus but different alleles with hybridize function and

Dear Thibaut,

Thank you for your response.
Firstly, in the dataste example for hybridize function, there is the
same number of allele among the two population.
Moreover, on other of my dataset, where I have not the same number of
allele in eahc loci, I can not made the analysis.
A error message said that the two genind object had not the same size.

 > Dg_1<-import2genind("B_Dg_1.gtx",package="adegenet")

  Converting data from GENETIX to a genind object...

...done.

 > Dl_1<-import2genind("B_Dl_1.gtx",package="adegenet")

  Converting data from GENETIX to a genind object...

...done.

 > Dg_1

    #####################
    ### Genind object ###
    #####################
- genotypes of individuals -

S4 class:  genind
@call: read.genetix(file = file, missing = missing, quiet = quiet)

@tab:  30 x 33 matrix of genotypes

@ind.names: vector of  30 individual names
@loc.names: vector of  8 locus names
@loc.nall: number of alleles per locus
@loc.fac: locus factor for the  33 columns of @tab
@all.names: list of  8 components yielding allele names for each locus
@ploidy:  2
@type:  codom

Optional contents:
@pop:  factor giving the population of each individual
@pop.names:  factor giving the population of each individual

@other: - empty -

 > Dl_1

    #####################
    ### Genind object ###
    #####################
- genotypes of individuals -

S4 class:  genind
@call: read.genetix(file = file, missing = missing, quiet = quiet)

@tab:  30 x 32 matrix of genotypes

@ind.names: vector of  30 individual names
@loc.names: vector of  8 locus names
@loc.nall: number of alleles per locus
@loc.fac: locus factor for the  32 columns of @tab
@all.names: list of  8 components yielding allele names for each locus
@ploidy:  2
@type:  codom

Optional contents:
@pop:  factor giving the population of each individual
@pop.names:  factor giving the population of each individual

@other: - empty -

 > F1<-hybridize(Dg_1,Dl_1,n=100,pop="Hybrids")
Erreur dans Ops.data.frame(tab1, tab2) :
   ‘+’ only defined for equally-sized data frames

Otherwise, you will find in attached file, a reproductible example
dataset in .gtx (B_Dg.gtx and B_Dl.gtx) and commands which reproduced
the error.

I used adegenet version 1.4-2 on RStudio.
Using RStudio can be the source of the problem, for example, because
adegraphics for the moment is less supported on RStudio than R.

Best regards,

Benjamin ALRIC

Le 23/02/2015 12:52, Jombart, Thibaut a écrit :
</pre>
<blockquote type="cite">
<pre>Hi there,

the number of alleles shouldn't have to be the same, so I'm not sure what is going on but this might be a bug.

May you send a minimum reproducible example (data and commands reproducing the error)? Also, what version of adegenet are you using?

Cheers
Thibaut


________________________________________
From: <a class="moz-txt-link-abbreviated" href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org" target="_blank">adegenet-forum-bounces@lists.r-forge.r-project.org</a> [<a class="moz-txt-link-abbreviated" href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org" target="_blank">adegenet-forum-bounces@lists.r-forge.r-project.org</a>] on behalf of Benjamin Alric [<a class="moz-txt-link-abbreviated" href="mailto:benjamin.alric@univ-lyon1.fr" target="_blank">benjamin.alric@univ-lyon1.fr</a>]
Sent: 21 February 2015 16:59
To: <a class="moz-txt-link-abbreviated" href="mailto:adegenet-forum@lists.r-forge.r-project.org" target="_blank">adegenet-forum@lists.r-forge.r-project.org</a>
Subject: [adegenet-forum] Simulated hybridization from same locus but different alleles with hybridize function and

Dear all,

I would like simulated hybridization between two population to assess
the power of admixture analysis (STRUCTURE).
I built two subsamples consisting of 30 indivudals showing the highest q
values for the cluster1 or cluster2 of previously STRUCTURE analysis.
  From these two subsamples I would like simulated hybridization (using
hybridize function of the adegenet R package) to assess the power of
admixture analysis.
For each population, genotype were determined through 8 microsatellite
loci for wichi one allele is code by a character string of 3 numbers.
Here you are the command:

Dg<-import2genind("B_Dg.gtx",package="adegenet")
Dl<-import2genind("B_Dl.gtx",package="adegenet")
Dg<- #####################
     ### Genind object ###
     #####################
- genotypes of individuals -

S4 class:  genind
@call: read.genetix(file = file, missing = missing, quiet = quiet)

@tab:  30 x 33 matrix of genotypes

@ind.names: vector of  30 individual names
@loc.names: vector of  8 locus names
@loc.nall: number of alleles per locus
@loc.fac: locus factor for the  33 columns of @tab
@all.names: list of  8 components yielding allele names for each locus
@ploidy:  2
@type:  codom

Optional contents:
@pop:  factor giving the population of each individual
@pop.names:  factor giving the population of each individual

@other: - empty -

Dl<-#####################
     ### Genind object ###
     #####################
- genotypes of individuals -

S4 class:  genind
@call: read.genetix(file = file, missing = missing, quiet = quiet)

@tab:  30 x 33 matrix of genotypes

@ind.names: vector of  30 individual names
@loc.names: vector of  8 locus names
@loc.nall: number of alleles per locus
@loc.fac: locus factor for the  33 columns of @tab
@all.names: list of  8 components yielding allele names for each locus
@ploidy:  2
@type:  codom

Optional contents:
@pop:  factor giving the population of each individual
@pop.names:  factor giving the population of each individual

@other: - empty -

hybrdis<-hybridize(Dg,Dl,n=100,pop="Hybrids")
g1<-genind2df(hybrids)
g1<-
           pop       10_14      Dp512     SwiD1            SwiD10
SwiD12    SwiD14    SwiD15    SwiD5
h001 Hybrids 226226    129         131143          194201 112119
181185   093098    161161165
h002 Hybrids 220226    129         126138          200201    112 175
181181   089098    151153165
h003 Hybrids 220226    129         126134143    200 123123    185185
093098    153163165
h004 Hybrids 220226    129         126131          200201 119123
185185   093098    153153165
h005 Hybrids 220226    129         126136136    199 123123    181185
089098    153161165
h006 Hybrids 226226    129129   136136          194 112112    181181
089098    153161165
h007 Hybrids 220226    129133   134143          194          119 175
181185   093          151153163165
....

We would expect to see two allele for each locus but it is not the case
for all microsatellite loci.
Somebody know why and where does the problem?

I checked the example dataset "microbov" for hybridize function, and I
see that temp$Salers and temp$Zebu (used to perform simulated
hybridization with hybridize function) presented the same count of
alleles at each locus.
When I check now my two datasets, I see that there are not the same
number of allele between the two populations. such a difference in the
number of allele between the two population could be the origne of the
problem...

<a class="moz-txt-link-abbreviated" href="mailto:Dg@all.names" target="_blank">Dg@all.names</a>
$L1
      1     2     3
"220" "226" "231"

$L2
      1     2     3
"125" "129" "133"

$L3
      1     2     3     4     5     6
"126" "131" "134" "136" "138" "143"

<a class="moz-txt-link-abbreviated" href="mailto:Dl@all.names" target="_blank">Dl@all.names</a>
$L1
      1     2     3
"223" "226" "229"

$L2
      1     2     3     4     5     6
"129" "133" "136" "137" "138" "139"

$L3
      1     2     3     4     5     6     7
"118" "134" "136" "138" "145" "150" "152"

Thank in advence for your help.

Sincerely yours,

Benjamin ALRIC



--
__________________________________________
Benjamin Alric, Post-Doc
UMR CNRS 5558 - LBBE
"Biométrie et Biologie Evolutive"
UCB Lyon1
Equipe Ecologie Quantitative et Evolutive des Communautés
Bâtiment Grégor Mendel
43 bd du 11 novembre 1918
69622 Villeurbanne Cedex
FRANCE
__________________________________________

_______________________________________________
adegenet-forum mailing list
<a class="moz-txt-link-abbreviated" href="mailto:adegenet-forum@lists.r-forge.r-project.org" target="_blank">adegenet-forum@lists.r-forge.r-project.org</a>
<a class="moz-txt-link-freetext" href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</a>
</pre>
</blockquote>
<pre>--
__________________________________________
Benjamin Alric, Post-Doc
UMR CNRS 5558 - LBBE
"Biométrie et Biologie Evolutive"
UCB Lyon1
Equipe Ecologie Quantitative et Evolutive des Communautés
Bâtiment Grégor Mendel
43 bd du 11 novembre 1918
69622 Villeurbanne Cedex
FRANCE
__________________________________________

</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">-- 
__________________________________________
Benjamin Alric, Post-Doc
UMR CNRS 5558 - LBBE
"Biométrie et Biologie Evolutive"
UCB Lyon1
Equipe Ecologie Quantitative et Evolutive des Communautés
Bâtiment Grégor Mendel
43 bd du 11 novembre 1918
69622 Villeurbanne Cedex
FRANCE
__________________________________________</pre>
</div>
</div>
</div>
</body>
</html>