Identifying which pairs of individuals were clones in the data

203 views
Skip to first unread message

sho...@mortonarb.org

unread,
Apr 13, 2018, 12:46:32 PM4/13/18
to poppr
I am able to successfully use poppr (function clonecorrect) for counting and removing clones from my dataset.  However I want to identify which pairs/groups were the clones. I.e. for those removed, which remaining individuals they matched to.  I want to do this so I can measure geographic distance between individuals that turned out to be clones.

Zhian Kamvar

unread,
Apr 13, 2018, 1:33:03 PM4/13/18
to sho...@mortonarb.org, poppr
Hi Sean,

You can use the `mlg.id()` function to extract this information on the full (not clone-corrected) data set. It will return a list where each element represents a genotype and contains a vector of sample names. You can use this list to subset a data frame of geographic coordinates. See the example below.


library("poppr")
data(monpop)
show(monpop)
#> 
#> This is a genclone object
#> -------------------------
#> Genotype information:
#> 
#>    264 multilocus genotypes 
#>    694 haploid individuals
#>     13 codominant loci
#> 
#> Population information:
#> 
#>      1 stratum - Pop
#>     12 populations defined - 
#> 7_09_BB, 26_09_BB, 26_09_FR, ..., 45_10_FR, 26_11_BB, 26_11_FR
#
# Filter the data to collapse all genotypes that are different by 
# at most one mutation
e <- .Machine$double.eps^0.5
mlg.filter(monpop) <- 1 + e
show(monpop)
#> 
#> This is a genclone object
#> -------------------------
#> Genotype information:
#> 
#>    190 contracted multilocus genotypes
#>        (1) [t], (diss.dist) [d], (farthest) [a] 
#>    694 haploid individuals
#>     13 codominant loci
#> 
#> Population information:
#> 
#>      1 stratum - Pop
#>     12 populations defined - 
#> 7_09_BB, 26_09_BB, 26_09_FR, ..., 45_10_FR, 26_11_BB, 26_11_FR
#
# The `mll()` function will list the multilocus genotype/lineage
# assignment per sample.

mll(monpop)[10:19] # Samples 10, 11, and 12 are all part of the same clone
#>  [1]  79  79  79  81 130  41  41  41  38 119

indNames(monpop)[10:19]
#>  [1] "A021" "A022" "A007" "A001" "A018" "A020" "A017" "A019" "A003" "A005"
#
# mlg.id will identify them. 
mlg.id(monpop)[["79"]] # MLL 79 contains four clones
#> [1] "A021" "A022" "A007" "A033"
#
# Using this with a 2-column data frame of geographic coordinates 
meandist <- function(i, df) mean(dist(df[i, , drop = FALSE]))
df  <- data.frame(x = rnorm(nInd(monpop)), 
                  y = rnorm(nInd(monpop)), 
                  row.names = indNames(monpop))
# Coordinates can be identified for MLL 79
ids <- mlg.id(monpop)
df[ids[["79"]], , drop = FALSE]
#>               x          y
#> A021 -0.5901603 -0.5354590
#> A022 -1.2622871  0.9373863
#> A007  0.3141743 -1.3958612
#> A033 -1.5612730 -1.2284351
#
# loop over the list to calculate mean distance
res        <- vapply(mlg.id(monpop), FUN = meandist, FUN.VALUE = numeric(1), df)
names(res) <- names(mlg.id(monpop))
res[["79"]]
#> [1] 1.82423


Created on 2018-04-13 by the [reprex package](http://reprex.tidyverse.org) (v0.2.0).


-----
Zhian N. Kamvar, Ph. D.
Postdoctoral Researcher (Everhart Lab)
Department of Plant Pathology
University of Nebraska-Lincoln
ORCID: 0000-0003-1458-7108




On Apr 13, 2018, at 11:46 , sho...@mortonarb.org wrote:

I am able to successfully use poppr (function clonecorrect) for counting and removing clones from my dataset.  However I want to identify which pairs/groups were the clones. I.e. for those removed, which remaining individuals they matched to.  I want to do this so I can measure geographic distance between individuals that turned out to be clones.

--
You received this message because you are subscribed to the Google Groups "poppr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to poppr+un...@googlegroups.com.
To post to this group, send email to po...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/poppr/cd25521f-1ae5-49e1-bcad-f9de38d4be76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc

sho...@mortonarb.org

unread,
Apr 13, 2018, 1:42:03 PM4/13/18
to poppr
Thank you!  This worked out perfectly.  Thanks for sample code
Reply all
Reply to author
Forward
0 new messages