Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_local_ploidy() throws an error with non-SSR loci #190

Closed
zkamvar opened this issue Jun 12, 2018 · 0 comments
Closed

get_local_ploidy() throws an error with non-SSR loci #190

zkamvar opened this issue Jun 12, 2018 · 0 comments
Assignees

Comments

@zkamvar
Copy link
Member

zkamvar commented Jun 12, 2018

This is in reference to https://groups.google.com/d/msgid/poppr/189bdc5d-4979-4245-942f-e7ebd01f7f6f%40googlegroups.com.

Here's the worked example:

Setup (click to expand)
if (!file.exists("trial.txt")){
  download.file("https://groups.google.com/group/poppr/attach/54e0e4c1740bf/trial.txt?part=0.1&authuser=0", destfile = "trial.txt")
}

if (!file.exists("strata.txt")){
  download.file("https://groups.google.com/group/poppr/attach/54e0e4c1740bf/strata.txt?part=0.2&authuser=0", destfile = "strata.txt")
}

suppressPackageStartupMessages(library("poppr"))
file <- read.table("trial.txt", header=T)

tfile <- t(file[,1:ncol(file)])   #transpose table
colnames(tfile) = tfile[1, ]   #markers labels
tfile = tfile[-1, ]

# to change rownames because the transposition don't leave the labels "ID"
g <- tfile
ID <- rownames(g)
rownames(g) <- NULL
fx <- cbind(ID,g)
View(fx)

x <- as.data.frame(fx, header=T) #trasform into a data.frame

locs <- x[, -c(1, 2)] 
colnames(locs) <- gsub("\\-", "_", colnames(locs))
# 
# ind <- as.character(file$lines)     # labels of the individuals
# population <- as.character(file$Pop)    # labels of the populations

id <- read.table("strata.txt", header=T)    # add strata

file_genind <- df2genind(locs, ploidy = 2, ind.names = ID, strata = id, NA.char = "NA", type = "codom", sep = "") # conversion into a genind object

file_amova <- poppr.amova(file_genind, ~rep/year/plot)
#> 
#> Found 238 missing values.
#> 
#> 3 loci contained missing values greater than 5%
#> 
#> Removing 3 loci: JHI_Hv50k_2016_206330, JHI_Hv50k_2016_206596,
#> JHI_Hv50k_2016_20687
#> Warning in get_local_ploidy(x): NAs introduced by coercion
#> Error in if (any(as.numeric(unlist(x@all.names, use.names = FALSE)) == : missing value where TRUE/FALSE needed

Created on 2018-06-12 by the reprex package (v0.2.0).

@zkamvar zkamvar self-assigned this Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant