Closed mkiravn closed 2 years ago
Hi Marida,
There's a bug in the haplotype
method for objects of class "character". I'm pasting a fixed version here:
haplotype.character <- function (x, labels = NULL, ...)
{
nms.x <- deparse(substitute(x))
if (!is.matrix(x))
stop("x must be a matrix")
h <- apply(x, 1, paste, collapse = "\r")
hnotdup <- !duplicated(h)
obj <- x[which(hnotdup), , drop = FALSE]
hnotdup <- h[hnotdup]
N <- nrow(obj)
if (is.null(labels))
labels <- as.character(as.roman(1:N))
rownames(obj) <- labels
class(obj) <- c("haplotype", "character")
attr(obj, "index") <- lapply(1:N, function(i) which(h == hnotdup[i]))
attr(obj, "from") <- nms.x
obj
}
Because of the namespaces, you have to use the above one (after copying/pasting into R) with:
haplotype.character(tohaplotype)
You'll also probably need to load this other one below (the [
method for class "haplotype" seems to be buggy too):
"[.haplotype" <- function(x, ...)
{
cls <- class(x)
if (length(cls) > 1) cls <- cls[-1]
y <- NextMethod("[")
class(y) <- cls
y
}
Please try this and tell me how it goes. Thanks for reporting this! Emmanuel
Hi Emmanuel,
yes- that all worked. Thank you so much for your quick reply!
Best, Marida
Hello! I am running into the following issue:
I am supplying toy files to reproduce the issue.
data_example.txt pops_example.txt
I start by reading in the haplotypes and a vector of populations for the individuals in the haplotype data frame.
For which the output is:
The I look at the distributions of the haplotypes in each population:
Which gives me this:
So the Neandertal haplotypes are all haplotype "I". Now I look at the haplotype of one of the Neanderthal individuals:
This makes sense because to some extent we expect missing data here. However, looking at haplotype "I" directly:
Gives me:
So I get two different haplotypes. Could you help me to understand why this is the case?
Thank you so much! Marida