[adegenet-forum] Problem converting structure file to genind (length of 'dimnames' [2] not equal to array extent)

Charlotte Hurry charlotte.hurry at griffithuni.edu.au
Wed Jul 29 09:51:26 CEST 2015


Hello again

I hope you don't mind but I'd like to double check my file conversion to
genind.  I understand that missing values are transformed to NA but I don't
understand why I have NA values at all loci for some individuals. I have
read the information online regarding Genind objects but nothing that
explains the conversion of allele data to the values in the Genind object.

For instance my genind object is as follows:
> tab(obj[loc=1])
        tb109.118 tb109.120 tb109.114 tb109.116 tb109.112 tb109.122
tb109.108
GM4_283         1         1         0         0         0         0
0
GM336           0         0         1         1         0         0
0
GM337          NA        NA        NA        NA        NA        NA
NA
E276            2         0         0         0         0         0
0
E277            1         0         0         1         0         0
0
E278            0         0         2         0         0         0
0

Whereas my original data file is this:
        tb109    tb117    tb129    tb130    tb136    tb187    tb188
GM4_283    1    118    108    132    125    122    168    159
GM4_283    1    120    112    138    129    122    176    168
GM336    1    114    112    128    123    124    168    -9
GM336    1    116    112    136    123    128    176    -9
GM337    1    -9    110    126    123    126    168    159
GM337    1    -9    112    126    123    126    176    174
E276    2    118    108    -9    -9    122    166    165
E276    2    118    112    -9    -9    122    176    190
E277    2    116    108    126    119    124    168    159
E277    2    118    112    138    129    128    176    174

What is the mechanism that forces all values of GM336 to be NA values in
the Genind, and is this correct?

Thank you once again.

Charlotte

On 29 July 2015 at 01:57, Jombart, Thibaut <t.jombart at imperial.ac.uk> wrote:

>  Hi Charlotte,
>
> thanks for a detailed report.
>
> STRUCTURE files are a bit of a pain because of all the possible options,
> so in general if you can get them in a different format (e.g. GENETIX,
> Fstat) it will make your life easier.
>
> Here, your instruction seems okay given the sample of the file, but the
> file itself seems wrong. STRUCTURE's doc suggests you should remove 'Ind'
> and 'Pop' from the first line.
>
> http://pritchardlab.stanford.edu/structure_software/release_versions/v2.3.4/structure_doc.pdf
>
> It works on the sample provided.
>
> Was this file generated by STRUCTURE directly?
>
> If the STRUCTURE standards have changed, please fill in an issue and we'll
> adapt read.structure:
> https://github.com/thibautjombart/adegenet/issues
>
> Best
> Thibaut
>
>    ------------------------------
> *From:* adegenet-forum-bounces at lists.r-forge.r-project.org [
> adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of
> Charlotte Hurry [charlotte.hurry at griffithuni.edu.au]
> *Sent:* 24 July 2015 05:08
> *To:* adegenet-forum at lists.r-forge.r-project.org
> *Subject:* [adegenet-forum] Problem converting structure file to genind
> (length of 'dimnames' [2] not equal to array extent)
>
>        Hello
>   I have been trying to convert my structure file to a genind object but
> I am having some issues.  I am getting this error and I can't find an
> appropriate fix.  I have looked through forum history and found a similar
> issue but the fix suggested didn't work for me.
>
>  my file looks like this:
> Ind    Pop    tb109    tb117    tb129    tb130    tb136    tb187    tb188
> GM4_283    1    118    108    132    125    122    168    159
> GM4_283    1    120    112    138    129    122    176    168
> GM336    1    114    112    128    123    124    168    0
> GM336    1    116    112    136    123    128    176    0
> GM337    1    0    110    126    123    126    168    159
> GM337    1    0    112    126    123    126    176    174
> E276    2    118    108    0    0    122    166    165
> E276    2    118    112    0    0    122    176    190
> E277    2    116    108    126    119    124    168    159
> E277    2    118    112    138    129    128    176    174
> E278    2    114    108    124    121    122    168    162
> E278    2    114    112    126    125    128    176    180
>
>  I used the script
> *> tems<-read.structure("TBtest1.str",row.marknames=1,onerowperind=FALSE,
> n.ind=190, n.loc=7, col.lab=1, col.pop=2, ask=TRUE)*
>
>  Which brings up the following message, and I press RETURN:
>
>
> * Which other optional columns should be read (press 'return' when done)?
> 1:  Converting data from a STRUCTURE .stru file to a genind object... *
>
> Then get this error:
>
>
>
> *Error in `colnames<-`(`*tmp*`, value = c("Ind", "Pop", "tb109", "tb117",
> :   length of 'dimnames' [2] not equal to array extent *
> Has anybody got a fix to get my original STRUCTURE file to work as a
> Genind object.?
>
>  As an aside, on the forum I found a work around under the title "Trouble
> converting to genid object", which converts a read.table document into
> genind which I followed and I got this error:
> Warning message:
> In .local(.Object, ...) : NAs introduced by coercion
>  and this file:
> > head(as.matrix(obj1))
>     V1 V2  V3  V4  V5  V6  V7  V8  V9
> 001 NA NA  NA  NA  NA  NA  NA  NA  NA
> 002 NA  1 118 108 132 125 122 168 159
> 003 NA  1 120 112 138 129 122 176 168
> 004 NA  1 114 112 128 123 124 168   0
> 005 NA  1 116 112 136 123 128 176   0
> 006 NA  1   0 110 126 123 126 168 159
>
>  So i would like a different solution to my problem if possible.
>  Many thanks
>  Charlotte
>
>
>   Charlotte
>
>


-- 
Charlotte Hurry
PhD Candidate
Australian Rivers Institute
Griffith University
07 37356655
http://www.griffith.edu.au/environment-planning-architecture/australian-rivers-institute/hdr-students/charlotte-hurry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20150729/ba9bdd89/attachment-0001.html>


More information about the adegenet-forum mailing list