[adegenet-forum] adegenet-forum Digest, Vol 126, Issue 1

Zhian Kamvar kamvarz at science.oregonstate.edu
Tue Mar 5 10:43:59 CET 2019


Hi Samuel,

The tab function simply gives back a matrix of allele counts (for a
genlight object). It won't replace the values IN the genlight object (since
R is side-effect free).

Because of the way a genlight object works, you can't replace the values
with the average counts of alleles, so what you might want to do is to use
`tab()` to get the allele matrix with missing replaced with the mean value
and then use `celing()` on that matrix to transform the average values to
the nearest allele copy number (note: you could also use `round()`, but
this will always round to the nearest even digit). From there, you can
convert back to a genlight with the missing values replaced.

On Mon, Mar 4, 2019 at 11:00 AM <
adegenet-forum-request at lists.r-forge.r-project.org> wrote:

> Send adegenet-forum mailing list submissions to
>         adegenet-forum at lists.r-forge.r-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum
>
> or, via email, send a message with subject or body 'help' to
>         adegenet-forum-request at lists.r-forge.r-project.org
>
> You can reach the person managing the list at
>         adegenet-forum-owner at lists.r-forge.r-project.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of adegenet-forum digest..."
>
>
> Today's Topics:
>
>    1. Replacing NAs in genlight object (Samuel Weaver)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 3 Mar 2019 12:53:16 -0600
> From: Samuel Weaver <weave271 at umn.edu>
> To: adegenet-forum at lists.r-forge.r-project.org
> Subject: [adegenet-forum] Replacing NAs in genlight object
> Message-ID:
>         <CAAeinLC0PVGsy7wrXdSrJLv7wDogqdiXvF+8FH3SPC=
> enha-qA at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> I'm trying to change NAs in my dataset to the mean allele frequency to run
> various PopGen analyses through adegenet, but have been having trouble.
> Commands start below.
>
> Data<-vcfR2genlight(MyVcf)
> Data
> /// GENLIGHT OBJECT /////////
>
>  // 11 genotypes,  5,467 binary SNPs, size: 877.8 Kb
>  7647 (12.72 %) missing data
>
>  // Basic content
>    @gen: list of 11 SNPbin
>
>  // Optional content
>    @ind.names:  11 individual labels
>    @loc.names:  5467 locus labels
>    @chromosome: factor storing chromosomes of the SNPs
>    @position: integer storing positions of the SNPs
>    @other: a list containing: elements without names
>
> I then try to run the command listed in the tutorial and elsewhere on the
> forum, which is as follows:
>
> tab(Data, NA.method="mean").
>
> This, however, does nothing to replace the NA values in the original "Data"
> genlight object. I've looked for hours on how to do this with no avail, so
> any help would be greatly appreciated.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20190303/cabd61d5/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> adegenet-forum mailing list
> adegenet-forum at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum
>
> ------------------------------
>
> End of adegenet-forum Digest, Vol 126, Issue 1
> **********************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20190305/b7c97639/attachment.html>


More information about the adegenet-forum mailing list