Closed bdvelie closed 6 years ago
Forgot to paste a link to some sample data
https://gist.githubusercontent.com/bdvelie/71d9245df7e9a21916f7/raw/Sample
Hmm, I'll keep this issue open for now, but here's a temporary fix for you. It looks like the trouble is happening because you only have SNPs for chromosome 3 and 8. I'm not sure off hand if the error is because you're not starting at 1, or if it's because you're "missing" SNPs for 4, 5, 6 and 7. Either way, I should generalize the code more.
But in the meantime, here's a hack. Clobber the data by replacing the 3's with 1s, and the 8s with 2s, draw the plot, but pass a character vector to the chrlabs
argument. Like this:
library(qqman)
d <- read.table("Sample.txt", header=TRUE)
d$CHR[d$CHR==3] <- 1
d$CHR[d$CHR==8] <- 2
manhattan(d, chrlabs=c("3", "8"))
Hi Stephen,
Thanks for the help. I'm still not sure what was causing the problem yesterday, but the hack works great. Additionally, when I ran it today on the entire dataset (1-31 chr) it worked perfectly fine using the exact same file that was giving the error yesterday. Perhaps it was just something with R that resolved itself.
Thanks again for the help,
Brandon
I am getting the same error, when I exclude chr1.
@zx8754 please post some example data and code as a github gist.
@stephenturner Here is an example code to reproduce the error:
library(dplyr)
library(qqman)
#using @bdvelie's data
x <- read.table("https://gist.githubusercontent.com/bdvelie/71d9245df7e9a21916f7/raw/Sample",
header=TRUE) %>%
select(CHR,SNP,BP,P)
head(x)
# CHR SNP BP P
# 1 3 AX-104433016 3525 0.870700
# 2 3 AX-104944723 4679 0.093030
# 3 3 AX-104996406 6794 0.706400
# 4 3 AX-103330248 7003 0.090690
# 5 3 AX-103033987 8340 0.561400
# 6 3 AX-103305412 31255 0.008776
table(x$CHR)
# 3 8
# 21185 17331
#add couple of dummy SNPs to chr 1
x_fix <- rbind(
data.frame(CHR=c(1,1,1),
SNP=paste0("snp",1:3),
BP=1:3,
P=c(0.5,0.003,0.00002)),
x)
table(x_fix$CHR)
# 1 3 8
# 3 21185 17331
manhattan(x) #gives error
manhattan(x_fix) #no problems :)
It's a hack, but this works. Obviously need to fix this so manhattan(x)
just works.
library(dplyr)
library(qqman)
x <- read.table("https://gist.githubusercontent.com/bdvelie/71d9245df7e9a21916f7/raw/Sample",
header=TRUE) %>%
tbl_df %>%
select(CHR,SNP,BP,P)
x %>% arrange(CHR, BP) %>%
mutate(realCHRs=CHR) %>%
mutate(CHR=factor(CHR, labels=1:n_distinct(CHR)) %>% as.numeric) %>%
manhattan(chrlabs=unique(.$realCHRs) %>% as.character)
Hi Stephen,
Thanks for developing such a useful tool. I've been using it for awhile and it has always worked great, but I recently ran into a problem that I can't seem to figure out. The manhattan plot function has worked and still works great on my older data sets, but on the newest one it is only working when I limit the data to one chromosome. When I expand it to multiple chromosomes (even only 2) I am continually getting the following error:
Error in axis(1, at = ticks, labels = labs, ...) : no locations are finite In addition: Warning messages: 1: In min(d[d$CHR == i, ]$pos) : no non-missing arguments to min; returning Inf 2: In max(d[d$CHR == i, ]$pos) : no non-missing arguments to max; returning -Inf 3: In min(d[d$CHR == i, ]$pos) : no non-missing arguments to min; returning Inf 4: In max(d[d$CHR == i, ]$pos) : no non-missing arguments to max; returning -Inf Error in axis(1, at = ticks, labels = labs, ...) : no locations are finite
I've tried to sort through it and solve the problem, but I've had no luck. As far as I'm aware the data is in a suitable format and matches all the other files I've used before. At this point I've been staring at it so much even if it were something simple I don't think I'd see it. Any thoughts on what may be causing the problem?
Brandon