[adegenet-forum] Removing individuals from genind obj

Caitlin Collins caitiecollins at gmail.com
Thu Oct 29 09:33:44 CET 2015


Hi Shannon,

When you attempted to remove individuals from the genind object by working
on the @tab slot (the second step you showed above), what you are really
doing is asking to only remove them from the data matrix stored in the @tab
slot, and not from all of the meta-information so lovingly stored in other
slots of the object.

The solution is to work with the genind object in its entirety, not just
the @tab slot. With the object names you are using, I think this should
work:

     # create list of individuals (rows) to remove from @tab slot (and all
of the other slots!!)
     removeInd <- c("Ind5", "Ind10", "Ind60")

     # remove individuals from *genind object*
     # note that in this step there's no longer a comma needed before the
closing square bracket
     data <- data[!row.names(data at tab) %in% removeInd]

Hope that does the trick!

All the best,
Caitlin.

On Thu, Oct 29, 2015 at 4:40 AM, Shannon O'Leary <shannon.j.oleary at gmail.com
> wrote:

> Hi,
>
> During my data analysis I have identified individuals that I want to
> remove from the genind object - as opposed to removing those individuals
> from my genepop file and re-reading it back into R as a genind object.
>
> I created a list of individual names (I formatted the genind object so
> that the individuals are named according to my sample names) and used it to
> subset the matrix stored in the @tab slot.
>
>
>      # create list of individuals (rows) to remove from @tab slot
>      removeInd <- c("Ind5", "Ind10", "Ind60")
>
>      # remove individuals from @tab slot
>      data at tab <- data at tab[!row.names(data at tab) %in% removeInd,]
>
>
> When I check the dimensions of the @tab slot and the number of individuals
> in the genind object, the returned number indicate that the individuals in
> the list have been removed from the genind object.
>
>      # number of rows and columns in @tab slot
>      dim(GTF_genotypes at tab)
>
>      # number of Individuals in genind object
>      nInd(GTF_genotypes)
>
> But when I check the length of the vector stored in the @pop slot it
> hasn't changed, same for the information @strata slot.
>
>      # number of individuals in @pop slot
>      length(GTF_genotypes at pop)
>
> Is there a way to remove individuals from the genind object so that that
> change is then reflected in all the slots of the genind object?
>
>
>
> Thanks,
> Shannon
>
>
> ------------------------------------------------------------------------
> Shannon J. O'Leary
> Postdoctoral Research Associate
> Marine Genomics Lab
> Harte Research Institute for Gulf of Mexico Studies
> Texas A&M Corpus Christi
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20151029/fe6e2e67/attachment.html>


More information about the adegenet-forum mailing list