in reply to Population of HoAoA based on file contents

Thanks for the replies. I obviously didn't describe what I'm trying to accomplish sufficiently well, so let me try again.

These are actually huge 1000 Genomes files, which I want to do population genetics analysis on using bioperl Bio::PopGen modules. But rather than passing an entire chromosome to get the statistics from (which I have already done: it works but the results are not genetically relevant), I want to process 100 kilobase windows sequentially and get separate statistics for each window.

So I am trying to split my data up accordingly. The particular file that I gave a sample of starts at coordinate (i.e. DNA base) number 16,287,215. Only variant bases are listed in the files; this is why there are large gaps between coordinates. I want to start my windows from '1' (as in general, coordinates will vary for different chromosomes), so in this case windows 0 to 161 will be empty, but this doesn't matter as I simply won't pass empty windows to bioperl for analysis. I was imagining that my data would look something like this:

$data{HG00553}[ [], [], [], ...., [0 0,0 0,0 0,0 0,0 0,0 0,0 0,....], +[], [], etc.] $data{HG00554}[ [], [], [], ...., [0 0,0 0,0 0,0 0,0 0,0 0,0 0,....], +[], [], etc.]

..where the pairs of zeros here would be in array number 162 (still comma-delimited), and the following arrays would also be populated (with data not given in the tiny sample I show), but the earlier arrays would be empty in this specific case. It seems to me that a hash of arrays of arrays would be the best way to go about this, but please correct me if this is wrong.

Then subsequently I can pass a particular window number for all individuals to the popgen module to get my stats for that genomic region, then do this for all windows and for each chromosome.

I hope this clarifies what I'm trying to do, and further help would be great! Thanks again.

Replies are listed 'Best First'.
Re^2: Population of HoAoA based on file contents
by state-o-dis-array (Hermit) on May 11, 2012 at 14:11 UTC
    So you want (?):
    $data{HG00554}[162] = (0 0, 0 0, ... , 0 0 )
    I'm hoping you've come to understand why you don't want to use the shift in:
    $data{$individual}[ [ shift @snp_bins ] ] = $snp;
    Assuming so, you could do something like:
    for my $index ( 0 .. $#snp_bins ){ push( @{$data{HG00554}[$snp_bins[$index]]}, $snps[$index] ); }
    I hope this is helpful, I'm still not convinced I'm understanding what exactly you're needing.

      I think I'm on the right track now. I can see what was wrong with my original code, and I think that the structure you show above should be what I'm looking for.

      Let me work on it some more (and re-read more carefully the relevant Perl documentation), then if I still have problems I'll either add another comment below or start a fresh post (I won't have much time to work on it until next week, however). Thanks for all your help.

Re^2: Population of HoAoA based on file contents
by aaron_baugher (Curate) on May 11, 2012 at 19:14 UTC

    Ok, I think I get it. Instead of $data{HG00553}[162] pointing to an array of two-bit elements as I did, you want it to contain a comma-delimited string of those elements? In that case, you can join them together after the array is built by inserting this line into my code:

    $data{HG00553}[162] = join ',', @{$data{HG00553}[162]};

    That still leaves the question of what you'd want in any undefined elements of the array, though.

    Aaron B.
    Available for small or large Perl jobs; see my home node.